In quant trading competitions like Algothon, success depends on understanding the scoring system which uses a piecewise function based on mean (mu) and standard deviation of P&L, where the Sharpe ratio (mu/sigma) measures risk-adjusted returns. The scoring is scale-dependent, meaning larger position sizes yield higher scores, so participants should maximize capital allocation. Key strategies include using simple linear models with cross-validation to avoid overfitting, focusing on returns rather than raw prices for scale-independent predictions, and implementing statistical validation through confidence intervals to ensure the strategy has genuine predictive power. The competition requires balancing model complexity with limited data (750 rows) while accounting for transaction fees and position sizing constraints.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Advice for Algothon 2026
Added:Hello everyone, welcome to this video.
So this video is going to be uh on this competition called Algafon. Uh it's a quant trading competition run by SIG which are a quant trading firm [snorts] and uh they've got this competition uh for students. I think it's only in Australia and New Zealand and you have a a challenge of how to build a quant trading strategy uh for like a portfolio of assets and uh it's a really great way of building the skills. So even if you have zero experience or it's a great way to build this experience without actually losing any money as well. So I really recommend to to have a go at it.
Uh uh you you'll learn a lot about it and uh yeah it will make you better uh give you better modeling skills and better coding skills. So yeah so this is what the video is about because it's it's quite probably a bit daunting because there's quite a lot of terminology and I'm just going to break it down and give you like a good foundation to to build upon.
>> [snorts] >> So maybe I go over this algafon, right?
Uh so maybe I give a little shout out to everyone that's on the top of the leaderboard here. So we got uh last time I checked this it was the Disciples of Claude, Ivan, and where's Jat Street? Uh Jat Street's dropped down a bit. These were the top three, but now looking here, we've got some new new particip participants that are on the top of the leaderboard. And uh so yeah, I just uh so it these guys or teams uh they they submit every day and they can update the the score. So uh so this is what the current leaderboard looks like. And yeah, so we'll go into into detail of this uh algorithm. And also by the way, I should mention I been I've been AFK for like two months. So, I've had like a house renovation and uh I've also been working on this course uh and I'm nearly ready to to um to advertise it and uh so I'm just got like a closed beta just working with some uh small amount of people and uh once that that's all good then I I'll publish this. I'll make a video about it and uh so yeah this is this is what it's look like for example um teaching like some probability like you got actual exercises as well and it goes into probability econometrics machine learning and actually the end of goal is they have to create a strategy anyway so that that's what I've been up to uh just wondering if I'm still alive or not but anyway let's let's concentrate on the the competition so and by the way even if you're not uh in this competition I really recommend just to download the data then tried to make the the predictions because it it gives you some really good uh experience and modeling and how to build a strategy because it's uh yeah I say it's like a fantastic way to uh to build these skills without actually losing any money and uh so yeah so let's have a look at the score right so the score uh is is what's called a peacewise function so it it's conditional based on this mu and your mu is your uh your mean which is your a measure of your central location and in this context is how much P&L you make on average. Okay? And uh if it's negative, then it's just uh then your mu. But however it's positive, it then gets scaled by this term here. And I I'll go break this down here because it looks kind maybe a bit intimidated or scary. What the hell is it doing? But it's actually quite simple. Uh so we'll go over this. Uh but there's two really main statistical concepts we need to understand here. One is the mean, which is like how much P&L you make. For example, I've got uh an array of trade P&Ls and I take the mean and it tells me on average I make $12.5, right?
Uh but then I've got another one and this one uh uh even I look at or the win rate I win four times at five but then has a negative uh mean because like I've got this one huge like loss and it's just like outweighs all my previous gains and this is like a mu of $112, right? Negative $112. Okay, so that's mu the measure of central location. That should be uh uh kind of obvious. And now we've got the standard deviation which is a measure essentially how stable is your P&L and it's a measure of how uh it deviates from your cent your mean. Okay.
And so I've got like two leaderboard traits. Let's say the guys at the top of the leaderboard. These are their trades when we go and analyze them, right? Uh [snorts] and we look at the mean, right?
And they got a mean of $100. So on average they make $100 on each trade.
And uh they got you look at the standard deviation uh it's a very low and you can see here look if the mu is 100 and you can see these values here they don't really deviate away too much away from 100 right so this is why the standard deviation is low so the lower the better essentially uh however let's say with this one like let's say okay maybe bot maybe mid mid table right and they've also got a mew of 100 but you the they have much higher stable less stable returns, right? You can see like uh they really deviate away from 100. You got 200, then you got 101 99 and then suddenly like 203. So exactly the same average trade return, right? But this has a much higher standard deviation, right? And this is what the the competition is looking for. It's not only just for like um how much you make essentially, but also um how stable are your trades. So for example, if there's the top of the leaderboard and let's say they both have like an average 100, uh this one will be penalized way more than this one. And this is uh then this brings us to the next uh ratio which is called the sharp ratio which is essentially your mean over the standard deviation, right? And this is uh so this is what it models, right? So for example, this we look at the sharp this is a sharp ratio of 70. Okay, it's a it's a toy example, right? And uh then you look at the sharp ratio of the bottom, it's uh 0.9. So it it really the higher your sharp ratio, the more uh risk your stable your returns are. And that's what it essentially measures, how stable your returns are. And this is the metric that's used for the competition.
However, in the competition, it doesn't go over uh what the square root of 252 is and why you multiplying it by the the sharp ratio. So, uh, that might be a bit confusing. So, maybe I explain this. So, um, you want to analyze your sharp ratios, right? So, for example, I've got a strategy, uh, working on an hourly level and I've got a strategy that works on a weekly level. You need to be able to to compare them like for like. So, you analyze them to yearly. And this is where the this MP square root of 252.
And just from looking at I know it's the square root of 252, then it's business days. So um I know this is like daily tick data that this is they're assuming right and yeah so that's the the the competition the the the analyze sharp ratio the so that's what this SR is for this is the sharp ratio and now we're going to just break this down this this term here so we know what we know now what mu is we know what sigma is we know what sharp ratio and now we can go over this scaling factor and it's what's called an asmtoically bounded. That's sounds kind of complicated, but it's really not. It's just saying that it's bounded to either zero and one. Um, and just to to show this, I've just created this plot here. So, as you can see, the the it never like as the sharp ratio we say tends to infinity as in it increases, it never goes over one. So, we say this is asmtotically bounded. And uh and the circular same if the sharp ratio is zero then uh it never goes less than zero. So we say this is bounded to 01. So essentially it's uh scaling your mu. So the you could have like two strategies both have $100. Uh if it has a very low sharp then it's going to maybe take it like multiply it by 0.1. But if you got a very high sharp then let's say I don't know a sharp of I don't know six then it's going to be very close to maybe about 0.9. Okay. And then so this you you you wanting to to optimize for risk adjusted P&L and I haven't said returns here because uh this brings them to the next point to this the it's quite an interesting thing what they've done here and uh it's that the scoring is scale dependent. So typically you you measure things in returns, right? Because if I say, okay, my trading strategy made uh $10, you go, okay, well that's that's not a lot, right? But what about if I said, okay, well, I started with like 10 cents, then that's really impressive because it's a huge return on an investment. Uh so um yeah, this is an interesting thing they've done here is that and the thing because it's scale dependent. So this is uh this is the the scoring. This is how it's calculated, right? So it's just the mean multiplied.
Oh, this is assuming the P&L is positive. I haven't added the edge case where it's ne not negative but um then you multiply by the scaling factor, right? And that scaling factor is this uh the that term that I showed you, right? And let's say you look at the scoring here. Uh the trade P&L is uh let's say this is your trade P&L.
you you I think the let's say you can trade up to like 10,000 I think it's a 10 10k and one of them algo is 100k uh and I just using I'm not using the full amount that I can trade right so I'm not using the full notional size that I position size I could use and I've got a score of five however if I just multiply my trade size by 10 then I increase my score so this really um is asking you to go home or or go big or go home type of things. It's like if you really want to make you need to to allocate uh use as much money or the the max capital as possible that they they give you and so yeah so that's a really important thing.
So if you're just maybe you you're trading you've got like an edge but you're not making it maybe in should increase your trade size and uh this is an important part as well. So this comes into the course as well. So for example like if you multiply uh like an expectation inside multiply the by a constant inside the expectation is exactly the same as multiplying the the constant outside the expectation and this comes into into like this as well. So I could have just taken 10 multiply by the scoring. But um yeah, so th this uh just the key point is is that you should be you should be trading big sizes should always allocate the full amount that you can trade. Uh it may be that you may want to do it in piece pieces, but you should always try to make sure that your position notional size is always the max uh on the top side of the of the amount that you can trade uh because it's scale dependent.
So uh yeah so that's really an important thing. So if you real if you if your trade sizes is too small you need to you should increase them and then uh if you got an edge then you increase your score. Okay. And so now I've gone over this the scoring is scaled uh dependent and also showed that it's like asmtotically bounded. Uh so now now what what do you want to predict right and there's four things that you can predict here. one is the future price uh future price delta was just the difference between the the future price and the current price over the oh yeah there's just the yeah and then you got the return and then the log return I'm just going to go into more detail on this right uh I wouldn't recommend to predict the future price it's just bit painful really because once you predict the future price you need to work out okay is this over um is this predicting it's going up or predicting going down so you have to take a delta anyway So um but you know there's no right or wrong answer. If you find uh that you have a model that predicts the future price well then uh just use that but you just have to remember that you'll need to take the delta from the future price and the current price to work out okay is this uh volume the price is going up or price it going down. [snorts] Uh but yeah then you got the delta which is just the the future price minus the the current price. So as you can see here this is the future price. So uh on the row that's the current price that's the future price you can see here that corresponds to here. So how to do this by the way is to do the shift. So for example if I want to predict seven day or this is I'm guessing it's days. Um like 99% sure it's days. Then I'm predicting seven days ahead but we just call them ticks because they haven't actually explicitly said they're days but yeah just say ticks. Uh so I'm predicting seven ticks ahead [snorts] and uh so yeah so that that's what I'm doing. and calculating the the future price seven ticks uh away and yeah so that's pretty much the the the delta and and you can see here with the delta you you see um how much it goes up or down by right so this is like a price movement uh but the only problem with this is that it's scale dependent and remember that for example if this is quite a volatile like for example bitcoin or something like if it moves by $10 at the beginning uh or no let's just keep to this algo, right? Let's say uh it moves by $1, right? That's means more than it does like at the bottom, right?
Because it was at 192. So, um it it's it's scale dependent. So, you it depends on the on the price. So, this is why it's probably better to to model the the return because then it's uh it's scale independent. So, and uh so and again, it's to calculate the future price return. It's just the the price delta normalized over the current price and then that gives you the uh the return and you can just see here look you can see it's uh and this is good because imagine the other um the other you can then compare other um uh returns from other we call cross returns as well using these returns. So that would be my cho choice is to to to work with returns.
Okay. And uh another really important uh important uh concept that for important note is that the position sizing. So it's it's it's very interesting because they've got they've got this like edge case which is if it's ALGO they allow you to trade up to a notional of 100K but the rest is just 10K and also the transaction fees are extremely low very generous. Uh so literally left algo that you you have no fees whatsoever here. So the the you're if this was me I'd be focusing I make sure my first model or first strategy I've got is really good is algo you want to spend time on that because um because the if this if the scoring was scale independent as in using returns uh it wouldn't be such a big deal but I think this is like a really important thing I think that the they want you to to spot is like okay the the scoring is scale dependent you have huge position size for ALGO. Uh I would focus a lot of time uh on ALGO, right? Um make sure that model's good because that could be the difference between being first place or second place uh potentially. So yeah, and also as well that this the fees are like zero. So uh you could even predict on a on a short time scale as well. Uh but yeah, so that's just really important. So I I would spend make sure you have really good model for and spend time to make sure your out this algo strategy is really good. [snorts] Okay. So now you got your uh we've discussed that then okay and I want to explain why is it so hard to predict in trading and it's because there's so much noise in it and uh the best way is to visualize it. So again I'll just downloaded the the data. Uh it was 500 rows but they've recently updated it now. So now I've got 750 rows and you've got the assets here. I've just listed them all down and I've plotted them. I don't [snorts] recommend maybe just to have a look at them, but it's very easy to um uh I wouldn't recommend to do is just like just plot a line for it because uh I'm guessing there's going to be a huge region change and my guess for example this it's probably like some senoid or cyclic function with noise in it. So my guess is that this is going to be like some sort of like periodic cyclic function, but you know I that's just my intuition. I've not uh so just be very careful just putting like a line in there and think it's going to go down. Um but you you if you have good models and you should you should be able to bet correctly if it's going to go down or up. So okay. So that's the and I also just recommend just by looking at the finding the don't look at the charts and find like to find patterns is you have to look by the the the data. Okay. So uh again I just want to just show the why is it so hard. So the first thing we can do is build an what's called an autocorrelation matrix. Okay. So um I've built I've got the returns I've got what's called the lag and lag one and lag two. So I've just taken the the the daily percentage change uh which is the returns essentially and I'm just got the the first lag the previous return or the current return uh and then the pre the two days uh return. Okay. So that's the and you can see here like for example there's a a positive correlation. So that means that when uh it previously currently goes up it goes up in the future.
it tends to and then opposite way around and you can see here it's not very strong correlations and this is what you'll find and we have to actually look at the data you can see it's like extremely hard to and this is the reason why it's very hard to predict in financial time series because you're trying to find uh a function a polomial that can represent this data and it's uh it's hard to do right because okay where if you're going to put a straight line through it where put it. Uh so it's it's extremely noisier. It's like for example if the you could maybe if it was less noise you could see like um a clearer pattern, right? Okay, this is a nonlinear pin. This is quadratic. This is linear. But here it's like literally just it's noise. So it it's this is why it's very hard to predict. [snorts] So, and I this um one of the things you want to do as well is look at the analyze the magnitude of price movements. Uh just to see like how much it moves up by uh for different forecast horizons. Uh so for example, it's basically you're just taking the absolute of the of the delta and this tells you like on average how much does it move up up or down by right and it may be like for example you this goes from two and you increase it to three that the mean like doubles, right? Um so this is like just to give you an analysis like okay um for for your strategies like what's the expected magnitude of price movements uh that you could possibly receive and as you can see here like for 30 days is now the means like 3.6 six.
I've done this uh not I've done the scale dependent, but probably better if I did it like returns. Uh okay, so that's that. And so, okay, we've looked a bit wiser.
We've looked at what to predict the scoring and now let's get into the meat and bones is like, okay, to create a model to predict a future price and then to create a strategy based on your model's predictions. So, what I'm just going to do is just set a forecast horizon to 30 days. And I would say there's there's probably a sweet spot of um like for example if you just predict a very long forecast horizon and you your model like let's say overfits and it's like [snorts] it it takes a long time uh you may want to to change your uh you and you say like you got fixed rule to say okay I'm going to close it after 30 days then you're in a bad position for a long time and also another important Important thing about the scoring is I think it's b based on your net asset value. So essentially it model is you it's factoring your realized P&L which is the trades that you've made and the money you've made but also the unrealized P&L which is your the value of your position. So that's a very important part as well. So you have to model this doesn't unfortunately doesn't model the unrealized size but that's something that you can add in is to to model the unrealized part.
Okay. So you got to decide on a forecast horizon. So I've just set it to 30. So I I calculate the the future price uh 30 ticks ahead and I calculate the return and its lack. And and what I'm doing is I'm creating what's called a cross return matrix. So I'm looking I'm doing this for all the assets and this is why I got um uh I loop over the assets because this is I want to do it for every single one. So I'm not doing this manually. I'm just doing it automatically. Yeah. So this is the the returns cross returns matrix. So you can see here like for example I've got you can see like the there's some like strong correlations and you can see here um what but I say this with a pinch of salt right because we haven't uh this is uh we need to like look at the insample um correlations if we're going to to use it because it could just be that it was very strong in the historical data but that correlation is weak now in the most recent data. So, uh, I just want to to to point that out. But, yeah, let's just have a quick look at, um, one of them, right? So, what we're going to do is look at this M MMBT and, uh, look at its previous return.
So, like say the current return to predict this ALGO return, right? Uh, which is the our future return. And you can see here that it's okay we can maybe put like a line through it like just looking at this intuitively we could fit in like uh and again you there's multiple things you could say like okay this is some sort of polomial you could put like a line through like there or you could put like a line just a straight line and my my recommendation is just to use what's called a first order approximation. So even this probably looks like it's a nonlinear function, just approximate it as as a linear because it's less likely to fit and it just gives you a very nice linear expectation. So for example, if the more that mmt moves in one way, let's uh the greater the expectation that algo is going to move in a certain direction, right? Um but looking at this, this looks like it's going to be like a a positive, right? Uh but we'll we'll have a look and see what it models, right? So I really recommend to to start with like linear models. And another important thing is that there's only 750 data points, right? So if you try and fit in your network, it's just going to overfit. Uh so yeah, just really recommend to to to use basic models and uh you'd be surprised like uh how well [snorts] you can do with models uh basic models like just less parameters. The the simplicity is where it can be powerful, right? [snorts] Okay. Right. So the first thing you need to do is to split the data by time. And this is so important because you don't want to leak data that it uh for example if you use scikite train test train split it shuffles by default. But uh so I really recommend just to do it yourself and you can see like okay um and what I just do is I do docopy just because when you add the fields you don't get these like warning signals uh warning signs sorry. And so like again show like it's split the the data and uh so the oldest the most recent data is our test. So we don't learn a pattern from it. We just reserve it for for testing if it actually has learned a pattern or not. So uh now we're going to build this linear regression. It's a we're just going to train to learn a pattern from the the previous or the current M as MMBT MMBT uh to predict the ALGO return. Right. And this is like the most basic model that you can sort of build like for for making forecasts. Uh so and you can see here I printed out the the weight of the bias. So this tells me that this is sort of like a a trend following uh uh model, right? Because it's modeling that if the MMBT uh price return goes up, the expectation is that the uh ALGO return goes up.
Okay. Okay. And then but you the the caveat here is that if it's just predicts it go like this weight uh is biased by this intercept. Okay. So for example uh after multiplying the weight uh with the the the current return let's say it's just like 0.01 then it's actually going to bias it into a negative prediction like predict going down. Right? So uh that's just one nuance you have to to think about. Okay.
And then we need to back test it. So we've this data uh has not been passed to the model. It's it's unseen data and we want to see okay how well does it do to predict. Uh just another caveat it's like it make it's making a prediction like every uh on every tick like okay if it predicted on this day would it win or not?
So then this is what we add to this column here yhat which is our prediction and I just print out right. So for example here uh the actual price movement uh is this return of just uh 5%.
uh then the MBB MBB MBT return is negative and because it's a momentum uh it's modeling momentum trading dynamics then it also says like okay it predicts it going down but we don't know if this is good or bad right and this is what we need to do now uh is to work out okay has it predicted it correctly or not and that's the next port of call so the the next thing to do is to to extract the signal and because we're working and this is the beauty of working with price movements is that um you naturally can just take the sign of your prediction and that tells you the signal which is okay do you go up or you go down. Um but you could like for example if you're predicting the future price and again there there's no right or wrong here it's just whatever uh your preferences or your your the signals but let's say you work with price you have to calculate the uh the delta. So, um this is my just preference is just work with price movements.
Okay. So, now we've got the signals. You can see here like the signals were betting it was going to go down. Uh and then we've got the the trade return. So, that's basically if we made this trade based on our signal, would we make money or not? So, essentially it's just the actual return which is algo return multiplied by the signal. Right? So, let's break it down a bit. Okay. So the act the algo return actually goes down.
Uh the previous return for mmt was uh down.
Okay predicting it was going down by 11%. Uh our yhat saying that it's going to go down by 2% right and that's the signal and then that's our our trade return. Uh so because it's we've made a bet that it's going to go down. It has gone down because we've multiplied the the yhat by the sorry algo return by the signal and you know when you you you multiply two negative numbers together you get a positive right so that that's why we we extract the signal right so this is telling us this is how much we made right if we but this is assuming that we close like on the dot on the tick like 30 days uh ahead right and again like let's maybe just do this one here so for example MMBT See uh it's it's a positive. It's quite Oh, that's a quite a a big price movement.
And you see that uh this the stronger the price movement here, the stronger the expectation the price is going to go up. So uh we can see here that our price movement here um is predicted it goes up because remember that the weight is positive. So uh it takes a a waiting of it and then as the the bias and it's a negative bias and this is our signal right because we just take the sign of our prediction and we multiply our signal against the actual return and that's the realized return that we would have right and this is just gross but this just tells us like another thing is when you're building the models is you don't want to factor in the fees because uh you know your fees could change all the time right they could fluctuate um you want to do it gross. Well, in the absence of fees because the fees change, you have to go and retrain your model and uh yeah, it's this is more on the execution side. The model's just like making good predictions where the price is going minus any execution details. Okay, so that's the the the signal and now we want to do is to calculate the expected trade return. And we need to also just I just wanted to show like a visual representation of it and just show you like uh because what's what's nice about linear models is it's just a very nice approximation to cut through the noise and it's very easy to interpret, right?
Uh because just imagine you run this you let's say you go and work at SIG and you've got a model and it starts to lose money by using a linear model it's extremely inter interpretable. So you know okay well this dynamic is decaying and you can see like why whereas using neural network it'd be quite hard to understand why the model is not maybe has decayed. So uh and this is and it's also really nice because I can say like okay um mmt the greater the expectation uh uh the greater the return here say for example 0.8 8 the greater the expectation that algo return uh goes up or here. So the greater the number here the greater the expectation algo goes up and you can see here that it does sort of model like it models this part very nicely right and [snorts] then here is uh then on the other side if the expectation uh is 0.2 too. It's a momentum that you know majority of the data points are on this side. So, man manages the uh the entails quite well here. Anyway, so this is um we can do more analysis on it, but I just want to show you like it's just a linear expectation. So uh yeah so that's the that's the mod the model of fit and uh so it's literally just put in a line through the noise and uh another thing we can do is to add transaction fees and because this is algo it has extremely low fees and just you know okay because it's important to know okay if you executed this would you still have an edge or not um so what we do is say what's our entry notional let's just say we we're always Remember we have to go like we the scoring is scale dependent.
So we want to go go big or go home type of mentality. We just always want to make sure that we have a maximize our notional size. So for ALGO I put my entry notional is always going to be 100,000 right? Um and then my exit notional is basically my entry notional multiplied by the trade return. And that tells me the uh the notional here. Then you got the ALGO transaction fees. So I calculated on that's based on the notional value of the um of the position on entry and then at exit. And this is what's called roundtrip fees, right?
Because you you have one trade to open a position and then you have one trade to close a position. And then if you you combine them together and that's your total roundtrip fee which is modeled here, right?
And then I've got the the P&L growth which is just your the entry notional multiplied by the the trade return. And what else do we have here? And then yeah, you've got the the net which is just the the P&L gross minus the total fees. And uh so yeah, that gives you the uh fee structures here when you add them in. But for algo uh because the fe the fees are are so normal you could even for example I'm predicting on a 30-day that you could even predict on like I don't know next tick ahead uh because the fees are so low but you got to be careful because the scoring is scale dependent the price may not move enough to be able to to to maximize your scoring and so again I think this you have to find what the sweet spot is because if you tra I recommend to do this is to build a Uh or you could even take the Yeah, that's be interesting. Yeah, that you could you could do some research to find okay uh let's say you get all your predictions correctly. You could just say like okay uh what would the scoring be if I predicted assuming that you make all the 100% guesses correctly and you you'll notice that there's a sweet spot. Um because as well the shorter your time horizon is the more noise the more harder it is to to predict. But um yeah, unfortunately because this the scoring it really encourages you to to make you to maxim like you need large returns essentially. But if you're going to make large returns like predict uh you got to be careful of uh because it it's based on your net asset value that you have to factor in your unrealized P&L. So, for example, you make a bet a 30-day forecast and uh majority of the time, let's say 30 days and say for 28 days, it's in a very strong negative uh value, right? But then suddenly on the last two days, it shoots up like um this affects your unrealized P&L.
Anyway, um but yeah, and this is a very important part. Uh this is probably one of the most important parts is because the this only 750 data points it's so easy to overfit. I've I've I've already I've given you some advice how to ensure you don't overfit which is to use first order approximations and also to do the in sample and out of sample just to make sure that you're you're not overfitting right but that's that's not enough to to ensure that it's a generalized statistic right so for example this momentum trading dynamics that I'm modeling now uh I I wouldn't be confident at the moment that it's generalized right but the problem is I don't have enough data like if there was loads of data then that would be a bit better, right? But um this is where the cross validation really comes in. So I really encourage you to to to use cross validation. And there's probably two ways you can do this. One is expanding window and uh or rolling window. And so essentially it's just like you're training uh on let's say maybe the first 50 ticks to predict the next future 50 ticks, right? So from 049 or let's just say what what to first tick to 50th tick is your training and you're going to predict it from ticks 50 to 100. Okay. And then you you slide the window by 50. So now your training window is now 50 to 100 and you're predict you're testing it or back testing it against 100 to 150. And you just keep repeating this, right? And and what's quite nice with the cross validation is when you get new data points when when you actually run this and submit this, right? Uh maybe I just go to here uh uh submit is when you when you submit it, you could do you could do the rolling window uh approach. So you could recalibrate your your models uh on the on the new data points. So for example, you run this and it's evaluated and it's got it's just run the uh increased the know the window size by 50. You could then retrain your model to do this and this would be a very good way to to ensure that okay ensure that your models don't overfit because you're factoring the most recent uh data. So that's just one uh tip for you there is you could use this rolling window or you could use expanding window and there's no right or wrong. is just maybe um finding which one's better for you. But I don't just recommend just to keep like a split. Ah there's another thing that you could do as well which is you want to check the um your the sensitivity of your uh your train test split ratio. So for example I've split it here to uh what have I split it to? I think it was like 70% for for training and 30%.
Okay. However, if I change this to, you know, you want to do what's called a sweep uh or sensitivity test, like for example, if I change that to that and I now rerun it and it completely breaks, then this tells me that uh you know, it's uh it's sensitive to the the change. And you know, it should be able to if you can do a sweep of this and say like, okay, I've done it. If it works on split from 60 to to 80 whatever and it's fine then this gives us a bit of more confidence as well. So this is another form of cross validation slash sensitivity analysis.
Okay. So that's just one thing that you should factor in. Okay. Where was I? Uh okay that's the model fit. Where do we go? Ah yeah. Okay. So that's the cross validation. All right. So that that tells us like okay is do we have a strong generalized statistic here? uh in our context of this model like okay do we have a strong uh mean um version momentum dynamics between MMBT and ALGO right okay but another thing we need to do is like for example if I've just got three trades and they're both like amazing right I could have like uh extremely good sharp from it right uh uh but it could just be a statistical fluke right you want some form of statistical validation uh and this is what we can do is like we want to uh have a hypothesis right and the hypothesis here is that our null hypothesis is that we don't have an edge and more specifically is that the expectation of a P&L equals zero that means you know we don't have an edge and we want to see if we can reject it and the way we're going to do this by calculating the confidence intervals so like okay we're going to calculate the 95% confidence intervals so before we can do that we need to calculate the standard error and the standard error is essentially your the standard deviation um uh divided by the square root of a number of data points.
So it penalizes if you only if you if you only got like a small amount of data points then it strongly penalizes you but however if you got quite a lot of data points then uh your your your error will be lower. Okay. Uh so that's the standard error. uh and now we want to calculate the the 95% confidence intervals and this will tell us like if we can reject the null hypothesis or not.
So this is why I really recommend once you've built a model and you want to know or you get your trades whatever then you you can calculate the 95% conf well it doesn't have to be 95 you could even do like 99 if you want to be even like more confident right uh but I wouldn't do anything less than 95 uh so the you need to calculate the margin error and essentially um this 1.96 is the said score for for the 95% confidence interval right and you just multiply by the standard error and this is the margin of error And once you got the margin error, then you just need to calculate the mu which we already know which is the central location for our trade return. [snorts] And now we can calculate the confidence intervals both the upper bound and the lower bound. So for the lower bound we just it's just the mu minus the margin of error. And then for uh confidence interval of upper it's just the mu plus the margin of error. Right? And we just print them out. Okay. And and you can see here that uh we have a posit this is very important is that uh [snorts] there's not s it's not bad in the range here in the domain of this that it's not there's no zero right so we can reject the null hypothesis because we can see that okay the confidence interval is greater than zero so we can reject it.
uh you'll see with lots of models that you you get like a uh you even if you plot them it looks very good right but um when you calculate the confidence intervals you can't reject the null hypothesis so uh I'd recommend to but again and I should also cover it it's not like gospel or like the truth like okay if it passes it it's still you know overfit right but it just gives you a bit more confidence statistical confidence that if you deploy this that it has an edge with 95% confidence, right? So, um yeah, that's just uh so don't just think okay uh it rejects the null hypothesis. It's guaranteed to to to work, right? Still need to make sure that you have a generalized statistic. But this um yeah okay so that's that's two ways and also if your presentation as well just like even if like for example I it be very curious because I think there's going to be loads of like chat GPT type of like coded solutions um I'd for your presentation I think it's very important that you show statistical validation of your results right so if you just go well I just created it in check GPT and that certainly you know it doesn't look good, right?
But if you showed like okay you've got like a strong statistical validation both in terms that it's generalized and the it's valid like no hypothesis you can also check the p values which is b essentially just the same as uh just a different angle for the 95% confidence intervals then that it shows you okay well there's a bit of rigor statistical rigor to this so that's uh one one thing I recommend for for the people that get into the presentations is to you know show that you there's good good research behind it.
Okay. And then we need to go into coding uh strategy and the we want to take advantage of of Python's polymorphism, right? Uh so yeah, I'm not sure if they they they tackled this, but uh I wouldn't say it's 100%, but it's just a very good practice to do is they have like a base strategy and this is base strategy. It's got this on tick and this is what gets called on every tick which is basically every row once there's a new row it calls this method and then you need to decide okay do you want to buy or do you want to sell or whatever and uh so the one of the first implementations should be like do nothing strat so like it just returns zero and uh maybe let's just explain what it should return so it's the signed trade size that you want right uh so for example or zero, you're not going to do anything. However, if this was like minus one, that means to buy one contract or one unit of the negative go short one contract. I'm not I'm not sure what the units are, but you know, one quantity of of that underlying asset, right? But then if this was like two, that means to have a position of uh to buy two. But there's just one caveat to this is uh is that for example if you go and buy I don't know 10 quantities of algo you need to consistently and you want to keep hold of that position you need to consistently keep sending 10 at each tick uh otherwise it will like for example you send 10 and then you send nine it will reduce your position by one. So you have to keep state of your current position and actually that maybe could be in the space anyway. Yeah, but that's just a very important detail, right? So for example, this do nothing, it does zero, right? And then for this model that we've got is what's called an AR1 type of model because uh technically it's not all AR1 anyway. Uh yeah, maybe I should call this a linear model. Yeah.
So you got this like linear model regression strategy, right? And uh so maybe I don't want to go too much into the the details. You can I've made this available. So essentially what it does is is it says okay what's our forecast horizon? So how many ticks ahead do we predict in the future? What's the weight and bias of our our linear regression?
And again the beauty is is that we don't have any like this is just there's just two parameters to this uh to the model.
It's just the weight and the bias. And um and then you've got your trade size or max size. It's like okay, what's the size of the of the position it should be.
And uh and then you've got this lag index which is the the index of the um the the the model input essentially and then the target so we can get the current price to calculate the quantities. Anyway, I think maybe it'd be better if I just go over the the logic. So it's always pass remember I said that you if you got position of 10 you've got like a position of 10 quantities going long. So you have to consistently keep returning 10 uh quantity like 10 consistently until you want to go and sell it. So for example if I want to go then flatten my position as in close all 10 quantities they'll need to pass zero right. Um so this is what I do. So like for example if it first starts or if it's already ticked. So for example this is like 30 days. If it's already gone up to 30 days then call this code. So the first thing I do is like okay well if it's uh 30 days I need to reset the counter. Uh then I get the the the the time series for the the lag which is our MMBT. Actually, it might be easier if I just show you the ah this is another important part is that you've got this portfolio strategy which is a list of strategies and this mod is a is what's going to be called for our our main function that we you pass to the the system right? Uh so it's it's an array of 51 uh you um integers and each one represents the the number of contracts or or units you want to buy and sell. So this is and what it does is it just loops over each asset. So and make sure it's inlined. So the first one is algo, right? So uh it just calls this and yeah maybe if I go over it in this more detail. Yeah.
Okay.
Uh so we got the uh what I do is I got this function. I maybe go to configure portfolio strategy. So I've just built one model but I don't have a model for for the rest of the strategies. Right.
Uh so what I've just done is for the rest of them I've just created this do nothing which just returns zero rate and then uh so I've got a strategy for this one. Uh [snorts] and then but what ideally you want to build potentially models for and there's actually there's many different ways to skin a cat here.
So for example, you could predict all 51 in one like so rather than just predict one individually, you could just predict it all together. Um and then you can also just do like portfolio optimization on this as well. So you've got signals and then your portfolio could take those signals and work out okay um you know adjust the position size or maybe like okay there may be some factors you want to to mitigate risk factors whatever but um yeah so I'm just going to say this is the only way but there's this is just a foundation just a very basic thing for you to work on and to build up and and this is where the importancy of the iteration comes in because you want to iterate on every every day You should you should be like uh just think like a sportsman, right? A sportsman trains every day and you know just think of like Ronaldo. I think I remember watching a video about Ronaldo. It's like some days he doesn't feel like going to training but he he has this mentality. It's like he has to go and you know it's this like elite type of mindset and you got to go in there and you got to uh iterate on your models like every day take advantage of it because it's like uh you it's a feedback loop to know if your model if if you is your is your strategy progressing in the right way or in the wrong way and you can use this to do experiments right so for example one thing could be you could do like an unconditional model which is like you don't condition it on anything like there's no like You basically calculate the expected return unconditionally and you just say like okay well based on the so for example you just make a bet that that the whole thing is going to go down and you can say okay well is there any value in that and then that gives you okay well uh I can't use the unconditional mean so um yeah the there's multiple things you can do I just basically you just want to take advantage that you have the these days to improve your models and uh Yeah.
So that's very important. Okay. So now we've gone over portfolio strategy. Now I configure this algo strategy. Right.
So I just take the the model coefficients. Um so I recommend because in the when you submit your competition you you're not allowed it's ide in a real world situation you would serialize your models to disk a version them and then um load your models from uh disk.
However, this competition has a a rule that you can't include any files. Uh it can only just be the Python file and that's it. Uh and also the requirements.ext which is the meta text for the dependencies. Uh so you can't serialize the model. So you have to encode the you'll need to create like a dictionary of all your model configurations. And uh so for example here I've got the the model weight and I've got the model bias and I've got let's say this is my feature sim which is MMBT. And what I do is I work out the index of it, right? So I' get the lag index of it and then I've got the target index because we need to know we need to know what the current price of ALGO is. So we can work out how much that the quantity should be. So maybe if I show you like for where I do this here. So I get like the target current price. So that's the current price and I work out what the trade quantity and uh I then round it just use an integer rounding to say okay my max size uh which I've set to 100,000k divided by the current price and then just take the rounding of it right um [snorts] so yeah and that's that really and oh the another important thing so once you've done this you need to implement this get my position and what I've done here is like I've got it to to call on tick so uh I just point out what does the the data structure look like for prices. So essentially what will happen is is like on the first tick you'll get some uh 500 data points for each time series. So for example this is just like two time series uh but you're going to get it 51 times. So uh and each element is a time series for the corresponding index. So the first index is algo. So you'll see this and then when in the next tick each time series will increase by one. So, I'm just making these numbers up. These aren't the real numbers, but okay. 3.2. And it that's the next tick. So, and what's really nice is uh take advantage that all the previous prices are encoded in passed into you. So, you don't need to to uh you don't need to to manage the state of like okay storing them uh the previous prices. It's already taken care of for you. So it's a very this competition is really nice because uh it gives you a real world scenario of like uh how to to write the code essentially but without all the nitty-gritty details like okay market impact and stuff like this. It just goes down to the core thing which is making predictions and making money essentially from from from your algorithms.
Uh so yeah so that's that's it. There was one thing I wanted to mention but I just can't I wanted to discuss. Yeah, I can't remember. All right, so that's that. Uh, I wish everyone good luck and uh uh yeah, I'll be very interested to hopefully whoever wins, maybe I can interview them and go over and obviously don't want to to to leak anything of their secret source, but maybe just go over the the mentality, what they did, what they tried, advice for future participants. So um yeah um I think the main thing is have fun and just is really great to build up these uh these skills and even if you're not a student in Australia or New Zealand like student in America or even just curious I think trying to to do this is great. Ah that's the thing I was going to mention is what's really great about this is it doesn't hold your hand. It just throws you in the deep end. You have to work out okay what know what what's my trade size? uh what's my forecast horizon?
Should I go one day, 2 day, 30 days? Do I trade 100% of the max capital allocated to the asset or do I just go 70%. And there's so many like variables you need to cover, right? And you've only got like I think it's only about 30 days. So you need to prioritize like okay, what's more important as well because it's not only just about uh it's also how about how you plan this and how you delegate out between you and your team, right? So do like if it's just a team of two of you, do one of you take uh 50% of the work the other one or does one do all the modeling and one does the coding? So yeah, this is um like really important steps. is like working you also have to work as a team. And so this is really great uh because if you have really let's say you're really smart guys and you maybe you've got loads of experience doing machine learning and uh writing [snorts] algorithms but if you can't communicate well then uh you're not going to do well. So it's just a really good real world uh competition to to mimic what it would be like to work on a quant trading desk because it's not only just about skills, it's about how you work together also under pressure under challenge, right? Because you got like a certain amount of days to to get this like uh to the top, right? So yeah, it's a really fun competition. Anyway, so that's the end of the video. I hope that was useful. Please um yeah, please like and subscribe and all that. And uh yeah, and I'll see you on the other side of this competition. Cheers. Bye.
Related Videos

Definition:Bounded variation and if f is monotonic on [a,b] then f is Bounded variation on [a,b]
wingsofmathematicsbytanush2507
4K views•2019-09-05

Prof Chris Holmes | Bayesian fitting and evaluation of complex models arising in...
uclfacultyofpopulationheal9290
564 views•2019-07-03

Patrick Landreman: A Crash Course in Applied Linear Algebra | PyData New York 2019
PyDataTV
9K views•2019-11-30

Approximating the Standard Deviation from Data of a Histogram
donnasmith8529
15K views•2019-09-26

HSC Maths Standard 2 | "At Least One" Probability Rule
ATARNotesHSC
697 views•2019-05-20

Spectral Sequences Live! 17: The Grothendieck spectral sequence
k-theory8604
395 views•2025-11-10

Structural Equation Modeling for Beginners
QuantFish
1K views•2025-09-30

Exploring Practical Applications of Linear and NonLinear Models In Business Research Dr.Jeelan Basha
MallikarjunaDKaggal
258 views•2025-05-26
Trending

we're almost finished the house (ep.125)
JennaPhipps
347K views•2026-07-22

We Finally Know Where Saturn’s Rings Came From
astrumspace
79K views•2026-07-22

BIG BET: Cathie Wood goes ALL IN on Elon Musk
FoxBusiness
89K views•2026-07-22

MIC DROP: Smithsonian Director Called Out For Woke Propaganda
TheAmalaEkpunobi
37K views•2026-07-23