otp.Empty#
- class Empty(db=utils.adaptive_to_default, symbol=utils.adaptive_to_default, tick_type=utils.adaptive, start=utils.adaptive, end=utils.adaptive, schema=None, **kwargs)#
Bases:
onetick.py.core.source.Source
Empty data source
- Parameters
db (str) – Name of the database from which to take schema.
symbol (str, list of str,
Source
,query
,eval query
) – Symbol(s) from which data should be taken.tick_type (str,) – Name of the tick_type from which to take schema.
start (
datetime.datetime
,otp.datetime
,onetick.py.adaptive
) – Time interval from which the data should be taken.end (
datetime.datetime
,otp.datetime
,onetick.py.adaptive
) – Time interval from which the data should be taken.schema (dict) – Schema to use in case db and/or tick_type are not set.
kwargs – Deprecated. Use
schema
instead. Schema to use in case db and/or tick_type are not set.
Examples
We can define schema:
>>> data = otp.Empty(schema={'A': str, 'B': int}) >>> otp.run(data) Empty DataFrame Columns: [A, B, Time] Index: [] >>> data.columns() {'A': <class 'str'>, 'B': <class 'int'>, 'TIMESTAMP': <class 'onetick.py.types.nsectime'>, '_START_TIME': <class 'onetick.py.types.nsectime'>, '_END_TIME': <class 'onetick.py.types.nsectime'>, '_SYMBOL_NAME': <class 'str'>, '_DBNAME': <class 'str'>, '_TICK_TYPE': <class 'str'>, '_TIMEZONE': <class 'str'>}
Or we can get schema from the database:
>>> data = otp.Empty(db='SOME_DB', tick_type='TT') >>> data.columns() {'X': <class 'int'>, 'TIMESTAMP': <class 'onetick.py.types.nsectime'>, '_START_TIME': <class 'onetick.py.types.nsectime'>, '_END_TIME': <class 'onetick.py.types.nsectime'>, '_SYMBOL_NAME': <class 'str'>, '_DBNAME': <class 'str'>, '_TICK_TYPE': <class 'str'>, '_TIMEZONE': <class 'str'>}