Skip to content

Commit

Permalink
Merge pull request #266 from rsheftel/dev
Browse files Browse the repository at this point in the history
v4.2.0
  • Loading branch information
rsheftel authored Aug 21, 2023
2 parents bc642ec + 691ccbe commit da74cde
Show file tree
Hide file tree
Showing 21 changed files with 18,818 additions and 18,778 deletions.
2 changes: 1 addition & 1 deletion .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']
python-version: ['3.8', '3.9', '3.10', '3.11']

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
10 changes: 9 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Market calendars to use with pandas for trading applications.

Documentation
-------------
http://pandas_market_calendars.readthedocs.io/en/latest/
http://pandas-market-calendars.readthedocs.io/en/latest/

Overview
--------
Expand Down Expand Up @@ -159,3 +159,11 @@ Future
------
This package is open sourced under the MIT license. Everyone is welcome to add more exchanges or OTC markets, confirm
or correct the existing calendars, and generally do whatever they desire with this code.

Sponsor
-------
.. image:: https://www.tradinghours.com/img/logo-with-words.png
:target: https://www.tradinghours.com/data
:alt: TradingHours.com

`TradingHours.com <https://www.tradinghours.com>`_ provides the most accurate and comprehensive coverage of market holidays and trading hours data available. They cover over 900 markets around the world. Their data is continually monitored for changes and updated daily. `Learn more <https://www.tradinghours.com/data>`_
10 changes: 10 additions & 0 deletions docs/change_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@

Updates
-------
4.2.0 (08/20/2023)
~~~~~~~~~~~~~~
- CBOE GoodFriday special close is broken, reverted back to standard GoodFriday logic PR #265
- Fixed BSE Holiday PR #248 Issue #245
- Updated TASE Holidays 2022-2025 PR #263
- King Charles III's Coronation Day holiday to LSE calendar PR #255
- Added NYSE tests for 2024 and 2025 PR #259
- Deleted setup.cfg that was only used for flake8. Will move to Black in a future release
- Moved all setuptools build workflows to pyproject.toml and deleted setup.py

4.1.4 (02/04/2023)
~~~~~~~~~~~~~~
- Updated TASE Holidays 2022-2025
Expand Down
6 changes: 3 additions & 3 deletions pandas_market_calendars/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pkg_resources
from importlib import metadata

from .calendar_registry import get_calendar, get_calendar_names
from .calendar_utils import convert_freq, date_range, merge_schedules
Expand All @@ -23,8 +23,8 @@

# if running in development there may not be a package
try:
__version__ = pkg_resources.get_distribution('pandas_market_calendars').version
except pkg_resources.DistributionNotFound:
__version__ = metadata.version('pandas_market_calendars')
except metadata.PackageNotFoundError:
__version__ = 'development'

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion pandas_market_calendars/calendar_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from .exchange_calendars_mirror import *


def get_calendar(name, open_time=None, close_time=None):
def get_calendar(name, open_time=None, close_time=None) -> MarketCalendar:
"""
Retrieves an instance of an MarketCalendar whose name is given.
Expand Down
2 changes: 1 addition & 1 deletion pandas_market_calendars/exchange_calendar_bse.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
Timestamp('2022-10-26', tz='UTC'), # Diwali-Balipratipada
Timestamp('2022-11-08', tz='UTC'), # Guru Nanak Jayanti
Timestamp('2023-01-26', tz='UTC'), # Thu, Republic Day
Timestamp('2023-03-08', tz='UTC'), # Wed, Holi
Timestamp('2023-03-07', tz='UTC'), # Wed, Holi
Timestamp('2023-03-18', tz='UTC'), # Sat, Maha Shivaratri
Timestamp('2023-03-30', tz='UTC'), # Thu, Ramanavami
Timestamp('2023-04-04', tz='UTC'), # Tue, Mahavir Jayanthi
Expand Down
17 changes: 9 additions & 8 deletions pandas_market_calendars/exchange_calendar_cboe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@
from .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.
"""
year_str = str(dt.year)
year = dt.year
christmas_weekday = Christmas.observance(
pd.Timestamp(year_str+"-12-25")
pd.Timestamp(year, 12, 25)
).weekday()
nyd_weekday = USNewYearsDay.observance(
pd.Timestamp(year_str+"-01-01")
pd.Timestamp(year, 1, 1)
).weekday()
if christmas_weekday != 4 and nyd_weekday != 4:
return GoodFriday._apply_rule(
pd.Timestamp(str(dt.year)+"-"+str(dt.month)+"-"+str(dt.day))
)
return GoodFriday._apply_rule(dt)
else:
# compatibility for pandas 0.18.1
return pd.NaT
Expand Down Expand Up @@ -57,7 +56,6 @@ class CFEExchangeCalendar(MarketCalendar):
"market_close": ((None, time(15, 15)),)
}


@property
def name(self):
return "CFE"
Expand All @@ -72,7 +70,8 @@ def regular_holidays(self):
USNewYearsDay,
USMartinLutherKingJrAfter1998,
USPresidentsDay,
GoodFridayUnlessChristmasNYEFriday,
# GoodFridayUnlessChristmasNYEFriday, #TODO: When this is fixed can return to using it
GoodFriday,
USIndependenceDay,
USMemorialDay,
USLaborDay,
Expand All @@ -96,6 +95,7 @@ def adhoc_holidays(self):
USNationalDaysofMourning,
))


class CBOEEquityOptionsExchangeCalendar(CFEExchangeCalendar):
name = "CBOE_Equity_Options"
aliases = [name]
Expand All @@ -104,6 +104,7 @@ class CBOEEquityOptionsExchangeCalendar(CFEExchangeCalendar):
"market_close": ((None, time(15)),)
}


class CBOEIndexOptionsExchangeCalendar(CFEExchangeCalendar):
name = "CBOE_Index_Options"
aliases = [name]
Expand Down
7 changes: 6 additions & 1 deletion pandas_market_calendars/exchange_calendar_jpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def adhoc_holidays(self):
FuneralShowa,
EnthronementDays,
AutumnalCitizenDates,
NoN225IndexPrices
NoN225IndexPrices,
EquityTradingSystemFailure
))

@property
Expand All @@ -74,9 +75,12 @@ def regular_holidays(self):
JapanMarineDay1996To2002,
JapanMarineDay2003To2019,
JapanMarineDay2020,
JapanMarineDay2021,
JapanMarineDay,
JapanMountainDay2016to2019,
JapanMountainDay2020,
JapanMountainDay2021,
JapanMountainDay2021NextDay,
JapanMountainDay,
JapanRespectForTheAgedDay1966To1972,
JapanRespectForTheAgedDay1973To2002,
Expand All @@ -86,6 +90,7 @@ def regular_holidays(self):
JapanHealthAndSportsDay1973To1999,
JapanHealthAndSportsDay2000To2019,
JapanSportsDay2020,
JapanSportsDay2021,
JapanSportsDay,
JapanCultureDayUntil1972,
JapanCultureDay,
Expand Down
Loading

0 comments on commit da74cde

Please sign in to comment.