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

Problems with NYSE calendar - Xmas eve 1945 and 1956 #196

Open
cactus1549 opened this issue Dec 4, 2020 · 1 comment · May be fixed by #204
Open

Problems with NYSE calendar - Xmas eve 1945 and 1956 #196

cactus1549 opened this issue Dec 4, 2020 · 1 comment · May be fixed by #204
Labels
bug Something isn't working

Comments

@cactus1549
Copy link

This is related to #147 .

I am backtesting with data going back to 1900. If I do:

import pandas as pd
from pytz import UTC
from trading_calendars.exchange_calendar_xnys import XNYSExchangeCalendar

start =  pd.Timestamp('1900-01-02', tz=UTC)
tcal = XNYSExchangeCalendar(start=start)

I get the following errors:

(zipline) xxx@yyy:~/qa/trader$  cd /home/xxx/qa/trader ; /usr/bin/env /home/xxx/anaconda3/envs/zipline/bin/python /home/xxx/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 33469 -- /home/xxx/qa/zipline-test/test_trading_calendar.py 
Traceback (most recent call last):
  File "/home/xxx/anaconda3/envs/zipline/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/xxx/anaconda3/envs/zipline/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/xxx/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/__main__.py", line 45, in <module>
    cli.main()
  File "/home/xxx/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/home/xxx/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 267, in run_file
    runpy.run_path(options.target, run_name=compat.force_str("__main__"))
  File "/home/xxx/anaconda3/envs/zipline/lib/python3.6/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/home/xxx/anaconda3/envs/zipline/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/home/xxx/anaconda3/envs/zipline/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/xxx/qa/zipline-test/test_trading_calendar.py", line 8, in <module>
    tcal = XNYSExchangeCalendar(start=start)
  File "/home/xxx/anaconda3/envs/zipline/lib/python3.6/site-packages/trading_calendars/trading_calendar.py", line 143, in __init__
    _overwrite_special_dates(_all_days, self._closes, _special_closes)
  File "/home/xxx/anaconda3/envs/zipline/lib/python3.6/site-packages/trading_calendars/trading_calendar.py", line 1199, in _overwrite_special_dates
    raise ValueError("Special dates %s are not trading days." % bad_dates)
ValueError: Special dates [Timestamp('1945-12-24 19:00:00+0000', tz='UTC'), Timestamp('1956-12-24 19:00:00+0000', tz='UTC')] are not trading days.
@gerrymanoim
Copy link
Collaborator

Ah interesting. So this is an interaction between

ChristmasEvesAdhoc = [
    Timestamp("1945-12-24", tz="UTC"),
    Timestamp("1956-12-24", tz="UTC"),
]

and

# NYSE closed at 2:00 PM on Christmas Eve until 1993.
ChristmasEveBefore1993 = Holiday(
    "Christmas Eve",
    month=12,
    day=24,
    end_date=Timestamp("1993-01-01"),
    # When Christmas is a Saturday, the 24th is a full holiday.
    days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY),
)

So I think ChristmasEveBefore1993 just needs to be split apart to cover these cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants