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 | 0.016861 | 0.129851 |
| 1 | 2022-09-01 10:02:00 | 0.001083 | 0.032903 |
| 2 | 2022-09-01 10:03:00 | 0.004457 | 0.066762 |
| 3 | 2022-09-01 10:04:00 | 0.001522 | 0.039015 |
| 4 | 2022-09-01 10:05:00 | 0.001840 | 0.042895 |
| ... | ... | ... | ... |
| 355 | 2022-09-01 15:56:00 | 0.000230 | 0.015159 |
| 356 | 2022-09-01 15:57:00 | 0.000491 | 0.022159 |
| 357 | 2022-09-01 15:58:00 | 0.000508 | 0.022529 |
| 358 | 2022-09-01 15:59:00 | 0.000034 | 0.005794 |
| 359 | 2022-09-01 16:00:00 | 0.000625 | 0.024996 |
360 rows × 3 columns