Giter VIP home page Giter VIP logo

agatha's Introduction

Agatha

license PyPI version

Agatha is a tool to help you predict future prices (open, close) or daily volume for any given stock ticker.

full|full

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?

agatha's People

Contributors

driemworks avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.