2. Core Concepts at a Glance
This chapter organizes the core concepts in qteasy in tables and brief notes, making it easy to quickly look them up when reading subsequent chapters or using the API. For a more complete structure and relationships, see Overall Architecture and Design Approach.
2.1. 1. 概念表(名称 / 含义 / 在文档中的位置)
Concepts |
Meaning |
Where It Fits in This Series |
|---|---|---|
DataSource |
An abstraction of local data storage that manages historical data tables in files or databases, and does not proactively pull data. |
|
Data Table |
Tables in the DataSource that store market, financial, macro, and other data in a unified structure. |
|
DataType |
A type description of “information that a strategy can reference,” determined by name, freq, asset_type, etc. |
Data Retrieval, Storage, and Data Types, How Strategies Declare and Use Data |
htype |
Historical data type name (e.g., close, open), often used together with freq and asset_type to identify a kind of data |
|
dtype_id |
The unique identifier of a DataType, in the form |
See “Composition and Examples of dtype_id” below. |
Operator |
The strategy container and execution entry point; holds a list of Groups and the group_timing_table, and provides run(config) |
|
Group |
A collection of strategies with the same run_freq and run_timing, with a signal_type and a blender |
|
Strategy |
The base Strategy class and its subclasses; declares data_types/window_length and Parameters, and implements realize() |
|
run_freq |
The execution frequency of a strategy (group), e.g., |
|
run_timing |
When a strategy (group) runs within a period, e.g., |
|
group_timing_table |
A Time Step × Group table that marks which Groups run at each time step. |
|
blender |
How signals from multiple strategies within the same Group are combined (expression or default rules) |
|
signal_type |
Signal types: PT (target position), PS (proportional buy/sell), VS (quantity buy/sell) |
Below: “Three signal types PT/PS/VS” |
Parameter |
Definition of strategy tunable parameters (name, type, value range, etc.) |
|
data_types |
Required data types declared by the strategy (DataType or list) |
|
window_length |
Window length of historical data required by the strategy (e.g., 20 days) |
|
realize() |
Strategy logic entry point; takes no parameters; fetches data via get_pars/get_data and returns signals |
|
get_data / get_pars |
Within realize(), fetch data by dtype_id and fetch tunable parameters by parameter name |
|
Backtester |
Backtest executor: drives the Operator according to group_timing_table and simulates fills |
|
Optimizer |
Optimizer: searches the parameter space and runs backtests multiple times, aggregating the objective function |
|
Trader |
Live trading management: triggers the Operator according to schedule and coordinates the Broker |
|
Broker |
Abstract interface for order execution and fill reports |
|
config |
Run configuration (asset pool, time range, costs, capital plan, etc.), shared by backtesting/live trading/optimization |
|
qt.run |
Unified entry point: qt.run(op, mode=…, **kwargs) → op.run(config, datasource, logger) |
2.2. 2. dtype_id 的构成与示例
dtype_id is composed of three parts concatenated together: name_assettype_freq.
name: data type name (e.g., close, open, total_mv, pe).
assettype: asset type, such as
E(stocks),IDX(index),ANY(any).freq: data frequency, e.g.,
d(daily),w(weekly),m(monthly),q(quarterly).
Example:
dtype_id |
Meaning |
|---|---|
|
Daily closing price of stocks |
|
Daily closing price of an index |
|
Daily closing price of any asset |
|
Quarterly total market capitalization of stocks |
|
Daily stock P/E ratio (if available) |
When the strategy calls get_data(dtype_id), the id used must match the dtype_id generated by the DataType declared by the strategy (usually viewable via the strategy’s data_type_ids property).
2.3. 3. 三种信号类型 PT/PS/VS 的语义对比表
Type |
Full name |
Meaning (one sentence) |
Example |
|---|---|---|---|
PT |
Position Target |
Target position ratio: the signal indicates the desired long/short position ratio to reach. |
0.5 indicates a target 50% long position. |
PS |
Proportion Signal |
Proportional trading: the signal indicates what proportion of capital or holdings to buy/sell. |
0.5 indicates using 50% of capital to buy, or selling 50% of the position. |
VS |
Volume Signal |
Quantity-based trading: the signal indicates the quantity to buy/sell (shares or units). |
100 indicates buying 100 shares; -50 indicates selling 50 shares. |
The same numeric value will be interpreted as different order intents under different signal_type; a Group’s signal_type is determined when adding the strategy, and strategies within the same group output the same type of signal, which is then blended by the blender.
2.4. 4. 三种策略基类的输入/输出对比表
Base class |
Typical use cases |
Inputs (get_data, etc.) |
Outputs (return value of realize) |
|---|---|---|---|
RuleIterator |
Market timing, single-rule iteration |
Single-asset or multi-asset data window (by dtype_id) |
Scalar signal (e.g., 1 / -1 / 0); the same rule applies to all assets |
FactorSorter |
Factor-based stock selection |
Multi-asset cross-sectional data (e.g., factor values for multiple stocks) |
1D factor array (one value per asset); the engine selects stocks by factor ranking and filtering rules |
GeneralStg |
General-purpose multi-asset strategy |
Multi-asset, multi-data-type data window |
1D signal array (one target position or buy/sell ratio per asset) |
For more details, see How Strategy Runs: Timing, Data, and Parameters.