otp.inspection.DB#
- class DB(name, context=utils.default)#
Bases:
object
An object of available databases that the
otp.databases()
function returns. It helps to make initial analysis on the database level: available tick types, dates with data, symbols, tick schema, etc.- dates()#
Returns list of dates for which data is available.
- Returns
Returns
None
when there is no data in the database- Return type
datetime.date
orNone
Examples
>>> some_db = otp.databases()['SOME_DB'] >>> some_db.dates() [datetime.date(2003, 12, 1)]
- property last_date#
The latest date on which db has data
- Returns
Returns
None
when there is no data in the database- Return type
datetime.datetime
orNone
Examples
>>> some_db = otp.databases()['SOME_DB'] >>> some_db.last_date datetime.date(2003, 12, 1)
- tick_types(date=None, timezone=None)#
Returns list of tick types for the
date
.- Parameters
- Returns
List with string values of available tick types.
- Return type
Examples
>>> nyse_taq_db = otp.databases()['NYSE_TAQ'] >>> nyse_taq_db.tick_types(date=otp.dt(2022, 3, 1)) ['QTE', 'TRD']
- schema(date=None, tick_type=None, timezone=None)#
Gets the schema of the database.
- Parameters
date (
otp.dt
,datetime.datetime
, optional) – Date for the schema.None
means thelast_date
tick_type (str, optional) – Specifies a tick type for schema.
None
means use the one available tick type, if there are multiple tick types then it raises theException
. It uses thetick_types()
method.timezone (str, optional) – Allows to specify a timezone for searching tick types.
- Returns
Dict where keys are field names and values are
onetick.py
types. It’s compatible with theonetick.py.Source.schema
methods.- Return type
Examples
>>> nyse_taq_db = otp.databases()['NYSE_TAQ'] >>> nyse_taq_db.schema(tick_type='TRD', date=otp.dt(2022, 3, 1)) {'PRICE': <class 'float'>, 'SIZE': <class 'int'>}
- symbols(date=None, timezone=None, tick_type=None, pattern='.*')#
Finds a list of available symbols in the database
- Parameters
date (
otp.dt
,datetime.datetime
, optional) – Date for the symbols look up.None
means thelast_date
tick_type (str, optional) – Tick type for symbols.
None
means union across all tick types.timezone (str, optional) – Timezone for the lookup.
None
means the default timezone.pattern (str) – Regular expression to select symbols.
- Return type
Examples
>>> nyse_taq_db = otp.databases()['NYSE_TAQ'] >>> nyse_taq_db.symbols(date=otp.dt(2022, 3, 1), tick_type='TRD', pattern='^AAP.*') ['AAP', 'AAPL']