r/algotrading 1d ago

Strategy XGBoost

[removed]

24 Upvotes

75 comments sorted by

55

u/roztok_potok 1d ago

No ml method will work if you don't have a profitable model as a base. Ml is addition only.

17

u/dukenasty1 1d ago

It’s so wild to see people and we can only assume are asking an ML model to just do all the work of creating a strategy and then be surprised it doesn’t work. But also, I swear half the people in the sub now just use Claude so it’s really more of a “build me a money printer, make no mistakes”

I’m getting too old for this sub I guess

3

u/roztok_potok 1d ago

That's no suprise. On YouTube, Reddit, Instagram you can see so called gurus showing the alleged gains. Everyone wants to print the money. In the simplest way and LLM/ML is considered the magic box that can do it. Reality is way more complex.

2

u/dukenasty1 1d ago

That’s my experience also. Hard to beat market experience and then move to coding what you’ve found to work. Ignore all that noise and and grift

2

u/roztok_potok 1d ago

Finding edge itself seems almost impossible. Years of practice and hard work.

0

u/sky018 22h ago

What? You just fast track the coding part, even if you code by hand, with either TEMA, MA, RSI, etc, whatever it is known there, statistics will still play a vital role.

I think you're hating at the tool, and not the people who are using the tool. So yes, even I will tell you, use claude to code and get what you want as soon as you can, fast output, doesn't mean it is bad lol.

1

u/Grand-Fly-6090 1d ago

I should just stop. I keep trying because it looks like it has all the pieces needed to make this work. It just cannot form any decent prediction.

Maybe that’s an overstatement. It does do a really good job of predicting if a price will stay in a boundary. Maybe that’s where I should focus next.

6

u/roztok_potok 1d ago

You can predict volatility but not a direction. Try this way. HAR models give good results.

2

u/jamesscheibel 1d ago

you can predict both but volatility is way way easier.

2

u/roztok_potok 1d ago

I have never seen a model that predicts price direction and is better than a coin toss

1

u/jamesscheibel 1d ago

it wasn't easy and it isn't a strong signal. And sometimes you cannot act on it fast enough as the price moves (especially if you are doing over night calculations). even when stars align its hard to tell what is real and what is luck when the edge is small. a hold out test may well say "yes you have it" but it can be painful sitting through weeks of live investment wondering if there is a bug or this is just a downswing or ???

so yeah. not easy to do. volatility though much more reasonable.

1

u/roztok_potok 1d ago

I would not use such signal especially if it does not beat buy and hold. Is it profitable after cost and spread?

1

u/jamesscheibel 1d ago

not yet. but i dont have a long enough trade history with it even if it was profitable to have confidence. so ask again in a year or 2. what is nice though, once you have a hand hold (a slight edge) it gives you something to work with to try and improve.

2

u/roztok_potok 1d ago

That's a straight road to overfitting. You can customize strategy as far as it starts fitting to your data and baam suddenly you have money printer that dies in real conditions.

In a year or 2 that signal might die if for example market regime changes.

However good luck buddy. All the best

3

u/jamesscheibel 1d ago

preaching to the choir.

1

u/Agreeable_Forever978 1d ago

How do you model volatility ? With indications as features? Please shade some light on that

Then i am working on a personal project it’s about classifying trades from a given strategy classifying whether a trade will hit tp-n an i optimise the precision to have positive EV on test ond hold out set
This was going fine until the model accuracy goesto 50-53 % in may to July data ,, this introduced insane drawdowns up-to 39 % and i cant yet find a way around this

1

u/jamesscheibel 15h ago

create a target/classifier that represents the volatility you are after. (like you would for anything you data mine) ex: what is the expected total price movement over the next 3 days. create features that you think can give you that . throw it through a dataminig tool of your choice and your hold out results will probably pretty good if your features were well chosen

0

u/AphexPin 1d ago

skill issue

1

u/Grand-Fly-6090 1d ago

Thank you!

1

u/InfinityTortellino 1d ago

When you say profitable model as a base do you mean strategy? Model implies a predictive model trained by ML from my understanding?

1

u/roztok_potok 1d ago

Yeah, profitable, hard tested strategy. ML can act as a filter to improve your returns but trading signals needs to be generated by your trading model. You can feed ML with the signals and check how it performs. If you put garbage or noise in you will get garbage or noise out.

3

u/InfinityTortellino 1d ago

Just for the sake of argument though, if the assumption that incoming feature data can inform a profitable strategy’s decision to buy or sell is on the table; shouldn’t in theory a ML algorithm be able to convert those features into a tradable signal given proper data preparation? I’m genuinely curious, I have been trying to unsuccessfully use ML to build signal for fun in my spare time

1

u/roztok_potok 1d ago

That's the case here. You train your model on profitable strategy to produce trade signals. However there is, not saying infinite, but large number of variables that influence asset price it's impossible to catch them all. For example you can't record human psychology as numbers, sure you can have some synthetic measurement like greed index but they are derivates of price fluctuations and price itself as predictor of future price is a weak predictor. Just noise. We as retail traders lack computing power to run complex algos or/and have no access to data that is meaningful for those algos.

I haven't seen so far profitable algo strategy driven by ML. Not saying they don't exist. More like people who wrote them stay quiet.

Correct me if I am wrong.

1

u/InfinityTortellino 1d ago

I guess I am trying to understand what this profitable strategy would be built upon if not some sort of feature data that could also be fed into a ML model. Are you saying that to reduce the number of possibilities that are fed into a ML model and reduce noise you need to start by manually building strategies instead of feeding in many features and hoping the computer figures it out? Does proper use of feature engineering and proper splitting of training testing and hold out data converge those two approaches or is it a lost cause?

1

u/roztok_potok 1d ago

Like I said if you hope that ML will make you profitable because you throw on it some data you are delusional. MLs are transformers, math, matrixes. Computations are deterministic. Garbage in garbage out. Also if you increase number of features you increase degrees of freedom. This is a straight path to overfit because you can find such combinations that fit your test data perfectly but in real trading it will fail. That's why it is very hard.

An analogy. Place a random person from the society in the plane cockpit and tell to take off. You expect that person will fail unless it's a pilot but chances are really low. Same with ML, but you expect that it will magically transform your data into profitable strategy. No way. The best you can get are models trained on finance data like chronos-2 or timesFM but these are not designed to produce trading signals. You need to get your hands dirty to find profitable strategy. There is no free lunch.

1

u/educhana 1d ago

Random Forest is better than XGBoost for this kind of problems.

AFML book IS your friend

1

u/roztok_potok 1d ago

But no book can make you profitable in algo world. You can learn the techniques but these are just tools. There is wide world of finance or math knowledge that you must know in order to write successfull algos. That's very hard.

0

u/metalayer 1d ago

This absolutely is not true. If it was, quant shops wouldn't be pouring billions into buying GPU clusters. They are not doing that just to make underwriters for already profitable trades. The simple fact is that most retail systematic traders are not math PhDs and are using shitty features with low/no predictive power, but that doesn't mean it can't be done.

1

u/roztok_potok 1d ago

Go and check the latest scientific papers on price prediction or math in that matter. None of them proves price prediction is possible.

Perhaps there is some complex math that quants or PhD can produce and can be run on multi billion hardware. And they keep it as secret. I am not saying it is not possible. However let's be real. As you said retails can't compete with HFT firms.

0

u/addsubps 1d ago

If none of them prove price prediction is possible in any way, they're probably not a good source for determining what is possible.

18

u/Bowaka 1d ago

Tree based models are particularly sensitive to distribution drift.

1

u/Luctom 1d ago

may I ask why?

2

u/addsubps 1d ago

Because they optimize thresholds, not weights.

1

u/Luctom 23h ago

Thank you

1

u/Bowaka 23h ago

It's more that they average the existing within the training space but are not able to extrapolate outside of it, unlike a linear regression for example.
Trees don't learn a relationship within the data, it just learn its statistical behavior locally. The problem behind that on space problems, its easy to go in unexplored zones.

6

u/veskald 1d ago

One thing missing from this thread: how are you scoring the model? If its accuracy or AUC, thats not the same question as "does this make money". A model can be right about direction more often than not and still lose after spread and commission, because the moves you catch on 10 minute windows are small and the costs are fixed. Score the model by net PnL per trade after real costs from the start, not by prediction quality - a lot of "promising but not profitable" models die instantly under that metric, and you stop wasting months on them.

The other thing is you are now searching: 5, 10, 15 minute windows, different symbols, XGBoost then LGBM then HAR. Every combination you try raises the chance that the best one looks good by luck alone. Keep a log of everything you tested including what died, and when something finally works, look at that number first - one winner out of fifty attempts is a very different claim than one out of three.

0

u/Grand-Fly-6090 1d ago

On scoring, I’m using net pnl in agreement with your suggestion. My cost model is a simple 1 bp supported by trades executed by my bot.

2

u/veskald 1d ago

Good, thats the right metric. One thing to check on SOXL specifically: is that 1 bp covering spread and slippage or just commission? On a 3x ETF the spread alone can be wider than that at some times of day, and with 10 minute windows the move you are capturing is small enough that the difference decides whether the edge exists. Would be worth pulling actual fill prices from your bot trades against the signal price and seeing what the real number is like a execution log.

1

u/Grand-Fly-6090 1d ago edited 1d ago

I’ll focus my cost estimate on soxl to confirm. Thank you!

6

u/Manfred_der_Gorilla 1d ago

I tried Xgboost and random forests for 15 minute intervals, but it is really just noisy. You might get some decent in sample predictive power but out of sample my models always collapse

1

u/Grand-Fly-6090 1d ago

I've tried 5 and 15 minute windows, and they were worse than 10 minute windows. Could have been the SOXL symbol and when I was looking.

8

u/Chemical_Badger6227 1d ago

10min windows are very noisy. Try using 1hr windows. I’ve back tested over 100 strategies and found it zero edge using XGBoost. In fact the best edge came from the simplest of signals. In my case, it was volume ratio and the mvrv ratio.

3

u/Grand-Fly-6090 1d ago

Do you mean 1 hour windows of 1 minute bars, or are you suggesting to use 1 hour ohlc bars?

2

u/Chemical_Badger6227 1d ago

1hr ohlc bars

3

u/Suspicious_Meet_1220 1d ago

I have tried, it works on papers. What mean is the model is guessing with 70% accuracy. Missing at detecting pullbacks during major ones and reversal is not very smooth it goes from 100- 60/50 in a stepa manner so i am not able to design a strategy arround it.

2

u/IllustriousGrade7691 1d ago

Need larger window 10 minutes are random noise and it is not the modell its always the data modell differnce is negligible between LGBM XGBoost. Everyone is using lgbm since it trains faster. Also i would advise you to not manually code you modells but use Codex. Think is you will not create a good modell per hand heck even AI cannot there is just not that much inforamtino. People make moy arb tading between platforms or some shit.

Big quant firms maybe will manyge 30% return per year but you would not. Give codex or claude a try

1

u/Grand-Fly-6090 1d ago

Agreed. I am using codex for my XGBoost work. I'll take a look at LGBM and HAR mentioned below. Thank you.

2

u/IllustriousGrade7691 1d ago

What are you trying to predict Stocks or Crypto, might want to check https://numer.ai/ its an interesting albeit old project idk how relevant it is the ai agent can explain they do target returns prediction 20 or 60 days in the future use things like multiple targets groups and feature neutralisation. Check their notebooks or let codex check them and see if it helps the modell

1

u/Grand-Fly-6090 1d ago

I’m trading stocks and etf’s. Intra day.

2

u/Automatic-Essay2175 1d ago

Like you said, I’ve used it to filter existing signal

2

u/jamesscheibel 1d ago edited 1d ago

the short answer is yes. but i use homegrown GBM. it is comparable to XGBoost though. there are a lot of asterisks next to that yes. the data miner tool/method you use is just 1 tiny piece. like trying to build a hot rod from scratch and deciding on what kind of engine you are going to use but having decided very little else. i do use 10 minute bars fwiw

1

u/Grand-Fly-6090 1d ago

Thank you! This is very helpful.

1

u/Grand-Fly-6090 1d ago

The 10 minute bars are working out a little better. I guess they filter out some of the noise.

2

u/Linett-Chukwuemeka61 1d ago

XGBoost is solid for time series forecasting if you're doing feature engineering properly - just watch out for overfitting on noisy market data since it'll happily memorize noise patterns. What kind of prediction targets are you working with?

1

u/Grand-Fly-6090 1d ago

I’m trying to determine if my sell limit (target) will be hit before my sell stop. The target is 1.5R, so a P(target) > 0.5 should be worthwhile. The 1 minute bar data was way too noisy to do anything useful.

2

u/drguid 1d ago

It's fantastic on the daily chart. But you need to do a certain amount of pre-screening. Start with a good indicator and XGBoost will turn it into an incredible indicator.

Also training it takes LOT of work. No kidding. But now I have profit factors of 1.5 to infinity lol.

2

u/ZealousidealName5703 15h ago edited 15h ago

Depending on your boundary conditions, yes xgboost can be extremely effective. I got 0.88/1 AUC at highest but really low number of live trades like 50 per day. My current AUC is at 0.8541.

1

u/Grand-Fly-6090 14h ago

That’s pretty awesome! What flavor of bars are you using. I died on 1 minute bars. 10 minute bars are better.

2

u/mr-claesson 1d ago edited 1d ago

You need to engineer features that you believe have an edge, like if you believe in fair value gap, macd divergence etc. Pure OHLCV does not work.

Next challenge is to make the training data somewhat balanced to avoid lazy guessing. It is really easy to achieve high accuracy on a highly unbalanced/biased training set.

And after that you have years ahead of you to fall in other traps until your realize the foundation, then you can start hunting optimizations using different model architectures

To lower the risk of overfiting make sure results are stable over rolling folds splitts, not just an ordinary train/validate/test split

1

u/jamesscheibel 1d ago

yeah, getting the right features is crucial but then the whole things is a house of cards. you need it all to make it work.

1

u/stratcore 1d ago

One check before changing models: overlapping 10-minute windows can leak almost the same bars into train and test, even with a time-ordered split at row level. Purge at least the full feature and label horizon around each fold, fit every transform inside the fold, and keep one final period untouched. Also compare against a regularized logistic baseline. If XGBoost cannot beat that after actual costs and turnover, the extra complexity is not buying signal.

1

u/Outrageous_Band9708 1d ago

that will never happen

everything below 1H candles is pure noise

anyone with a strat there is just riding market beta without realizing it.

1

u/DeezY-1 13h ago

XGBoost isn’t a trading strategy nor is it a supplement it can be a feature. I encourage you to look into the mathematics behind these models. They have nothing to do with market dynamics

2

u/mkvalor 9h ago

What is missing are derived features from the base data. Not sufficient to just point it at OHLCV and call it a day. And each ticket/contract needs its own feature engineering and modeling.

For one thing, price is not predictive. So you have to think about how to transform price into something more stationary. And I don't mean just copy a pytorch line about standardizing price or normalizing it.

Here is a hint: consider how to aggregate all sorts of behaviors such as buckets representing counys of orders over the past 10ms, 100 ms, 500 ms... This becomes a new set of features that can inform the boosted tree model. If your data doesn't come in with sub-second precision, grab at least milliseconds from your own computer clock and add them on.

First you must consider what the market is doing, then observe it, then you can eventually get to the place of modeling it.

2

u/Livid_Parsnip_2816 5h ago

I’d stop asking XGBoost to predict every one-minute bar and use it as a meta-filter. Generate trades with a simpler base rule, then train the model on take/skip or position size. Ten raw bars carry very little context; add volatility state, spread, time of day and distance from the higher-timeframe trend, then use purged walk-forward validation with an embargo. Normalized features help, but leakage and target choice are usually the bigger problem.