Giter Club home page Giter Club logo

stockpy's Introduction

StockPy

The StockPy project is an exploration into the use of machine learning to create an automated stock robot. It is incomplete, and steps are being added over time. Currently a porfolio (in Schwab CSV export format) is read, and then both realtime and historical data is used to analyse and plot the data.

The algorithms used are adapted from the Udacity course 'Machine Learning for Trading'.

Software Overview

There are two main modules:

  1. currentquotes - reads the csv-formated portfolio of stocks and loops querying google finance to get current stock values. It then calls the stats.py module in two entry points:
  • dostats - which performs intra-day statisitics and plots

  • analyze_portfolio - which performs historical stock data analysis and plots

  1. dostats - uses pandas to do intra-day and historical statistics and plots

Intra-day Statistics

The main entry point of current_quotes reads the stock profolio and then loops writing data to a CSV file of the stock data every 60 seconds. It then calls dostats on each stock in the portfolio and analyze_portfolio on the list of stocks.

The function dostats uses pandas to read the CSV stock data file for a stock and an index to use as a comparison. The index currently used is SPY the Standard and Poors 500 index. It then performs the following analysis and produces a plot of the data:

  1. Daily Bollinger Bands™

  2. Daily Returns

  3. Histogram of daily returns vs the index

  4. Year-to-date historical comparison of returns against the index

  5. Scatter plot of daily returns against the index

Historical Statistics

The function analyze_portfolio analyzes the entire portfolio performance against the index. It calculates the normalized value of the portfolio, then calculates a rolling mean of the profolio against the index.

Further Work

Next I hope to add deep learning algorithms to further explore the possibilities of the use of AI in stock data analysis.

Sample plots
Bollinger Bands
Bollinger Bands
Daily Returns
Daily Returns
Histogram
Histogram
YTD
YTD Returns
Scatter Plot
Scatter Plot
Returns History
Returns History

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.