Accessing a Lower Level API#

Some of OneTick’s functionality may not be explicitly added to onetick-py but can be access through a lower-level API called onetick.query. See docs/onetick.query.api.python.html in OneTick documentation.

import onetick.py as otp
import onetick.query as otq

trd = otp.DataSource('NYSE_TAQ', tick_type='TRD')

trd.sink(otq.Variance(input_field_name='PRICE', output_field_name='VAR_PRICE', bucket_interval=60))
trd = trd.table(VAR_PRICE=float, strict=False) # need to explicitly add the fields added by the `sink` methods to the schema

trd['std'] = otp.math.sqrt(trd['VAR_PRICE'])

otp.run(trd,  start=otp.dt(2022,9,1,10), end=otp.dt(2022,9,1,16), symbols='AA')
Time VAR_PRICE std
0 2022-09-01 10:01:00 NaN NaN
1 2022-09-01 10:02:00 NaN NaN
2 2022-09-01 10:03:00 NaN NaN
3 2022-09-01 10:04:00 NaN NaN
4 2022-09-01 10:05:00 NaN NaN
... ... ... ...
355 2022-09-01 15:56:00 0.000283 0.016808
356 2022-09-01 15:57:00 0.001258 0.035470
357 2022-09-01 15:58:00 0.000520 0.022799
358 2022-09-01 15:59:00 0.000224 0.014981
359 2022-09-01 16:00:00 0.001153 0.033962

360 rows × 3 columns