Learn

⌂Dashboard◈Learn

Practice

⌁Charts◷Replay↻Review

My learning

▥Stats☆Bookmarks⌕Search✦AI

Learning principle

Understand risk before practising decisions.

Trade ButyFree · Neutral
👤 Log in
📚Learn📈Markets⏮Replay✎Review🔍Search🤖AI👤 Log in
Trade Buty

A free & neutral trading education platform for Chinese speakers worldwide. Structured courses (learn) × live charts & replay (practice).

⚠️ Risk notice: All content is for study and research only and does not constitute investment advice. Markets are risky.

Navigate

LearnMarketsReplaySearchAIStatsPrivacy PolicyContent from kline-butyFeedback
© 2026 sun1090 · MIT LicenseContent from kline-buty

On this page

  • 1. The Complete Quant Workflow
  • 2. Strategy Type Landscape
  • 2.1 CTA Trend Following
  • 2.2 Mean Reversion
  • 2.3 Statistical Arbitrage
  • 2.4 Calendar / Inter-Commodity Spreads
  • 2.5 Cash-Futures Arbitrage
  • 2.6 Market Making
  • 2.7 High-Frequency T0
  • 2.8 Event Driven
  • 3. The Factor System
  • 3.1 Common factor categories
  • 3.2 Factor research and evaluation metrics
  • 4. Backtesting Framework Selection
  • 5. Core Backtesting Metrics
  • 6. Backtesting Pitfall Checklist
  • 7. Parameter Optimization and Overfitting Prevention
  • 7.1 Three common approaches
  • 7.2 Practical advice to reduce overfitting
  • 8. The Paper-to-Live Gap
  • 9. Execution Algorithms
  • 10. Live Monitoring
  • 10.1 Strategy health
  • 10.2 Daily review
  • 10.3 Exception alerts
  • 11. Engineering the Backtest Platform and Research

Chapter progress

10 · System Integration

Every earlier chapter was written for traders: how to read the market, how to manage positions, how to avoid pitfalls. T

0/11 lessons0%

Next chapter →

12 · Market Ecosystem→

The earlier chapters taught you to "read the rules and read the charts." This chapter asks you to step back and take a m

Learn/10 · System Integration
Lesson 06/6 / 11 lessons

06 · Quantitative Strategies and Backtesting

An engineer's guide to quant strategy R&D: from logic validation to a deployable, monitorable code system.

📖 ~16 min read
On this page▾
  • 1. The Complete Quant Workflow
  • 2. Strategy Type Landscape
  • 2.1 CTA Trend Following
  • 2.2 Mean Reversion
  • 2.3 Statistical Arbitrage
  • 2.4 Calendar / Inter-Commodity Spreads
  • 2.5 Cash-Futures Arbitrage
  • 2.6 Market Making
  • 2.7 High-Frequency T0
  • 2.8 Event Driven
  • 3. The Factor System
  • 3.1 Common factor categories
  • 3.2 Factor research and evaluation metrics
  • 4. Backtesting Framework Selection
  • 5. Core Backtesting Metrics
  • 6. Backtesting Pitfall Checklist
  • 7. Parameter Optimization and Overfitting Prevention
  • 7.1 Three common approaches
  • 7.2 Practical advice to reduce overfitting
  • 8. The Paper-to-Live Gap
  • 9. Execution Algorithms
  • 10. Live Monitoring
  • 10.1 Strategy health
  • 10.2 Daily review
  • 10.3 Exception alerts
  • 11. Engineering the Backtest Platform and Research

A quant strategy R&D guide for software companies and engineering teams. Earlier articles taught traders "how to read the market and place orders"; this article covers the engineer's view: "how to turn a piece of trading logic into a code system that is verifiable, deployable, and monitorable".

Disclaimer: all content on this site is for study and research only and does not constitute investment advice. Markets carry risk; invest with caution.


1. The Complete Quant Workflow

From idea to scaled capital, a standard quant R&D pipeline:

text
Data → factors/signals → strategy logic → backtest → parameter optimization → paper trading → small-capital live → scale up
StageKey outputQuestions the engineer must answerTypical duration
DataCleaned market data/order/funds storesIs the data complete? Aligned? Free of survivorship bias?1–4 weeks
Factors/signalsComputable candidate featuresIs the factor effective? Is the correlation with returns stable?2–6 weeks
Strategy logicBacktestable strategy codeAre the entry/exit rules, position sizing, stop-loss quantifiable?1–3 weeks
BacktestPerformance reportIs there alpha left after removing every bias?2–8 weeks
Parameter optimizationRobust parameter rangesDo the parameters hold out-of-sample? Any overfitting?1–4 weeks
Paper tradingSimulated trading recordsDoes the strategy still hold under live latency/matching?4–12 weeks
Small-capital liveReal fill recordsDo slippage, capacity, and execution match expectations?4+ weeks
Scale upMore capital / more instrumentsWhere is the capacity ceiling? Does return decay with size?Ongoing

Key insight: every stage can flow back to a previous one. If small-capital live trading shows slippage eating 80% of returns, go back and redo the execution layer; that is fine — what is not fine is skipping stages and jumping straight to big money.


2. Strategy Type Landscape

StrategyPrincipleTypical instrumentsDifficultyCapacity
CTA trend followingFollow price trends; cut losses, let profits runCommodity futures, equity indices, crypto★★Large
Mean reversionPrice reverts after deviating from the mean; profit from reversalsStocks, ETFs, crypto spot★★Medium
Statistical arbitrageProfit when the spread between correlated instruments reverts; market neutralStock pairs, ETF baskets★★★Medium
Calendar / inter-commodity spreadSame product across months, or spreads between related productsCommodity futures★★★Medium
Cash-futures arbitrageConvergence of the futures-spot spread; earn the basisIndex futures + ETF, commodity futures + spot★★★Medium
Market makingRest both bid and ask; earn the bid-ask spread and rebatesOptions, crypto futures, active stocks★★★★Small (speed game)
High-frequency T0Multiple intraday round trips; profit from micro-spreads / book fluctuationT+0 instruments (futures, crypto, HK stocks)★★★★★Tiny
Event drivenTrade on announcements, macro data, news, on-chain dataStocks, crypto★★★Large

2.1 CTA Trend Following

Principle: once formed, a trend tends to persist; enter with the trend, cut losses with stops, let profits run. Typical signals: moving-average crossovers, Donchian channel breakouts, momentum breakouts.

  • Typical instruments: commodity futures (rebar, iron ore, PTA), index futures, high-volatility names like BTC.
  • Difficulty: ★★. Simple logic but a low win rate (~30–40%) with a high win/loss ratio; the test is whether you can keep executing through the drawdown.
  • Capacity: large. Mostly low-to-mid frequency; a single strategy can absorb tens of millions to hundreds of millions.

2.2 Mean Reversion

Principle: after a short-term deviation from the mean (e.g., a moving average, Bollinger Bands), price reverts with high probability. Typical signals: fading Bollinger excursions, RSI overbought/oversold.

  • Typical instruments: stocks, ETFs, and crypto spot with good liquidity.
  • Difficulty: ★★. Hard because "how long until reversion" is uncontrollable — great in range-bound markets, catching falling knives in one-way trends.
  • Capacity: medium. Trades more frequently than CTA with limited per-trade size; wins on frequency.

2.3 Statistical Arbitrage

Principle: find cointegrated asset pairs (e.g., two highly correlated stocks); when the spread widens past a threshold, short the rich one and buy the cheap one; close when the spread converges. Holding period is usually days to weeks; market neutral (bears almost no broad-market risk).

  • Typical instruments: same-industry stock pairs, ETFs vs constituents, perpetuals vs futures.
  • Difficulty: ★★★. Requires solid statistics (cointegration tests, Kalman filters), and spread relationships do break — they need dynamic monitoring.
  • Capacity: medium. Neutral-strategy capacity depends heavily on the number of tradable pairs in the market.

2.4 Calendar / Inter-Commodity Spreads

Principle: calendar — when the spread between different expiries of the same product (e.g., rebar Jan vs May) leaves its fair range, buy low and sell high, and close on convergence. Inter-commodity — when the strength relationship between related products (e.g., soybean meal vs soybean oil, hot-rolled coil vs rebar) misaligns, trade the strength hedge.

  • Typical instruments: mostly commodity futures.
  • Difficulty: ★★★. The "fair range" of the spread shifts with supply-demand, inventories, and positioning structure; static ranges go stale easily.
  • Capacity: medium.

2.5 Cash-Futures Arbitrage

Principle: when the futures price is above spot (positive basis), buy spot/ETF and short futures; close on delivery or basis convergence to harvest a fairly certain spread. Index cash-futures arbitrage (IF/IC + ETF) is the classic version.

  • Typical instruments: index futures + spot ETF, commodity futures + spot warehouse receipts.
  • Difficulty: ★★★. Capital-hungry, and you must handle dividends, ex-rights, and index-tracking error details.
  • Capacity: large, but opportunities are infrequent and thin per trade.

2.6 Market Making

Principle: rest orders on both sides, get hit by takers to earn the bid-ask spread, plus exchange maker rebates (reduced or even negative fees). The core is inventory risk management — after being hit you must not accumulate directional exposure.

  • Typical instruments: options (the classic), crypto futures, inactive stocks.
  • Difficulty: ★★★★. A contest of quoting models, inventory management, and low latency; retail traders and startups rarely beat top market makers.
  • Capacity: small. Per-instrument capacity is limited; scale across many instruments.

2.7 High-Frequency T0

Principle: high-frequency intraday round trips, earning micro book spreads, queue advantages, or the impact-cost rebate of splitting large orders. Holding periods run from seconds to minutes; returns are extremely latency-dependent (milliseconds, even microseconds).

  • Typical instruments: futures, crypto futures, HK stocks (T+0 and shortable).
  • Difficulty: ★★★★★. Hardware (FPGA, same-datacenter colocation), network, and system tuning are all mandatory.
  • Capacity: tiny, with extreme winner-take-most effects.

2.8 Event Driven

Principle: anticipate price reactions to earnings, dividends, macro data, policy, or large on-chain transfers. Can be manually triggered (a human confirms after the event) or fully automated (data streams trigger signals).

  • Typical instruments: stocks (earnings season), crypto (regulatory/on-chain events), commodities (inventory/weather reports).
  • Difficulty: ★★★. The hard part is data acquisition and cleaning; event data is extremely noisy.
  • Capacity: large. Event-driven at low-to-mid frequency is among the highest-capacity categories.

3. The Factor System

Factors are the "raw material" of strategies: a computable historical data feature with predictive power over an instrument's future returns.

3.1 Common factor categories

CategoryRepresentative factorsLogic
MomentumN-day return, moving-average deviationThe strong stay strong; the institutionalized form of momentum chasing
ReversalNegative of the N-day cumulative gainWhat ran up too much pulls back; what fell too much bounces
Volatility factorsRealized volatility, ATR, BVOLLow-volatility instruments often carry a risk premium
Volume-priceVolume amplification ratio, volume-price divergence, turnoverVolume leads price; volume confirms signals
Term structureFutures near-far month spread (contango/backwardation)Rollover returns and market sentiment
AlternativeSentiment, fund flow, on-chain metricsCompensation for information asymmetry

3.2 Factor research and evaluation metrics

The standard factor research flow: pose the hypothesis → compute the factor → layered backtest → evaluate → combine → track live.

Core evaluation metrics:

MetricDefinitionRule-of-thumb
IC (information coefficient)Rank correlation (Spearman) between factor value and next-period return; higher |IC| = stronger predictive power|IC| > 0.02 noteworthy, > 0.05 excellent
IR (information ratio)IC mean / IC standard deviation; measures factor stabilityIR > 0.3 good, > 0.5 excellent
Layer monotonicitySplit into 5–10 factor layers; do layer returns line up monotonicallyMonotonic means the factor logic is self-consistent
TurnoverFactor rebalancing ratioToo high and costs eat the alpha
CapacityCapital the factor can absorb when ranking the market by liquidityThe more niche the factor, the smaller the capacity

A factor's "mortality rate" is high: screen 100 candidates, and after IC stability, layer monotonicity, cost deduction, and out-of-sample tests, usually no more than 5 survive.


4. Backtesting Framework Selection

FrameworkLanguageStrengthsWeaknessesFits
vn.pyPythonMature domestic ecosystem, built-in CTA/arbitrage/options templates, direct connection to domestic futures OMSsSteep learning curve; some features tied to its own architectureDomestic futures/equities teams
backtraderPythonLightweight and easy to start, rich docs and community, simple backtest→paper switchMediocre performance (pure Python loops); slow on big dataIndividuals/small teams at low-to-mid frequency
In-house frameworkAnyFully controllable; custom matching simulation, parallel backtests, parameter sweeps on demandLong development cycle; reinventing wheels and planting bugsTeams with engineering strength planning to scale
OthersPython/Rvectorbt, QuantConnect (cloud), Zipline, qlib (Microsoft)Each has its own orientationChoose per need

Selection advice:

  • Start with backtrader or vn.py to validate ideas fast; do not build in-house on day one.
  • Build in-house only when: the existing backtest engine is the bottleneck (parameter sweeps too slow, matching model unrealistic) and the team has 2+ dedicated backtest engineers.
  • The backtest engine's matching model matters more than the framework's fame: "fill at the next bar's open" vs "fill against the order book tick by tick" produces wildly different results.

5. Core Backtesting Metrics

MetricFormula/definitionNotes
Annualized return(ending equity / starting equity)^(252/trading days) − 1Compounded basis; extrapolation distorts when the backtest spans under a year
Sharpe ratio(annualized return − risk-free rate) / annualized volatilityExcess return per unit of volatility; >1 good, >2 excellent
Max drawdownLargest drop from any equity peak: max(peak − trough) / peakHow bad the worst case is; deserves more attention than returns
Calmar ratioAnnualized return / max drawdownReturn per unit of "worst pain"; >1 good
Win rateprofitable trades / total tradesA high win rate ≠ a good strategy; read with the win/loss ratio
Win/loss ratioaverage win / average lossTrend strategies usually have low win rate, high win/loss ratio
Turnovertraded volume / open interest (or traded value / account equity)Determines the share of fees and slippage in returns
Return/drawdown curveTime-series visualizationSee when drawdowns happened and in what market regime

The order to read a backtest report: max drawdown and drawdown duration first, then annualized return and Sharpe, then win rate and win/loss ratio. A strategy with 100% annualized return and a 60% max drawdown will be abandoned mid-way by nearly everyone in live trading.


6. Backtesting Pitfall Checklist

PitfallPlain-language explanationConcrete example
Look-ahead functionThe backtest used data unavailable at the timeUsing volume data "published only after the close" to trade that same close
Look-ahead biasParameters estimated on the full sample applied to every historical pointThe best moving-average window computed on all of 2015–2025, used to backtest 2018
Survivorship biasKeeping only instruments that still exist todayA stock pool holding only current constituents — delisted and blown-up names removed, returns inflated
OverfittingParameters tuned to fit historical noise exactlyA strategy with 12 parameters, grid-searched one by one to "historical perfection"; live is a mess

💀 Backtest returns are not live returns

Backtest returns ≠ live returns. A backtest is walking repeatedly over known history: it underestimates slippage, overestimates capacity, and misses real-world constraints by construction; a parameter-optimized strategy adds overfitting risk on top. Rule of thumb: a paper-trading strategy at 30% annualized mostly keeps only 10–20% after real slippage and fees; if paper returns are only 10% to begin with, don't go live.

| Fees and slippage unaccounted | Ignoring or underestimating transaction costs | A high-frequency strategy backtested at zero fees; live fees + slippage eat all the profit | | Infinite-liquidity assumption | The backtest assumes any size fills | A stock trading 100k shares a day, with the backtest buying 50k lots daily | | Period bias | The backtest window is the strategy's "good weather" | Backtesting a trend strategy only through the 2020–2021 bull run, ignoring the 2018 and 2022 choppy bears | | Time/timezone errors | Data misalignment | Mixing unadjusted prices with K-lines in different time zones | | Limit-up-down / T+1 ignored | The backtest does what live trading cannot | An A-share strategy buying and selling same-day, ignoring the T+1 rule |

Self-check method: print the signal log for every trading day and manually audit a few random days — "could I really get this data at the time? Could I really fill at this price?"


7. Parameter Optimization and Overfitting Prevention

7.1 Three common approaches

ApproachDescriptionRisk
Grid searchSweep parameter combinations for the highest returnHigh (nearly guaranteed overfit)
Out-of-sample testingTune on the first 70%, freeze and validate on the last 30%Medium (out-of-sample used once only; must be long enough)
Walk-forwardRolling: tune on the front window → validate on the back window → slide forward; every decision uses only "past data"Low (closest to the live cadence)

7.2 Practical advice to reduce overfitting

  • Fewer parameters: every extra parameter raises overfitting risk exponentially; if 2 parameters work, don't use 5.

⚠️ Out-of-sample testing can only be used once

Out-of-sample testing is not repeatable — the out-of-sample window can be tested once; repeatedly "test then retune" turns out-of-sample into in-sample. Parameters must be "flat": performance around the optimum should change slowly; if moving the parameter from 19 to 21 crashes performance, it is noise fitting.

  • Parameters must be "flat": performance around the optimum should change slowly; if moving the parameter from 19 to 21 crashes performance, it is noise fitting.
  • Out-of-sample is one-shot: the out-of-sample window can be tested once; repeatedly "test then retune" turns out-of-sample into in-sample.
  • Constraints + penalties: cap returns at plausible ranges (e.g., flag any factor with >100% annualized return as suspicious) and penalize high turnover and extreme positions.
  • Multi-period, multi-instrument validation: bear-market samples from 2015, 2018, and 2022 are mandatory; the same logic holding across instruments boosts credibility a lot.

8. The Paper-to-Live Gap

DimensionPaper assumptionLive realityCountermeasure
SlippageOften fixed ticks or zeroImpact cost rises nonlinearly with sizeModel impact as "book depth × order size"
CapacityUnlimitedOversized single orders move the priceConstrain order size with ATS (volume participation)
LatencyInstant fillsNetwork + OMS + market data latency 10ms–1sRecord the gap between signal time and fill time
MatchingSimplified matching modelQueueing, partial fills, limit-locked fills impossibleReplay with tick/book-level matching models
EmotionNoneAfraid to enter after losing streaks; oversizing after winsDiscipline + automation + pre-trade risk checks
DataComplete and cleanOutages, bad prints, adjustment changesData validation and outage alerts
CostsFixed feesExchange rebates / block discounts exist; real costs are messierBackfill with the real account fee schedule

Rule of thumb: a paper-trading strategy at 30% annualized mostly keeps only 10–20% after real slippage and fees; if paper returns are only 10% to begin with, don't go live.

💀 Paper trading at 30% annualized mostly keeps only 10-20% after real slippage and fees

A paper-trading strategy at 30% annualized mostly keeps only 10–20% after real slippage and fees; if paper returns are only 10% to begin with, don't go live. The paper-to-live gap is not in the strategy itself but in slippage, capacity, latency, matching differences, and emotion — miss any one of the five and it eats your returns.


9. Execution Algorithms

The strategy decides "what and how much to buy"; execution algorithms decide "how to buy".

AlgorithmPrincipleFits
TWAP (time-weighted average price)Slice a large order evenly across timeRoutine accumulation with no strong intraday pattern, low-profile required
VWAP (volume-weighted average price)Slice order size along the historical volume profileInstruments with uneven liquidity distribution (e.g., stock open/close volume bursts)
Iceberg orderExpose only part of the order, hide the restThin liquidity, intent concealment
IS / Implementation ShortfallOptimize between impact cost and opportunity cost; fill fastLarge orders, event-driven, time-sensitive scenarios

Quantifying execution quality: compare the "actual average fill price" against the "VWAP at signal time"; the deviation is the execution cost. Use this difference (slippage capture) as the KPI of the execution algorithm.


10. Live Monitoring

10.1 Strategy health

MetricAlert threshold (example)Meaning
Position driftDeviation from target position > 20%Too many cancels/failures drifting the position
Per-order slippageN consecutive orders at 2x benchmark slippageLiquidity shock or algorithm failure
NAV drift vs backtest baseline2 consecutive weeks off by > 3 standard deviationsMarket structure change or an implementation bug
Fill rateBelow 80%Resting-order strategy failing
Order timeoutNo report within X secondsNetwork or OMS anomaly

10.2 Daily review

  • Auto-generate the daily report: strategy NAV, return attribution (factor contribution breakdown), fill details, slippage stats, exception event list.
  • Manual review: revisit the day's 3 most contested trades — "was the signal right at the time? Was the execution clean?"

10.3 Exception alerts

  • Tiered alerts: SMS/messaging (critical) → email/IM group (normal) → weekly report (routine).
  • Must-have hard alerts: fund anomalies, positions conflicting with risk rules, N consecutive cancels, market data outage, process crash.
  • Alerts must carry context (strategy name, instrument, values, time) — otherwise the 3 a.m. page is unreadable.

11. Engineering the Backtest Platform and Research

  • Parameter and result versioning: every backtest records parameters, data version, and code version; use Git plus an experiment ledger (or MLflow-style tools) to guarantee "results are reproducible".
  • Parallel backtesting: parameter sweeps are embarrassingly parallel; multi-core/cluster parallelism is standard equipment for an in-house platform.
  • Data versioning: re-running after market data changes makes backtest results drift; tag data with versions and bind backtest results to data versions.
  • Signal logs: persist all live signals in full, so afterwards "strategy sent no signal vs system failed to execute" is obvious at a glance.

⚠️ Risk Warning

Backtest returns ≠ live returns. A backtest is walking repeatedly over known history: it underestimates slippage, overestimates capacity, and misses real-world constraints by construction; a parameter-optimized strategy adds overfitting risk on top. Quantitative trading still faces strategy decay, liquidity droughts, system failures, extreme markets, and more; leverage amplifies losses in the same proportion as gains. Recommendations: run paper trading for at least 3 months before small-capital live; keep small-capital live stable for 3+ months before adding capital; define "stop conditions" before any strategy goes live (e.g., disable the strategy at X% drawdown). All strategy descriptions here are for study and research only and do not constitute investment advice.

📝 系统对接篇 · 随堂测

3 concept questions · instant grading

📖 Done reading? See the real market

Find the concepts from this lesson on the live chart — understand before you continue.

Open live chart →
🤖Ask AI: 06 · Quantitative Strategies and Backtesting→

Related lessons

  • →01 · Integration Overview and Role Division: Draw the Map Before Writing Code
  • →02 · Exchanges and OMSs: Which Layer Your System Actually Connects To
  • →03 · Market Data Systems: The Eyes of Trading Software
  • →04 · Trading Interfaces and Order Lifecycle: The Heart of the System
  • →05 · Risk Controls and Capital Management: The Last Line of Defense Must Be Your Own

Next

07 · Data and Infrastructure

→