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.
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 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::
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::
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.
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'
)