What is backtesting?
Hope is not a risk management plan - backtest first!
Essentially, back testing is going back in time and testing your trading strategy on past market data. This is what helps quants and traders decide on which strategies to implement in the current market - it separates the winning strategies from those that lose money.
Key Steps involved in Backtesting
1) Define the strategy – what are the buy sell rules? (for example, are we deciding on actions based on moving averages, RSI, Mean Reversion etc.)
2) Gathering historic data – using sources such as Yahoo finance, Alpaca etc. and choosing the market you want to look at (e.g. crypto, forex, or stocks in a particular industry), over a selected period of time in the past.
3) Implement the new strategy in code – like in python using the pandas command as mentioned in a previous post.
4) Run the Backtest – simulate these trades over historical data.
5) Analyse the results – the specific points that would be noted are the win rate, Sharpe ratio, max drawdown and other performance metrics.
6) Avoid Overfitting – This is the trap of making a strategy too perfect for the past period you are testing on – (remember markets tend to follow patterns but no two conditions are ever exactly the same).
What to look for during these backtests
Win Rate
Win rate measure the percentage of trades that are profitable. It is calculated by:
A high win rate means there are more successful trades, take a look at the possible results for reference:
Win Rate Likelihood Examples
50-60% Very Common High frequency and statistical arbitrage strategies.
60-70% Strong Win Rate Seen in market-making or well-optimised systematic strategies.
70-80% Exceptional Found in low-risk arbitrage or strategies with high execution precision.
80%+ Rare Usually indicates overfitting in backtests or ultra-low risk arbitrage (e.g. latency arbitrage).
However this metric alone can be misleading alone. Win rate tells you how often you win but not how much you win when you’re right, or how much you lose when you’re wrong. The result also doesn’t reflect volatility of an asset – a high win rate may suggest the stock has a steep equity drop!
Sharpe Ratio
If a win rate tells you how smartly you’re winning. It’s the risk adjusted return – essentially, how much return you’re getting per unit of risk. A higher Sharpe ratio means you’re not just making money, you’re doing it efficiently.
Formula
Sharpe Ratio = (Portfolio Return – Risk Free Rate) / Portfolio Standard Deviation
Interpreting the results:
< 1 You’re taking on too much risk for the return you’re getting
1-1.99 Decent – you’re doing alright zone
2-2.99 Strong – you’re taking on more risk and getting rewarded
3+ Elite Hedge fund material
However like win rate this indicator is not without its setbacks. Sharpe Ratio assumes returns are normally distributed (they’re often not). It also fails to distinguish between upside and downside volatility, punishing both when upside volatility is what we want! If your strategy has skew or fat tails, consider alternatives like the Sortino Ratio.
These are two of the main measures to look at when backtesting - with Win Rate telling you how often you win and Sharpe Ratio telling you how efficiently you’re winning. While both are useful they are just a small part in testing a strategy and are best interpreted alongside other metrics for a well-rounded overview of performance.
This Weeks Quant News Story
Quant funds leverage algorithm-driven strategies to remove human biases and minimize the risk of style drift, ensuring a disciplined and systematic investment approach. By relying on predefined models, these funds eliminate emotional decision-making, a common obstacle in traditional investing. However, their rigidity can be a double-edged sword - while they excel in structured environments, they may struggle to adapt to unprecedented market shocks where human intuition could provide an edge. I believe this trade-off between automation and adaptability raises an important question - do you think quant strategies should include some level of discretionary intervention to navigate anomalies effectively? Read more here.
Key Terms
Latency Arbitrage - Latency arbitrage is an HFT (high frequency trading) strategy that exploits price discrepancies between exchanges due to data transmission delays.
Style Drift - Style drift is when a fund deviates from its stated investment strategy over time.
Sharpe Ratio – Measures how much excess return you’re getting per unit of total risk (standard deviation)
Sortino Ratio – Measures excess return per unit of downside risk, ignoring upside volatility.