Open yeshengyi opened 6 years ago
I'm getting same issue, going to look into the blog that he posted to see if I can find a way to fix it. If anyone else finds a way to fix it please let me know.
I believe this is my mistake, in the agent/agent.py the random.random() is supposed to be np.random.rand()
i will check and update
Getting the same thing....first wanted to check here to see if anyone had posted an issue already. Going to take a look myself to see what may be causing it.
I found the problem to be that the original logic this was based on expected randomness to occur from the start and then the model will pick up once epsilon met a certain criteria, however in evaluate we never run expReplay, nor do I believe we have to, however because of this a "Buy" never occurs. So for now the simple solution to get the model running in eval was to issue a buy during the first iteration through, then the model runs fine the rest of the way. Perhaps a change to this in a future implementation will be to find the approximate best time to enter/buy the stock and then from there let the model run.
This was my analysis for the night. Hope it helps some of you get going again. You can find the changes at the below pull request or my fork. It's a bit late here so headin to bed.
https://github.com/llSourcell/Reinforcement_Learning_for_Stock_Prediction/pull/7
the fix works well, thanks!
I tried that fix, for my try, it only buy at the first time, then the program end. @yeshengyi You used his latest commit and your model work fine ?
Sorry, I was too quick to say that.. The profit is no longer 0, but it was all Sell after the first buy...
Hmmm...wondering if something happened during the merge...one sec let me try on mine.
Alright....so it was the case. I made a backup last night before performing the merge and missed 2 lines at the bottom of evaluate.py. Can one of you please try the below additional call and let me know if it works for you. I will add to pull request after verification. Sorry about that.
It really works this time... Thanks!
Thanks @yeshengyi for testing. Will add to PR.
working good here too, thanks @xtr33me :smile:
@xtr33me I noticed this too, so I play around the code. I may be wrong, just my 2 cents. I feel this is due to the design of the model. During the training, the sit, buy, sell activity is randomly generated, so there is no problem. However, the reward only tie to sell, so there is no reward to buy or sell, because there is no linkage between other actions and sell. Therefore, the prediction is always sell. Even with buying in the first iteration, it will just sell the 2nd day. Then it kept predicting sell, while there is no inventory at all.
The training works fine, but evaluate always gives profit=0, where is the model.fit?
Seems like the model is only compiled, but not fitted...