I want to use zipline offline without jupyter notebooks. I have tried to get zipline to ingest from quandl and use the data successfully but I haven't succeeded. Here is my environment -
python 3.5, using pycharm, pip3 freeze gives me -
alembic==1.0.5
alphalens==0.3.4
backcall==0.1.0
bcolz==0.12.1
Bottleneck==1.2.1
certifi==2018.11.29
chardet==3.0.4
Click==7.0
colorama==0.4.1
contextlib2==0.5.5
cycler==0.10.0
cyordereddict==1.0.0
Cython==0.29.2
decorator==4.3.0
empyrical==0.5.0
idna==2.8
intervaltree==3.0.2
ipython==7.2.0
ipython-genutils==0.2.0
jedi==0.13.2
kiwisolver==1.0.1
Logbook==1.4.1
lru-dict==1.1.6
lxml==4.3.0
Mako==1.0.7
MarkupSafe==1.1.0
matplotlib==3.0.2
multipledispatch==0.6.0
networkx==1.11
numexpr==2.6.9
numpy==1.14.3
pandas==0.22.0
pandas-datareader==0.7.0
parso==0.3.1
patsy==0.5.1
pickleshare==0.7.5
prompt-toolkit==2.0.7
pyfolio==0.9.0
Pygments==2.3.1
pyparsing==2.3.0
python-dateutil==2.7.5
python-editor==1.0.3
pytz==2018.7
requests==2.21.0
requests-file==1.4.3
scikit-learn==0.20.2
scipy==1.2.0
seaborn==0.9.0
six==1.12.0
sortedcontainers==2.1.0
SQLAlchemy==1.2.15
statsmodels==0.9.0
tables==3.4.4
toolz==0.9.0
trading-calendars==1.6.1
traitlets==4.3.2
urllib3==1.24.1
wcwidth==0.1.7
win-unicode-console==0.5
wrapt==1.10.11
zipline==1.3.0
My test code is as follows:
from zipline.api import order, record, symbol
import os
def initialize(context):
pass
def handle_data(context, data):
order(symbol('AAPL'), 10)
record(AAPL=data.current(symbol('AAPL'), 'price'))
def run_algo():
data_ingest = False
bundle = 'quantopian-quandl'
if data_ingest:
auth_tok = "################"
data_ingest_command = 'set QUANDL_API_KEY=%s && zipline ingest -b %s' % (auth_tok,bundle)
os.system(data_ingest_command)
path = 'C:\\Users\\mattt\\PycharmProjects\\FFTTrading\\trades2.py'
print('zipline run -f %s --bundle %s --start 2016-3-1 --end 2017-12-30' % (path,bundle))
run_command = 'zipline run -f %s --bundle %s --start 2013-3-1 --end 2017-12-28 -o backtest.pickle' % (path,bundle)
os.system(run_command)
run_algo()
I have already run the ingesting data portion and it succeeded. My last time ingesting data was 10:49 PM on 1/5/2019 (My time). I am running the code above at 12:55 PM on 1/7/2019 (My time) however I get this output-
zipline run -f C:\Users\mattt\PycharmProjects\FFTTrading\trades2.py --bundle quantopian-quandl --start 2016-3-1 --end 2017-12-30
[2019-01-07 17:55:33.814552] INFO: Loader: Cache at C:\Users\mattt/.zipline\data\SPY_benchmark.csv does not have data from 2013-03-01 00:00:00+00:00 to 2017-12-28 00:00:00+00:00.
[2019-01-07 17:55:33.814552] INFO: Loader: Downloading benchmark data for 'SPY' from 2013-02-28 00:00:00+00:00 to 2017-12-28 00:00:00+00:00
[2019-01-07 17:55:35.311201] WARNING: Loader: Still don't have expected benchmark data for 'SPY' from 2013-02-28 00:00:00+00:00 to 2017-12-28 00:00:00+00:00 after redownload!
zipline run -f C:\Users\mattt\PycharmProjects\FFTTrading\trades2.py --bundle quantopian-quandl --start 2016-3-1 --end 2017-12-30
[2019-01-07 17:55:40.745023] WARNING: Loader: Refusing to download new benchmark data because a download succeeded at 2019-01-07 17:55:35.311202+00:00.
zipline run -f C:\Users\mattt\PycharmProjects\FFTTrading\trades2.py --bundle quantopian-quandl --start 2016-3-1 --end 2017-12-30
[2019-01-07 17:55:46.134072] WARNING: Loader: Refusing to download new benchmark data because a download succeeded at 2019-01-07 17:55:35.311202+00:00.
zipline run -f C:\Users\mattt\PycharmProjects\FFTTrading\trades2.py --bundle quantopian-quandl --start 2016-3-1 --end 2017-12-30
[2019-01-07 17:55:51.581558] WARNING: Loader: Refusing to download new benchmark data because a download succeeded at 2019-01-07 17:55:35.311202+00:00.
zipline run -f C:\Users\mattt\PycharmProjects\FFTTrading\trades2.py --bundle quantopian-quandl --start 2016-3-1 --end 2017-12-30
Can anyone figure out what is happening here? How would I go about properly ingesting and using data? Thank you!
Not sure if this is still revelant, but in case others experience this as well:
The problem is with the SPY Benchmark data which used to be sourced from IEX as part of the ingestion process. IEX no longer offers free access to unregistered users.
Solutions can be found here: https://github.com/quantopian/zipline/issues/2480
Basically: Either "fake" the benchmark or register for IEX Cloud (for free) and change benchmarks.py to issue an API call with your IEX Cloud account.
Dirk