匡醍量化|大富翁量化

Quant 101

This is a long-form article in the "Quantitative General Knowledge" series: from "having a strategy idea" to "running it in a real account," you must navigate five hurdles: environment, data, adjustment, orders, and exceptions. After reading, you should be able to answer: What QMT does and doesn’t manage; and what the minimum viable link for a first live trade looks like.

One-Sentence Conclusion

Your Stage What to Do Site Entry
Haven't installed QMT yet Set up the environment and connect to market data (XtQuant Development Environment Configuration) Practice
Strategy makes money in backtesting Connect live data, handle adjustments and trading calendars (Live Trading Access Methods) Practice
Ready to place the first order Run through the minimum closed loop of "place order → fill report → position," then discuss adding positions Practice

1. What QMT Does and Doesn’t Do

Set expectations first; many people new to QMT waste two weeks here.

What QMT manages: Market data push (Level-1, some brokers offer Level-2), strategy triggers (scheduled/event-driven), placing orders and fill reports, and account position queries. Its Python interface, XtQuant, wraps these into dozens of functions. The full environment configuration process is detailed in the xtquant related articles.

What QMT does NOT manage: Historical data backfilling (it only gives you "now"; you must accumulate the past yourself), strategy logic itself (factors, signals, and risk control are all on your side), multi-account fund management, and exception recovery (you must write your own disconnection reconnection strategies).

In short: QMT is your hands and eyes, not your brain. Anything that belongs to the "brain"—data, research, risk control—exists outside of QMT.

Don't aim for "fully automatic" right away. The goal for your first live trade has only three points: receive market data, place orders, and reconcile accounts.

# Link Self-Check List (Check off in order)
# 1. Market Data: XtQuant can subscribe to real-time tick/K-line for target instruments
# 2. Signal: Calculate a signal using the received market data (even if it's "buy one lot at fixed time")
# 3. Order Placement: After the signal triggers, the XtQuant order function returns a successful order_id
# 4. Report: You can see this fill in the fill report callback
# 5. Reconciliation: After market close, the position queried by XtQuant == the position seen in the broker's APP

Do not add a single cent until all items are checked off. Steps 1-3 can be completed in a simulation environment; steps 4 and 5 must be run with minimal capital in a real environment—90% of the differences between simulation and live trading lie in the details of fill reports and fund freezing.

3. Three Things About Live Data: Adjustment, Calendar, Subscription

Adjustment: The most common reason "strategies suddenly stop making money" in live trading is related to adjustment. The article Pitfalls of Ex-Dividend/Ex-Rights Adjustment provides a method to speed up adjustment factor calculation by 100x. The core conclusion is: adjustment factors must be sourced from the same source as market data, calculated programmatically, and verified daily. Do not maintain them manually.

Trading Calendar: Live scripts must know "is the market open today?" Do not use natural day differences, nor calculate it on the fly—maintain a trading calendar table (one for each different market) and load it once before the market opens.

Subscription: Live trading is "push," not "polling." Conflicts between minute/bar data subscriptions and multiple Clients are common pitfalls (the QMT Real-Time Minute Line Subscription System has a complete solution), as well as how to restart miniQMT without logging in after an unexpected exit (Restart miniQMT Without Login)—these two articles are required reading for live stability.

# Live Day Startup Sequence (Recommended to write as a script, don't rely on memory)
# 1. Check XtQuant connection status (reconnection mechanism)
# 2. Load trading calendar: Is the market open today?
# 3. Subscribe to market data → Wait for the first tick (confirm the channel is alive)
# 4. Load yesterday's positions → Reconcile with strategy's expected positions
# 5. Start signal loop

4. Orders and Exceptions: Where Live Trading Differs from Backtesting

5. Upgrade Path from Manual to Automatic

  1. Manual Order + Programmatic Signal (Weeks 1-2): The signal program only provides suggestions; humans click to confirm. Verify signal quality.
  2. Semi-Automatic (Weeks 3-4): Program places orders, humans monitor the screen, and can stop at any time. Verify the order link.
  3. Fully Automatic + Night Watchman (Starting Month 2): The program has full authority, but there is an independent "Night Watchman" process—doing only three things: monitoring position deviations, monitoring abnormal logs, and triggering circuit breakers (liquidate + alarm).

Do not skip Step 1. The vast majority of live trading accidents happen to those who go "fully automatic" for the first time.

6. Further Reading

There is no silver bullet in live trading, only checklists. If you write the startup sequence and exception branches above into code rather than keeping them in your head, you will surpass 80% of those attempting live trading for the first time.

33 articles · grouped by level

Beginner (1)

Intermediate (25)

Practitioner (7)

← All topics · Tag cloud · 中文专题