A thread on building better algorithmic trading systems for crypto from first principles 1/
Its Sunday morning here in Phuket, Thailand. I have cool tunes on and I'm ready to share some things that are common knowledge for practicioners but not widely known among retail tradoors Let's get after it /2 https://www.youtube.com/watch?...
The type of signal where you "long at a 20 day breakout" can "work" but they are by definition inefficient More on that by my buddy Kris here https://krislongmore.substack.... You can improve virtually any signal by making it continuous. How? /3
If its a moving average, instead of "if > 200 SMA go long" Measure the distance to the SMA instead. Hey presto, you got a better signal /4
One thing you probably know intuitively, BTC and TRASHCOIN aren't the same They don't move the same, liquidity isn't the same, edges aren't the same... so you shouldn't treat your signals the same /5
The "proper kwant" way is to build barra/axioma style factor models and adjust for everything you know is predictably fucking with price But an 80/20 solution for ghetto kwants from these streets is to vol normalise the time series before running features Apples to apples /6
Next thing to consider is what "lookbacks" to use Should we use 20 day breakouts or 50 day breakouts... 100 EMA or 200 EMA? Here's how to think about that puzzle /7
Retailoors will be tempted to run a backtest and take the best looking ones That's bad (explicit overfitting) It's one of the 3 types of overfitting which we gotta dig into /8
There are 3 primary ways of fucking up trading system design, but they all boil down to overfitting I recently saw @AgustinLebron3 has a blog now at https://reducibleerrors.com/ The logo is the math explanation of what Ima talk about /9
@AgustinLebron3 Statistically, there is a very small amount of parameter optimisation you can do before out of sample performance declines Know this: You can't polish a turd, but you can roll it in a nice color of glitter /10
@AgustinLebron3 This sounds trite, but its a big deal And overfitting is everywhere Consider the 3 types of overfitting 1. Implicit - I tried something and it "didn't work" so I threw it away 2. Explicit - I chose the best backtest out of 2 3. Tacit - I "know <thing> works" /11
@AgustinLebron3 The takeaway is that I'm already doing a significant amount of fitting just because I know that other people do momentum and carry and I do too Doesn't leave much wiggle room left before I'm building something that looks good in backtests but not in the real world. /12
@AgustinLebron3 Side point: stop losses are a form of risk control A crappy form of risk control unless you think this is the effect you are modelling /13
@AgustinLebron3 Technically, adding a stop loss to any setup turns it into a trend following setup Consider *carefully* if you want this This is why stop losses turn virtually all mean reversion systems into losers /14
@AgustinLebron3 Alright, I think I've covered the basics - Use continuous signals - Don't overfit - Stop losses probably not What kind of risk control should we use instead? /15
@AgustinLebron3 I'm gonna propose something pretty radical 1. Put your trades on when you think you have edge, in proportion to the edge you think you have 2. Take them off when you don't think you have any more edge, or reduce when you think the edge has reduced This is the "pro method" /16
@AgustinLebron3 If we model the effect we think we have closely AND We hold the correct position size for the edge we think we have THEN we have MOST of the edge harvested /17
@AgustinLebron3 Mostly, this is the point where retail tradoors should stop Trading systems get complicated at a frightening rate It can be terrible to have things go wrong and be unable to diagnose whats going wrong https://youtu.be/gd-1fRBPiIY?t... /18
@AgustinLebron3 But what if we want to go a bit further. What if we wanted to get all the way to state of the art trading systems? FUCK. Good trick. But lets get after it. /19
@AgustinLebron3 The basics are two things 1. Trading edges are noisy. Trade more shit 2. Trading systems work sometimes and then stop See this paper https://ideas.repec.org/a/bla/... /20
@AgustinLebron3 The implication of edges working then stopping then working again is that you need more edges "I trade breakouts" guy is gonna spend a lot of his life getting buttfucked by the market (that's me, that's literally me) /21
@AgustinLebron3 There are three aspects to the edges you are mostly gonna be trading 1. Lookback window 2. Sampling method 3. Feature calculation This is stuff that's "beginner level" if you have a job in kwant finance, don't think I'm flexing here at all /22
@AgustinLebron3 Which lookback window? Meaning which moving average, which breakout etc? What we are trying to accomplish is answer the question "do we have any reason for thinking 20 day breakouts are better than 50 day?" /23
@AgustinLebron3 Note we can't answer this with a backtest (see previous discussion on overfitting) cos the past is different than the future innit Most times we just don't have any reason for thinking X is better than Y So you COULD equal weight stuff and make an average /24
@AgustinLebron3 Back in the real world equal weighting is hard to beat. That's your first stop But if you think about it, what we are trying to do is get equal amounts of signal so we can let the evidence show us how to weight things Better things should be traded bigger /25
@AgustinLebron3 The GOAT @macrocephalopod shared this /26
@AgustinLebron3 @macrocephalopod You can see that the correlation between 10,20,40,80,160,320 day breakouts is a constant .71 You can fuck with that to prove it to yourself using this spreadsheet #gid=0 class="text-blue-500 hover:underline" target="_blank" rel="noopener noreferrer">https://docs.google.com/spread... /27
@AgustinLebron3 @macrocephalopod So we've chosen a bunch of parameters to give us similar correlations Now we can shove them into a portfolio optimizer of some sort /28
@AgustinLebron3 @macrocephalopod This could be simple hueristics if you are a Chad like @investingidiocy It could be an MVO which is the classical solution It could be a ridge MVO as suggested by @0xfdf (tanks mang, this works great!) /29
@AgustinLebron3 @macrocephalopod @investingidiocy @0xfdf Note: everything you build has to be maintained IMO @investingidiocy has systems which are about the practical level of work a single person would want to take on Trading systems are built by teams for a reason Be very careful about falling down nerdholes /30
@AgustinLebron3 @macrocephalopod @investingidiocy @0xfdf That being said, the purpose of this thread is to fall down a few nerd holes, innit Let's start to think about all the different edges we might monetize Which starts from first principles /31







