Skip to content
- 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’)
- 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
- 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)
Like this:
Like Loading...
Related