trading-bot
trading-bot copied to clipboard
How to predict current decision
Hey, so to predict the current timestamp what would I need to do?
adding in methods.py the following and calling it from a file similar to eval.py?
def predict_next(agent,data,window_size):
state = get_state(data, len(data)+1, window_size + 1)
# select an action
action = agent.act(state)
if action == 1:
print("BUY!")
elif action == 2:
print("SELL! (if you bought a stock")
else:
print("HOLD.")```
Hi,
I've added predict_next to methods.py and created a similar script to eval.py - but get the following error:
Traceback (most recent call last):
File ".\predict.py", line 65, in
Any suggestions?
Thanks in advance, great project! predict.zip
- apologies, I'm not well-versed in Python
Hey, I'll have to look that up in the next days, but yes I had the same error. I think as a quick fix you could add sth along the lines of
#ops.py
def get_state(data, t, n_days):
"""Returns an n-day state representation ending at time t
"""
#blocks = []
#for feature in datan.columns:
#feature = "Close"
#data = list(datan[feature])
if len(data) == 0:
raise Exception("DATA IS ZERO!!! CHECK YFINANCE OUTPUT")
d = t - n_days - 1
block = []
if d >= 0:
block = data[d: t + 1]
else:
block = data[0:d] # pad with t0
res = []
for i in range(n_days - 1):
x = sigmoid(block[i + 1] - block[i]) # x is number
res.append(x)
return np.array([res])
Very kind of you to respond, thanks so much.On 3/11/2020 22:20, Justin Güse [email protected] wrote: Hey, I'll have to look that up in the next days, but yes I had the same error. I think as a quick fix you could add sth along the lines of #ops.py def get_state(data, t, n_days): """Returns an n-day state representation ending at time t """ #blocks = [] #for feature in datan.columns: #feature = "Close" #data = list(datan[feature]) if len(data) == 0: raise Exception("DATA IS ZERO!!! CHECK YFINANCE OUTPUT") d = t - n_days - 1 block = [] if d >= 0: block = data[d: t + 1] else: block = data[0:d] # pad with t0 res = [] for i in range(n_days - 1): x = sigmoid(block[i + 1] - block[i]) # x is number res.append(x) return np.array([res])
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.