It's not a future prediction
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.
@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.
@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 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.
Ideally the prediction should be written immediately from image graph_263 (or 264) ,
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.
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.
@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!!!!
This seems to not actually be recognizing the patterns as predictive of future movement, but rather simply identifying patterns that precede upward/downward movement BECAUSE they appear adjacent to upward/downward movement. That is, if you give it an image of a chart, it will spot patterns that come before up/down movements that are shown on the chart. But if you then trim the image to remove the part where it actually moved in the "predicted" direction to see if it can still recognize the pattern as predictive of a direction, the box disappears. It is apparently relying on pixels adjacent to the boxes it identifies in its determination. For this to have predictive power, it will need to be able to identify patterns indicative of an upward or downward move without any subsequent candles visible. Therefore, demonstrating that it is relying on the candle pattern itself, not simply looking at something that already moved in a given direction, and being able to simply state the obvious.
Now with the right side trimmed to cut out the upward movement supposedly "predicted" by the second "up" label:
As you can see, once the right side is removed, it can no longer identify the pattern as predictive of an up-coming upward move. I conclude that it is actually seeing the upward move and using that visual information to label the previous candles as "up".
Hi
@Punchey
,
it does predict when well configured and with the good image format.
However I tested it in various (live) contexts and it has some bias.. and it doesn't beat my manual trading results for now.
Any idea how can I get an array of strings with up/down .. e.g if in the image there are boxes 0.44 UP, 0.2 UP, 0.3 Down etc.. I expect an array [up, up, down].
Thanks
@Yoshevski This line of code https://github.com/wamaithaNyamu/MLSpikeDetector/blob/d1e5c936c91ac5f012dc27af9b37ae2ab55c847d/make_predictions.py#L167 has the array of class predictions