Start free trial
EnglishEnglish
EspañolSpanish
简体中文Chinese
繁體中文Chinese (Traditional)
FrançaisFrench
DeutschGerman
日本語Japanese
PortuguêsPortuguese
ItalianoItalian
한국어Korean
РусскийRussian
NederlandsDutch
العربيةArabic
PolskiPolish
हिन्दीHindi
Tiếng ViệtVietnamese
SvenskaSwedish
ΕλληνικάGreek
TürkçeTurkish
ไทยThai
ČeštinaCzech
RomânăRomanian
MagyarHungarian
УкраїнськаUkrainian
IndonesiaIndonesian
DanskDanish
SuomiFinnish
БългарскиBulgarian
עבריתHebrew
NorskNorwegian
HrvatskiCroatian
CatalàCatalan
SlovenčinaSlovak
LietuviųLithuanian
SlovenščinaSlovenian
СрпскиSerbian
EestiEstonian
LatviešuLatvian
فارسیPersian
മലയാളംMalayalam
தமிழ்Tamil
اردوUrdu
Searching...
SoBrief
Machine Trading

Machine Trading

Deploying Computer Algorithms to Conquer the Markets
by Ernest P. Chan 2016 256 pages
3.83
80 ratings
Amazon Kindle Audible
Try Full Access for 3 Days
Unlock listening & more!
Continue

Key Takeaways

1. Bridge backtesting and live execution to eliminate translation errors and look-ahead bias

Notice that I deliberately use the same box to indicate the computer program that generates backtest results and live orders: This is the best way to ensure we are trading the exact same model that we have backtested.

Unifying backtest and execution. The cornerstone of successful algorithmic trading is maintaining absolute consistency between your historical simulations and live execution. If your backtesting code is written in one language (like R or MATLAB) and your execution system is rewritten in another (like C++ or C#), you introduce a high probability of translation bugs and execution discrepancies. By utilizing platforms that support both backtesting and live API execution, you ensure that the exact same mathematical logic governs both environments.

Data integrity matters. High-quality, survivorship-bias-free data is the lifeblood of any quantitative model. Using consolidated closing prices instead of primary exchange auction prices can dangerously inflate backtest performance, creating phantom profits that disappear in live trading. Quantitative traders must carefully select data vendors that account for corporate actions, delisted securities, and bid-ask spreads at the close.

  • CSI and Quandl: Excellent for daily stock, ETF, and futures data.
  • CRSP: The gold standard for survivorship-bias-free historical data and closing bid-ask quotes.
  • OptionMetrics: Essential for historical options implied volatility surfaces.

Selecting the right platform. Choosing a development environment is a trade-off between research productivity and execution speed. While scripting languages like MATLAB and Python excel at rapid prototyping and mathematical modeling, institutional execution systems often require compiled languages to minimize latency. The ideal compromise is to prototype in a high-level language and compile computationally intensive functions into C++ or C# for live deployment.

2. Maximize long-term compound growth using the Kelly criterion while strictly managing tail risk

If we leverage our strategy or portfolio higher than this optimal leverage, CAGR may start to go down with increasing leverage, and is almost guaranteed to be −100 percent when the leverage is high enough.

Maximizing compound growth. The Kelly criterion provides the mathematically optimal leverage to maximize the long-term compound annual growth rate (CAGR) of a portfolio. However, because the standard Kelly formula assumes a Gaussian distribution of returns, it frequently underestimates the impact of fat-tailed black swan events. Over-leveraging beyond the Kelly optimal is a catastrophic mistake that inevitably leads to the complete ruin of the trading account.

Managing tail risk. To survive in the real markets, traders must prioritize capital preservation over theoretical mathematical optimality. Practical money management requires scaling down Kelly leverage—often to "half-Kelly" or lower—to keep maximum drawdowns within tolerable psychological and financial limits. This conservative approach provides a safety buffer against non-Gaussian market shocks and estimation errors in your strategy's historical win rate.

  • CAGR: Compound Annual Growth Rate, assuming constant leverage and reinvestment.
  • Sharpe Ratio: Risk-adjusted return based on standard deviation.
  • Calmar Ratio: CAGR divided by the absolute maximum drawdown over a three-year period.

Alternative allocation methods. When historical returns are highly unpredictable, traditional Markowitz mean-variance optimization fails. In these scenarios, traders should pivot to robust alternatives that do not rely on return forecasts, focusing instead on risk management:

  • Minimum Variance Portfolios: Allocating capital to minimize overall portfolio variance.
  • Risk Parity: Equalizing the risk contribution of each asset, often by scaling leverage inversely to volatility.
  • Maximum Drawdown Targeting: Equalizing risk based on historical tail risk rather than standard deviation.

3. Exploit persistent market anomalies using fundamental, option-implied, and statistical factors

Because of these risks, most factor returns remain alive and well, year after year. This is the reason why we will study factor models in this chapter, despite their relative lack of sex appeal compared to alpha generation.

Exploiting systematic risk. Unlike pure alpha, which is highly capacity-constrained and rapidly arbitraged away, factor returns persist because they represent compensation for bearing systematic, undiversifiable risk. By constructing long-short portfolios based on these factors, traders can capture "smart beta" returns that remain robust over long horizons. These strategies have massive capacity and are highly suitable for institutional-scale capital.

Cross-sectional vs. time-series. Time-series factors (like Fama-French's HML and SMB) explain contemporaneous returns and are primarily used for risk management and performance attribution. In contrast, cross-sectional factor loadings (like ROE, book-to-market, or liquidity) can be ranked to predict future relative performance across a universe of stocks. Ranking these factors allows traders to construct market-neutral portfolios that are insulated from broad market movements.

  • ROE (Return on Equity): A powerful fundamental predictor of future stock returns.
  • Liquidity: Historically, less liquid stocks outperform, though this relationship can reverse in large-cap universes.
  • Short Interest: Days-to-cover (DTC) serves as a strong negative predictor of future returns.

Statistical factor models. When fundamental factors are unavailable or irrelevant, Principal Component Analysis (PCA) can extract unobservable statistical factors directly from the asset covariance matrix. These mathematical factors are highly effective for short-term and intraday trading across correlated assets. Because statistical factors are recomputed dynamically in a rolling window, they automatically adapt to changing market regimes.

4. Leverage mathematical models like ARMA and State Space systems to predict short-term price movements

Time-series techniques are most useful in markets where fundamental information and intuition are either lacking or not particularly useful for short-term predictions.

Predicting short-term momentum. Autoregressive (AR) and Autoregressive Moving Average (ARMA) models use lagged historical prices and noise terms to forecast the next period's price. These models are highly effective in highly liquid, non-fundamental markets like foreign exchange, where short-term mean reversion and momentum dominate. By optimizing the lag parameters using information criteria, traders can capture transient micro-trends.

Multivariate relationships. Vector Autoregressive (VAR) and Vector Error Correction (VEC) models expand time-series analysis to multiple cointegrated assets. By modeling the joint dynamics of an entire sector, these models capture lead-lag relationships and mean-reverting spreads across related instruments. This allows for highly sophisticated pairs trading and sector-neutral statistical arbitrage.

  • AR(p): Models current price as a linear combination of $p$ past prices.
  • ARMA(p, q): Incorporates $q$ lagged noise terms to reduce the required number of autoregressive lags.
  • VEC(p): Models price changes directly, making it highly intuitive for cointegrated pairs trading.

State space modeling. State space models, implemented via the Kalman filter, allow traders to model hidden, unobservable variables like a dynamic hedge ratio or a moving average. This recursive filter updates its parameters in real-time with every new data point, making it highly adaptive to changing market regimes. Unlike static rolling regressions, the Kalman filter minimizes lag and provides optimal estimates of the true underlying market state.

5. Use ensemble methods like bagging, random forests, and cross-validation to prevent data-snooping

If we just turn our machine learning algorithms loose on these data, it is very easy to come up with trading rules that worked extremely well in certain past periods, but fail terribly going forward.

The data-snooping trap. Machine learning algorithms possess immense power to map complex, non-linear relationships between predictors and market returns. However, because financial data has a notoriously low signal-to-noise ratio, these algorithms are highly prone to overfitting, memorizing historical noise rather than learning generalizable patterns. A model that looks spectacular in-sample will often collapse completely when deployed in live trading.

Ensemble learning methods. To combat overfitting, quantitative traders must employ robust ensemble techniques that combine multiple "weak learners" into a single, stable "strong learner." These methods introduce artificial randomness to prevent the model from becoming overly sensitive to any single training set:

  • Bagging (Bootstrap Aggregating): Training multiple models on random samples of the data with replacement.
  • Random Forests: Constructing decision trees where only a random subset of predictors is considered at each split.
  • Cross-Validation: Dividing the training set into multiple folds to validate out-of-sample accuracy during model selection.

Data normalization. When training machine learning models on a cross-section of multiple assets, data normalization is mandatory. Predictors and response variables must be scaled by their historical volatility to ensure that high-beta assets do not dominate the learning process. Without proper normalization, the algorithm will simply learn to trade the most volatile stocks, exposing the portfolio to unmanaged risk.

6. Trade volatility and correlation directly through delta-neutral strategies like gamma scalping and dispersion

The reason selling insurance (or equivalently, selling options) is profitable is that insurance has a decaying time value: as time goes on, if nothing bad happens, the value of the insurance contract continues to drop.

The volatility risk premium. Shorting volatility is one of the most historically profitable strategies in quantitative finance, driven by the persistent gap between implied and realized volatility. However, because short volatility strategies are akin to selling insurance, they are exposed to catastrophic tail risk during market crises. To harvest this premium safely, traders must employ delta-neutral options strategies or trade volatility derivatives with strict risk controls.

Delta-neutral strategies. To isolate volatility and correlation returns, options traders construct delta-neutral portfolios that eliminate exposure to the direction of the underlying asset. These strategies allow traders to profit from the passage of time (theta) or changes in volatility (vega):

  • Gamma Scalping: Dynamically trading the underlying asset to offset the negative theta of a long option position.
  • Dispersion Trading: Exploiting the overpricing of index options relative to individual component options by shorting the index option and buying component options.
  • Implied Volatility Mean Reversion: Trading the relative cheapness or expensiveness of options across a cross-section of assets.

Predicting volatility. While predicting price direction is notoriously difficult, predicting realized volatility using GARCH models is highly achievable. However, because realized volatility often moves in the opposite direction of implied volatility on a daily basis, traders must structure their execution vehicles carefully. Successfully trading volatility predictions requires understanding the term structure and roll costs of volatility futures.

7. Navigate the fragmented, high-frequency landscape by optimizing order types and routing

If we send a large market order to an exchange, it is likely to walk the book and the average execution price won't be the NBBO.

The fragmented landscape. The modern financial landscape is highly fragmented, with trades executed across dozens of lit exchanges and dark pools. This fragmentation makes understanding market microstructure essential for minimizing transaction costs, slippage, and market impact. A strategy that is highly profitable on paper can easily be rendered useless by poor execution and sub-optimal order routing.

Optimizing order types. To survive in a high-frequency environment, traders must move beyond simple market and limit orders. Utilizing advanced, exchange-specific order types allows passive traders to gain queue priority and active traders to sweep liquidity without revealing their intentions:

  • Hide-and-Light: Hidden limit orders that automatically reprice to avoid locking the market, preserving time priority.
  • Intermarket Sweep Orders (ISOs): Limit orders that bypass the Reg NMS routing requirements, allowing rapid execution across multiple venues.
  • Immediate-or-Cancel (IOC): Orders that execute immediately against resting liquidity or cancel, preventing adverse selection.

Navigating dark pools. Dark pools offer the advantage of executing trades at the NBBO midprice, saving traders the cost of the bid-ask spread. However, because dark pools are susceptible to latency arbitrage and manipulation, traders must continuously monitor them for adverse selection. Utilizing dark pools is highly effective for executing large orders without generating market-disrupting order flow.

8. Decode the actions of informed traders by analyzing signed transaction volume and queue dynamics

On average, traders using market orders are more likely to possess superior information since they are apparently so sure of the future price change that they are willing to pay the bid-ask spread to get into position quickly.

Decoding informed volume. Order flow—the net volume of aggressive buy market orders minus sell market orders—is one of the most powerful short-term predictors of price direction. By tracking the transactions of informed market participants, high-frequency algorithms can align themselves with the prevailing momentum. This relationship exists because informed traders prioritize execution speed over transaction costs.

Measuring order flow. While direct exchange feeds (like Nasdaq ITCH) provide explicit aggressor tags to identify buy and sell market orders, traders can also estimate order flow using public data. Bulk Volume Classification (BVC) allows traders to estimate order flow using standard volume bars, significantly reducing data overhead. This makes order flow analysis accessible to traders without expensive high-frequency infrastructure.

  • Tick Rule: Classifies a trade as a buy if the price is higher than the previous trade.
  • Quote Rule: Classifies a trade as a buy if it occurs above the bid-ask midprice.
  • Bulk Volume Classification: Uses the cumulative distribution of price changes over volume bars to estimate net order flow.

Order book imbalance. In addition to executed trades, the queue of resting limit orders provides valuable predictive information. A significant imbalance between the size of resting bids and offers (order book imbalance) strongly correlates with immediate, short-term midprice movements. High-frequency algorithms exploit this imbalance to front-run short-term price changes.

9. Apply quantitative frameworks to highly volatile, inefficient markets like Bitcoin

Currencies and bitcoins are the ideal playground for the quantitative analyst. Unlike stocks, bonds, or their derivatives, they are quite immune to fundamental factors...

Inefficient digital markets. As a relatively young and highly volatile asset class, Bitcoin presents a fertile ground for quantitative strategies. Because the market is highly fragmented across dozens of independent global exchanges, it exhibits significant structural inefficiencies that have long been arbitraged out of mature markets. This fragmentation creates unique opportunities for quantitative traders.

Applying quantitative models. Due to the lack of traditional fundamental drivers, Bitcoin prices are highly receptive to pure technical and statistical models. Time-series techniques like ARMA and mean-reverting Bollinger bands can generate highly profitable trading signals on intraday Bitcoin data. The high volatility of the asset class amplifies the returns of these strategies, provided leverage is managed conservatively.

  • High Volatility: Bitcoin's annualized volatility is multiple times higher than traditional currencies or equities.
  • Strong Mean Reversion: Intraday Bitcoin prices exhibit powerful mean-reverting tendencies.
  • Order Flow Predictability: Aggressor-tagged trade data from Bitcoin exchanges provides highly accurate order flow signals.

Cross-exchange arbitrage. The price of Bitcoin often diverges significantly across different global exchanges, creating apparent riskless arbitrage opportunities. However, traders must carefully weigh these theoretical profits against transaction fees, withdrawal delays, and the substantial credit risk of holding deposits on unregulated exchanges. Successful arbitrage requires automated, low-latency execution across multiple venues.

10. Build an antifragile, diversified trading business that enhances both intellectual freedom and personal well-being

By starting up your own algorithmic trading outfit, you can diversify your career risks away from sole dependence on P&L. Nobody can stop you from teaching, consulting, and writing books while building a robust portfolio of strategies.

Intellectual and personal freedom. Beyond the potential for financial gain, algorithmic trading offers unparalleled intellectual freedom and lifestyle benefits. Operating an independent trading business from home eliminates the stress of corporate bureaucracy, long commutes, and toxic workplace dynamics, directly contributing to personal well-being. This autonomy allows traders to focus entirely on creative research and strategy development.

Building a diversified career. To survive the inevitable drawdowns of the financial markets, a quantitative trader should build an "antifragile" career. By diversifying income streams through consulting, writing, and teaching, a trader reduces emotional stress, which in turn leads to more disciplined, objective trading decisions. This diversification ensures that the trader's livelihood is not solely dependent on short-term market performance.

  • Strategy Diversification: Maintaining a portfolio of at least 10 independent, low-correlation strategies.
  • Dynamic Capital Allocation: Continuously scaling down underperforming strategies and scaling up profitable ones.
  • Synergistic Activities: Leveraging teaching and research to discover new market inefficiencies.

Managing external capital. Transitioning from a proprietary trader to an investment manager allows you to scale your business and provide a valuable service to others. While managed accounts offer transparency and ease of setup, establishing a fund or pool structure is ultimately superior for executing complex, diversified multi-strategy portfolios. This transition requires building institutional-grade infrastructure and maintaining strict regulatory compliance.


Last updated:

Report Issue
Want to read the full book?
Want to read the full book?
Follow
Listen
Now playing
Machine Trading
0:00
-0:00
Now playing
Machine Trading
0:00
-0:00
1x
Queue
Home
Swipe
Library
Get App
Try Full Access for 3 Days
Listen, bookmark, and more
Compare Features Free Pro
📖 Read Summaries
Read unlimited summaries. Free users get 3 per month
🎧 Listen to Summaries
Listen to unlimited summaries in 40 languages
❤️ Unlimited Bookmarks
Free users are limited to 4
📜 Unlimited History
Free users are limited to 4
📥 Unlimited Downloads
Free users are limited to 1
Risk-Free Timeline
Today: Get Instant Access
Listen to full summaries of 26,000+ books. That's 12,000+ hours of audio!
Day 2: Trial Reminder
We'll send you a notification that your trial is ending soon.
Day 3: Your subscription begins
You'll be charged on Jul 8,
cancel anytime before.
Consume 2.8× More Books
2.8× more books Listening Reading
Our users love us
600,000+ readers
Trustpilot Rating
TrustPilot
4.6 Excellent
This site is a total game-changer. I've been flying through book summaries like never before. Highly, highly recommend.
— Dave G
Worth my money and time, and really well made. I've never seen this quality of summaries on other websites. Very helpful!
— Em
Highly recommended!! Fantastic service. Perfect for those that want a little more than a teaser but not all the intricate details of a full audio book.
— Greg M
Save 62%
Yearly
$119.88 $44.99/year/yr
$3.75/mo
Monthly
$9.99/mo
Start a 3-Day Free Trial
3 days free, then $44.99/year. Cancel anytime.
Unlock a world of fiction & nonfiction books
26,000+ books for the price of 2 books
Read any book in 10 minutes
Discover new books like Tinder
Request any book if it's not summarized
Read more books than anyone you know
#1 app for book lovers
Lifelike & immersive summaries
30-day money-back guarantee
Download summaries in EPUBs or PDFs
Cancel anytime in a few clicks
Scanner
Find a barcode to scan

We have a special gift for you
Open
38% OFF
DISCOUNT FOR YOU
$79.99
$49.99/year
only $4.16 per month
Continue
2 taps to start, super easy to cancel
Settings
General
Widget
Loading...
We have a special gift for you
Open
38% OFF
DISCOUNT FOR YOU
$79.99
$49.99/year
only $4.16 per month
Continue
2 taps to start, super easy to cancel