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

Explanation of code #24

Open IsaacBentata opened 5 years ago

IsaacBentata commented 5 years ago

Hi, Thank you for this repo. I was wondering what's the meaning of:

`def getState(data, t, n): d = t - n + 1

print(data[d:t + 1], "data")

block = data[d:t + 1] if d >= 0 else -d * [data[0]] + data[0:t + 1] # pad with t0
res = []
for i in range(n - 1):
    res.append(sigmoid(block[i + 1] - block[i]))
return np.array([res])`

Does the state have to be transformed like this?

I am looking at turning this into a multivariable model (with inputs outside price), so getting clarification on this function would be great.

Thanks