About
Why I built this.
I made a trading bot that looked like it worked. It didn't. Finding out why turned into a better project than the bot.
I built a trading bot. It used EMA, VWAP, MACD and RSI — the four indicators everyone uses. I backtested it and the results looked good.
I didn't believe them. I hadn't done anything original. Four standard indicators, free data, a laptop. If that beat the market, a lot of people with more money and better tools would already be doing it.
So I checked properly. I'd made three mistakes.
I was testing on the same data I used to pick the settings. Try enough combinations of moving average lengths and one of them looks great. That's not a discovery, it's just the best result out of everything I tried.
I wasn't subtracting what it costs to trade. Every trade pays the spread, the commission and the slippage. My bot traded every few days. Those costs add up faster than I expected — one of the rules I tested later paid away 78% of its value in costs.
And my backtest was earning the same day's return off the same day's signal. You can't do that. A signal from Monday's close isn't knowable until Monday has closed, so the earliest you can trade it is Monday's close. That one mistake is worth about 20 points of Sharpe ratio. I only found it because I went looking.
Fixing all three took nearly all the performance away.
One of the four indicators turned out not to be what I thought either. Real VWAP is intraday — it resets every session. On a daily chart it can't be calculated at all. What people call daily VWAP is something else with the same name.
That was more interesting than the bot. So this is the project now: take the indicators millions of people trade on, test them in a way that's hard to fool, and publish what's left every week. Including the weeks the answer is nothing.
Rules I've set myself
- Publish the bad weeks. A week where nothing worked is a result. It's also the week I'm most likely to be right about.
- Decide the thresholds first. Survived, weakened and failed are fixed in code before I see the numbers. If I could move them afterwards they wouldn't mean anything.
- Say what's wrong with it every time. Survivorship bias, one cost assumption for every stock, no borrow costs on shorts. They're in every report because they don't stop being true.
- Never edit a published number. If a later week contradicts an earlier one, both stay up and I write about the gap.
- Publish the code and the data. Every figure comes from one command anyone can run. A result nobody can check is just an opinion.
Where it's got to
The last run tested 3,308 combinations — every indicator against 849 companies in the S&P 500 and FTSE 350. The median score was 2.4 out of 10. Twelve scored 8 or above, and I don't trust those either: test 3,308 things and a handful will look good by accident. The only thing that would convince me is if the same ones survive next week, on data that didn't exist when I picked them.
The live portfolio
Backtests only prove so much, because I can always run one again until I like the answer. So there's a paper portfolio trading the one strategy that survived. Orders get published before they fill and the whole order book is public. I can't re-run it. That's the point.
Me
I'm a sixth-form student at TASIS England, applying to read economics and finance at university. I have the CFA Institute Investment Foundations certificate and a Wharton online finance certificate. I've been writing Python trading systems for a while, which is how this started, and the first thing it proved was that mine didn't work.
I'm not a professional and this isn't investment advice. It's a student project run in public with the workings shown.
Corrections welcome. If you can show me a number here is wrong, that's the most useful thing you could send me, and I'll publish the correction.
Email hello@marginco.co.uk. If a number here is wrong I'd rather hear it from you than not, and the correction goes up with the week it belongs to.