The Drift Problem
Your JoinQuant strategy thinks you hold 1,000 shares of a stock. Your QMT terminal shows 950 shares. Somewhere between the signal and the execution, 50 shares disappeared. This gap — between what your strategy expects and what your terminal actually holds — is called position drift.
Drift is not just an inconvenience. It compounds over time. A strategy that assumes 1,000 shares will calculate position sizes, risk metrics, and rebalancing targets based on that assumption. If the reality is 950, every subsequent decision is slightly wrong. Over weeks and months, these small errors accumulate into significant portfolio deviation.
Why Do Positions Diverge?
Position drift has several common causes:
- Slippage — the executed price differs from the signal price, resulting in a different number of shares filled
- Trading halts — a signal targets a stock that hits the daily price limit or is suspended from trading
- Partial fills — the order is only partially executed due to insufficient liquidity
- Manual intervention — you or someone on your team manually adjusts a position outside the strategy
- System errors — a signal is missed, delayed, or incorrectly processed
Regardless of the cause, the result is the same: your strategy's model of reality diverges from actual market reality. QuantLink's drift monitoring catches this divergence before it becomes a problem.
How QuantLink Monitors Drift
QuantLink uses a dual-source comparison approach:
- Virtual positions — reported daily by JoinQuant at 15:05 (via the injected
run_dailyposition snapshot reporter) - Actual positions — reported by your QMT terminal after market close
Every day at 15:10, QuantLink's scheduled drift check compares both position snapshots. It calculates the drift percentage for each held symbol:
Drift % = | Virtual Quantity - Actual Quantity | / Virtual Quantity x 100The results are displayed in the strategy dashboard with per-symbol breakdowns.
Drift Severity Levels
QuantLink classifies drift into three levels:
| Level | Threshold | Meaning |
|---|---|---|
| Normal | < 5% | Acceptable divergence, likely from minor slippage |
| Minor Drift | 5% - 15% | Notable gap, may warrant investigation |
| Severe Drift | > 15% | Significant divergence, strategy model is materially wrong |
When drift crosses the minor or severe threshold, QuantLink flags it in the dashboard. You can configure custom threshold values based on your strategy's tolerance for divergence.
Multi-Strategy Terminal Handling
Things get more complex when a single QMT terminal executes signals from multiple strategies. In this scenario, a simple position snapshot comparison does not work — the terminal's total position is the aggregate of all strategies trading that symbol.
QuantLink detects multi-strategy terminals automatically using the isMultiStrategyTerminal() check. When detected, the drift monitoring system switches from snapshot-based comparison to execution record derivation:
- Instead of comparing snapshots, QuantLink aggregates
executionRecord.filledQuantityper symbol from each strategy - This gives an estimated position per strategy, even when multiple strategies share the same terminal
- The drift calculation then compares each strategy's estimated execution-based position against its JoinQuant virtual position
The API returns a dataSource field (snapshot or execution_records) so you always know which method was used for a given comparison.
Calibration: Syncing Reality Back to Your Strategy
Detecting drift is only half the solution. Fixing it is the other half.
QuantLink's calibration feature lets you push your actual QMT positions back to JoinQuant's virtual portfolio in one click. This re-aligns the strategy's internal model with reality, ensuring that subsequent position sizing and rebalancing decisions are based on accurate data.
The calibration process:
- Pulls current actual positions from your QMT terminal
- Compares them against JoinQuant virtual positions
- Generates adjustment orders to align the virtual portfolio
- Executes the adjustments in JoinQuant's simulated environment
After calibration, the drift resets to near zero, and your strategy operates on a clean foundation.
Three Drift APIs
QuantLink exposes three drift-related APIs for different use cases:
| API | Endpoint | Purpose |
|---|---|---|
| Signal drift | GET /api/strategies/[id]/drift | Compare expected signal quantity vs. actual filled quantity from execution records |
| Position drift | GET /api/strategies/[id]/position-drift | Compare JoinQuant virtual positions vs. QMT actual positions (single-strategy terminals) |
| Shared drift | GET /api/strategies/[id]/shared-drift | Same as position drift, but for recipients of shared strategies |
Each API returns per-symbol drift data with severity classification, making it straightforward to build custom alerts or integrate drift monitoring into your own tools.
Key Advantages
- Dual-source comparison — virtual vs. actual, not just one data source
- Automatic daily checks — runs at 15:10 every trading day, no manual trigger needed
- Multi-strategy support — smart switching between snapshot and execution record modes
- Severity classification — normal, minor, and severe levels with configurable thresholds
- One-click calibration — sync actual positions back to your strategy in seconds
- Shared strategy visibility — drift monitoring works for both owned and received strategies
Position drift is inevitable in live trading. QuantLink ensures it never goes unnoticed — and gives you the tools to fix it when it matters.