14. Start QTEASY

Manage qteasy start up configurations

qteasy.run(op: Operator, **kwargs) Union[dict, list][source]

Run the given Operator according to the current configuration and enter different working modes such as backtesting, optimization, or live trading.

This function is qteasy’s unified entry point: based on the global configuration QT_CONFIG['mode'] (which can be temporarily overridden via qt.configure(mode=...)), it selects live trading mode, backtest mode, optimization mode, etc., automatically prepares the required data sources and log objects, and calls Operator.run() to execute the full workflow. For detailed behavior and output structure of each mode, see the relevant sections in the documentation “Running qteasy and Working Modes”.

Parameters:
  • op (Operator) – An Operator object with strategies and runtime parameters already configured.

  • **kwargs – Configuration items temporarily overridden for this run; the key names must be valid qteasy configuration keys, such as mode, asset_pool, invest_start, invest_end, etc.

Returns:

When mode == 1 (backtest mode), it usually returns a dict containing backtest results; when mode == 2 (optimization mode), it usually returns a list containing results for multiple parameter sets; for the exact return structure in live trading mode and other modes, see Operator.run() and the related documentation.

Return type:

dict or list

Examples

run typically touches external state such as data sources, log paths, and run modes. The example below shows the minimal “visible and stable” call setup:

>>> import qteasy as qt
>>> op = qt.Operator('dma')
>>> op.__class__.__name__
'Operator'

If you have correctly configured the data source and asset pool, you can further execute (the output structure varies by mode)::

qt.run(op, mode=qt.BACKTEST_MODE)
qteasy.info(**kwargs)[source]

Entry function for qteasy module help information (reserved).

Parameters:

**kwargs – Reserved parameter (not used in the current version).

Returns:

Not implemented in the current version; calling it will raise NotImplementedError.

Return type:

None

Raises:

NotImplementedError – Not implemented in the current version.

Examples

This function is a reserved entry point. It is recommended to use the Sphinx documentation or help(qteasy) to get help information:

>>> import qteasy as qt
>>> qt.info.__name__
'info'

Run modes and constants quick reference

qteasy uses a set of global constants to represent run modes (live trading/backtest/optimization/forecast). You can override them temporarily before or after calling qt.run via qt.configure(mode=...), or within qt.run(op, mode=...).

Example (constant values produce stable output):

>>> import qteasy as qt
>>> qt.LIVE_MODE, qt.BACKTEST_MODE, qt.OPTIMIZE_MODE, qt.PREDICT_MODE
(0, 1, 2, 3)

Log and root-directory path constants (values are affected by configuration, and in particular the log path supports runtime hot updates):

>>> import qteasy as qt
>>> isinstance(qt.QT_ROOT_PATH, str)
True
>>> isinstance(qt.QT_SYS_LOG_PATH, str) and isinstance(qt.QT_TRADE_LOG_PATH, str)
True