llSourcell / Reinforcement_Learning_for_Stock_Prediction

This is the code for "Reinforcement Learning for Stock Prediction" By Siraj Raval on Youtube
641 stars 363 forks source link

Resolved issue around inability to evaluate and overflow in sigmoid #7

Closed xtr33me closed 6 years ago

xtr33me commented 6 years ago

Was always getting a profit of 0 when evaluating model. This was primarily due to a "Buy" never occurring and therefore agent.inventory was always empty. So I set it so the first iteration a buy will occur and then the model will pick up from there. I'm thinking that in a future adjustment to this, we can infer the best time to buy in to the model based on the sliding window, or perhaps another means. For now, this at least allows for the evaluation to occur on other datasets.

Sigmoid was also overflowing when gamma (x) was higher than what math.exp could handle which on my system was around 700. The implementation used was one with which I found on SO.

MonaTanggg commented 6 years ago

I tried your commit but it only create a Buy in the beginning, then the program end. Have no idea why.

xtr33me commented 6 years ago

@MonaTanggg Yea it looks like 2 lines didn't make it in the merge last night. I have gone about including them as well. Sorry about that. It should work for you now.

star277hk commented 6 years ago

Work perfectly, thanks