-
Notifications
You must be signed in to change notification settings - Fork 142
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
BUG: Trading calendar with end date treats last business day as regular even if it is a special close/open day. #8
Comments
I just came across this as well. Example for reference:
returns...
i.e. close on 2020-12-31 is correct (12.30) although...
returns...
Worth noting that cases when this bug appears include whenever the end date is the last day of a year (I imagine not uncommon usage) and that last day of the year (i.e. new year's eve) is a special close (certainly not uncommon!). |
The bug's here: result = result.loc[(result >= start_date) & (result <= end_date)] Using the XLON example above, what's happening is Fix: end_rng = end_date + pd.Timedelta(1, "D")
result = result.loc[(result >= start_date) & (result < end_rng)] Fix in PR #88. |
While working on #4, I discovered what is likely a bug in the
TradingCalendar
base class.When a calendar, e.g. for
XETR
orXWBO
, is created with end date, say,2020-12-30
, then that day itself always seems to be treated as a regular business day if the exchange is open at all that day.However,
XETR
andXWBO
have rules in that make the last trading day of a year a special close day. This seems to be ignored in this case. If the end date is chosen to be after the special close day in question, then the special close is again reflected accurately.The bug seems to manifest itself only in the edge case where the end date is a special open/close day.
@gerrymanoim Can you have look? You're probably quicker at finding the root cause. Let me know if I can help.
The text was updated successfully, but these errors were encountered: