otp.RefData#

class RefData(ref_data_type=None, symbol=utils.adaptive, db=utils.adaptive_to_default, start=utils.adaptive, end=utils.adaptive, **kwargs)#

Bases: onetick.py.core.source.Source

Shows reference data for the specified security and reference data type.

It can be used to view corporation actions, symbol name changes, primary exchange info and symbology mapping for a securities, as well as the list of symbologies, names of custom adjustment types for corporate actions present in a reference database as well as names of continuous contracts in database symbology.

Parameters
  • ref_data_type (str) –

    Type of reference data to be queried. Possible values are:

    • corp_actions

    • symbol_name_history

    • primary_exchange

    • symbol_calendar

    • symbol_currency

    • symbology_mapping

    • symbology_list

    • custom_adjustment_type_list

    • all_calendars

    • all_continuous_contract_names

  • symbol (str, list of str, Source, query, eval query) – Symbol(s) from which data should be taken.

  • db (str) – Name of the database.

  • start (otp.datetime) – Start time for tick generation. By default the start time of the query will be used.

  • end (otp.datetime) – End time for tick generation. By default the end time of the query will be used.

Examples

Show calendars for a database TRAIN_A_PRL_TRD in the given range:

>>> src = otp.RefData(
...     'all_calendars',
...     db='TRAIN_A_PRL_TRD',
...     start=otp.dt(2018, 2, 1),
...     end=otp.dt(2018, 2, 9),
... )  
>>> otp.run(src, symbol_date=otp.dt(2018, 2, 1))  
                 Time        END_DATETIME CALENDAR_NAME SESSION_NAME SESSION_FLAGS DAY_PATTERN  START_HHMMSS          END_HHMMSS TIMEZONE  PRIORITY DESCRIPTION
0 2018-02-01 00:00:00 2018-02-06 23:59:59          FRED      Regular             R   0.0.12345         93000              160000  EST5EDT         0
1 2018-02-06 23:59:59 2018-02-07 23:59:59          FRED      Holiday             H   0.0.12345         93000              160000  EST5EDT         1
2 2018-02-07 23:59:59 2050-12-31 23:59:59          FRED      Regular             F   0.0.12345         93000              160000  EST5EDT         0

See also

REF_DATA OneTick event processor