GithubHelp home page GithubHelp logo

aspromatis's Introduction

Ingesting Your Own Zipline Data Bundle

This code will format stock pricing history in the format of daily bars including OHLCV (Open, High, Low, Close, Volume) data. The bars will be adjusted for stock splits. Dividend data will also be appended for a complete view of returns.

The files will be formatted as CSV files and will then utilize the Zipline csvdir.py process to read in the files as a new data bundle.

For this project, I source my data from Polygon.io. You can sign up for an API key at Polygon.io.

Alternatively, you can use your Alpaca Trading API key to get free access to Polygon data.

Requirements

For instruction on how to set up your own virtual environment, go to my other project folder on GitHub

For information on how to pull stock data from Polygon.io, go to my other project folder on GitHub

Here is a link to the Zipline documentation as well as to the Zipline GitHub page

Process

You will need to update your csvdir.py file, located at:

zip35/lib/python3.5/site-packages/zipline/data/bundles/csvdir.py

To run the ingest program, you will need to register your data in the extension.py file located in your home directory (typically your user name, press shift-cmd-. to reveal hidden files in finder on Mac):

.zipline/extension.py

The file prepare_bundle.py is the code that will format your OHLCV, split, and dividend data into the format needed by the zipline csvdir.py process

The file get_trading_days.py is the code that will grab the trading days of the New York Stock Exchange for the date range you are looking for

The Command to run the zipline data bundle ingest process (run this in your terminal for the proper environment)

$ zipline ingest -b custom-bundle

To view the new bundle:

$ zipline bundles

The Zipline program will save the data in the .zipline/data directory. You can use DB Browser to view some of the files.

The Asset Allocation example program was primarily writen by Andreas Clenow in the book Trading Evolved, with a few modification by me. I recommend his book if you want to learn more about algo-trading.

Note, I'm using VS Code with the ipykernel (Jupyter Notebook) capability to run in a notebook like experience. You can certainly also run this without this.

Additional instructions on my YouTube channel

aspromatis's People

Contributors

qujingpengf 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.