It's not a future prediction

#1
by HoussemTayech - opened

I have tried your AI more than 1000 times on different charts, at the beginning I liked the idea of the project, but unfortunately I find that the title "stockmarket-future-prediction" is misleading. The output is only the display of results already obtained and not predictions of the future direction of the stock.
Correct me if I'm wrong.

@HoussemTayech I had the same thought, however after rereading the description (several times), I decided to make a test to see the predictive capabilities. If you make a time series plot of a stock in a cv mat and then run the prediction each loop, it does in fact predict up/down future directions. Hope this helps.

FODUU org

@ruphobia Thanks for clearing up the information. I hope @HoussemTayech you got an answer. Everything is not mentioned here. It creates predictions, but if you do a time series plot, then it will be able to help you.

@ruphobia can you please send some image it can predict on? Wasn't able to get it to work

@stevejobbin "an image" won't help you. Give me some time to put something up on github; basically what you need to do is to draw your data on an opencv mat, then present your mat after you draw each pixel from the time series, then it will begin to predict. I guess the original idea is that you can have it "watching" your screen / video feed and alert you to an up coming up/down event. I'm using it a bit differently; I had theorized that it may be difficult to make this prediction from the raw data and that looking at an evolving plot would yield better results (because that's what we do when watching our stocks). Then I found this, works pretty good. At any rate, I will post here when I get something up on github for you to experiment with.

@stevejobbin Here's an example of how to use time series data and this model; https://github.com/Ruphobia/foduucom_stockmarket-future-prediction_example

Hope this helps....

@ruphobia thanks for the code, finally made it work using data from yahoofinance. For your code the dataset on GitHub is faulty but downloading directly from the original repo made it work

@wamaitha Thanks, will double check to make sure the data works; possible this has something to do with git lfs stuffs. Glad it's working for you, this really is a neat and practical model.

@ruphobia , thanks indeed your approach is correct.
I am still facing some difficulties to have the prediction immediately written on the good graph, example for one of my runs : on image graph_282 attached, the prediction appears after the price started to go up already, then if we enter long position it will be too late.
graph_282.jpg

Ideally the prediction should be written immediately from image graph_263 (or 264) ,
graph_263.jpg
where we already see the complete timerange represented in the prediction box on graph_282.

Any clue why we have this delay of ~20 sec using your example code ?

@dev50 I've been experimenting with this, a few observations:
1: It doesn't pickup all UP/DOWN conditions, so some might be missed.
2: It doesn't always pickup predictions in time, see #3, #4
3: You should be tracking the location of the bounding box to determine if the hit was towards the right side. Meaning that you are about to get an UP or Down event. This approach was not in my example code.
4: My example code was meant to prove out that this model does work, not meant to be a final solution. For example, I've had many more hits by changing my graph type to a candle stick. If you look at the images on the model card, and mimic this style of output, you will get more frequent and reliable hits.

Ultimately, this model is very good, however, don't expect it to be the end-all solution for prediction, I have run extensive tests using real-time, real world data. You will need more than just this model if you are planing to make a trading bot.

I just recently finished assembling a new "AI" server to add to my stock bot cluster, I won't be able to update the example code to use the candlestick output until I get this machine installed in the rack. And unfortunately, this is lower down on my todo list. If you are unable to wait for me to update the sample code (it may be some time), have a look at the style of graph on the model card (https://huggingface.co/foduucom/stockmarket-future-prediction) and make the necessary changes to the sample code to use this output style, you will get much better results. Also remember to look at the location of the bounding box and discard anything that is "too far" to the left.

I happen to have made this work using candlestick data and even got a good backtest winrate of 54% on a 2 year backtest on some stocks. https://github.com/wamaithaNyamu/MLSpikeDetector.

The updated code also implements a flask endpoint to query the model.
@dev50 Let me know if you have any questions.

@wamaitha That's outstanding, good work. Changing to candlestick vastly improves the performance. Are you tracking the location of the hit within the window? I've notice better win/loss results if you only take the right most hits.

Thanks @ruphobia ! Your work really inspired me on this one.
Yes I was tracking the location.
https://github.com/wamaithaNyamu/MLSpikeDetector/blob/d1e5c936c91ac5f012dc27af9b37ae2ab55c847d/make_predictions.py#L167
Here I was using the right most prediction. The one closest to the most recent price.

This comment has been hidden

@wamaitha Perfect!!!, also try backtesting with various "right side" values, it's interesting to see how this effects your win ratio. For more inspiration, here's a look at what my non-ai algo did last year in Q2-2023 live with real cash. After 87 days, ended up with a win ratio of about 58% and a daily average gain of 8.8%. The goal was to run for 90 market days and collect live data, however, as you may recall last summer, we had that marked strangeness due to the debt ceiling thing. As I was trading with real $$$, I decided that I had enough data and shut it down early to avoid loosing anymore cash.

I think your next step should be to calculate your actual gain in dollars and percent per day as this is way more relevant than daily win ratio. Ultimately, your goal is to make money, doesn't really matter what the win ratio is. Something that helped me out a lot in backtesting was to build a server farm to iterate through a bunch of algorithms, parameters and strategies quickly.

Good luck!!!!

2023_Q2.png

@ruphobia @wamaitha ,
indeed that is far better with candlesticks and close box filter.
thanks

Sign up or log in to comment