- Speaker #0
Hello. Welcome back to Papers with Backtest podcast. Today we dive into another algo trading research paper.
- Speaker #1
Yep. Another journey into the world of systematic trading.
- Speaker #0
Algorithmic trading research, it's really all about trying to find those systematic edges in the market, moving beyond just gut feelings, right?
- Speaker #1
Precisely. I mean, in today's markets, you really need that systematic analysis. Looking at historical data, that's key to finding trading rules that might actually work.
- Speaker #0
And that's exactly our mission today. We're diving deep into the trading rules and maybe more importantly, the backtest results from the book Algorithmic Trading, Winning Strategies and Their Rationale.
- Speaker #1
Yeah, the aim is to pull out those practical insights. You know, how do you actually build and check these strategies? We're leaning on the author's real world experience here.
- Speaker #0
The book covers a lot of ground stocks, ETFs, futures, currencies.
- Speaker #1
Uh-huh. And different styles too, like mean reversion, momentum. But we'll keep our focus tight on the actual rules they used and what the backtest showed.
- Speaker #0
Definitely. And it's worth remembering the author managed hedge funds through some pretty major market events like the 08 crisis.
- Speaker #1
Right. That experience adds weight. It tells you something about the real challenges, the bumps in the road you hit with algo trading.
- Speaker #0
OK, let's kick things off. The book hammers home the importance of backtesting, foundational stuff. Absolutely. Now, just for anyone maybe newer to this, backtesting is basically a... Taking your strategy and running it on old market data. Yeah. To see how it would have done.
- Speaker #1
That's the gist of it. Yeah. The hope is, you know, if it worked in the past, maybe it's got a shot in the future. But this is crucial. The book really stresses doing your own independent backtesting, even for strategies that are already published. Okay.
- Speaker #0
Why? Why retest something if someone's already shared the results? Seems like extra work.
- Speaker #1
Well, several big reasons. First off, Strategies can be incredibly sensitive to the real nitty-gritty details of how you implement them.
- Speaker #0
Nitty-gritty like what?
- Speaker #1
Oh, things you might not even think about initially. Like, what exact order type do you use? Market on open. Or maybe a market order a few seconds after the open.
- Speaker #0
Ah, I see. Those could give different prices.
- Speaker #1
Big time. Or, for futures, what closing time are you using in your test? Does it match the stock market close or the specific futures close? It matters. And maybe the biggest one? What price? triggers your trade. The bid. The ask. The last trade.
- Speaker #0
Wow, okay. Those details probably aren't always spelled out in papers, are they?
- Speaker #1
Often not fully, but they're absolutely vital when you go live. They can totally change your profitability.
- Speaker #0
So doing our own backtest lets us nail down those specifics for our setup.
- Speaker #1
Exactly. And ideally, like the book points out, your backtesting setup should be close to your live execution system. You want to test what you'll actually trade.
- Speaker #0
Makes sense. What else does independent testing uncover besides implementation details?
- Speaker #1
It lets you really scrutinize things for hidden flaws, like biases in the data you're using, or maybe flaws in the strategy logic itself. And importantly, you can do true out-of-sample testing. Use data that came out after the strategy was published. If it suddenly falls apart on that new data, well, that's a big red flag.
- Speaker #0
Right. Maybe just worked on that specific historical period by luck.
- Speaker #1
Precisely.
- Speaker #0
Okay, so. Backtesting is non-negotiable. Let's talk pitfalls. The book mentions several. Data snooping bias sounds ominous.
- Speaker #1
It is in a way. It's also called overfitting. Basically it happens when your model is too flexible, too many knobs to tweak. Yeah. You fiddle with it until it looks amazing on your historical data. But you might just be fitting noise, random patterns that won't repeat. Then it performs poorly live.
- Speaker #0
Like finding shilps and clouds and expecting them to predict the weather.
- Speaker #1
That's a good analogy, yeah. And a common trap, the book notes, is trying to validate on out-of-sample data, but then tweaking the model again based on that data.
- Speaker #0
Ah, so you contaminate your test set. You do.
- Speaker #1
You've basically turned your out-of-sample data into more in-sample data, just reinforcing the bias.
- Speaker #0
Sneaky. Okay, another one. Survivorship bias, especially with stocks. What's that about?
- Speaker #1
Right. So many stock databases only include companies still trading today. They leave out the ones that went bust or got bought out.
- Speaker #0
The losers, basically.
- Speaker #1
The ones that didn't survive, yeah. Yeah. This can make backtests look way better than reality, especially for, say, long-only mean reversion strategies.
- Speaker #0
Why those specifically?
- Speaker #1
Because those strategies often buy stocks that have dropped, hoping they'll bounce back. If your data only shows the stocks that did bounce back, the survivors, your results look great.
- Speaker #0
But you wouldn't know in real time which ones would survive.
- Speaker #1
Exactly. You'd buy some that just keep falling and get delisted. Interestingly, for short-selling strategies, It can sometimes make results look worse because the failing stocks you would have profited from shorting are missing.
- Speaker #0
So it cuts both ways but usually inflates long strategies.
- Speaker #1
Often, yes. The bias on the long side tends to be stronger. It's a reminder that you might only be seeing the winners in historical data.
- Speaker #0
Really important. Any other data gremlins to watch out for?
- Speaker #1
Definitely need to adjust for stock splits and dividends. If you don't, a price drop on the ex-dividend date looks like a crash, triggering fall signals. Right.
- Speaker #0
Simple error, big impact.
- Speaker #1
And for things like pair trading across markets, make sure your prices are simultaneous, or as close as possible. You need prices from the same point in time.
- Speaker #0
What about short selling and back tests? Any special issues there?
- Speaker #1
Yeah, shorting isn't always easy. Stocks can be hard to borrow. There might be rules like the old uptick rule restricting when you can short. If your backtest assumes you can always short anything instantly.
- Speaker #0
It's unrealistic.
- Speaker #1
Very. It can seriously overstate profits for short strategies.
- Speaker #0
Okay, moving beyond stocks. Currencies, futures, different data headaches.
- Speaker #1
For currencies, the price you get can really depend on your broker or platform. Spreads vary. So using actual bid-ask data in your backtest is much more realistic.
- Speaker #0
Got it. And futures.
- Speaker #1
Constructing those continuous contracts is tricky. Stitching together expiring contracts needs care. How you back adjust for price level or for returns can create artificial jumps or mess up P&L, especially if you're trading spreads between contracts. You got to choose the right method.
- Speaker #0
Man, it really is all about the details and backtesting. Yeah. Okay. Let's shift gears to some strategy examples from the book. First, a linear factor model for ranking stocks. What's the core idea?
- Speaker #1
OK. So this uses statistical factors, things derived from fundamentals or market data. You normalize them, put them on a common scale and then see how they historically related to stock returns.
- Speaker #0
To rank stocks.
- Speaker #1
Yeah, to rank them. The goal isn't necessarily to predict exact returns, but more relative returns. Which stocks are likely to do better or worse than others based on these factors? Then you build, say, a long-short portfolio.
- Speaker #0
And the book mentions Joel Greenblatt's magic formula as an example.
- Speaker #1
Right. A classic example of a simple factor approach. It ranks stocks using just two things. Return on capital, how well the company uses its money.
- Speaker #0
Efficiency.
- Speaker #1
And earnings yield, basically, how cheap the stock is relative to its earnings.
- Speaker #0
Value and quality.
- Speaker #1
Exactly. Rank on both, combine the ranks. By the top, say, 30 stocks hold for a year. The book quotes a pretty impressive back-tested return. like 30.8 percent annually from 88 to 04, much better than the S&P 500 then. Shows the power of simple rational factors.
- Speaker #0
Impressive. Okay, mean reversion. The book has a conceptual linear strategy.
- Speaker #1
Yeah, this one's more illustrative. The core idea is simple. Prices stray from their average but tend to snap back.
- Speaker #0
Revert to the mean.
- Speaker #1
Right. So this strategy trades when a price deviates significantly from its moving average. The size of the trade is scaled. You trade more, the further away it gets, often using standard deviation to measure that deviation.
- Speaker #0
And the look-back period.
- Speaker #1
Often tied to the estimated half-life of mean reversion, how long it typically takes to revert halfway back. It's presented as a fairly simple model, less prone to overfitting because it doesn't have tons of parameters.
- Speaker #0
Then there's a Bollinger Band example on the GLD-USO spread, gold versus oil ETFs.
- Speaker #1
Uh-huh. Bollinger Bands create those dynamic channels around a moving average. Here, they applied it to the price difference between GLD and USO. The spread. Yeah. And they used a dynamic hedge ratio, adjusting the shares over time. Entry was when the spread hit a Z-score of one standard deviation away. Exit was when it came back to zero, the average.
- Speaker #0
And did it work, even though gold and oil aren't, like, perfectly linked long-term?
- Speaker #1
Apparently, yes. The book reported positive returns and sharp ratio in the backtest, even without strong coin aggression. Suggests you can sometimes find short-term mean reversion in spreads, even if the assets wander apart eventually.
- Speaker #0
Interesting. Okay, momentum. Example using TU Futures Treasury notes.
- Speaker #1
Yeah, a time series momentum strategy. Super simple rule. If the price went up over the last 12 months, buy. If it went down, sell short. Hold for one month.
- Speaker #0
And the logic?
- Speaker #1
Based on finding a statistically significant positive link between the 12-month return and the next month's return for those futures historically. They also mentioned a tweak involving daily incremental investments.
- Speaker #0
Simple, but data-driven. What about cross-sectional momentum? commodities example.
- Speaker #1
Right. This looked across a bunch of commodities, like 52 of them. Each month, rank them by their 12-month return. Okay. Then by the top performer's future, short the bottom performer's future, hold for a month, re-rank, repeat.
- Speaker #0
And the results?
- Speaker #1
Excellent backtest results reported for mid-2005 to late-2007. High APR, good sharp ratio. Yeah. But, and this is a huge, but the book notes, it got hammered during the 2008 crisis.
- Speaker #0
Ah, a momentum crash.
- Speaker #1
Exactly. A stark reminder that what works in one market regime can fail spectacularly in another. Fact tests don't always capture that fragility.
- Speaker #0
Very true. Lastly, news sentiment strategies. Briefly, what's the idea?
- Speaker #1
This uses tech to read news, social media, etc., and assign sentiment scores, positive or negative, to companies or assets.
- Speaker #0
So quantifies the buzz.
- Speaker #1
Sort of, yeah. Then you build strategies, like buying stocks with improving positive sentiment, shorting ones with rising negative sentiment. The book mentions reports of high returns in sharps and back tests. Okay. But often before costs.
- Speaker #0
Costs of trading and the data feed itself, presumably.
- Speaker #1
Right. Those can eat into profits quickly.
- Speaker #0
These examples really show the variety. but also highlight that you have to look closely at the rules and the backtest context critically.
- Speaker #1
Absolutely. And like the book stresses, even if a backtest looks good, is it statistically significant or just luck?
- Speaker #0
How do you test for that?
- Speaker #1
The book touches on a few ways. Comparing your Sharpe ratio to certain thresholds, using Monte Carlo simulations, basically generating random price paths to see how often sheer luck produces similar results. Okay. or even just randomizing your actual trades across history to see if timing luck was the key factor. Different methods, different assumptions about randomness. So they might give different answers.
- Speaker #0
It's complex. The book also mentions market regime shifts, structural changes. How did those mess things up?
- Speaker #1
Big time. Think about decimalization in U.S. stocks back in 2001. Spreads got way tighter.
- Speaker #0
Killed some Stadarb strategies, right?
- Speaker #1
Exactly. Strategies relying on tiny bid-ask spreads suddenly struggled. Or the 2008 crisis. Massive volatility spikes, volume changes. That completely changed the game for many mean reversion and even momentum strategies.
- Speaker #0
So the market itself changes the rules.
- Speaker #1
Constantly. The author's own crisis survival stories highlight key lessons. Don't manually override your system in panic. Stay under leveraged. Accept that strategy performance waxes and wanes. And beware of overconfidence. It's dangerous.
- Speaker #0
Humility is key. Okay, last point. Software and platforms. What does the book cover?
- Speaker #1
It mentions a few categories. Scripting languages like Python, MATLAB, very flexible but steeper learning curve maybe.
- Speaker #0
For custom builds.
- Speaker #1
Yeah. Then Excel with VBA, easier entry for some but might choke on complex stuff. And specialized platforms like FXO, MetaTrader, TradeStation often have built-in backtesting and broker links.
- Speaker #0
Trade-offs between flexibility and ease of use.
- Speaker #1
Pretty much. And it touches on collocation for high-frequency trading, putting your servers right next to the exchange's servers to cut down latency. Milliseconds matter there.
- Speaker #0
requires direct data feeds too speed is everything at that level okay this has been a really insightful look at the trading rules and back test realities from algorithmic trading really drives home the complexities it does and for anyone listening who's into this you've got to remember the challenges data quality those biases we talked about implementation details market changes it's a minefield if you're not careful and that crucial takeaway a great back test is not a crystal ball It needs rigorous out-of-sample validation. a real understanding of why it works, and a healthy dose of skepticism.
- Speaker #1
Precisely. It's about continuous learning, critical thinking, and yeah, staying humble about the market's ability to surprise you.
- Speaker #0
Thank you for tuning in to Papers with Backtests podcast. We hope today's episode gave you useful insights. Join us next time as we break down more research. And for more papers and backtests, find us at https.paperswithbacktests.com. Happy trading.