Agatha
Stock market prediction using Keras
Install / Use
npx skills add driemworks/agathaInstalls into whichever agent you are using.
README
Agatha
Agatha is a tool to help you predict future prices (open, close) or daily volume for any given stock ticker.
<p align="center"> <img src="https://github.com/driemworks/agatha/blob/master/resources/images/full.PNG?raw=true" alt="full" width="400" height="400">|<img src="https://github.com/driemworks/agatha/blob/master/resources/images/prediction.PNG?raw=true" alt="full" width="400" height="400"> </p>Should I have faith in the predictions?
Probably not.
How it works
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.
Requirements
- python 3.5 or higher
Installation
There are two ways to install agatha.
Install using pip
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.
Build form 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
Usage
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
- ticker is the stock ticker
- attribute is the stock attribute to predict (open, close, volume),
- alphavantage data is downloaded as a csv and then pickled (saved as .pkl)
- the model_data is saved as json
- the weights file is saved as .h5
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.
Future Enhancements
- Allow other sources of historical data (including cryptocurrencies)
- Any suggestions?
Related Skills
mcp
Use the `mcp_perplexity-ask_perplexity_search` tools to answer questions. You should use this instead of the `web_search` tool because it is a lot more accurate.
practical-power-systems-synthesis
This skill enables synthesis in the domain of power-systems (engineering). It represents research-level-level expertise and is designed for production use in research, industry, and educational contexts. Use this skill when you need to perform synthesis operations related to power-systems.
semi-supervised-optogenetics-testing
This skill enables testing in the domain of optogenetics (neuroscience). It represents intermediate-level expertise and is designed for production use in research, industry, and educational contexts. Use this skill when you need to perform testing operations related to optogenetics.
data-mining-interpretation-fundamental
This skill enables interpretation in the domain of data-mining (data-science). It represents fundamental-level expertise and is designed for production use in research, industry, and educational contexts. Use this skill when you need to perform interpretation operations related to data-mining.
