5. Historical Data Types — the DataType Object

DataType describes a single historical data type as a triplet of name + frequency + asset type—the common language for the data pipeline and for strategies to declare data needs. qteasy ships many built-in DataType instances and supports user-defined types via the documented interfaces.

class qteasy.DataType(name: str = '', *, freq: Optional[str] = None, asset_type: Optional[str] = None)[source]

The core object in qteasy for describing a single historical data type (name, frequency, and asset type).

Each DataType is uniquely defined by name, freq, and asset_type. Use it to declare strategy data needs, drive internal fetch flows such as get_history_data_from_source(), and extend custom types when needed. See the “DataType and Historical Data Type Management” chapter for the full type table and customization workflow.

Examples

The example below shows the DataType class name (stable output). When creating a DataType, provide name/freq/asset_type:

>>> import qteasy as qt
>>> qt.DataType.__name__
'DataType'
property asset_type: str

String form of asset types, e.g. 'E' or 'E,IDX'

property asset_type_str: str

String form of asset types, e.g. 'E' or 'E,IDX'

property asset_types: list

List of user-defined asset types in use

property data_table_names

Resolve table name(s), preferring user-defined names; fall back to built-in table names if none are defined.

property dtype_id

For example: close_E_d

get_available_time(asset_type=None) Optional[str][source]

Time of day when this data type becomes available (e.g., close at 15:00, open at 9:30; intraday types may have no fixed time).

5. Properties

asset_type: str

Asset type such as 'E', 'IDX', 'FD', etc. With multi-asset support, specify asset type to obtain the corresponding availability time.

get_data_from_source(datasource, *, symbols: Optional[str] = None, starts: Optional[Union[str, Timestamp]] = None, ends: Optional[Union[str, Timestamp]] = None)[source]

Method for DataType to fetch data from DataSource according to the type’s retrieval mode.

If symbols is None, returns un-symbolised data; otherwise symbolised data.

Parameters:
  • datasource (DataSource) – Data type object

  • symbols (str) – Comma-separated share codes, e.g. '000001.SZ,000002.SZ'

  • starts (str) – Start date, YYYYMMDD format

  • ends (str) – End date, YYYYMMDD format

property id

Frequency-agnostic ID like close(E), marking data for different asset types

property unsymbolized

return True if this data type is unsymbolized data type (i.e. reference data type)