Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean install fails - trading_calendars is broken and unmaintained #176

Closed
Tantalon opened this issue Jul 18, 2021 · 5 comments · Fixed by #178
Closed

clean install fails - trading_calendars is broken and unmaintained #176

Tantalon opened this issue Jul 18, 2021 · 5 comments · Fixed by #178

Comments

@Tantalon
Copy link
Contributor

Tantalon commented Jul 18, 2021

A clean install of alpaca_backtrader_api fails on import:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/regg002/.local/share/virtualenvs/Repo-7RUXb6y2/lib/python3.9/site-packages/alpaca_backtrader_api/__init__.py", line 1, in <module>
    from .alpacastore import AlpacaStore
  File "/Users/regg002/.local/share/virtualenvs/Repo-7RUXb6y2/lib/python3.9/site-packages/alpaca_backtrader_api/alpacastore.py", line 12, in <module>
    import trading_calendars
  File "/Users/regg002/.local/share/virtualenvs/Repo-7RUXb6y2/lib/python3.9/site-packages/trading_calendars/__init__.py", line 16, in <module>
    from .trading_calendar import TradingCalendar
  File "/Users/regg002/.local/share/virtualenvs/Repo-7RUXb6y2/lib/python3.9/site-packages/trading_calendars/trading_calendar.py", line 33, in <module>
    from .calendar_helpers import (
  File "/Users/regg002/.local/share/virtualenvs/Repo-7RUXb6y2/lib/python3.9/site-packages/trading_calendars/calendar_helpers.py", line 6, in <module>
    NP_NAT = np.array([pd.NaT], dtype=np.int64)[0]
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NaTType'

This is due to quantopian/trading_calendars#224: "[trading_calendars] isn't being maintained (see the README) although a fork exchange_calendars is being maintained and this issue was resolved in the latest release (3.2)." [ref]

@Tantalon Tantalon changed the title trading_calendars dep is broken and unmaintained clean import fails - trading_calendars is broken and unmaintained Jul 18, 2021
@Tantalon Tantalon changed the title clean import fails - trading_calendars is broken and unmaintained clean install fails - trading_calendars is broken and unmaintained Jul 18, 2021
@claytantor
Copy link

vi /Users/claytongraham/.pyenv/versions/trading-bot/lib/python3.8/site-packages/trading_calendars/calendar_helpers.py

change:

#NP_NAT = np.array([pd.NaT], dtype=np.int64)[0]
NP_NAT = pd.NaT.value

@likenji
Copy link

likenji commented Sep 27, 2021

vi /Users/claytongraham/.pyenv/versions/trading-bot/lib/python3.8/site-packages/trading_calendars/calendar_helpers.py

change:

#NP_NAT = np.array([pd.NaT], dtype=np.int64)[0]
NP_NAT = pd.NaT.value

useful for pd.version = 1.3.3 Many thanks!

@kianjones9
Copy link

kianjones9 commented Nov 20, 2021

I tried the above workaround (changing value of NP_NAT) which gets me further... but then throws this error:

Starting Portfolio Value: 10000.00
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/kian/.local/lib/python3.8/site-packages/alpaca_backtrader_api/alpacastore.py", line 415, in _t_candles
    cdl = cdl.loc[
  File "/home/kian/.local/lib/python3.8/site-packages/pandas/util/_decorators.py", line 311, in wrapper
    return func(*args, **kwargs)
  File "/home/kian/.local/lib/python3.8/site-packages/pandas/core/frame.py", line 5948, in dropna
    raise KeyError(list(np.compress(check, subset)))
KeyError: ['high']

@EStork09
Copy link

EStork09 commented Dec 7, 2021

@kianjones9 #172 references this error, specifically this comment

@likenji
Copy link

likenji commented Dec 7, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants