rsheftel/pandas_market_calendars

CBOE_Index_Options calendar not reporting holidays correctly with Pandas 2.0.0

jgiacobbi opened this issue · 3 comments

1:

import pandas_market_calendars as mcal
from holidays import UnitedStates # This is just a shortcut to hand coding a bunch of holidays

cboe = mcal.get_calendar("CBOE_Index_Options")
for date, _ in UnitedStates(years=2023).items():
    print(cboe.schedule(date, date))
    print()

1a (output):

Empty DataFrame
Columns: [market_open, market_close]
Index: []

                         market_open              market_close
2023-01-02 2023-01-02 14:30:00+00:00 2023-01-02 21:15:00+00:00

                         market_open              market_close
2023-01-16 2023-01-16 14:30:00+00:00 2023-01-16 21:15:00+00:00

                         market_open              market_close
2023-02-20 2023-02-20 14:30:00+00:00 2023-02-20 21:15:00+00:00

                         market_open              market_close
2023-05-29 2023-05-29 13:30:00+00:00 2023-05-29 20:15:00+00:00

                         market_open              market_close
2023-06-19 2023-06-19 13:30:00+00:00 2023-06-19 20:15:00+00:00

                         market_open              market_close
2023-07-04 2023-07-04 13:30:00+00:00 2023-07-04 20:15:00+00:00

                         market_open              market_close
2023-09-04 2023-09-04 13:30:00+00:00 2023-09-04 20:15:00+00:00

                         market_open              market_close
2023-10-09 2023-10-09 13:30:00+00:00 2023-10-09 20:15:00+00:00

Empty DataFrame
Columns: [market_open, market_close]
Index: []

                         market_open              market_close
2023-11-10 2023-11-10 14:30:00+00:00 2023-11-10 21:15:00+00:00

                         market_open              market_close
2023-11-23 2023-11-23 14:30:00+00:00 2023-11-23 21:15:00+00:00

                         market_open              market_close
2023-12-25 2023-12-25 14:30:00+00:00 2023-12-25 21:15:00+00:00

2:

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:        20.04
Codename:       focal

python3.9 --version
Python 3.9.16

pip3.9 freeze | grep pandas
pandas==2.0.0
pandas-market-calendars==4.1.4

3:
After upgrading to pandas 2.0.0, the CBOE Index Options calendar fails to recognize CBOE's listed holidays (https://www.cboe.com/about/hours). The above output shows what is happening: holidays with open and close times. The expected output is empty dataframes for each holiday.

After downgrading to pandas 1.5.3 all holiday schedules return empty dataframes as expected.

Have there been any updates with this issue?

I've also experienced a change in behaviour with the CFE calendar after upgrading to pandas 2.0.2.

Reproducible example:

Before upgrading:

pandas==1.3.5
pandas-market-calendars==4.1.4
>>> import pandas_market_calendars as mcal
>>> cfe = mcal.get_calendar('CFE')
>>> cfe.valid_days(dt.date(2023, 2, 17), dt.date(2023, 2, 22))
DatetimeIndex(['2023-02-17 00:00:00+00:00', '2023-02-21 00:00:00+00:00',
               '2023-02-22 00:00:00+00:00'],
              dtype='datetime64[ns, UTC]', freq='C')

After upgrading:

pandas==2.0.2
pandas-market-calendars==4.1.4
>>> import pandas_market_calendars as mcal
>>> cfe = mcal.get_calendar('CFE')
>>> cfe.valid_days(dt.date(2023, 2, 17), dt.date(2023, 2, 22))
DatetimeIndex(['2023-02-17 00:00:00+00:00', '2023-02-20 00:00:00+00:00',
               '2023-02-21 00:00:00+00:00', '2023-02-22 00:00:00+00:00'],
               dtype='datetime64[ns, UTC]', freq='C')

The latter case seems to be ignoring the 20 February 2023 market holiday

I believe this is related to #265 as the behavior of the Holiday() function in pandas seems to have an undocumented change in v2.0.0 where the function that is passed in to the observance parameter prior to 2.0.0 would be a function that was passed a single datetime, now post 2.0.0 it appears the function will be passes a list of datetimes. Because the change is not documented, this requires analysis to reverse out the change.

Fixed in PR #279