1. Configure QTEASY

View the current system configuration information of qteasy:

qteasy.configuration(config_key=None, level=0, up_to=0, default=True, verbose=False) None[source]

View the current configuration variables of qteasy,

Parameters:
  • config_key (str or list of str) – The variable name to be displayed. If no name is given, all matching variable names are displayed according to level, up_to, etc. Multiple variable names can be given in the form of a comma-separated string or in the form of a list. The following two methods are equivalent: ‘local_data_source, local_data_file_type, local_data_file_path’ [‘local_data_source’, ‘local_data_file_type’, ‘local_data_file_path’]

  • level (int, Default: 0) – The level of the configuration variable to be displayed. If config is given, this parameter is ignored

  • up_to (int, Default: 0) – The upper limit of the level of the configuration variable to be displayed. It needs to be set in conjunction with level. For example, when level == 0, up_to == 2, all configuration variables at levels 0 to 2 will be displayed. If config is given, this parameter is ignored

  • default (Bool, Default: False) – If or not show the default value of the configuration variable, if True, both the current value and the default value of the configuration variable will be shown

  • verbose (Bool, Default: False) – Whether to display the full description information, if True, the detailed description of the configuration variable will be displayed at the same time.

Return type:

None

Notes

See get_config() for an example of its use.

qteasy.get_config(config_key=None, level=0, up_to=0, default=True, verbose=False)[source]

Display qt’s current configuration variables, same as get_config / configuration

Parameters:
  • config_key (str or list of str) – The variable name to be displayed. If no name is given, all matching variable names are displayed according to level, up_to, etc. Multiple variable names can be given in the form of a comma-separated string or in the form of a list. The following two methods are equivalent: ‘local_data_source, local_data_file_type, local_data_file_path’ [‘local_data_source’, ‘local_data_file_type’, ‘local_data_file_path’]

  • level (int, Default: 0) – The level of the configuration variable to be displayed. If config is given, this parameter is ignored

  • up_to (int, Default: 0) – The upper limit of the level of the configuration variable to be displayed. It needs to be set in conjunction with level. For example, when level == 0, up_to == 2, all configuration variables at levels 0 to 2 will be displayed. If config is given, this parameter is ignored

  • default (Bool, Default: False) – If or not show the default value of the configuration variable, if True, both the current value and the default value of the configuration variable will be shown

  • verbose (Bool, Default: False) – Whether to display the full description information, if True, the detailed description of the configuration variable will be displayed at the same time.

Return type:

None

Examples

>>> get_config('local_data_source')
No. Config-Key            Cur Val        Default val
----------------------------------------------------
1   local_data_source     database       <file>
>>> get_config('local_data_source, local_data_file_type, local_data_file_path')
No. Config-Key            Cur Val        Default val
----------------------------------------------------
1   local_data_source     database       <file>
2   local_data_file_type  csv            <csv>
3   local_data_file_path  data/          <data/>
>>> get_config(level=0, up_to=2)
No. Config-Key            Cur Val        Default val
----------------------------------------------------
1   mode                  1              <1>
2   time_zone             Asia/Shanghai  <Asia/Shanghai>
3   asset_pool            000300.SH      <000300.SH>
4   asset_type            IDX            <IDX>
5   live_trade_account_id None           <None>
6   live_trade_account    None           <None>
7   live_trade_debug_mode False          <False>
8   live_trade_init_cash  1000000.0      <1000000.0>
... (more rows)
>>> get_config(level=0, up_to=1, verbose=True)
No. Config-Key            Cur Val        Default val
      Description
----------------------------------------------------
1   mode                  1              <1>
      qteasy 的运行模式:
      0: 实盘运行模式
      1: 回测-评价模式
      2: 策略优化模式
      3: 统计预测模式
2   time_zone             Asia/Shanghai  <Asia/Shanghai>
      回测时的时区,可以是任意时区,例如:
      Asia/Shanghai
      Asia/Hong_Kong
      US/Eastern
      US/Pacific
      Europe/London
      Europe/Paris
      Australia/Sydney
      Australia/Melbourne
      Pacific/Auckland
      Pacific/Chatham
      etc.
3   asset_pool            000300.SH      <000300.SH>
      可用投资产品池,投资组合基于池中的产品创建
4   asset_type            IDX            <IDX>
      投资产品的资产类型,包括:
      IDX  : 指数
      E    : 股票
      FT   : 期货
      FD   : 基金
qteasy.get_configurations(config_key=None, level=0, up_to=0, default=True, verbose=False)[source]

Display qt’s current configuration variables, same as get_config / configuration

Parameters:
  • config_key (str or list of str) – The variable name to be displayed. If no name is given, all matching variable names are displayed according to level, up_to, etc. Multiple variable names can be given in the form of a comma-separated string or in the form of a list. The following two methods are equivalent: ‘local_data_source, local_data_file_type, local_data_file_path’ [‘local_data_source’, ‘local_data_file_type’, ‘local_data_file_path’]

  • level (int, Default: 0) – The level of the configuration variable to be displayed. If config is given, this parameter is ignored

  • up_to (int, Default: 0) – The upper limit of the level of the configuration variable to be displayed. It needs to be set in conjunction with level. For example, when level == 0, up_to == 2, all configuration variables at levels 0 to 2 will be displayed. If config is given, this parameter is ignored

  • default (Bool, Default: False) – If or not show the default value of the configuration variable, if True, both the current value and the default value of the configuration variable will be shown

  • verbose (Bool, Default: False) – Whether to display the full description information, if True, the detailed description of the configuration variable will be displayed at the same time.

Return type:

None

Examples

See get_config() for an example of its use.

Modify qteasy’s configuration information.

qteasy.configure(config=None, reset=False, only_built_in_keys=True, **kwargs) None[source]

Configure qteasy’s runtime parameters QT_CONFIG

Parameters:
  • config (ConfigDict 对象) – If you need to set or adjust the parameters of the config object, the default is None, then set the parameters directly to the QT_CONFIG object.

  • reset (bool) – Defaults to False, True ignores incoming kwargs and sets all parameters to their default values

  • only_built_in_keys (bool) – Default value is False, if True, only internal parameters are allowed to be passed, False allows any parameter to be passed.

  • **kwargs – All parameters to be set

Return type:

None

Notes

Use get_config() or configuration() to view the current QT_CONFIG parameters

Examples

>>> configure(reset=True)  # 将QT_CONFIG参数设置为默认值
>>> configure(invest_cash_amounts=[10000, 20000, 30000], invest_cash_dates=['2018-01-01', '2018-02-01', '2018-03-01'])
>>> get_config('invest_cash_amounts, invest_cash_dates')
No. Config-Key            Cur Val                       Default val
-------------------------------------------------------------------
1   invest_cash_amounts   [10000, 20000, 30000]         <[100000.0]>
2   invest_cash_dates     ['2018-01-01', '2018-02-01'...<None>
qteasy.set_config(config=None, reset=False, only_built_in_keys=True, **kwargs) None[source]

Configure the qteasy runtime parameter QT_CONFIG, equivalent to configure()

Parameters:
  • config (ConfigDict 对象) – If you need to set or adjust the parameters of the config object, the default is None, then set the parameters directly to the QT_CONFIG object.

  • reset (bool) – Defaults to False, True ignores incoming kwargs and sets all parameters to their default values

  • only_built_in_keys (bool) – Default value is False, if True, only internal parameters are allowed to be passed, False allows any parameter to be passed.

  • **kwargs – All parameters to be set

Return type:

None

Examples

See also configure()

View, modify, or delete the contents of qteasy’s startup configuration:

qteasy.start_up_settings() None[source]

Print the contents of the boot settings stored in the qteasy boot configuration file

Return type:

None

Examples

>>> import qteasy as qt
>>> qt.start_up_settings()
Start up settings:
--------------------
local_data_source = file
local_data_file_type = csv
local_data_file_path = data/
qteasy.update_start_up_setting(**kwargs) None[source]

Updating boot settings stored in the qteasy boot configuration file

The startup settings can include system-defined configuration parameters as well as user-defined configuration parameters

Parameters:

**kwargs – Configuration parameters to be updated

Return type:

None

Examples

>>> import qteasy as qt
>>> qt.start_up_settings()
Start up settings:
--------------------
local_data_source = file
local_data_file_type = csv
local_data_file_path = data/
>>> qt.update_start_up_setting(local_data_source='database', local_data_file_type='feather')
Start up settings updated successfully!
>>> qt.start_up_settings()
Start up settings:
--------------------
local_data_source = file
local_data_file_type = feather
local_data_file_path = data/
qteasy.remove_start_up_setting(*args) None[source]

Remove one or more boot settings stored in the qteasy boot configuration file

The name of the configuration parameter to be deleted must be given, and multiple configuration parameters can be deleted at the same time

Parameters:

*args (str) – List of required configuration parameter names

Return type:

None

Examples

>>> import qteasy as qt
>>> qt.start_up_settings()
Start up settings:
--------------------
local_data_source = file
local_data_file_type = csv
local_data_file_path = data/
>>> qt.remove_start_up_setting('local_data_source')
Start up settings removed:  ('local_data_source',)
>>> qt.start_up_settings()
Start up settings:
--------------------
local_data_file_type = csv
local_data_file_path = data/

Reset all configuration variables to their default values: the

qteasy.reset_config(config=None)[source]

Reset the config object by setting all parameters to their default values; if config is None, reset qt.QT_CONFIG

Parameters:

config (ConfigDict) – Config objects that need to be reset

Return type:

None

Notes

Equivalent to calling configure(config, reset=True)

Reading configuration information from a file.

qteasy.load_config(*, config=None, file_name=None) ConfigDict[source]
Read the corresponding config parameter from the file file_name and write it to config, if config is

None, then save the parameter to QT_CONFIG

Parameters:
  • config (ConfigDict 对象) – A config object, default None, if not None and is a ConfigDict object, then write the read configuration parameters to the config

  • file_name (str) – File name, default None, if None, file name is saved_config.cfg

Returns:

config – Configuration parameters read in

Return type:

ConfigDict

Raises:
  • FileNotFoundError – Report an error if the given file does not exist. If no filename is given, an error is reported when config/saved_config.cfg does not exist

  • Examples:

  • --------

  • >>> load_config()

Write configuration information to the file.

qteasy.save_config(*, config=None, file_name=None, overwrite=True, initial_config=False) str[source]

Save config as a file Not yet implemented: if initial_config is True, update the configuration to the initialization configuration file qteasy.cfg ()

Parameters:
  • config (ConfigDict or dict, Default: None) – A config object or a dict containing configuration variables; if None, then qt.QT_CONFIG is saved.

  • file_name (str, Default: None) – File name, if None, the file name is “saved_config.cfg”.

  • overwrite (bool, Default: True) – Default True, overwrites renamed files, if False, an error will be reported when the saved file already exists

  • initial_config (bool, Default: False (functionality not implemented)) – Save configuration variables to the initial configuration file qteasy.cfg. If the configuration variables already exist in qteasy.cfg, overwrite the corresponding variables. TODO: Implement the feature to write configuration variables into the qteasy.cfg initial configuration file. Since objects are currently written using pickle as a binary file, while qteasy.cfg is a text file, a new writing method needs to be implemented.

Returns:

file_name – name of the saved file

Return type:

str

All configuration variables for qteasy

The following are the configuration variables of qteasy, you can view the current configuration information by qteasy.get_config() function, and you can also modify the configuration information by qteasy.configure() function.

Note

Entry points to the simulated live-trading docs after completing S1.3 (by usage goal):

  • Quick start: live_trading/1-overview.md

  • Get it running first: live_trading/2-configuration-and-run.md

  • Understand order rejections and statuses: live_trading/3-risk-and-order-lifecycle.md

  • Extend the broker: live_trading/4-broker-adapter-and-integration.md

  • XtQuant/MiniQMT 契约 v1(英文):live_trading/4a-xtquant-broker-adapter-contract-v1.md

  • Debugging and postmortem: live_trading/5-artifacts-and-troubleshooting.md

  • Two-path hands-on tutorial: tutorials/8-live-trade-risk-and-broker-walkthrough.md

Note:

  • live_trading focuses on module capabilities and scenario-based explanations;

  • references focuses on an API-oriented feature list;

  • api focuses on interface details exported by autodoc.

For user-visible order rejection messages, error messages, and log examples, the documentation uses English copy consistently.

qteasy Configuration Variables

Name

Level

Default Value

Description

mode

0

[1, 2, 3] becomes: [0, 1, 0, 2, 0, 3, 0] after padding.

Run mode of qteasy.
0: Live trading mode
1: Backtesting-evaluation model
2: Strategy Optimization Model
3: Statistical forecasting model

time_zone

4

``local’’

The default value is “local”, which means use local time zone.
If you need to fix the time zone, set any legal time zone, for example:
Asia/Shanghai
Asia/Hong_Kong
US/Eastern
US/Pacific
Europe/London
Europe/Paris
Australia/Sydney
Australia/Melbourne
Pacific/Auckland
Pacific/Chatham
etc.

asset_pool

0

000300.SH

Pools of investment products are available and portfolios are created based on the products in the pools

The set of names of the historical data to be fetched, if htypes is empty, the system will try to create all possible htypes by basing on the name of the historical data and the freq/asset_type parameter. the input can be str or list: - str: ‘open, high, low, close’ - list: [‘open’, ‘high’, ‘low’, ‘close’] - list: [‘open’, ‘high’, ‘low’, ‘close’] - list: [‘open’, ‘high’, ‘low’, ‘close’] ‘high’, ‘low’, ‘close’]

0

Limit the types of assets contained in the acquired data to the following options or a combination of the following options. Legitimate combinations include comma-separated strings or lists of strings, e.g., ‘E, IDX’ and [‘E’, ‘IDX’] are both legitimate inputs.

Asset types of investment products, including:
IDX : Index
E : Equities
FT : Futures
FD : Fund

live_trade_account_id

0

``None’’

Live trading account ID for live trading, if this parameter is specified, it will be directly
Execute live trades using this account, if the account ID does not exist, an error will be reported
If account_id is not given, then live_trade_account_name must be given
to create a new account ID

live_trade_account_name

0

``None’’

The name of the account to be used for live trading, if live_trade_account is None
A new account ID must be created, at which point this parameter must be given and account_name set to
Value of this parameter

live_trade_debug_mode

1

True returns the HistoryPanel object, False returns a dictionary containing the DataFrame object.

Live trading debug mode, True: debug mode, False: normal mode

live_trade_init_cash

1

1000000.0

Initial capital for a live trading account, floating point, for example:
1000000.0 : Initial capital of 1 million
1,000,000 : Initial capital of 1,000,000

live_trade_init_holdings

1

``None’’

Initial position in a live trading account, dictionary, for example:
{‘000001.SZ’: 1000, ‘000002.SZ’: 2000} : Initial positions are
000001.SZ: 1000 shares, 000002.SZ: 2000 shares

live_trade_broker_type

1

``simulator’’

The type of trading agent for a live trading account can be set to simulate the trading agent returning results, manually entering results or connecting to the trading agent’s trading interface
Simulator is used by default.

live_trade_broker_params

1

``None’’

Trading agent parameters for live trading accounts, dictionaries, for example:
{‘host’: ‘localhost’, ‘port’: 8888} : hostname and port number of the transaction agent
Please refer to the documentation of the trading agent for specific parameter settings.
If the ‘simulator’ broker is used and this parameter is set to None, the config
backtest parameter

live_price_acquire_channel

2

``Eastmoney’’

A way to get real-time prices when trading live:
eastmoney - Get real-time prices with eastmoney.com
tushare - Get real-time prices with tushare (you need to activate your own permissions)
akshare - Not Implemented: Get Real-Time Prices from akshare

live_price_acquire_freq

2

15MIN

Frequency of access to real-time prices during live trading:
H - Data acquisition every 1 hour
30MIN - Fetch data every 30 minutes
15MIN - Fetch data every 15 minutes
5MIN - data acquisition every 5 minutes
1MIN - Fetch data every 1 minute

watched_price_refresh_interval

4

[(1, 2, 3), (4, 5), (6, 7)] merged to read: [(2), (4.5), (6.5)]

Monitor the real-time price refresh frequency during live trading, in seconds, default is 5 seconds.
This value cannot be lower than 5 seconds

trade_batch_size

0

0.01

Minimum subscription lot size for investment products, floating point, for example:
0.01: You can buy investment products in minimum increments as small as 0.01 units
1. : 只能购买整数份额的投资产品
100: Investment products can be purchased in integral multiples of 100.
n : the number of shares of investment products that can be purchased is an integer multiple of n, and n does not have to be an integer.

sell_batch_size

0

0.01

The minimum sell or redeem lot size of an investment product, in floating point numbers, for example:
0.01: You can sell investment products in minimum increments as small as 0.01 units
1. : 只能购买整数份额的投资产品
100: Investment products can be purchased in integral multiples of 100.
n : the number of shares of investment products that can be purchased is an integer multiple of n, and n does not have to be an integer.

cash_decimal_places

2

[1, 2, 3] becomes: [0, 1, 0, 2, 0, 3, 0] after padding.

Decimal digits of cash, for example:
0: Cash can only be an integer
2: Retain two digits after the decimal point

amount_decimal_places

2

[1, 2, 3] becomes: [0, 1, 0, 2, 0, 3, 0] after padding.

Decimal digits of the share of an investment product, for example:
0: Shares can only be whole numbers
2: Retain two digits after the decimal point

riskfree_ir

1

``0.0035`’’

Risk-free interest rate, if “Consider time value of cash” is selected, then the cash will increase in value at this rate per annum at the time of backtesting.

``parallel`’’

1

``True’’

If True, policy parameter optimization will utilize multi-core CPUs for parallel computation to improve efficiency

hist_dnld_parallel

4

``16’’

Number of threads enabled when downloading historical data, 0 or 1 for single-threaded downloads, greater than 1 for multi-threaded downloads.

hist_dnld_delay

4

0.0

In order to prevent excessive pressure on the server data, the length of delay after downloading a certain amount of data when downloading historical data, in seconds.

hist_dnld_delay_evy

4

0

To prevent the server from being overstressed with data, the download of historical data is delayed for a period of time for every certain amount of data downloaded.
This parameter is the amount of data downloaded between two delays

hist_dnld_prog_bar

4

True returns the HistoryPanel object, False returns a dictionary containing the DataFrame object.

Whether to display a progress bar when downloading historical data

hist_dnld_retry_cnt

4

[(1, 2, 3), (4, 5), (6, 7)] merged to read: [(2), (4.5), (6.5)]

Number of automatic retries for failed downloads of historical data

hist_dnld_retry_delay

4

``1.0’’

Delay time in seconds before auto-retry in case of failure to download historical data

hist_dnld_backoff

4

``2.0’’

Delay time multiplier for automatic retries when downloading historical data fails
For example, setting hist_dnld_backoff = 2 fails every retry
The delay time will become twice as long as the previous one.

auto_dnld_hist_tables

4

[]

[PLANNED] List of historical data table names that are automatically downloaded during live trading, for example:
[“stock_daily”, “index_weekly”, “stock_monthly”]
This feature is not enabled in the current version, and the configuration has no actual effect.

gpu

4

True returns the HistoryPanel object, False returns a dictionary containing the DataFrame object.

[PLANNED] If True, use GPU-accelerated computation during strategy parameter optimization.
This feature is not implemented yet; setting this parameter will not change the runtime behavior of the current version.

local_data_source

1

file

Determine how local historical data is stored:
file - historical data is stored as a local file.
The file format is specified in the “local_data_file_type” attribute, including csv/hdf and other options.
database - historical data is stored in a mysql database
When you select this option, you need to configure the database connection information in the configuration file
db - equivalent to “database”.

local_data_file_type

4

``csv’’

Determines the storage format of the local historical data file:
csv - historical data files are stored in csv form, slow but can be opened in Excel
hdf - historical data files stored in hd5 form, data storage and reading speed faster
feather/fth - historical data files stored in feather format, fast data exchange but not suitable for long-term storage

local_data_file_path

4

HistoryPanel – if as_data_frame is set to False, a HistoryPanel object is returned

Determine the local historical data file storage path

local_db_host

4

``localhost`’’

Hostname of the database used to store historical data, which should be a mysql database or MariaDB

local_db_port

4

``3306’’

The port number of the database used to store historical data, the default value is the port number 3306 of the mysql database

local_db_name

4

qt_db

The name of the database used to store historical data, default value is “qt_db”.

local_db_user

4

The user name for accessing the database, which must have sufficient operational privileges
It is recommended to configure the database username and password through the configuration file

local_db_password

4

Database access password
It is recommended to configure the database username and password through the configuration file

sys_log_file_path

4

syslog/

Storage path for system operation logs and error logs
Supports relative paths (relative to QT_ROOT_PATH), absolute paths, and home-directory paths starting with ~;
Changes made via qt.configure() / qt.set_config() take effect immediately (hot update) without re-importing.
The path must not contain illegal characters (such as control characters, or on Windows <>"|?*), otherwise a ValueError is raised.

trade_log_file_path

4

tradelog/

Storage path for detailed trade logs and trade summaries (shared by backtesting and live trading).
Supports relative paths (relative to QT_ROOT_PATH), absolute paths, and home-directory paths starting with ~;
Changes made via qt.configure() / qt.set_config() take effect immediately (hot update) without re-importing.
The path must not contain illegal characters; otherwise, a ValueError is raised.

trade_log_keep_days

4

[1, 2, 3] becomes: [0, 1, 0, 2, 0, 3, 0] after padding.

Retention days for CSVs written during backtests, such as trade_log_* / trade_summary_* / value_curve_*; default is 3.
After the process loads the qteasy module, perform a one-time daily cleanup on the current trade_log_file_path directory (not before each backtest writes files).
Set to None or less than or equal to 0 to disable auto-deletion; when needed, you can call qt.rotate_trade_logs() to clean up manually.

trade_log

1

``True’’

Whether to generate a detailed list of transactions, giving a detailed list of daily transactions in the form of pd.DataFrame
Includes trading signals and trading results at each step

benchmark_asset

1

000300.SH

Asset type used to generate benchmark returns for backtesting results evaluation results, default benchmark is CSI 300 Index
Benchmark indices are used to generate multipurpose evaluation results such as alpha, beta ratios, etc., because these metrics, in addition to examining the investment returns of the
In absolute terms, it is also necessary to consider the average performance of the market over the same period, and only if the investment returns outperform the average market performance will the
be counted as excess or alpha returns, which is what the investment strategy seeks to achieve
The benchmark asset type and price type are automatically inferred by the system based on benchmark_asset and the runtime schedule.

``report’’

1

``True’’

Prints a report of run results when True
Real-time mode displays a report on strategy operation, backtest mode displays a report on backtest results, and optimization mode displays a report on optimization results.

``visual’’

0

``True’’

Use charts to display the results of a visualization run when it is True
(Backtesting mode displays backtesting reports and optimization mode displays optimization results reports)

``buy_sell_points`’’

4

``True’’

True displays buy and sell points on the backtest chart, using red and green arrows to indicate the position of the buy and sell points.

show_positions

4

``True’’

True shows investment positions with a color band in the backtest charts

cost_fixed_buy

2

0.0

Fixed cost or fixed commission on the purchase of a security or asset that does not vary with the amount of the purchase
The default value is $10

cost_fixed_sell

2

0.0

Fixed cost or fixed commission on the sale of a security or asset that does not vary with the amount sold
Default value is 0

cost_rate_buy

1

``0.0003`’’

The cost rate or commission rate when buying a security or asset, calculated as a percentage of the purchase amount
The default value is 3 parts per million

cost_rate_sell

1

0.0001

Cost rate or commission rate when selling a security or asset, calculated as a percentage of the amount sold
The default value is 1 in 10,000

cost_min_buy

2

``5.0’’

The minimum cost or commission at which a security or asset is bought, and the buying commission can only be greater than or equal to that minimum amount
The default value is $5

cost_min_sell

2

``5.0’’

The minimum cost or commission when selling a security or asset, and the selling commission can only be greater than or equal to that minimum amount

cost_slippage

2

0.0

Slippage, a preset parameter that simulates additional transaction costs due to trading delays or large transaction amounts.

invest_start

0

``None’’

Start date of backtesting in backtesting mode
When left blank (None), it will be automatically inferred at runtime as the date one year earlier based on invest_end (or the current date).
When set explicitly, the format is “YYYYMMDD”.

invest_end

0

``None’’

End date of backtesting in backtesting mode
When left blank (None), the current date will be used automatically at runtime.
When set explicitly, the format is “YYYYMMDD”.

invest_cash_amounts

1

``[100000.0]’’

Amount of money invested, a tuple or list, the amount of money invested each time, multiple numbers indicate multiple investments

invest_cash_dates

2

``None’’

Backtest the date of the operation’s cash input, a str or list, with multiple dates indicating multiple cash inputs. Default is None
When this parameter is None, the cash input date is the same as invest_start, and when the parameter is not None, this parameter overrides the
invest_start
When the parameter input type is str, the format is “YYYYMMDD”.
If you need to simulate multiple fixed inputs of cash, or multiple diversified inputs, you can enter a list type or str type
The following two input methods are equivalent:
“20100104,20100202,20100304” =
[“20100104”, “20100202”, “20100304”]

``allow_sell_short`’’

4

True returns the HistoryPanel object, False returns a dictionary containing the DataFrame object.

Whether or not short selling transactions are permitted,:
False - default value, short selling is not allowed, the maximum number of sells is only the number of currently available positions
True - short selling is allowed, if the quantity sold is greater than the quantity held, then a short position is held

long_position_limit

3

``1.0’’

The limit value of the percentage of long positions allowed to be established by trading signals during backtesting, i.e., the percentage of long positions allowed to be utilized
what percentage of total assets (including cash and total stock holdings) is used to hold long positions.
Default value 1.0, i.e. 100%
If the value is set greater than 1, it means that it is allowed to build a position in excess of the cash held, a situation that generates negative cash
Balance, indicating debits and credits incurred

short_position_limit

3

``-1.0’’

The limit value of the percentage of short positions allowed to be established by trading signals during backtesting, i.e., the percentage of allowed holdings of
Maximum percentage limit of short positions to total current net assets, default value -1.0, i.e., the maximum allowed borrowing
Equity equal to 100% of the value of total net assets and hold a short position, when a negative equity share is held and the
Generate positive cash inflows

backtest_price_adj

4

``none’’

Compound price treatment in backtesting:
The treatment of stock dividends and ex-rights, normally, should be calculated at the time of the stock dividends and ex-rights dividends and dividend payments on the position
Volume and cash impacts, but this treatment is currently complex, and for the time being, a simpler approach will be used.
method, i.e., backtesting directly using compounded prices, is currently handled in two ways
- none/n - 默认值,不使用复权价格,但也不处理派息,这只是临时处理,因
Disregarding ex-dividend for the purpose of long-term backtesting will result in a significant difference between the backtested results and the actual results.
- back/b - 使用后复权价格回测,可以弥补不考虑分红派股的不足
- adj - 使用前复权价格回测。

PT_signal_timing

3

``lazy’’

When the backtest signal mode is PT (position target), the control checks the actual position percentage and automatically generates trades.
The timing of the signal, default normal
- aggressive: 在整个策略运行时间点上都会产生交易信号,不论此时PT信号是否发
We monitor the difference between actual and planned positions in real time, whenever there is a deviation between the two.
The signal is generated when you are away from it.
- lazy: 在策略运行时间点上,只有当持仓比例发生变化时,才会产生交易
Signals, not real-time monitoring of actual versus planned positions

PT_buy_threshold

3

0.0

Position difference threshold for triggering buy signals when the backtest signal mode is PT (position target)
In this model, a buy signal is triggered when the position of the investment product held is lower than the target position and the difference exceeds a threshold value
For example, when the sell threshold is 0.05 i.e. 5%, if the target position is 30%, then only if the actual position is <= 25%, then the
Trading signals, i.e. when the difference between the actual position and the target position is greater than 5%.

PT_sell_threshold

3

0.0

Position difference thresholds for triggering sell signals when the backtest signal mode is PT (position target)
In this model, a sell signal is triggered when the position of the investment product held is higher than the target position and the difference exceeds a threshold value
For example when the sell threshold is 0.05 i.e. 5%, if the target position is 30%, then only if the actual position is >= 35%, then it will generate
Trading signals, i.e. when the difference between the actual position and the target position is greater than 5%.

price_priority_OHLC

3

``OHLC’’

When backtesting if there are multiple price types of trading signals and the type of trading price is OHLC, the processing of various
Prioritization of different price signals.
The input type is a character string, O, H, L, C, A stands for Open, High, Low, Close, Nav respectively.

price_priority_quote

3

``Normal’’

If there are multiple price types of trading signals at the time of backtesting, and the type of trading price is a real-time quote, the backtesting program processes the
Prioritization of different price signals.
Inputs include “normal” and “reverse”, respectively:
- “normal”: 优先处理更接近成交价的报价,如卖1/买1等
- “reverse”: 优先处理更远离成交价的报价,如卖5/买5等

cash_delivery_period

3

0

The delivery cycle for selling a stock for cash in backtesting is represented by a number N, which means that cash delivery can be completed on the Nth day after the trade date.
Cash is added to total assets as soon as it is acquired, but funds in transit (funds that have not yet been delivered) cannot be used for the next transaction
When the cash delivery period is zero, there is an option to sell the asset first in the same round to get as much cash as possible to use in the round
BUY

stock_delivery_period

3

[1, 2, 3] becomes: [0, 1, 0, 2, 0, 3, 0] after padding.

The stock delivery cycle after the stock is bought during backtesting, using a number N to represent the Nth day after the trade date on which the asset delivery can be completed.
Shares are added to total assets immediately upon acquisition, but shares not yet delivered cannot be used for the next transaction

market_open_time_am

3

09:30:00

Morning opening hours of trading markets

market_close_time_am

3

``11:30:00’’

Morning closing time of the trading market

market_open_time_pm

3

``13:00:00`’’

Afternoon opening hours of trading markets

market_close_time_pm

3

15:00:00

Afternoon closing time of the trading market

strategy_open_close_timing_offset

3

[1, 2, 3] becomes: [0, 1, 0, 2, 0, 3, 0] after padding.

The opening/closing runtime offset of the strategy signal in minutes, when the strategy signal runtime is opening/closing and needs to be brought forward/postponed
An offset is run to avoid not being able to trade.

opti_start

0

``None’’

Strategy Optimization Interval Start Date in Optimization Mode
When left blank (None), it will be automatically inferred at runtime as the date one year prior to opti_end.

opti_end

0

``None’’

End date of the strategy optimization interval in optimization mode
When left blank (None), it will be automatically inferred at runtime based on the current date.

opti_cash_amounts

1

``[100000.0]’’

The amount of money invested in the optimization model, a tuple or list, the amount of money invested each time, multiple numbers indicate multiple investments

opti_cash_dates

2

``None’’

The date of the strategy optimization interval cash input, a str or list, with multiple dates indicating multiple cash inputs. Default is None
When this parameter is None, the cash input date is the same as invest_start, and when the parameter is not None, this parameter overrides the
invest_start
When the parameter input type is str, the format is “YYYYMMDD”.
If you need to simulate multiple fixed inputs of cash, or multiple diversified inputs, you can enter a list type or str type
The following two input methods are equivalent:
“20100104,20100202,20100304” [“20100104”, “20100202”, “20100304”]

opti_type

3

``single’’

Optimization Type. Refers to the way in which the optimized data is utilized.
“single” - In each round of optimization testing, a single backtest covering the entire interval is performed and evaluated on the optimization interval
Backtest results
“multiple” - In each round of the optimization test, the data in the optimization interval is divided into multiple subintervals in which the sub
The intervals are tested separately and the results of all the tests are used to determine the evaluation of the strategy over the entire interval

opti_sub_periods

3

[(1, 2, 3), (4, 5), (6, 7)] merged to read: [(2), (4.5), (6.5)]

Only valid for unsupervised optimization. Only valid for unsupervised optimization, and only when the optimization type is “multiple”. The number of sub-intervals to cut the optimization interval into

opti_sub_prd_length

3

``0.6’’

Only valid if the optimization type is “multiple”. Ratio of the length of each optimization sub-interval to the length of the whole optimization interval.
For example, when the length of the optimization interval is 10 years, this parameter of 0.6 means that the length of each optimization subinterval is 6 years

test_start

0

``None’’

Start date of the strategy test period in optimization mode.
When left blank (None), it will be automatically inferred at runtime as the six months prior to test_end.
When set explicitly, the format is “YYYYMMDD”.

test_end

0

``None’’

Strategy test interval end date in optimization mode
When left blank (None), it will be automatically inferred at runtime based on the current date.
When set explicitly, the format is “YYYYMMDD”.

test_cash_amounts

1

``[100000.0]’’

The Optimization Mode strategy tests the amount of money invested, a tuple or list, each time you put money in.
When simulating cash multiple fixed investment inputs, enter multiple numbers to indicate multiple inputs
The number of digits entered must be the same as the number of dates in cash_dates

test_cash_dates

2

``None’’

The date of the strategy optimization interval cash input, a str or list, with multiple dates indicating multiple cash inputs. Default is None
When this parameter is None, the cash input date is the same as invest_start, and when the parameter is not None, this parameter overrides the
invest_start parameter |
When the parameter input type is str, the format is “YYYYMMDD”.
If you need to simulate multiple fixed inputs of cash, or multiple diversified inputs, you can enter a list type or str type
The following two input methods are equivalent:
“20100104,20100202,20100304” [“20100104”, “20100202”, “20100304”]

test_type

3

``single’’

Test Type. Refers to how the test data is utilized.
“single” - a single backtest covering the entire interval on the test interval in each round of optimization testing
and evaluating backtesting results
“multiple” - In each round of optimization testing, the data from the test interval is divided into multiple subintervals in this
The strategy is tested separately on some subintervals and the results of all the tests are used to determine the strategy’s performance on the whole interval.
Evaluation results
“montecarlo” - a Monte Carlo test that generates a large number of randomized modes based on the statistical nature of the historical data of the test interval
The proposed price change data are used to evaluate the performance of the strategy, and finally the statistical significance is given
Results of the evaluation of the right to education

test_indicators

2

years,fv,return,mdd,v,ref,alpha,beta,sharp,info

Evaluation metrics for testing and evaluating the optimized strategy parameters.
Formatted as a comma-separated string, multiple evaluation metrics are output as a dictionary containing one or more of the following types
“years” - total year
“fv” - final values
“return” - total return rate
“mdd” - max draw down
“ref” - reference data return
“alpha” - alpha rate
“beta” - beta rate
“sharp” - sharp rate
“info” - info rate

indicator_plot_type

2

histo

Types of visualization charts for optimization or test result evaluation metrics.
0 - errorbar type
1 - scatter type
2 - histo type
3 - violin type
4 - box type

test_sub_periods

3

[1, 2, 3] becomes: [0, 1, 0, 2, 0, 3, 0] after padding.

Only valid if test type is “multiple”. Number of test intervals to split into subintervals

test_sub_prd_length

3

``0.75`’’

Valid only if the test type is “multiple”. Ratio of each test sub-interval length to the whole test interval length.
For example, when the length of the test interval is 4 years, this parameter 0.75 means that the length of each test sub-interval is 3 years

test_cycle_count

3

``100’’

Only valid if test type is “montecarlo”. The amount of simulated test data generated.
Generate 100 sets of simulated price data by default and perform 100 strategy backtests and evaluate their statistics

optimize_target

1

final_value

The optimization objective of the strategy. That is, optimization is done with the goal of finding the best strategy for that metric

maximize_target

1

``True’’

Find the strategy with the largest objective value when True, and the strategy with the lowest objective value when False

opti_method

1

[1, 2, 3] becomes: [0, 1, 0, 2, 0, 3, 0] after padding.

Strategy optimization algorithm with the following optional values.
0 - Grid method, grid search of the entire vector space at regular intervals
1 - Monte Carlo method, searching for the best strategy by randomly taking out certain points in the vector space
2 - Incremental Progressive Length Method, which performs multiple rounds of search on the vector space, and selects some of the subsets based on the results at the end of each search round
space, narrowing the step size for further searches
3 - Genetic algorithms to find global optimums by modeling the evolution of populations of organisms in response to environmental stresses (not yet completed)
4 - ML method, machine learning based algorithm for optimal strategy search (not yet completed)

opti_grid_size

3

[1, 2, 3] becomes: [0, 1, 0, 2, 0, 3, 0] after padding.

Useful when searching for the optimal strategy using an exhaustive search method with a search step of

| opti_sample_count

3

``256’’

Useful when searching for an optimal strategy using Monte Carlo methods, the number of samples in the vector space

opti_r_sample_count

3

``16’’

Useful when searching for the optimal strategy using the progressive length method, the number of random samples taken in each round

opti_reduce_ratio

3

``0.1’’

useful when searching for an optimal strategy using the progressive growth method.
Proportion retained on merit after each round of random sampling, and likewise the proportion of subspace reduction

opti_max_rounds

3

[(1, 2, 3), (4, 5), (6, 7)] merged to read: [(2), (4.5), (6.5)]

Useful when searching for an optimal strategy using the progressive length method, the maximum number of rounds for a multi-round search, the search stops when the number of rounds is greater than this value

opti_min_volume

3

``1000’’

Useful when searching for the optimal strategy using the progressive length method, with a minimum volume of space, stopping the search when the spacevolume falls below this value

``opti_population`’’

3

1000.0

Useful in searching for optimal strategies using genetic algorithms, the number of populations

opti_output_count

3

``30’’

Number of optimal parameters output after optimization of policy parameters