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 Acquisition, Storage, and Data Types

Data Table

Tables in the DataSource that store market, financial, macro, and other data in a unified structure.

Data Acquisition, Storage, and Data Types

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

Data Acquisition, Storage, and Data Types

dtype_id

The unique identifier of a DataType, in the form name_assettype_freq (e.g., close_E_d)

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)

Operator and Group

Group

A collection of strategies with the same run_freq and run_timing, with a signal_type and a blender

Operator and Group

Strategy

The base Strategy class and its subclasses; declares data_types/window_length and Parameters, and implements realize()

How a Strategy Runs

run_freq

The execution frequency of a strategy (group), e.g., 'd' for daily, 'm' for monthly.

Operator and Group

run_timing

When a strategy (group) runs within a period, e.g., 'close' at close, 'open' at open.

Operator and Group

group_timing_table

A Time Step × Group table that marks which Groups run at each time step.

Operator and Group

blender

How signals from multiple strategies within the same Group are combined (expression or default rules)

Operator and Group

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

How a Strategy Runs

data_types

Required data types declared by the strategy (DataType or list)

How a strategy declares and uses data

window_length

Window length of historical data required by the strategy (e.g., 20 days)

How a strategy declares and uses data

realize()

Strategy logic entry point; takes no parameters; fetches data via get_pars/get_data and returns signals

How a Strategy Runs

get_data / get_pars

Within realize(), fetch data by dtype_id and fetch tunable parameters by parameter name

How a strategy declares and uses data

Backtester

Backtest executor: drives the Operator according to group_timing_table and simulates fills

Backtesting, Live Trading, and Optimization

Optimizer

Optimizer: searches the parameter space and runs backtests multiple times, aggregating the objective function

Backtesting, Live Trading, and Optimization

Trader

Live trading management: triggers the Operator according to schedule and coordinates the Broker

Backtesting, Live Trading, and Optimization

Broker

Abstract interface for order execution and fill reports

Backtesting, Live Trading, and Optimization

config

Run configuration (asset pool, time range, costs, capital plan, etc.), shared by backtesting/live trading/optimization

Backtesting, Live Trading, and Optimization

qt.run

Unified entry point: qt.run(op, mode=…, **kwargs) → op.run(config, datasource, logger)

Backtesting, Live Trading, and Optimization

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

close_E_d

Daily closing price of stocks

close_IDX_d

Daily closing price of an index

close_ANY_d

Daily closing price of any asset

total_mv_E_q

Quarterly total market capitalization of stocks

pe_E_d

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.