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 OneTick server documentation for details.
import onetick.py as otp
from onetick.py.otq import otq
trd = otp.DataSource('US_COMP_SAMPLE', 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(2024, 2, 1, 10), end=otp.dt(2024, 2, 1, 16), symbols='AA')
| Time | VAR_PRICE | std | |
|---|---|---|---|
| 0 | 2024-02-01 10:01:00 | NaN | NaN | 
| 1 | 2024-02-01 10:02:00 | NaN | NaN | 
| 2 | 2024-02-01 10:03:00 | NaN | NaN | 
| 3 | 2024-02-01 10:04:00 | NaN | NaN | 
| 4 | 2024-02-01 10:05:00 | NaN | NaN | 
| ... | ... | ... | ... | 
| 355 | 2024-02-01 15:56:00 | NaN | NaN | 
| 356 | 2024-02-01 15:57:00 | NaN | NaN | 
| 357 | 2024-02-01 15:58:00 | NaN | NaN | 
| 358 | 2024-02-01 15:59:00 | NaN | NaN | 
| 359 | 2024-02-01 16:00:00 | NaN | NaN | 
360 rows × 3 columns