otp.Symbols#

class Symbols(db=None, tick_type='ANY', start=utils.adaptive, end=utils.adaptive, date=None, find_params=None, keep_db=False, pattern='%', for_tick_type=None, show_tick_type=False, symbology='', show_original_symbols=False, **kwargs)[source]#

Bases: onetick.py.core.source.Source

Construct a source that returns ticks with information about symbols in a database. The SYMBOL_NAME field is populated with symbol names. The TICK_TYPE field contains corresponding tick type (enables by the show_tick_type parameter).

Parameters
  • db (str) – Name of the database where to search symbols

  • tick_type (str,) – Tick type to use. Default is ANY

  • 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.

  • date (datetime.date) – Alernative way of setting instead of start/end times

  • keep_db (bool) – Flag that indicates whether symbols should have a db prefix.

  • pattern (str) – SQL syntax patter for symbols. Default is ‘%’

  • for_tick_type (str) – Fetch only symbols belong to this tick type, if specified.

  • show_tick_type (bool) – Add the TICK_TYPE column with the information about tick type

  • symbology (str) – The destination symbology for a symbol name translation. Translation is performed, if destination symbology is not empty and is different from that of the queried database.

  • show_original_symbols (bool) – Switches original symbol name propagation as a tick field ORIGINAL_SYMBOL_NAME if symbol name translation is performed (if symbology is set). Note that if this parameter is set to True, database symbols with missing translations are also propagated.

Note

Additional fields that can be added to Symbols will be converted to symbol parameters

Examples

>>> s = otp.Symbols('SOME_DB')
>>> d = otp.DataSource('SOME_DB', tick_type='TT')
>>> sorted(otp.run(d, symbols=s).keys())
['S1', 'S2']