Skip to content

Commit

Permalink
Merge pull request #285 from rsheftel/dev
Browse files Browse the repository at this point in the history
v4.3.0
  • Loading branch information
rsheftel authored Sep 5, 2023
2 parents 4a824d9 + 350d6ba commit f9ab04a
Show file tree
Hide file tree
Showing 75 changed files with 696 additions and 223 deletions.
7 changes: 5 additions & 2 deletions .github/config_new_release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

new_version: '4.1.4'
new_version: '4.3.0'

change_log: |
- Updated TASE Holidays 2022-2025
- Fixed for pandas 2.0 so all tests pass PR #282
- Move exchange_calendar*.py files to pandas_market_calendar/exchange_calendars/ PR #284
- Move holidays_*.py to pandas_market_calendar/holidays/ PR #284
- Major cleanup including unused imports PR #284
release_body: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ celerybeat-schedule
.env
.venv
env/
venv/
venv*/
env.bak/
venv.bak/

Expand Down
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Market calendars to use with pandas for trading applications.
:target: http://pandas-market-calendars.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://coveralls.io/repos/github/rsheftel/pandas_market_calendars/badge.svg?branch=master
:target: https://coveralls.io/github/rsheftel/pandas_market_calendars?branch=master

Documentation
-------------
http://pandas-market-calendars.readthedocs.io/en/latest/
Expand Down
9 changes: 5 additions & 4 deletions docs/calendars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ Exchange BSE BSEExchangeCalendar rakesh1988

Futures Calendars
#################
========== ================ =================================== ============ ============
========== ================= =================================== ============ ============
Exchange Name Class Unit Tests Creator
========== ================ =================================== ============ ============
========== ================= =================================== ============ ============
CME CME_Equity CMEEquityExchangeCalendar Yes rsheftel
CME CME_Bond CMEBondExchangeCalendar Yes rsheftel
CME CME_Agricultural CMEAgriculturalExchangeCalendar Yes lionelyoung
========== ================ =================================== ============ ============
CME CME_Agricultural CMEAgriculturalExchangeCalendar Yes lionelyoung
CME CME Globex Crypto CMEGlobexCryptoExchangeCalendar Yes Coinbase Asset Management
========== ================= =================================== ============ ============

Bond Market Calendars
#####################
Expand Down
7 changes: 7 additions & 0 deletions docs/change_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Change Log

Updates
-------
4.3.0 (09/05/2023)
~~~~~~~~~~~~~~~~~~
- Fixed for pandas 2.0 so all tests pass PR #282
- Move exchange_calendar*.py files to pandas_market_calendar/exchange_calendars/ PR #284
- Move holidays_*.py to pandas_market_calendar/holidays/ PR #284
- Major cleanup including unused imports PR #284

4.2.1 (08/21/2023)
~~~~~~~~~~~~~~~~~~
- Fix the pyproject.toml to properly generate sdist PR #267
Expand Down
2 changes: 1 addition & 1 deletion examples/usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@
"# If you want to use the equity options exchange (8:30 - 15:00), including the order acceptance time at 7:30, and\n",
"# some special cases when the order acceptance time was different, do this:\n",
"\n",
"from pandas_market_calendars.exchange_calendar_cboe import CFEExchangeCalendar \n",
"from pandas_market_calendars.exchange_calendar.cboe import CFEExchangeCalendar \n",
"\n",
"class DemoOptionsCalendar(CFEExchangeCalendar): # Inherit what doesn't need to change\n",
" name = \"Demo_Options\"\n",
Expand Down
51 changes: 26 additions & 25 deletions pandas_market_calendars/calendar_registry.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
from .market_calendar import MarketCalendar
from .exchange_calendar_asx import ASXExchangeCalendar
from .exchange_calendar_bmf import BMFExchangeCalendar
from .exchange_calendar_cboe import CFEExchangeCalendar
from .exchange_calendar_cme import \
from .calendars.asx import ASXExchangeCalendar
from .calendars.bmf import BMFExchangeCalendar
from .calendars.bse import BSEExchangeCalendar
from .calendars.cboe import CFEExchangeCalendar
from .calendars.cme import \
CMEEquityExchangeCalendar, \
CMEBondExchangeCalendar
from .exchange_calendar_cme_globex_base import CMEGlobexBaseExchangeCalendar
from .exchange_calendar_cme_globex_agriculture import CMEGlobexAgricultureExchangeCalendar
from .exchange_calendar_cme_globex_fx import CMEGlobexFXExchangeCalendar
from .exchange_calendar_cme_globex_energy_and_metals import CMEGlobexEnergyAndMetalsExchangeCalendar
from .exchange_calendar_cme_globex_equities import CMEGlobexEquitiesExchangeCalendar
from .exchange_calendar_cme_globex_fixed_income import CMEGlobexFixedIncomeCalendar
from .exchange_calendar_eurex import EUREXExchangeCalendar
from .exchange_calendar_hkex import HKEXExchangeCalendar
from .exchange_calendar_ice import ICEExchangeCalendar
from .exchange_calendar_iex import IEXExchangeCalendar
from .exchange_calendar_jpx import JPXExchangeCalendar
from .exchange_calendar_lse import LSEExchangeCalendar
from .exchange_calendar_nyse import NYSEExchangeCalendar
from .exchange_calendar_ose import OSEExchangeCalendar
from .exchange_calendar_sifma import SIFMAUSExchangeCalendar, SIFMAUKExchangeCalendar, SIFMAJPExchangeCalendar
from .exchange_calendar_six import SIXExchangeCalendar
from .exchange_calendar_sse import SSEExchangeCalendar
from .exchange_calendar_tsx import TSXExchangeCalendar
from .exchange_calendar_bse import BSEExchangeCalendar
from .exchange_calendar_tase import TASEExchangeCalendar
from .exchange_calendars_mirror import *
from .calendars.cme_globex_base import CMEGlobexBaseExchangeCalendar
from .calendars.cme_globex_agriculture import CMEGlobexAgricultureExchangeCalendar
from .calendars.cme_globex_crypto import CMEGlobexCryptoExchangeCalendar
from .calendars.cme_globex_energy_and_metals import CMEGlobexEnergyAndMetalsExchangeCalendar
from .calendars.cme_globex_equities import CMEGlobexEquitiesExchangeCalendar
from .calendars.cme_globex_fx import CMEGlobexFXExchangeCalendar
from .calendars.cme_globex_fixed_income import CMEGlobexFixedIncomeCalendar
from .calendars.eurex import EUREXExchangeCalendar
from .calendars.hkex import HKEXExchangeCalendar
from .calendars.ice import ICEExchangeCalendar
from .calendars.iex import IEXExchangeCalendar
from .calendars.jpx import JPXExchangeCalendar
from .calendars.lse import LSEExchangeCalendar
from .calendars.nyse import NYSEExchangeCalendar
from .calendars.ose import OSEExchangeCalendar
from .calendars.sifma import SIFMAUSExchangeCalendar, SIFMAUKExchangeCalendar, SIFMAJPExchangeCalendar
from .calendars.six import SIXExchangeCalendar
from .calendars.sse import SSEExchangeCalendar
from .calendars.tase import TASEExchangeCalendar
from .calendars.tsx import TSXExchangeCalendar
from .calendars.mirror import *


def get_calendar(name, open_time=None, close_time=None) -> MarketCalendar:
Expand Down
2 changes: 1 addition & 1 deletion pandas_market_calendars/calendar_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def merge_schedules(schedules, how='outer'):
CAVEATS:
* This does not work for schedules with breaks, the break information will be lost.
* Onlu "market_open" and "market_close" are considered, other market times are not yet supported.
* Only "market_open" and "market_close" are considered, other market times are not yet supported.
:param schedules: list of schedules
:param how: outer or inner
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from pandas.tseries.holiday import AbstractHolidayCalendar, GoodFriday, EasterMonday
from pytz import timezone

from .holidays_oz import *
from .market_calendar import MarketCalendar
from pandas_market_calendars.holidays.oz import *
from pandas_market_calendars.market_calendar import MarketCalendar

AbstractHolidayCalendar.start_date = '2011-01-01'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pandas.tseries.holiday import AbstractHolidayCalendar, Day, Easter, GoodFriday, Holiday
from pytz import timezone

from .market_calendar import (FRIDAY, MarketCalendar)
from pandas_market_calendars.market_calendar import (FRIDAY, MarketCalendar)

# Universal Confraternization (new years day)
ConfUniversal = Holiday(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pandas import Timestamp
from pytz import timezone
from datetime import time
from .market_calendar import MarketCalendar
from pandas_market_calendars.market_calendar import MarketCalendar


BSEClosedDay = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,29 @@
from itertools import chain
import pandas as pd

from .holidays_us import (Christmas, USBlackFridayInOrAfter1993, USIndependenceDay, USMartinLutherKingJrAfter1998,
USMemorialDay, USNewYearsDay, HurricaneSandyClosings, USNationalDaysofMourning)
from .market_calendar import MarketCalendar
from pandas_market_calendars.holidays.us import (Christmas, USBlackFridayInOrAfter1993, USIndependenceDay, USMartinLutherKingJrAfter1998,
USMemorialDay, USNewYearsDay, HurricaneSandyClosings, USNationalDaysofMourning,
USJuneteenthAfter2022)
from pandas_market_calendars.market_calendar import MarketCalendar


# TODO: In pandas 2.0.3 this no longer works as the dt passed in is the entire matrix and not a single date
def good_friday_unless_christmas_nye_friday(dt):
"""
Good Friday is a valid trading day if Christmas Day or New Years Day fall
on a Friday.
"""
if isinstance(dt, pd.DatetimeIndex):
# Pandas < 2.1.0 will call with an index and fall-back to element by element
# Pandas == 2.1.0 will only call element by element
raise NotImplementedError()

year = dt.year
christmas_weekday = Christmas.observance(
pd.Timestamp(year, 12, 25)
).weekday()
nyd_weekday = USNewYearsDay.observance(
pd.Timestamp(year, 1, 1)
).weekday()
christmas_weekday = Christmas.observance(pd.Timestamp(year=year, month=12, day=25)).weekday()
nyd_weekday = USNewYearsDay.observance(pd.Timestamp(year=year, month=1, day=1)).weekday()
if christmas_weekday != 4 and nyd_weekday != 4:
return GoodFriday._apply_rule(dt)
return GoodFriday.dates(pd.Timestamp(year=year, month=1, day=1), pd.Timestamp(year=year, month=12, day=31))[0]
else:
# compatibility for pandas 0.18.1
# Not a holiday so use NaT to ensure it gets removed
return pd.NaT


Expand Down Expand Up @@ -70,8 +71,8 @@ def regular_holidays(self):
USNewYearsDay,
USMartinLutherKingJrAfter1998,
USPresidentsDay,
# GoodFridayUnlessChristmasNYEFriday, #TODO: When this is fixed can return to using it
GoodFriday,
GoodFridayUnlessChristmasNYEFriday,
USJuneteenthAfter2022,
USIndependenceDay,
USMemorialDay,
USLaborDay,
Expand Down Expand Up @@ -112,5 +113,3 @@ class CBOEIndexOptionsExchangeCalendar(CFEExchangeCalendar):
"market_open": ((None, time(8, 30)),),
"market_close": ((None, time(15, 15)),)
}


Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
from pandas.tseries.holiday import AbstractHolidayCalendar, GoodFriday, USLaborDay, USPresidentsDay, USThanksgivingDay
from pytz import timezone

from .holidays_us import (Christmas, ChristmasEveBefore1993, ChristmasEveInOrAfter1993, USBlackFridayInOrAfter1993,
USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay, USNationalDaysofMourning,
USNewYearsDay)
from .market_calendar import MarketCalendar
from pandas_market_calendars.holidays.us import (Christmas, ChristmasEveBefore1993, ChristmasEveInOrAfter1993, USBlackFridayInOrAfter1993,
USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay, USNationalDaysofMourning,
USNewYearsDay)
from pandas_market_calendars.market_calendar import MarketCalendar


# Useful resources for making changes to this file: http://www.cmegroup.com/tools-information/holiday-calendar.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from abc import ABC, abstractmethod
from .exchange_calendar_cme_globex_base import CMEGlobexBaseExchangeCalendar
from abc import abstractmethod
from .cme_globex_base import CMEGlobexBaseExchangeCalendar

from datetime import time
from itertools import chain

from pandas import Timestamp
from pandas.tseries.holiday import AbstractHolidayCalendar, GoodFriday, USLaborDay, USPresidentsDay, USThanksgivingDay
from pytz import timezone

from .holidays_us import (Christmas, ChristmasEveBefore1993, ChristmasEveInOrAfter1993, USBlackFridayInOrAfter1993,
USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay, USJuneteenthAfter2022,
USNationalDaysofMourning, USNewYearsDay)
from .market_calendar import MarketCalendar


from pandas_market_calendars.holidays.us import (Christmas, ChristmasEveBefore1993, ChristmasEveInOrAfter1993, USBlackFridayInOrAfter1993,
USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay,
USNewYearsDay)


class CMEGlobexAgricultureExchangeCalendar(CMEGlobexBaseExchangeCalendar):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@

from abc import ABC, abstractmethod

from datetime import time
from itertools import chain

from pandas import Timestamp
from pandas.tseries.holiday import AbstractHolidayCalendar, GoodFriday, USLaborDay, USPresidentsDay, USThanksgivingDay
from pytz import timezone

from .holidays_us import (Christmas, ChristmasEveBefore1993, ChristmasEveInOrAfter1993, USBlackFridayInOrAfter1993,
USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay, USJuneteenthAfter2022,
USNationalDaysofMourning, USNewYearsDay)
from .market_calendar import MarketCalendar
from pandas_market_calendars.holidays.us import (Christmas, ChristmasEveBefore1993, ChristmasEveInOrAfter1993, USBlackFridayInOrAfter1993,
USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay, USJuneteenthAfter2022,
USNewYearsDay)
from pandas_market_calendars.market_calendar import MarketCalendar


class CMEGlobexBaseExchangeCalendar(MarketCalendar, ABC):
Expand All @@ -34,6 +30,7 @@ class CMEGlobexBaseExchangeCalendar(MarketCalendar, ABC):
CME Markets: https://www.cmegroup.com/markets/agriculture.html#overview
- Agriculture
- Crypto
- Energy
- Equity Index
- FX
Expand Down
Loading

0 comments on commit f9ab04a

Please sign in to comment.