Skip to content

Commit

Permalink
Merge pull request #327 from rsheftel/dev
Browse files Browse the repository at this point in the history
v4.4.0
  • Loading branch information
rsheftel authored Feb 10, 2024
2 parents eeace9d + 25071c5 commit e3aa8a3
Show file tree
Hide file tree
Showing 16 changed files with 157 additions and 25 deletions.
5 changes: 2 additions & 3 deletions .github/config_new_release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
new_version: '4.3.2'
new_version: '4.4.0'

change_log: |
- Reformat all code using Black and make black a standard PR #290
- Add XNSE as a name for BSE calendar # 277
- Now works with pandas 2.2.0
release_body: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.12"

- name: install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.12"

- name: Install dependencies
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ '3.8', '3.9', '3.10', '3.11' ]
python-version: [ '3.9', '3.10', '3.11', '3.12']

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -25,7 +25,7 @@ jobs:
- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest coveralls black===23.7.0
pip install pytest coveralls black===24.1.1
pip install .
- name: ensure black format
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 24.1.1
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.8
language_version: python3.12
9 changes: 9 additions & 0 deletions docs/change_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ Change Log

Updates
-------
4.4.0 (02/10/2024)
~~~~~~~~~~~~~~~~~~
- Verified to work on pandas 2.2.0, max version changed in pyproject.toml
- Updated minimum version of Python to 3.9
- Corrected 2024 us sifma holidays & early closes #326
- Added national holiday for BMF calendar (Black Awareness Day, Nov 20th) #321
- Added BMF calendar holiday for New Year's Eve on Sunday #318
- BSE/NSE trading holidays 2024 updated #316

4.3.3 (12/30/2023)
~~~~~~~~~~~~~~~~~~
- PR #310 to add EUREX Fixed Income calendars
Expand Down
25 changes: 21 additions & 4 deletions pandas_market_calendars/calendars/bmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,21 @@
month=11,
day=15,
)
# Day of Black Awareness
# Day of Black Awareness (municipal holiday for the city of São Paulo)
ConscienciaNegra = Holiday(
"Dia da Consciencia Negra",
month=11,
day=20,
start_date="2004-01-01",
end_date="2019-12-31",
)
# Day of Black Awareness (national holiday)
ConscienciaNegraNacional = Holiday(
"Dia da Consciencia Negra",
month=11,
day=20,
start_date="2023-12-22",
)
# Christmas Eve
VesperaNatal = Holiday(
"Vespera Natal",
Expand All @@ -122,6 +129,13 @@
day=30,
days_of_week=(FRIDAY,),
)
# New Year's Eve falls on Sunday
AnoNovoDomingo = Holiday(
"Ano Novo Domingo",
month=12,
day=29,
days_of_week=(FRIDAY,),
)

##########################
# Non-recurring holidays
Expand All @@ -147,14 +161,15 @@ class BMFExchangeCalendar(MarketCalendar):
- Corpus Christi (60 days after Easter)
- Tiradentes (April 21)
- Labor day (May 1)
- Constitutionalist Revolution (July 9 after 1997 until 2021, skipping 2020)
- Constitutionalist Revolution (July 9 from 1997 until 2021, skipping 2020)
- Independence Day (September 7)
- Our Lady of Aparecida Feast (October 12)
- All Souls' Day (November 2)
- Proclamation of the Republic (November 15)
- Day of Black Awareness (November 20 after 2004 until 2021, skipping 2020)
- Day of Black Awareness, municipal holiday for the city of São Paulo (November 20 from 2004 until 2021, skipping 2020)
- Day of Black Awareness, national holiday (November 20 starting in 2024)
- Christmas (December 24 and 25)
- Day before New Year's Eve (December 30 if NYE falls on a Saturday)
- Friday before New Year's Eve (December 30 or 29 if NYE falls on a Saturday or Sunday, respectively)
- New Year's Eve (December 31)
"""

Expand Down Expand Up @@ -190,10 +205,12 @@ def regular_holidays(self):
Finados,
ProclamacaoRepublica,
ConscienciaNegra,
ConscienciaNegraNacional,
VesperaNatal,
Natal,
AnoNovo,
AnoNovoSabado,
AnoNovoDomingo,
]
)

Expand Down
14 changes: 14 additions & 0 deletions pandas_market_calendars/calendars/bse.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,20 @@
Timestamp("2023-11-14", tz="UTC"), # Tue, Diwali
Timestamp("2023-11-27", tz="UTC"), # Mon, Guru Nanak's Birthday
Timestamp("2023-12-25", tz="UTC"), # Mon, Christmas
Timestamp("2024-01-26", tz="UTC"), # Fri, Republic Day
Timestamp("2024-03-08", tz="UTC"), # Fri, Mahashivratri
Timestamp("2024-03-25", tz="UTC"), # Mon, Holi
Timestamp("2024-03-29", tz="UTC"), # Fri, Good Friday
Timestamp("2024-04-11", tz="UTC"), # Thu, Id-Ul-Fitr (Ramadan Eid)
Timestamp("2024-04-17", tz="UTC"), # Wed, Shri Ram Navmi
Timestamp("2024-05-01", tz="UTC"), # Wed, Maharashtra Din
Timestamp("2024-06-17", tz="UTC"), # Mon, Bakri Id / Eid ul-Adha
Timestamp("2024-07-17", tz="UTC"), # Wed, Moharram
Timestamp("2024-08-15", tz="UTC"), # Thu, Independence Day
Timestamp("2024-10-02", tz="UTC"), # Wed, Mahatma Gandhi Jayanti
Timestamp("2024-11-01", tz="UTC"), # Fri, Diwali
Timestamp("2024-11-15", tz="UTC"), # Fri, Guru Nanak's Birthday
Timestamp("2024-12-25", tz="UTC"), # Wed, Christmas
]


Expand Down
4 changes: 4 additions & 0 deletions pandas_market_calendars/calendars/sifma.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
ThursdayBeforeUSIndependenceDay2pmEarlyClose,
USLaborDay,
USColumbusDay,
USVeteransDay2022,
USVeteransDay,
USThanksgivingDay,
DayAfterThanksgiving2pmEarlyClose,
Expand Down Expand Up @@ -126,6 +127,7 @@ def regular_holidays(self):
USIndependenceDay,
USLaborDay,
USColumbusDay,
USVeteransDay2022,
USVeteransDay,
USThanksgivingDay,
Christmas,
Expand Down Expand Up @@ -221,6 +223,7 @@ def regular_holidays(self):
UKSummerBank,
USLaborDay,
USColumbusDay,
USVeteransDay2022,
USVeteransDay,
USThanksgivingDay,
UKChristmas,
Expand Down Expand Up @@ -324,6 +327,7 @@ def regular_holidays(self):
JapanSportsDay2020,
JapanHealthAndSportsDay2000To2019,
JapanCultureDay,
USVeteransDay2022,
USVeteransDay,
JapanLaborThanksgivingDay,
USThanksgivingDay,
Expand Down
5 changes: 4 additions & 1 deletion pandas_market_calendars/holidays/jp.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@
)

JapanShowaDayUntil1972 = Holiday(
name="Showa Day", month=4, day=29, end_date=Timestamp(1972, 12, 31) # 1965
name="Showa Day",
month=4,
day=29,
end_date=Timestamp(1972, 12, 31), # 1965
)

JapanShowaDay = Holiday(
Expand Down
14 changes: 13 additions & 1 deletion pandas_market_calendars/holidays/sifma.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@
# 2021 is early close.
# 2022 is a full holiday.
# 2023 is early close.
# 2024 is a full holiday
GoodFridayAdHoc = [
Timestamp("2022-04-15", tz="UTC"),
Timestamp("2024-03-29", tz="UTC"),
]

GoodFriday2pmEarlyCloseAdHoc = [
Expand All @@ -119,6 +121,7 @@

DayBeforeGoodFriday2pmEarlyCloseAdHoc = [
Timestamp("2022-04-14", tz="UTC"),
Timestamp("2024-03-28", tz="UTC"),
]

##################################################
Expand Down Expand Up @@ -201,11 +204,20 @@
# When falls on Saturday, no holiday is observed.
# When falls on Sunday, the Monday following is a holiday.
##########################################################
USVeteransDay2022 = Holiday(
"Veterans Day Prior to 2023",
month=11,
day=11,
end_date=Timestamp("2022-12-31"),
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
observance=sunday_to_monday,
)

USVeteransDay = Holiday(
"Veterans Day",
month=11,
day=11,
end_date=Timestamp("2022-12-31"),
start_date=Timestamp("2023-12-31"),
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
observance=sunday_to_monday,
)
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[project]
name = "pandas_market_calendars"
version = "4.3.3"
version = "4.4.0"
authors = [
{ name = "Ryan Sheftel", email = "rsheftel@alumni.upenn.edu" },
]
description = "Market and exchange trading calendars for pandas"
readme = "README.rst"
requires-python = ">=3.8"
requires-python = ">=3.9"
keywords = ["trading", "exchanges", "markets", "OTC", "datetime", "holiday", "business days"]
license = { text = "MIT" }
classifiers = [
Expand All @@ -17,15 +17,15 @@ classifiers = [
# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: MIT License',
# Specify the Python versions you support here.
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
]
dependencies = ['pandas>=1.1, <2.0', 'pytz', 'python-dateutil', 'exchange-calendars>=3.3']
dependencies = ['pandas>=1.1', 'pytz', 'python-dateutil', 'exchange-calendars>=3.3']

[project.optional-dependencies]
dev = ['pytest', 'black==23.7.0', 'pre-commit']
dev = ['pytest', 'black', 'pre-commit']

[build-system]
requires = ["setuptools>=61.0", "wheel"]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_XNYS_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import pandas as pd
import pytz
from zoneinfo import ZoneInfo
from pandas.testing import assert_index_equal

import pandas_market_calendars as mcal
Expand All @@ -16,7 +16,7 @@ def test_weekmask():


def test_time_zone():
assert xnys_cal.tz == pytz.timezone("America/New_York")
assert xnys_cal.tz == ZoneInfo("America/New_York")
assert xnys_cal.name == "XNYS"


Expand Down
37 changes: 35 additions & 2 deletions tests/test_bmf_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def test_time_zone():
def test_2020_holidays_skip():
# 2020-07-09 - skipped due to covid
# 2020-11-20 - skipped due to covid

holidays = BMFExchangeCalendar().holidays().holidays
for date in ["2019-07-09", "2019-11-20", "2021-07-09", "2021-11-20"]:
assert pd.Timestamp(date, tz="UTC").to_datetime64() in holidays
Expand All @@ -22,6 +23,8 @@ def test_2020_holidays_skip():

def test_post_2022_regulation_change():
# Regional holidays no longer observed: January 25th, July 9th, November 20th
# November 20th was reinstated as a national holiday starting in 2024

holidays = BMFExchangeCalendar().holidays().holidays

for year in [2017, 2018, 2019, 2021]: # skip 2020 due to test above
Expand All @@ -30,10 +33,40 @@ def test_post_2022_regulation_change():
pd.Timestamp(datetime.date(year, month, day), tz="UTC").to_datetime64()
in holidays
)

for year in range(2022, 2040):
for month, day in [(1, 25), (7, 9), (11, 20)]:
for month, day in [(1, 25), (7, 9)]:
assert (
pd.Timestamp(datetime.date(year, month, day), tz="UTC").to_datetime64()
not in holidays
)
for year in range(2022, 2024):
for month, day in [(11, 20)]:
assert (
pd.Timestamp(datetime.date(year, month, day), tz="UTC").to_datetime64()
not in holidays
)


def test_sunday_new_years_eve():
# All instances of December 29th on a Friday should be holidays

holidays = BMFExchangeCalendar().holidays().holidays

for year in range(1994, 2040):
date = pd.Timestamp(datetime.date(year, 12, 29), tz="UTC")
if date.day_of_week == 4:
# December 29th on a Friday

assert date.to_datetime64() in holidays


def test_post_2022_nov20():
# November 20th national holiday should be present from 2024

holidays = BMFExchangeCalendar().holidays().holidays

for year in range(2024, 2040):
assert (
pd.Timestamp(datetime.date(year, 11, 20), tz="UTC").to_datetime64()
in holidays
)
3 changes: 2 additions & 1 deletion tests/test_market_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from pandas.testing import assert_frame_equal, assert_index_equal, assert_series_equal
from pandas.tseries.holiday import AbstractHolidayCalendar
from pytz import timezone
from zoneinfo import ZoneInfo

from pandas_market_calendars import get_calendar, get_calendar_names
from pandas_market_calendars.calendars.mirror import TradingCalendar
Expand Down Expand Up @@ -1586,7 +1587,7 @@ def test_mirror():

def test_basic_information():
assert mcal_iepa._EC_NOT_INITIALIZED
assert mcal_iepa.tz == timezone("America/New_York") == ecal_iepa.tz
assert mcal_iepa.tz == ZoneInfo("America/New_York") == ecal_iepa.tz
assert mcal_iepa.open_offset == -1 == ecal_iepa.open_offset
assert mcal_iepa.open_time == time(20)
assert mcal_iepa.close_time == time(18)
Expand Down
Loading

0 comments on commit e3aa8a3

Please sign in to comment.