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

merge_schedules ignores case of market_open > market_close #356

Open
bsdice opened this issue Nov 29, 2024 · 0 comments
Open

merge_schedules ignores case of market_open > market_close #356

bsdice opened this issue Nov 29, 2024 · 0 comments

Comments

@bsdice
Copy link

bsdice commented Nov 29, 2024

Yo, not sure if bug or feature. If you merge NYSE with XETRA for December 2024, last merged date will have an "impossible" time, because Xetra on 2024-12-30 closes at 13:00 UTC, and this is the last trading day of this year. Whereas NYSE only opens 1.5 hours later at 14:30 UTC. So you get this line:

2024-12-30 2024-12-30 14:30:00+00:00 2024-12-30 13:00:00+00:00

I worked around it in my code using:

m_fixed = m[m["market_close"] > m["market_open"]]

Reproducer:

#!/usr/bin/env -S /bin/sh -c "_top_dir=\"\$(dirname \"\$(realpath -s \"\$0\")\")\"; cd \"\$_top_dir\"; exec \"\$_top_dir/python/install/bin/python3\" -W once::DeprecationWarning -X dev \"\$0\" \"\$@\""
import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "lib"))

import pandas_market_calendars as mcal

start_date = "20241201"
end_date = "20241231"

nyse = mcal.get_calendar("XNYS")
xetra = mcal.get_calendar("XETR")

s1 = nyse.schedule(start_date, end_date)
s2 = xetra.schedule(start_date, end_date)

m = mcal.merge_schedules(schedules=[s1, s2], how="inner")
m_fixed = m[m["market_close"] > m["market_open"]]

print(s1.tail(2))
print(s2.tail(2))

print(m.tail(1))
print(m_fixed.tail(1))

Thank you, S

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

No branches or pull requests

1 participant