Loading...
Loading...
Complete Guide to QMT (Xuntou High-Speed Strategy Trading System) Python Strategy Development. Covers strategy writing, backtesting, live trading, API references, and code examples. Use this skill when developing QMT quantitative strategies or querying QMT APIs.
npx skill4agent add lzwme/finance-quant-skills qmt-docsTutorials/Guides (Practice-Oriented)
├── overview.md System overview, mode selection, getting started path
├── execution-mechanisms.md Detailed explanation of three operation mechanisms (including flowcharts and code templates)
├── backtesting-guide.md Complete backtesting process (data preparation → parameter setting → execution → analysis)
├── live-trading-guide.md Live trading guide (account configuration → order management → risk control)
├── quick-reference.md ★ Quick reference card for commonly used APIs
├── best-practices.md Coding standards, performance optimization, risk management, debugging techniques
├── joinquant-migration.md Guide for migrating JoinQuant strategies to QMT
└── examples/ Code examples (backtest / live-trading / subscribe / run-time)
API References (Official Complete Documentation)
└── python-innerApi/
├── start_now.md Quick start (backtest/live trading overview + three mechanism examples)
├── data_function.md Market and data functions (complete parameters for get_market_data_ex, etc.)
├── trading_function.md Trading functions (passorder, get_trade_detail_data, etc.)
├── system_function.md System functions (ContextInfo methods, timers, etc.)
├── callback_function.md Callback functions (push for account/order/deal/position)
├── quote_function.md Reference functions (extended data, factors, VBA calls)
├── drawing_function.md Drawing functions
├── interface_operation.md Interface operation instructions
├── data_structure.md Data structure definitions (fields of Bar/Tick/Order/Position objects, etc.)
├── enum_constants.md Enumeration constants (opType, orderType, order status, etc.)
├── variable_convention.md Variable conventions
├── code_examples.md Collection of complete code examples
├── user_attention.md User notes
└── question_answer.md Frequently asked questions
Data Dictionary
└── dict/ Data fields for various varieties (stock / indexes / future / option, etc.)| Scenario | Read First | Then Refer To |
|---|---|---|
| Beginner Getting Started | | |
| Writing Backtesting Strategies | | |
| Writing Live Trading Strategies | | |
| Querying API Usage | | |
| Migrating from JoinQuant | | |
| Optimizing Code Quality | | |
| Querying Data Structures | | |
Need to know how to use a function?
→ quick-reference.md (simplified version of commonly used functions)
→ python-innerApi/data_function.md (complete documentation for data acquisition functions)
→ python-innerApi/trading_function.md (complete documentation for trading functions)
→ python-innerApi/system_function.md (system/ContextInfo methods)
Need to see complete code?
→ python-innerApi/code_examples.md (official example collection)
→ examples/ (selected examples)
Need to check field meanings?
→ python-innerApi/data_structure.md (data structure definitions)
→ dict/ (data dictionaries for various varieties)
Encounter errors/issues?
→ python-innerApi/question_answer.md (official FAQ)
→ python-innerApi/user_attention.md (notes)#coding:gbk # Must be on the first line of the file| Concept | Description |
|---|---|
| handlebar | K-line driven (recommended for backtesting) |
| subscribe | Event-driven (live trading only, high frequency) |
| run_time | Scheduled trigger (monitoring scenarios) |
| quicktrade=0 | Place order after K-line is completed (per K-line mode) |
| quicktrade=2 | Place order immediately (no waiting required) |
| Minimum Unit | 100 shares |
# Get historical market data (use subscribe=False for backtesting, subscribe=True for live trading)
data = C.get_market_data_ex(['close'], [stock], end_time=bar_date,
period='1d', count=100, subscribe=False)
close_list = list(data[stock].iloc[:, 0])
# Get full push real-time market data
tick = C.get_full_tick(['600000.SH'])
price = tick['600000.SH']['lastPrice']
# Place buy order (23=Buy, 1101=By share count, quicktrade=0 per K-line mode)
passorder(23, 1101, account, stock, 5, -1, 100, C)
# Place buy order (quicktrade=2 immediate order mode)
passorder(23, 1101, account, stock, 5, -1, 100, 'Strategy Name', 2, 'Remarks', C)
# Query positions
holds = get_trade_detail_data(account, 'stock', 'position')
holds_dict = {f'{p.m_strInstrumentID}.{p.m_strExchangeID}': p.m_nVolume for p in holds}
# Query available account funds (unit: cents)
cash = get_trade_detail_data(account, 'stock', 'account')[0].m_dAvailable#coding:gbkfieldsstocksget_market_data_exfields=stocks=FalseTrueget_trade_detail_data'stock''credit'm_dAvailablesubscriberun_time