stefan-jansen / zipline-reloaded

Zipline, a Pythonic Algorithmic Trading Library
https://zipline.ml4trading.io
Apache License 2.0
1.18k stars 216 forks source link

Custom bundle return ValueError: Start session #126

Closed MushiTheMoshi closed 1 year ago

MushiTheMoshi commented 2 years ago

Dear Zipline Maintainers,

Before I tell you about my issue, let me describe my environment:

Environment

* Operating System: 5.4.0-124-lowlatency #140-Ubuntu SMP PREEMPT Thu Aug 4 03:05:50 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux * Python Version: Python 3.8.10 * Python Bitness: 64 * How did you install Zipline: 2.2.0 * Python packages: * Python packages: `alembic==1.8.1 asttokens==2.0.8 backcall==0.2.0 bcolz-zipline==1.2.4 Bottleneck==1.3.5 certifi==2022.6.15 charset-normalizer==2.1.0 click==8.1.3 decorator==5.1.1 empyrical-reloaded==0.5.8 exchange-calendars==3.3 executing==0.10.0 greenlet==1.1.2 h5py=* Python packages: =3.7.0 idna==3.3 importlib-metadata==4.12.0 importlib-resources==5.9.0 intervaltree==3.1.0 ipython==8.4.0 iso3166==2.0.2 iso4217==1.11.20220401 jedi==0.18.1 korean-lunar-calendar==0.2.1 Logbook==1.5.3 lru-dict==1.1.8 lxml==4.9.1 Mako==1.2.1 MarkupSafe==2.1.1 matplotlib-inline==0.1.6 multipledispatch==0.6.0 multitasking==0.0.11 networkx==2.8.5 numexpr==2.8.3 numpy==1.23.2 packaging==21.3 pandas==1.4.3 pandas-datareader==0.10.0 parso==0.8.3 patsy==0.5.2 pexpect==4.8.0 pickleshare==0.7.5 prompt-toolkit==3.0.30 ptyprocess==0.7.0 pure-eval==0.2.2 Pygments==2.13.0 pyluach==2.0.0 pyparsing==3.0.9 python-dateutil==2.8.2 python-interface==1.6.1 pytz==2022.2.1 requests==2.28.1 scipy==1.9.0 six==1.16.0 sortedcontainers==2.4.0 SQLAlchemy==1.4.40 stack-data==0.4.0 statsmodels==0.13.2 TA-Lib==0.4.24 tables==3.7.0 toolz==0.12.0 trading-calendars==2.1.1 traitlets==5.3.0 urllib3==1.26.11 wcwidth==0.2.5 yfinance==0.1.74 zipline-reloaded==2.2.0 zipp==3.8.1`

Description of Issue

Unable to load custom bundle due to format issue, I am following this guide: https://zipline.ml4trading.io/bundles.html, when ingesting the bundle via zipline I am getting the below error: File "/home/julio/Projects/101/finance/zipline/venv/lib/python3.8/site-packages/zipline/data/bcolz_daily_bars.py", line 161, in __init__ raise ValueError("Start session %s is invalid!" % start_session) ValueError: Start session 2016-01-04 is invalid! extensions.py: `start_session = pd.Timestamp('2016-1-1', tz='utc') end_session = pd.Timestamp('2018-1-1', tz='utc')

register( 'custom-aapl', csvdir_equities( ['daily'], '/home/julio/Projects/101/finance/zipline/install/MarketData', ), calendar_name='NYSE', # US equities start_session=start_session, end_session=end_session )`

aapl.csv: Date,High,Low,Open,Close,Volume,Adj Close 2016-01-04,26.342500686645508,25.5,25.65250015258789,26.337499618530273,270597600.0,24.15149688720703 2016-01-05,26.462499618530273,25.602500915527344,26.4375,25.677499771118164,223164000.0,23.54627799987793 tree: MarketData/ └── Daily └── aapl.csv

What steps have you taken to resolve this already?

I have tried to change the date format to match csv's format, still not working...

Anything else?

...

Sincerely, Julio Guerrero

stefan-jansen commented 1 year ago

The dates/times included need to match the dates/times for which the exchange was open according to its calendar.