Stock market prediction using Keras
Agatha is a tool to help you predict future prices (open, close) or daily volume for any given stock ticker.
|
Probably not.
Agatha uses an LSTM network to predict close prices for a user-specified number of days in the future. The training data is downloaded via Alpha Vantage.
There are two ways to install agatha.
The easiest way to install agatha is via pip:
pip install agatha
Note: keep in mind that this requires python 3.5 or higher. Another Note: If you want the latest version build from sources.
Clone this repository. Inside the Agatha folder, create the agatha package using
python setup.py sdist
Then install using pip.
pip install dist/*
If you use anaconda, you can load the conda environment using the environment.yml file in resources/conda
and running conda env create -f environment.yml
First, import agatha's functions
from agatha import getOrTrainModel, predictFuture
Then get an API key from Alpha Vantage. To train a model for a particular ticker, use
model = getOrTrainModel(alpha_vantage_api_key, ticker, attribute, alphavantage_data,
model_data, weights_data, epochs=epochs, look_back=look_back)
where
Predictions for future close prices for a stock can have output type as json
or plot
(pyplot, as shown in graphs above)
prediction_output = predictFuture(model, num_days_to_predict, ouptut_type)
Example:
model = getOrTrainModel('adsfadsfasdf', 'GE', 'GE.pkl', 'open', 'model.json', 'weights.h5')
prediction_output = predictFuture(model, 2, 'json')
Example output JSON from predictFuture
:
{
"ticker":"GE",
"column":"open",
"predictions":[
{
"day":"1",
"price":"8.009521"
},
{
"day":"2",
"price":"8.117293"
}
}
Refer to app.py, for a working example.