Metadata#

A series of simple examples are provided showing how to retrieve metadata about each database or table.

Database Listing#

The list of Databases can be retrieved using the ShowDBList object. The run method expects a time range through start and end, and a symbol, although in this case the time range is ignored, and the symbol should correspond to any database in the environment.

Directed Graph returning list of Databases#
def db_list():
    db_list = otq.ShowDbList()
    graph = otq.Graph(db_list)
    return graph

result = otq.run(query,
    http_address=rest_url,access_token=access_token,
    output_mode="pandas",
    start=datetime(2024,1,3),
    end = datetime(2024,1,4),
    timezone='Europe/London',
    symbols='DB_INFO::'
    )

Database Authorized Listing#

The list of authorised Databases, including restrictions around time ranges can be retrieved through the AccessInfo object. The SYMBOL_NAME where clause needs to be specified.

Directed Graph returning Authorised list of Databases#
def auth_db_list():
    db_list = otq.AccessInfo(info_type='DATABASES')
    filter = otq.WhereClause(where='READ_ACCESS=1')
    graph = otq.Graph(db_list >> filter)
    return graph

Database Symbol Listing#

Databases are partitioned by symbol, and must be queried by SYMBOL_NAME. The list of available symbols for a specified database can change by day, and can be retrieved using the FindDbSymbols object. In this case the queried symbol is the database suffixed with ::. e.g. US_COMP_SAMPLE::

Symbol Listing for Specified Database and Time Window#
def sym_list():
    sym_list = otq.FindDbSymbols(pattern='%')
    graph = otq.Graph(sym_list)
    return graph

result = otq.run(sym_list,
    http_address=rest_url,access_token=access_token,
    output_mode="pandas",
    start=datetime(2024,1,3),
    end = datetime(2024,1,4),
    timezone='America/New_York',
    symbols='US_COMP_SAMPLE::'
    )

Table Listing#

The list of tables for a specified database can be retrieved using the DbShowTickTypes object. In this case the queried symbol is the database suffixed with ::. e.g. US_COMP_SAMPLE::

Table Listing for Specified Database#
def table_list():
    tick_types = otq.DbShowTickTypes()
    graph = otq.Graph(tick_types)
    return graph

result = otq.run(table_list,
    http_address=rest_url,access_token=access_token,
    output_mode="pandas",
    start=datetime(2024,1,3),
    end = datetime(2024,1,4),
    timezone='Europe/London',
    symbols='US_COMP_SAMPLE::'
    )

Field Listing#

The list of fields for a specified database can be retrieved using the ShowTickDescriptor object. Each Symbol may potentially have a different schema so the symbol should also be specified along with the database, and time range.

Field Listing for Specified Database, Symbol and Table, on a specified date.#
def field_schema():
    field_schema = otq.ShowTickDescriptor().tick_type('TRD')
    graph = otq.Graph(field_schema)
    return graph

result = otq.run(field_schema,
    http_address=rest_url,access_token=access_token,
    output_mode="pandas",
    start=datetime(2024,1,3),
    end = datetime(2024,1,4),
    timezone='America/New_York',
    symbols='US_COMP_SAMPLE::CSCO'
    )