Access & Installation#
Directed graphs can be issued via Python to a OneTick server using our Python API (onetick.query_webapi
), returning data directly into a dataframe.
To install the python wheel:
pip install -U --index-url https://pypi:NXBNcG86@pip.distribution.sol.onetick.com/simple/ onetick-py onetick-query-webapi
Directed graphs are stored in a Graph object using otq.Graph
, and the query is executed using otq.run
.
OneTick Cloud requires the specification of a client_id
and client_secret
which can be retrieved from your profile, after registering.
from datetime import datetime
import onetick.query_webapi as otq # See the About Tab for how to download and install from our pip server
rest_url = "https://rest.cloud.onetick.com"
access_token_url = "https://cloud-auth.parent.onetick.com/realms/OMD/protocol/openid-connect/token"
# Replace [client id] and [client_secret] with values retrieved from your profile
client_id = "[client_id]"
client_secret = "[client_secret]"
access_token = otq.get_access_token(access_token_url, client_id, client_secret)
def trades():
pt = otq.Passthrough(fields='PRICE,SIZE,EXCHANGE').tick_type('TRD')
add_value = otq.AddField(field='TRADED_VALUE',value='PRICE*SIZE')
filter_on = otq.WhereClause(where='EXCHANGE="N" and SIZE > 100')
graph = otq.Graph(pt >> add_value >> filter_on)
return graph
query = trades()
result = otq.run(query,
http_address=rest_url,access_token=access_token,
output_mode="pandas",
start=datetime(2024,1,3,9,30,0),
end = datetime(2024,1,3,9,31,0),
timezone='America/New_York',
symbols='US_COMP_SAMPLE::CSCO'
)
for sym in result:
print(result.output(sym).data)