Hello.
Welcome back to Papers with Backtest podcast.
Today we dive into another algo trading research paper.
Yep.
Another journey into the world of systematic trading.
Algorithmic trading research,
it's really all about trying to find those systematic edges in the market,
moving beyond just gut feelings,
right?
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.
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.
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.
The book covers a lot of ground stocks,
ETFs,
futures,
currencies.
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.
Definitely.
And it's worth remembering the author managed hedge funds through some pretty major market events like the 08 crisis.
Right.
That experience adds weight.
It tells you something about the real challenges,
the bumps in the road you hit with algo trading.
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.
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.
Why?
Why retest something if someone's already shared the results?
Seems like extra work.
Well,
several big reasons.
First off,
Strategies can be incredibly sensitive to the real nitty-gritty details of how you implement them.
Nitty-gritty like what?
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.
Ah,
I see.
Those could give different prices.
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.
Wow,
okay.
Those details probably aren't always spelled out in papers,
are they?
Often not fully,
but they're absolutely vital when you go live.
They can totally change your profitability.
So doing our own backtest lets us nail down those specifics for our setup.
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.
Makes sense.
What else does independent testing uncover besides implementation details?
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.
Right.
Maybe just worked on that specific historical period by luck.
Precisely.
Okay,
so.
Backtesting is non-negotiable.
Let's talk pitfalls.
The book mentions several.
Data snooping bias sounds ominous.
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.
Like finding shilps and clouds and expecting them to predict the weather.
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.
Ah,
so you contaminate your test set.
You do.
You've basically turned your out-of-sample data into more in-sample data,
just reinforcing the bias.
Sneaky.
Okay,
another one.
Survivorship bias,
especially with stocks.
What's that about?
Right.
So many stock databases only include companies still trading today.
They leave out the ones that went bust or got bought out.
The losers,
basically.
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.
Why those specifically?
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.
But you wouldn't know in real time which ones would survive.
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.
So it cuts both ways but usually inflates long strategies.
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.
Really important.
Any other data gremlins to watch out for?
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.
Simple error,
big impact.
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.
What about short selling and back tests?
Any special issues there?
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.
It's unrealistic.
Very.
It can seriously overstate profits for short strategies.
Okay,
moving beyond stocks.
Currencies,
futures,
different data headaches.
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.
Got it.
And futures.
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.
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?
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.
To rank stocks.
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.
And the book mentions Joel Greenblatt's magic formula as an example.
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.
Efficiency.
And earnings yield,
basically,
how cheap the stock is relative to its earnings.
Value and quality.
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.
Impressive.
Okay,
mean reversion.
The book has a conceptual linear strategy.
Yeah,
this one's more illustrative.
The core idea is simple.
Prices stray from their average but tend to snap back.
Revert to the mean.
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.
And the look-back period.
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.
Then there's a Bollinger Band example on the GLD-USO spread,
gold versus oil ETFs.
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.
And did it work,
even though gold and oil aren't,
like,
perfectly linked long-term?
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.
Interesting.
Okay,
momentum.
Example using TU Futures Treasury notes.
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.
And the logic?
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.
Simple,
but data-driven.
What about cross-sectional momentum?
commodities example.
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.
And the results?
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.
Ah,
a momentum crash.
Exactly.
A stark reminder that what works in one market regime can fail spectacularly in another.
Fact tests don't always capture that fragility.
Very true.
Lastly,
news sentiment strategies.
Briefly,
what's the idea?
This uses tech to read news,
social media,
etc.,
and assign sentiment scores,
positive or negative,
to companies or assets.
So quantifies the buzz.
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.
Costs of trading and the data feed itself,
presumably.
Right.
Those can eat into profits quickly.
These examples really show the variety.
but also highlight that you have to look closely at the rules and the backtest context critically.
Absolutely.
And like the book stresses,
even if a backtest looks good,
is it statistically significant or just luck?
How do you test for that?
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.
It's complex.
The book also mentions market regime shifts,
structural changes.
How did those mess things up?
Big time.
Think about decimalization in U.S.
stocks back in 2001.
Spreads got way tighter.
Killed some Stadarb strategies,
right?
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.
So the market itself changes the rules.
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.
Humility is key.
Okay,
last point.
Software and platforms.
What does the book cover?
It mentions a few categories.
Scripting languages like Python,
MATLAB,
very flexible but steeper learning curve maybe.
For custom builds.
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.
Trade-offs between flexibility and ease of use.
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.
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.
Precisely.
It's about continuous learning,
critical thinking,
and yeah,
staying humble about the market's ability to surprise you.
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.