otp.Empty#

class Empty(db=utils.adaptive_to_default, symbol=utils.adaptive_to_default, tick_type=None, start=utils.adaptive, end=utils.adaptive, **schema)[source]#

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 or utils.adaptive) – Time interval from which the data should be taken.

  • end (datetime.datetime, otp.datetime or utils.adaptive) – Time interval from which the data should be taken.

  • schema (schema to use in case db and/or tick_type are not set) –

Examples

We can define schema:

>>> data = otp.Empty(A=str, B=int)
>>> data.to_df()
Empty DataFrame
Columns: []
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'>}