otp.SymbologyMapping#

class SymbologyMapping(dest_symbology=None, tick_type=utils.adaptive, start=utils.adaptive, end=utils.adaptive, symbols=utils.adaptive, schema=None, **kwargs)#

Bases: onetick.py.core.source.Source

Shows symbology mapping information for specified securities stored in the reference database.

Input (source) symbology is taken from the input symbol, if it has a symbology part in it (e.g., RIC::REUTERS::MSFT), or defaults to that of the input database, which is specified in the locator file.

Parameter symbol_date must be set in otp.run for this source to work.

Parameters
  • dest_symbology (str, otp.param) – Specifying the destination symbology for symbol translation.

  • tick_type (str) –

    Tick type to set on the OneTick’s graph node. Can be used to specify database name with tick type or tick type only.

    By default setting this parameter is not required, database is usually set with parameter symbols or in otp.run.

  • start – Custom start time of the source. If set, will override the value specified in otp.run.

  • end – Custom end time of the source. If set, will override the value specified in otp.run.

  • symbols – Symbol(s) from which data should be taken. If set, will override the value specified in otp.run.

Examples

Getting mapping for OID symbology for one symbol:

>>> data = otp.SymbologyMapping(dest_symbology='OID')
>>> otp.run(symbols='NYSE_TAQ::AAPL',  
...         symbol_date=otp.dt(2022, 1, 3),
...         date=otp.dt(2022, 1, 3))
        Time END_DATETIME MAPPED_SYMBOL_NAME
0 2022-01-03   2022-01-04               9706

Getting mapping for all symbols in NYSE_TAQ database in single source:

>>> data = otp.SymbologyMapping(dest_symbology='OID')
>>> data = otp.merge([data],
...                  symbols=otp.Symbols('NYSE_TAQ', keep_db=True),
...                  identify_input_ts=True)
>>> data = data[['SYMBOL_NAME', 'MAPPED_SYMBOL_NAME']]
>>> otp.run(data,  
...         symbol_date=otp.dt(2022, 1, 3),
...         date=otp.dt(2022, 1, 3))
            Time     SYMBOL_NAME MAPPED_SYMBOL_NAME
0     2022-01-03     NYSE_TAQ::A               3751
1     2022-01-03    NYSE_TAQ::AA             647321
2     2022-01-03   NYSE_TAQ::AAA             695581
3     2022-01-03  NYSE_TAQ::AAAU             673522
4     2022-01-03   NYSE_TAQ::AAC             703090
...          ...             ...                ...
11746 2022-01-03   NYSE_TAQ::ZWS             273584
11747 2022-01-03    NYSE_TAQ::ZY             704054
11748 2022-01-03  NYSE_TAQ::ZYME             655470
11749 2022-01-03  NYSE_TAQ::ZYNE             633589
11750 2022-01-03  NYSE_TAQ::ZYXI             208375