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

KeyErro: 'TURKEY' appears when I try to import zipline #118

Closed Keabla closed 2 years ago

Keabla commented 2 years ago

Dear Zipline Maintainers,

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

Environment

* Operating System: (Windows 11 Pro) * Python Version: `3.8.11` in the local environment * Python Bitness: `64'` * How did you install Zipline: (`conda`) * Python packages: `$ conda list` alembic 1.8.1 pyhd8ed1ab_0 conda-forge bcolz-zipline 1.2.4 py38he6999da_0 ml4t blas 1.0 mkl blosc 1.21.1 h74325e0_3 conda-forge bottleneck 1.3.5 py38hbdcd294_0 conda-forge brotlipy 0.7.0 py38h294d835_1004 conda-forge bzip2 1.0.8 h8ffe710_4 conda-forge ca-certificates 2022.6.15 h5b45459_0 conda-forge cached-property 1.5.2 hd8ed1ab_1 conda-forge cached_property 1.5.2 pyha770c72_1 conda-forge certifi 2022.6.15 py38haa244fe_0 conda-forge cffi 1.15.1 py38hd8c33c5_0 conda-forge charset-normalizer 2.1.0 pyhd8ed1ab_0 conda-forge click 8.1.3 py38haa244fe_0 conda-forge colorama 0.4.5 pyhd8ed1ab_0 conda-forge cryptography 37.0.1 py38h21b164f_0 empyrical-reloaded 0.5.8 py38_0 ml4t exchange-calendars 3.3 py38_0 ml4t greenlet 1.1.2 py38h885f38d_2 conda-forge h5py 3.7.0 nompi_py38hc790250_100 conda-forge hdf5 1.12.1 nompi_h57737ce_104 conda-forge idna 3.3 pyhd8ed1ab_0 conda-forge importlib-metadata 4.11.4 py38haa244fe_0 conda-forge importlib_resources 5.8.0 pyhd8ed1ab_0 conda-forge intel-openmp 2022.1.0 h57928b3_3787 conda-forge intervaltree 3.1.0 pyhd3eb1b0_0 iso3166 2.1.1 pyhd8ed1ab_0 conda-forge iso4217 1.9.20220401 pyhd8ed1ab_0 conda-forge korean_lunar_calendar 0.2.1 pyh9f0ad1d_0 conda-forge krb5 1.19.3 hc8ab02b_0 conda-forge libblas 3.9.0 12_win64_mkl conda-forge libcblas 3.9.0 12_win64_mkl conda-forge libcurl 7.83.1 h789b8ee_0 conda-forge libffi 3.4.2 h8ffe710_5 conda-forge libiconv 1.17 h8ffe710_0 conda-forge liblapack 3.9.0 12_win64_mkl conda-forge libssh2 1.10.0 h9a1e1f7_2 conda-forge libxml2 2.9.14 h0ad7f3c_0 libxslt 1.1.35 h2bbff1b_0 libzlib 1.2.12 h8ffe710_2 conda-forge logbook 1.5.3 py38_0 ml4t lru-dict 1.1.8 py38h294d835_0 conda-forge lxml 4.9.1 py38h294d835_0 conda-forge lz4-c 1.9.3 h8ffe710_1 conda-forge m2w64-gcc-libgfortran 5.3.0 6 conda-forge m2w64-gcc-libs 5.3.0 7 conda-forge m2w64-gcc-libs-core 5.3.0 7 conda-forge m2w64-gmp 6.1.0 2 conda-forge m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge mako 1.2.1 pyhd8ed1ab_0 conda-forge markupsafe 2.1.1 py38h294d835_1 conda-forge mkl 2021.4.0 h0e2418a_729 conda-forge mkl-service 2.4.0 py38h4f8af0f_0 conda-forge msys2-conda-epoch 20160418 1 conda-forge multipledispatch 0.6.0 py_0 conda-forge multitasking 0.0.9 pyhd8ed1ab_0 conda-forge networkx 2.8.5 pyhd8ed1ab_0 conda-forge numexpr 2.8.3 py38hb80d3ca_0 numpy 1.23.1 py38h223ccf5_0 conda-forge openssl 3.0.5 h8ffe710_0 conda-forge packaging 21.3 pyhd8ed1ab_0 conda-forge pandas 1.4.3 py38hcc40339_0 conda-forge pandas-datareader 0.10.0 pyh6c4a22f_0 conda-forge patsy 0.5.2 pyhd8ed1ab_0 conda-forge pip 22.2 pyhd8ed1ab_0 conda-forge pycparser 2.21 pyhd8ed1ab_0 conda-forge pyluach 2.0.0 pyhd8ed1ab_0 conda-forge pyopenssl 22.0.0 pyhd8ed1ab_0 conda-forge pyparsing 3.0.9 pyhd8ed1ab_0 conda-forge pysocks 1.7.1 py38haa244fe_5 conda-forge pytables 3.7.0 py38h7deab4d_0 conda-forge python 3.8.13 hcf16a7b_0_cpython conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python-interface 1.6.0 py_0 conda-forge python_abi 3.8 2_cp38 conda-forge pytz 2022.1 pyhd8ed1ab_0 conda-forge requests 2.28.1 pyhd8ed1ab_0 conda-forge scipy 1.8.1 py38h9bf8e03_0 conda-forge setuptools 63.2.0 py38haa244fe_0 conda-forge six 1.16.0 pyh6c4a22f_0 conda-forge snappy 1.1.9 h82413e6_1 conda-forge sortedcontainers 2.4.0 pyhd8ed1ab_0 conda-forge sqlalchemy 1.4.39 py38h294d835_0 conda-forge sqlite 3.39.1 h8ffe710_0 conda-forge statsmodels 0.13.2 py38hbdcd294_0 conda-forge ta-lib 0.4.21 py38hb572761_0 ml4t tbb 2021.5.0 h2d74725_1 conda-forge tk 8.6.12 h8ffe710_0 conda-forge toolz 0.12.0 pyhd8ed1ab_0 conda-forge trading-calendars 2.1.1 pyhd3deb0d_0 conda-forge ucrt 10.0.20348.0 h57928b3_0 conda-forge urllib3 1.26.10 pyhd8ed1ab_0 conda-forge vc 14.2 hb210afc_6 conda-forge vs2015_runtime 14.29.30037 h902a5da_6 conda-forge wheel 0.37.1 pyhd8ed1ab_0 conda-forge win_inet_pton 1.1.0 py38haa244fe_4 conda-forge xz 5.2.5 h62dcd97_1 conda-forge yfinance 0.1.74 pyhd8ed1ab_0 conda-forge zipline-reloaded 2.2.0 py38he6999da_0 ml4t zipp 3.8.0 pyhd8ed1ab_0 conda-forge zlib 1.2.12 h8ffe710_2 conda-forge zstd 1.5.2 h6255e5f_2 conda-forge

Now that you know a little about me, let me tell you about the issue I am having:

Description of Issue

Problem with zipline

Once I download zipline through the command "conda install -c ml4t zipline-reloaded", I try to import the package and I get the error "KeyError: TURKEY". It seems that python is having an issue reading something.

What steps have you taken to resolve this already?

I have tried to download and import the package through both mamba and conda, and for different Python Version: 3.6, 3.7, 3.8, 3.9.

Sincerely, $ Nitram

atpsg commented 2 years ago

See this issue This is because Turkey name has changed in the iso3166 package To avoid this issue you can force usage of a previous version of the package.

pip install iso3166==2.0.2

RichardDale commented 2 years ago

Further to this, if you're using conda there is a slightly different workaround, detailed in #114

stefan-jansen commented 2 years ago

Addressed by #117