Integrating three major sources—the official WonderTrader documentation (Read the Docs), community learning notes (WonderTrader-Learning-Notes), and unofficially compiled documentation (docs_wondertrader)—to provide a one-stop reference for wtpy/WonderTrader quantitative trading development.
When to Use This Skill
This skill should be triggered when:
- Use wtpy (WonderTrader Python framework) to develop quantitative strategies
- Use the WonderTrader C++ core for high-frequency/ultra-low-latency trading development
- Configure and run the CTA/SEL/HFT/UFT engines
- Perform strategy backtesting, simulated trading, or live trading
- Handle market data (DSB/CSV conversion, data recording, historical data management)
- Configure and use the WtMonSvr monitoring service or WtStudio
- Connect to trading and market data interfaces such as CTP/openctp/XTP
- Develop custom executors (ExtExecuter) or market data parsers (ExtParser)
- Troubleshoot common WonderTrader issues (compilation, configuration, running)
Quick Reference
Installation
pip install wtpy --upgrade
Backtest (CTA)
from wtpy import WtBtEngine, EngineType
from wtpy.apps import WtBtAnalyst
engine = WtBtEngine(EngineType.ET_CTA)
engine.init('../common/', "configbt.yaml")
engine.configBacktest(202201100930, 202202011500)
engine.commitBTConfig()
straInfo = StraDualThrust(name='pydt_cu', code="SHFE.cu.HOT",
barCnt=50, period="m5", days=30, k1=0.1, k2=0.1, isForStk=False)
engine.set_cta_strategy(straInfo)
engine.run_backtest()
analyst = WtBtAnalyst()
analyst.add_strategy("pydt_cu", folder="./outputs_bt/pydt_cu/",
init_capital=500000, rf=0.02, annual_trading_days=240)
analyst.run()
engine.release_backtest()
Live Trading (CTA)
from wtpy import WtEngine, EngineType
env = WtEngine(EngineType.ET_CTA)
env.init('../common/', "config.yaml")
straInfo = StraDualThrust(name='pydt_au', code="SHFE.au.HOT",
barCnt=50, period="m5", days=30, k1=0.2, k2=0.2, isForStk=False)
env.add_cta_strategy(straInfo)
env.run()
Contract Code Format
- Futures contracts:
CFFEX.IF.2306 - Futures main contracts:
CFFEX.IF.HOT - Commodity options:
CFFEX.IO2007.C.4000 - Stocks:
SSE.STK.600000 - ETF options:
SSE.ETFO.10003961
Trading Engines
| Engine | Applicable scenarios | Driving method | Latency |
|---|---|---|---|
| CTA | Timing/arbitrage with few instruments | Event + time | ~70μs (Python) |
| SEL | Multi-factor stock selection | Time (asynchronous) | - |
| HFT | High-frequency trading | Event | 1-2μs |
| UFT | Ultra-high-frequency (C++ only) | Event | <200ns |
Reference Files
This skill includes comprehensive documentation in references/:
Getting Started & Architecture
- getting-started-official.md - Official quick start (installation, running demos, backtest analysis)
- getting-started-notes.md - Community learning notes (version selection, strategy writing, environment deployment, detailed explanation of backtesting and live trading)
- architecture.md - Architecture analysis (decoupling of signals and trading, strategy groups, risk management)
Strategy Development
- strategies.md - Classic strategy implementations (DualThrust, ATR, Four Price of Fiali, Sky Garden, etc.)
- api.md - Detailed explanation of strategy APIs (data interface, trading interface, signal interface) and market data/trading interface integration
Configuration & Data
- configuration.md - Detailed explanation of configuration files (configbt.yaml, config.yaml, actpolicy.yaml, executers.yaml, etc.)
- data-tools.md - Data tools (WtDataHelper, CSV/DSB conversion, Tick data processing)
- data-management.md - Data management (WtDtServo, ExtDataLoader/Dumper, historical data processing, WtDHFactory)
Advanced Development
- advanced.md - Advanced development (ExtParser, ExtExecuter, C++ development environment setup, custom data storage)
- wtcpp-modules.md - Detailed explanation of C++ modules (QuoteFactory, CTA/HFT simulation, order placement process, source code analysis of configuration files)
- source-analysis.md - Source code analysis (backtesting framework, execution unit, HFT engine, CTA engine, signal execution process)
Operations & Troubleshooting
- tools-console.md - Web console and WtStudio user manual (monitoring, scheduling, backtest viewing, parameter optimization)
- faq.md - Common questions (engine selection, contract code rules, openctp integration, detailed explanation of CTA order placement interface)
Documentation Sources
| Source | Type | Pages | URL |
|---|---|---|---|
| WonderTrader official documentation | Official (RTD) | 53 | https://wtdocs.readthedocs.io/zh/latest/ |
| WonderTrader learning notes | Community | 75 | https://zzzzhej.github.io/WonderTrader-Learning-Notes/ |
| WonderTrader unofficial documentation | Unofficial | 27 | https://dumengru.github.io/docs_wondertrader/ |
Key Resources
- GitHub (C++): https://github.com/wondertrader/wondertrader
- GitHub (Python): https://github.com/wondertrader/wtpy
- PyPI: https://pypi.org/project/wtpy/
- QQ group: 610730738
Notes
- This skill was consolidated from three separate documentation sources
- Reference files preserve the original structure and code examples
- Content is primarily in Chinese (中文), matching the original documentation
- Code examples include both Python (wtpy) and C++ (WonderTrader core) implementations