rsheftel / pandas_market_calendars

Exchange calendars to use with pandas for trading applications
MIT License
803 stars 173 forks source link

Pandas future warning issued when getting schedule for a half day #239

Open jon23d opened 1 year ago

jon23d commented 1 year ago

Here is a sample showing two failure cases and one success case. The failures occur on half days when start and end dates are the same.

>>> import pandas_market_calendars as mcal
>>> from datetime import datetime
>>> calendar = mcal.get_calendar('NYSE')

>>> dt = datetime(2022, 11, 25)
>>> print(calendar.schedule(start_date=dt, end_date=dt, tz='America/New_York'))
<stdin>:1: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)`
                         market_open              market_close
2022-11-25 2022-11-25 09:30:00-05:00 2022-11-25 13:00:00-05:00

>>> dt = datetime(2023, 7, 3)
>>> print(calendar.schedule(start_date=dt, end_date=dt, tz='America/New_York'))
<stdin>:1: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)`
                         market_open              market_close
2023-07-03 2023-07-03 09:30:00-04:00 2023-07-03 13:00:00-04:00

>>> dt = datetime(2023, 7, 5)
>>> print(calendar.schedule(start_date=dt, end_date=dt, tz='America/New_York'))
                         market_open              market_close
2023-07-05 2023-07-05 09:30:00-04:00 2023-07-05 16:00:00-04:00

My system is running MacOS Monterey, python 3.10, and pandas market calendars 4.1.1

RaduCiumag commented 1 year ago

Same behaviours on Python 3.9.6 and pandas_market_calendars 4.1.4