Creating A Zipline Data Bundle

  1. Get daily OHLCV stock data using Python
    • via YahooFinance, Polygon.io, etc and save as a CSV file
    • Import necessary python modules
    • Set start & end dates manually
    • Run pdr.DataReader
      • spy = pdr.DataReader(‘SPY’, ‘yahoo’, start_date, end_date)
    • Save data to CSV
      • spy.to_csv(‘/Users/bars_adj/spy.csv’)
  2. Index dates to Zipline Trading calendar
    • Create trading_days tag in python
      • Start & end dates should use the same dates as step 1
    • Delete any trading days that are (new) holidays, i.e. Dec 5th, 2018
    • Create trading_calendar.csv
  3. Format original data into a Zipline ready CSV file
    • Reformat into dataframe & match days to trading day calendar
    • Adjust price values via ratio calculation & set dividend values to 0 if not available
    • Relabel columns with correct names needed to ingest bundle & round values to two decimal places
    • Save as new csv files (each ticker will be an individual file)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with WordPress.com
Get started
%d bloggers like this: