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.- property access_info: dict#
Get access info for this database and current user.
All dates are returned in GMT timezone.
This function result is cached, cache will be cleared after each
otp.databases
call.Examples
>>> some_db = otp.databases()['SOME_DB'] >>> some_db.access_info {'DB_NAME': 'SOME_DB', 'READ_ACCESS': 1, 'WRITE_ACCESS': 1, 'MIN_AGE_SET': 0, 'MIN_AGE_MSEC': 0, 'MAX_AGE_SET': 0, 'MAX_AGE_MSEC': 0, 'MIN_START_DATE_SET': 0, 'MIN_START_DATE_MSEC': Timestamp('1970-01-01 00:00:00'), 'MAX_END_DATE_SET': 0, 'MAX_END_DATE_MSEC': Timestamp('1970-01-01 00:00:00'), 'MIN_AGE_DB_DAYS': 0, 'MIN_AGE_DB_DAYS_SET': 0, 'MAX_AGE_DB_DAYS': 0, 'MAX_AGE_DB_DAYS_SET': 0, 'CEP_ACCESS': 0, 'DESTROY_ACCESS': 0}
See also
ACCESS_INFO OneTick event processor
- property min_acl_start_date: Optional[datetime.date]#
Minimum start date set in ACL for current user. Returns None if not set.
- property max_acl_end_date: Optional[datetime.date]#
Maximum end date set in ACL for current user. Returns None if not set.
- dates(respect_acl=False)#
Returns list of dates in GMT timezone 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 and the current user has access to.
- 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.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']