huseinzol05 / Stock-Prediction-Models

Gathers machine learning and deep learning models for Stock forecasting including trading bots and simulations
Apache License 2.0
7.69k stars 2.74k forks source link

About trained Agent. #2

Closed munkh-erdene closed 5 years ago

munkh-erdene commented 5 years ago

First of all thank you for sharing your code. Its interesting. I have a question how do i save a Trained agent and reuse it?

huseinzol05 commented 5 years ago

Which agent? I am really not suggest you to predict on different stock market, results may be not really good, unless you trained the agent on different stock market, so at least it will learn some stock market samples.

Just use pickle, let say I want to reuse this agent, evolution-strategy-agent.ipynb,

I assumed you already run this,

model = Model(window_size, 500, 3)
agent = Agent(model,10000,5,5)
agent.fit(500, 10)

Now you want to save,

import pickle
with open('my-agent.pkl', 'wb') as fopen:
   pickle.dump(agent, fopen)

Now you want to load,

import pickle
with open('my-agent.pkl', 'rb') as fopen:
   agent = pickle.load(fopen)

agent.buy()

You need to tweak some code inside agent.buy to accept dynamic timeseries data. Should not very hard to do it.

munkh-erdene commented 5 years ago

Thank you. I'm trying to train "evolution-strategy-bayesian-agent" model to predict Crude oil's price will go UP or DOWN.

I just need to predict one step ahead Crude oil' price will go UP or DOWN.

huseinzol05 commented 5 years ago

this agent cannot predicts a trend, it predicts decision to buy or sell based on a trend. you should forecast using ARIMA or deep learning models i provided in this repository.

munkh-erdene commented 5 years ago

Yeah i know. This Agent's decision is equal to prediction right? BUY decision = UP, SELL decision = DOWN.

AlconDivino commented 5 years ago

is there a possibility to continously feed data to the agent and get the decicion? or would one need to retrain with new data in the csv?