Closed andyschuster closed 2 years ago
Issue: valid_days() does not return correct tz-aware days if called with tz other than 'UTC'.
import pandas_market_calendars as market_cal market_cal.get_calendar('NYSE').valid_days( start_date=pd.to_datetime('2022-01-01'), end_date=pd.Timestamp.today(), tz='US/Eastern')
In version 4.1.0 the above code incorrectly returns US/Eastern dates shifted back by 5 hours:
DatetimeIndex(['2022-01-02 19:00:00-05:00', '2022-01-03 19:00:00-05:00', ... ], dtype='datetime64[ns, US/Eastern]', length=208, freq=None)
Notice the incorrect dates above. The first trading day in 2022 was 01-03.
Expected behavior should be the correct dates (with midnight normalized time), given NYSE operates on Eastern timezone:
DatetimeIndex(['2022-01-03 00:00:00-05:00', '2022-01-04 00:00:00-05:00', ... ], dtype='datetime64[ns, US/Eastern]', length=208, freq=None)
This behavior still works as expected in version 3.5.
Suggested fix: Revert change made 2 months ago on line 1092 in exchange_calendar_nyse.py from
trading_days = super().valid_days(start_date, end_date, tz= 'UTC')
back to
trading_days = super().valid_days(start_date, end_date, tz=tz)
pandas_market_calendars version: 4.1.0 (issue observed), 3.5 (issue not observed) Python version: tested on both 3.10, 3.11 System: Win 11 / miniconda
Issue: valid_days() does not return correct tz-aware days if called with tz other than 'UTC'.
In version 4.1.0 the above code incorrectly returns US/Eastern dates shifted back by 5 hours:
Notice the incorrect dates above. The first trading day in 2022 was 01-03.
Expected behavior should be the correct dates (with midnight normalized time), given NYSE operates on Eastern timezone:
This behavior still works as expected in version 3.5.
Suggested fix: Revert change made 2 months ago on line 1092 in exchange_calendar_nyse.py from
back to
pandas_market_calendars version: 4.1.0 (issue observed), 3.5 (issue not observed) Python version: tested on both 3.10, 3.11 System: Win 11 / miniconda