pandas-market-calendars 4.2.1__tar.gz → 4.3.1__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/PKG-INFO +4 -7
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/README.rst +3 -6
- pandas_market_calendars-4.3.1/pandas_market_calendars/calendar_registry.py +48 -0
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/pandas_market_calendars/calendar_utils.py +1 -1
- pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/__init__.py +0 -0
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_asx.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/asx.py +2 -2
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_bmf.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/bmf.py +1 -1
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_bse.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/bse.py +1 -1
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_cboe.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/cboe.py +15 -16
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_cme.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/cme.py +4 -4
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_cme_globex_agriculture.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/cme_globex_agriculture.py +5 -11
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_cme_globex_base.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/cme_globex_base.py +5 -8
- pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/cme_globex_crypto.py +147 -0
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_cme_globex_energy_and_metals.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +10 -18
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_cme_globex_equities.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/cme_globex_equities.py +3 -3
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_cme_globex_fixed_income.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/cme_globex_fixed_income.py +3 -4
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_cme_globex_fx.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/cme_globex_fx.py +3 -3
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_eurex.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/eurex.py +1 -1
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_hkex.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/hkex.py +3 -3
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_ice.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/ice.py +3 -3
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_iex.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/iex.py +2 -2
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_jpx.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/jpx.py +3 -3
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_lse.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/lse.py +2 -2
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendars_mirror.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/mirror.py +2 -2
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_nyse.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/nyse.py +2 -2
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_ose.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/ose.py +1 -1
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_sifma.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/sifma.py +7 -10
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_six.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/six.py +1 -1
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_sse.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/sse.py +2 -2
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_tase.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/tase.py +1 -1
- pandas_market_calendars-4.2.1/pandas_market_calendars/exchange_calendar_tsx.py → pandas_market_calendars-4.3.1/pandas_market_calendars/calendars/tsx.py +2 -2
- pandas_market_calendars-4.3.1/pandas_market_calendars/holidays/__init__.py +0 -0
- pandas_market_calendars-4.2.1/pandas_market_calendars/holidays_cme.py → pandas_market_calendars-4.3.1/pandas_market_calendars/holidays/cme.py +3 -4
- pandas_market_calendars-4.2.1/pandas_market_calendars/holidays_cme_globex.py → pandas_market_calendars-4.3.1/pandas_market_calendars/holidays/cme_globex.py +35 -6
- pandas_market_calendars-4.2.1/pandas_market_calendars/holidays_jp.py → pandas_market_calendars-4.3.1/pandas_market_calendars/holidays/jp.py +1 -1
- pandas_market_calendars-4.2.1/pandas_market_calendars/holidays_nyse.py → pandas_market_calendars-4.3.1/pandas_market_calendars/holidays/nyse.py +3 -5
- pandas_market_calendars-4.2.1/pandas_market_calendars/holidays_us.py → pandas_market_calendars-4.3.1/pandas_market_calendars/holidays/us.py +1 -5
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/pandas_market_calendars/market_calendar.py +28 -9
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/pandas_market_calendars.egg-info/PKG-INFO +4 -7
- pandas_market_calendars-4.3.1/pandas_market_calendars.egg-info/SOURCES.txt +81 -0
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/pyproject.toml +2 -2
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_asx_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_bmf_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_bse_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_cboe_calendars.py +1 -3
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_cme_agriculture_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_cme_bond_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_cme_equity_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_eurex_calendar.py +1 -1
- pandas_market_calendars-4.3.1/tests/test_exchange_calendar_cme_globex_crypto.py +286 -0
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_exchange_calendar_cme_globex_energy_and_metals.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_exchange_calendar_cme_globex_equities.py +1 -2
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_exchange_calendar_cme_globex_fixed_income.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_exchange_calendar_cme_globex_fx.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_hkex_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_ice_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_iex_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_jpx_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_lse_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_market_calendar.py +29 -20
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_nyse_calendar.py +2 -2
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_nyse_calendar_early_years.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_ose_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_sifma_calendars.py +3 -3
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_six_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_sse_calendar.py +2 -2
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_tsx_calendar.py +1 -1
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_utils.py +1 -1
- pandas_market_calendars-4.2.1/pandas_market_calendars/calendar_registry.py +0 -47
- pandas_market_calendars-4.2.1/pandas_market_calendars.egg-info/SOURCES.txt +0 -77
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/LICENSE +0 -0
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/NOTICE +0 -0
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/pandas_market_calendars/__init__.py +0 -0
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/pandas_market_calendars/class_registry.py +0 -0
- /pandas_market_calendars-4.2.1/pandas_market_calendars/holidays_cn.py → /pandas_market_calendars-4.3.1/pandas_market_calendars/holidays/cn.py +0 -0
- {pandas_market_calendars-4.2.1/pandas_market_calendars → pandas_market_calendars-4.3.1/pandas_market_calendars/holidays}/jpx_equinox.py +0 -0
- /pandas_market_calendars-4.2.1/pandas_market_calendars/holidays_oz.py → /pandas_market_calendars-4.3.1/pandas_market_calendars/holidays/oz.py +0 -0
- /pandas_market_calendars-4.2.1/pandas_market_calendars/holidays_sifma.py → /pandas_market_calendars-4.3.1/pandas_market_calendars/holidays/sifma.py +0 -0
- /pandas_market_calendars-4.2.1/pandas_market_calendars/holidays_uk.py → /pandas_market_calendars-4.3.1/pandas_market_calendars/holidays/uk.py +0 -0
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/pandas_market_calendars.egg-info/dependency_links.txt +0 -0
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/pandas_market_calendars.egg-info/requires.txt +0 -0
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/pandas_market_calendars.egg-info/top_level.txt +0 -0
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/setup.cfg +0 -0
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_XNYS_calendar.py +0 -0
- {pandas_market_calendars-4.2.1 → pandas_market_calendars-4.3.1}/tests/test_class_registry.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pandas_market_calendars
|
3
|
-
Version: 4.
|
3
|
+
Version: 4.3.1
|
4
4
|
Summary: Market and exchange trading calendars for pandas
|
5
5
|
Author-email: Ryan Sheftel <rsheftel@alumni.upenn.edu>
|
6
6
|
License: MIT
|
@@ -31,16 +31,13 @@ Market calendars to use with pandas for trading applications.
|
|
31
31
|
.. image:: https://badge.fury.io/py/pandas-market-calendars.svg
|
32
32
|
:target: https://badge.fury.io/py/pandas-market-calendars
|
33
33
|
|
34
|
-
.. image:: https://travis-ci.com/rsheftel/pandas_market_calendars.svg?branch=master
|
35
|
-
:target: https://travis-ci.com/rsheftel/pandas_market_calendars
|
36
|
-
|
37
|
-
.. image:: https://coveralls.io/repos/github/rsheftel/pandas_market_calendars/badge.svg?branch=master
|
38
|
-
:target: https://coveralls.io/github/rsheftel/pandas_market_calendars?branch=master
|
39
|
-
|
40
34
|
.. image:: https://readthedocs.org/projects/pandas-market-calendars/badge/?version=latest
|
41
35
|
:target: http://pandas-market-calendars.readthedocs.io/en/latest/?badge=latest
|
42
36
|
:alt: Documentation Status
|
43
37
|
|
38
|
+
.. image:: https://coveralls.io/repos/github/rsheftel/pandas_market_calendars/badge.svg?branch=master
|
39
|
+
:target: https://coveralls.io/github/rsheftel/pandas_market_calendars?branch=master
|
40
|
+
|
44
41
|
Documentation
|
45
42
|
-------------
|
46
43
|
http://pandas-market-calendars.readthedocs.io/en/latest/
|
@@ -5,16 +5,13 @@ Market calendars to use with pandas for trading applications.
|
|
5
5
|
.. image:: https://badge.fury.io/py/pandas-market-calendars.svg
|
6
6
|
:target: https://badge.fury.io/py/pandas-market-calendars
|
7
7
|
|
8
|
-
.. image:: https://travis-ci.com/rsheftel/pandas_market_calendars.svg?branch=master
|
9
|
-
:target: https://travis-ci.com/rsheftel/pandas_market_calendars
|
10
|
-
|
11
|
-
.. image:: https://coveralls.io/repos/github/rsheftel/pandas_market_calendars/badge.svg?branch=master
|
12
|
-
:target: https://coveralls.io/github/rsheftel/pandas_market_calendars?branch=master
|
13
|
-
|
14
8
|
.. image:: https://readthedocs.org/projects/pandas-market-calendars/badge/?version=latest
|
15
9
|
:target: http://pandas-market-calendars.readthedocs.io/en/latest/?badge=latest
|
16
10
|
:alt: Documentation Status
|
17
11
|
|
12
|
+
.. image:: https://coveralls.io/repos/github/rsheftel/pandas_market_calendars/badge.svg?branch=master
|
13
|
+
:target: https://coveralls.io/github/rsheftel/pandas_market_calendars?branch=master
|
14
|
+
|
18
15
|
Documentation
|
19
16
|
-------------
|
20
17
|
http://pandas-market-calendars.readthedocs.io/en/latest/
|
@@ -0,0 +1,48 @@
|
|
1
|
+
from .market_calendar import MarketCalendar
|
2
|
+
from .calendars.asx import ASXExchangeCalendar
|
3
|
+
from .calendars.bmf import BMFExchangeCalendar
|
4
|
+
from .calendars.bse import BSEExchangeCalendar
|
5
|
+
from .calendars.cboe import CFEExchangeCalendar
|
6
|
+
from .calendars.cme import \
|
7
|
+
CMEEquityExchangeCalendar, \
|
8
|
+
CMEBondExchangeCalendar
|
9
|
+
from .calendars.cme_globex_base import CMEGlobexBaseExchangeCalendar
|
10
|
+
from .calendars.cme_globex_agriculture import CMEGlobexAgricultureExchangeCalendar
|
11
|
+
from .calendars.cme_globex_crypto import CMEGlobexCryptoExchangeCalendar
|
12
|
+
from .calendars.cme_globex_energy_and_metals import CMEGlobexEnergyAndMetalsExchangeCalendar
|
13
|
+
from .calendars.cme_globex_equities import CMEGlobexEquitiesExchangeCalendar
|
14
|
+
from .calendars.cme_globex_fx import CMEGlobexFXExchangeCalendar
|
15
|
+
from .calendars.cme_globex_fixed_income import CMEGlobexFixedIncomeCalendar
|
16
|
+
from .calendars.eurex import EUREXExchangeCalendar
|
17
|
+
from .calendars.hkex import HKEXExchangeCalendar
|
18
|
+
from .calendars.ice import ICEExchangeCalendar
|
19
|
+
from .calendars.iex import IEXExchangeCalendar
|
20
|
+
from .calendars.jpx import JPXExchangeCalendar
|
21
|
+
from .calendars.lse import LSEExchangeCalendar
|
22
|
+
from .calendars.nyse import NYSEExchangeCalendar
|
23
|
+
from .calendars.ose import OSEExchangeCalendar
|
24
|
+
from .calendars.sifma import SIFMAUSExchangeCalendar, SIFMAUKExchangeCalendar, SIFMAJPExchangeCalendar
|
25
|
+
from .calendars.six import SIXExchangeCalendar
|
26
|
+
from .calendars.sse import SSEExchangeCalendar
|
27
|
+
from .calendars.tase import TASEExchangeCalendar
|
28
|
+
from .calendars.tsx import TSXExchangeCalendar
|
29
|
+
from .calendars.mirror import *
|
30
|
+
|
31
|
+
|
32
|
+
def get_calendar(name, open_time=None, close_time=None) -> MarketCalendar:
|
33
|
+
"""
|
34
|
+
Retrieves an instance of an MarketCalendar whose name is given.
|
35
|
+
|
36
|
+
:param name: The name of the MarketCalendar to be retrieved.
|
37
|
+
:param open_time: Market open time override as datetime.time object. If None then default is used.
|
38
|
+
:param close_time: Market close time override as datetime.time object. If None then default is used.
|
39
|
+
:return: MarketCalendar of the desired calendar.
|
40
|
+
"""
|
41
|
+
return MarketCalendar.factory(name, open_time=open_time, close_time=close_time)
|
42
|
+
|
43
|
+
|
44
|
+
def get_calendar_names():
|
45
|
+
"""All Market Calendar names and aliases that can be used in "factory"
|
46
|
+
:return: list(str)
|
47
|
+
"""
|
48
|
+
return MarketCalendar.calendar_names()
|
@@ -14,7 +14,7 @@ def merge_schedules(schedules, how='outer'):
|
|
14
14
|
|
15
15
|
CAVEATS:
|
16
16
|
* This does not work for schedules with breaks, the break information will be lost.
|
17
|
-
*
|
17
|
+
* Only "market_open" and "market_close" are considered, other market times are not yet supported.
|
18
18
|
|
19
19
|
:param schedules: list of schedules
|
20
20
|
:param how: outer or inner
|
File without changes
|
@@ -3,8 +3,8 @@ from datetime import time
|
|
3
3
|
from pandas.tseries.holiday import AbstractHolidayCalendar, GoodFriday, EasterMonday
|
4
4
|
from pytz import timezone
|
5
5
|
|
6
|
-
from .
|
7
|
-
from .market_calendar import MarketCalendar
|
6
|
+
from pandas_market_calendars.holidays.oz import *
|
7
|
+
from pandas_market_calendars.market_calendar import MarketCalendar
|
8
8
|
|
9
9
|
AbstractHolidayCalendar.start_date = '2011-01-01'
|
10
10
|
|
@@ -19,7 +19,7 @@ from pandas import Timestamp
|
|
19
19
|
from pandas.tseries.holiday import AbstractHolidayCalendar, Day, Easter, GoodFriday, Holiday
|
20
20
|
from pytz import timezone
|
21
21
|
|
22
|
-
from .market_calendar import (FRIDAY, MarketCalendar)
|
22
|
+
from pandas_market_calendars.market_calendar import (FRIDAY, MarketCalendar)
|
23
23
|
|
24
24
|
# Universal Confraternization (new years day)
|
25
25
|
ConfUniversal = Holiday(
|
@@ -6,28 +6,29 @@ from pytz import timezone
|
|
6
6
|
from itertools import chain
|
7
7
|
import pandas as pd
|
8
8
|
|
9
|
-
from .
|
10
|
-
|
11
|
-
|
9
|
+
from pandas_market_calendars.holidays.us import (Christmas, USBlackFridayInOrAfter1993, USIndependenceDay, USMartinLutherKingJrAfter1998,
|
10
|
+
USMemorialDay, USNewYearsDay, HurricaneSandyClosings, USNationalDaysofMourning,
|
11
|
+
USJuneteenthAfter2022)
|
12
|
+
from pandas_market_calendars.market_calendar import MarketCalendar
|
12
13
|
|
13
14
|
|
14
|
-
# TODO: In pandas 2.0.3 this no longer works as the dt passed in is the entire matrix and not a single date
|
15
15
|
def good_friday_unless_christmas_nye_friday(dt):
|
16
16
|
"""
|
17
17
|
Good Friday is a valid trading day if Christmas Day or New Years Day fall
|
18
18
|
on a Friday.
|
19
19
|
"""
|
20
|
+
if isinstance(dt, pd.DatetimeIndex):
|
21
|
+
# Pandas < 2.1.0 will call with an index and fall-back to element by element
|
22
|
+
# Pandas == 2.1.0 will only call element by element
|
23
|
+
raise NotImplementedError()
|
24
|
+
|
20
25
|
year = dt.year
|
21
|
-
christmas_weekday = Christmas.observance(
|
22
|
-
|
23
|
-
).weekday()
|
24
|
-
nyd_weekday = USNewYearsDay.observance(
|
25
|
-
pd.Timestamp(year, 1, 1)
|
26
|
-
).weekday()
|
26
|
+
christmas_weekday = Christmas.observance(pd.Timestamp(year=year, month=12, day=25)).weekday()
|
27
|
+
nyd_weekday = USNewYearsDay.observance(pd.Timestamp(year=year, month=1, day=1)).weekday()
|
27
28
|
if christmas_weekday != 4 and nyd_weekday != 4:
|
28
|
-
return GoodFriday.
|
29
|
+
return GoodFriday.dates(pd.Timestamp(year=year, month=1, day=1), pd.Timestamp(year=year, month=12, day=31))[0]
|
29
30
|
else:
|
30
|
-
#
|
31
|
+
# Not a holiday so use NaT to ensure it gets removed
|
31
32
|
return pd.NaT
|
32
33
|
|
33
34
|
|
@@ -70,8 +71,8 @@ class CFEExchangeCalendar(MarketCalendar):
|
|
70
71
|
USNewYearsDay,
|
71
72
|
USMartinLutherKingJrAfter1998,
|
72
73
|
USPresidentsDay,
|
73
|
-
|
74
|
-
|
74
|
+
GoodFridayUnlessChristmasNYEFriday,
|
75
|
+
USJuneteenthAfter2022,
|
75
76
|
USIndependenceDay,
|
76
77
|
USMemorialDay,
|
77
78
|
USLaborDay,
|
@@ -112,5 +113,3 @@ class CBOEIndexOptionsExchangeCalendar(CFEExchangeCalendar):
|
|
112
113
|
"market_open": ((None, time(8, 30)),),
|
113
114
|
"market_close": ((None, time(15, 15)),)
|
114
115
|
}
|
115
|
-
|
116
|
-
|
@@ -20,10 +20,10 @@ from pandas import Timestamp
|
|
20
20
|
from pandas.tseries.holiday import AbstractHolidayCalendar, GoodFriday, USLaborDay, USPresidentsDay, USThanksgivingDay
|
21
21
|
from pytz import timezone
|
22
22
|
|
23
|
-
from .
|
24
|
-
|
25
|
-
|
26
|
-
from .market_calendar import MarketCalendar
|
23
|
+
from pandas_market_calendars.holidays.us import (Christmas, ChristmasEveBefore1993, ChristmasEveInOrAfter1993, USBlackFridayInOrAfter1993,
|
24
|
+
USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay, USNationalDaysofMourning,
|
25
|
+
USNewYearsDay)
|
26
|
+
from pandas_market_calendars.market_calendar import MarketCalendar
|
27
27
|
|
28
28
|
|
29
29
|
# Useful resources for making changes to this file: http://www.cmegroup.com/tools-information/holiday-calendar.html
|
@@ -13,22 +13,16 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
|
-
from abc import
|
17
|
-
from .
|
16
|
+
from abc import abstractmethod
|
17
|
+
from .cme_globex_base import CMEGlobexBaseExchangeCalendar
|
18
18
|
|
19
19
|
from datetime import time
|
20
|
-
from itertools import chain
|
21
20
|
|
22
|
-
from pandas import Timestamp
|
23
21
|
from pandas.tseries.holiday import AbstractHolidayCalendar, GoodFriday, USLaborDay, USPresidentsDay, USThanksgivingDay
|
24
|
-
from pytz import timezone
|
25
|
-
|
26
|
-
from .holidays_us import (Christmas, ChristmasEveBefore1993, ChristmasEveInOrAfter1993, USBlackFridayInOrAfter1993,
|
27
|
-
USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay, USJuneteenthAfter2022,
|
28
|
-
USNationalDaysofMourning, USNewYearsDay)
|
29
|
-
from .market_calendar import MarketCalendar
|
30
|
-
|
31
22
|
|
23
|
+
from pandas_market_calendars.holidays.us import (Christmas, ChristmasEveBefore1993, ChristmasEveInOrAfter1993, USBlackFridayInOrAfter1993,
|
24
|
+
USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay,
|
25
|
+
USNewYearsDay)
|
32
26
|
|
33
27
|
|
34
28
|
class CMEGlobexAgricultureExchangeCalendar(CMEGlobexBaseExchangeCalendar):
|
@@ -15,17 +15,13 @@
|
|
15
15
|
|
16
16
|
from abc import ABC, abstractmethod
|
17
17
|
|
18
|
-
from datetime import time
|
19
|
-
from itertools import chain
|
20
|
-
|
21
|
-
from pandas import Timestamp
|
22
18
|
from pandas.tseries.holiday import AbstractHolidayCalendar, GoodFriday, USLaborDay, USPresidentsDay, USThanksgivingDay
|
23
19
|
from pytz import timezone
|
24
20
|
|
25
|
-
from .
|
26
|
-
|
27
|
-
|
28
|
-
from .market_calendar import MarketCalendar
|
21
|
+
from pandas_market_calendars.holidays.us import (Christmas, ChristmasEveBefore1993, ChristmasEveInOrAfter1993, USBlackFridayInOrAfter1993,
|
22
|
+
USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay, USJuneteenthAfter2022,
|
23
|
+
USNewYearsDay)
|
24
|
+
from pandas_market_calendars.market_calendar import MarketCalendar
|
29
25
|
|
30
26
|
|
31
27
|
class CMEGlobexBaseExchangeCalendar(MarketCalendar, ABC):
|
@@ -34,6 +30,7 @@ class CMEGlobexBaseExchangeCalendar(MarketCalendar, ABC):
|
|
34
30
|
|
35
31
|
CME Markets: https://www.cmegroup.com/markets/agriculture.html#overview
|
36
32
|
- Agriculture
|
33
|
+
- Crypto
|
37
34
|
- Energy
|
38
35
|
- Equity Index
|
39
36
|
- FX
|
@@ -0,0 +1,147 @@
|
|
1
|
+
import datetime as dt
|
2
|
+
|
3
|
+
from pandas.tseries.holiday import AbstractHolidayCalendar
|
4
|
+
import pytz
|
5
|
+
|
6
|
+
from .cme_globex_base import CMEGlobexBaseExchangeCalendar
|
7
|
+
from pandas_market_calendars.holidays.cme import (
|
8
|
+
GoodFriday2021,
|
9
|
+
GoodFridayAfter2021,
|
10
|
+
GoodFridayBefore2021,
|
11
|
+
USIndependenceDayBefore2022PreviousDay,
|
12
|
+
)
|
13
|
+
from pandas_market_calendars.holidays.cme_globex import (
|
14
|
+
ChristmasCME,
|
15
|
+
USMartinLutherKingJrFrom2022,
|
16
|
+
USMartinLutherKingJrPre2022,
|
17
|
+
USPresidentsDayFrom2022,
|
18
|
+
USPresidentsDayPre2022,
|
19
|
+
USMemorialDayFrom2022,
|
20
|
+
USMemorialDayPre2022,
|
21
|
+
USJuneteenthFrom2022,
|
22
|
+
USIndependenceDayFrom2022,
|
23
|
+
USIndependenceDayPre2022,
|
24
|
+
USLaborDayFrom2022,
|
25
|
+
USLaborDayPre2022,
|
26
|
+
USThanksgivingDayFrom2022,
|
27
|
+
USThanksgivingDayPre2022,
|
28
|
+
USThanksgivingFridayFrom2021,
|
29
|
+
USThanksgivingFridayPre2021,
|
30
|
+
)
|
31
|
+
from pandas_market_calendars.holidays.us import (
|
32
|
+
ChristmasEveInOrAfter1993,
|
33
|
+
USNewYearsDay,
|
34
|
+
)
|
35
|
+
|
36
|
+
|
37
|
+
# https://github.com/rsheftel/pandas_market_calendars/blob/master/docs/new_market.rst
|
38
|
+
class CMEGlobexCryptoExchangeCalendar(CMEGlobexBaseExchangeCalendar):
|
39
|
+
# The label you fetch the exchange with in mcal.get_calendar('CME Globex ...')
|
40
|
+
aliases = ["CME Globex Cryptocurrencies", "CME Globex Crypto"]
|
41
|
+
|
42
|
+
# https://www.cmegroup.com/markets/cryptocurrencies/bitcoin/bitcoin.contractSpecs.html
|
43
|
+
regular_market_times = {
|
44
|
+
# Tuple[Tuple[first date used, time, offset], ...]
|
45
|
+
# -1 offset indicates that the open is on the previous day
|
46
|
+
# None for first date used marks the start, subsequent market times must have an actual timestamp
|
47
|
+
"market_open": (
|
48
|
+
(None, dt.time(17, tzinfo=pytz.timezone("America/Chicago")), -1),
|
49
|
+
),
|
50
|
+
"market_close": (
|
51
|
+
(
|
52
|
+
None,
|
53
|
+
dt.time(16, tzinfo=pytz.timezone("America/Chicago")),
|
54
|
+
),
|
55
|
+
),
|
56
|
+
"break_start": (
|
57
|
+
(
|
58
|
+
None,
|
59
|
+
dt.time(16, tzinfo=pytz.timezone("America/Chicago")),
|
60
|
+
),
|
61
|
+
),
|
62
|
+
"break_end": (
|
63
|
+
(
|
64
|
+
None,
|
65
|
+
dt.time(17, tzinfo=pytz.timezone("America/Chicago")),
|
66
|
+
),
|
67
|
+
),
|
68
|
+
}
|
69
|
+
|
70
|
+
@property
|
71
|
+
def tz(self):
|
72
|
+
# Central Time
|
73
|
+
return pytz.timezone("America/Chicago")
|
74
|
+
|
75
|
+
@property
|
76
|
+
def name(self):
|
77
|
+
return "CME Globex Crypto"
|
78
|
+
|
79
|
+
# Check the .zip files at the bottom of this page
|
80
|
+
# https://www.cmegroup.com/tools-information/holiday-calendar.html?redirect=/tools-information/holiday-calendar/#cmeGlobex
|
81
|
+
# Note: many of the holiday objects (ie. GoodFridayBefore2021) were originally made for equities and other markets
|
82
|
+
# and hence have a start_date starting before crypto is actually available
|
83
|
+
|
84
|
+
@property
|
85
|
+
def regular_holidays(self):
|
86
|
+
# Days where the market is fully closed
|
87
|
+
return AbstractHolidayCalendar(
|
88
|
+
rules=[
|
89
|
+
GoodFridayBefore2021,
|
90
|
+
GoodFridayAfter2021,
|
91
|
+
ChristmasCME,
|
92
|
+
USNewYearsDay,
|
93
|
+
]
|
94
|
+
)
|
95
|
+
|
96
|
+
@property
|
97
|
+
def special_closes(self):
|
98
|
+
# Days where the market closes early
|
99
|
+
# list[Tuple[time, AbstractHolidayCalendar]]
|
100
|
+
return [
|
101
|
+
(
|
102
|
+
dt.time(8, 15, tzinfo=pytz.timezone("America/Chicago")),
|
103
|
+
AbstractHolidayCalendar(rules=[GoodFriday2021]),
|
104
|
+
),
|
105
|
+
(
|
106
|
+
dt.time(12, tzinfo=pytz.timezone("America/Chicago")),
|
107
|
+
AbstractHolidayCalendar(
|
108
|
+
rules=[
|
109
|
+
USMartinLutherKingJrPre2022,
|
110
|
+
USPresidentsDayPre2022,
|
111
|
+
USMemorialDayPre2022,
|
112
|
+
USIndependenceDayPre2022,
|
113
|
+
USLaborDayPre2022,
|
114
|
+
USThanksgivingDayPre2022,
|
115
|
+
]
|
116
|
+
),
|
117
|
+
),
|
118
|
+
(
|
119
|
+
dt.time(12, 15, tzinfo=pytz.timezone("America/Chicago")),
|
120
|
+
AbstractHolidayCalendar(
|
121
|
+
rules=[
|
122
|
+
ChristmasEveInOrAfter1993,
|
123
|
+
USIndependenceDayBefore2022PreviousDay,
|
124
|
+
USThanksgivingFridayPre2021,
|
125
|
+
]
|
126
|
+
),
|
127
|
+
),
|
128
|
+
(
|
129
|
+
dt.time(12, 45, tzinfo=pytz.timezone("America/Chicago")),
|
130
|
+
AbstractHolidayCalendar(rules=[USThanksgivingFridayFrom2021]),
|
131
|
+
),
|
132
|
+
# TODO: this market already closes at 1600 normally, do we need these holidays?
|
133
|
+
(
|
134
|
+
dt.time(16, tzinfo=pytz.timezone("America/Chicago")),
|
135
|
+
AbstractHolidayCalendar(
|
136
|
+
rules=[
|
137
|
+
USMartinLutherKingJrFrom2022,
|
138
|
+
USPresidentsDayFrom2022,
|
139
|
+
USMemorialDayFrom2022,
|
140
|
+
USJuneteenthFrom2022,
|
141
|
+
USIndependenceDayFrom2022,
|
142
|
+
USLaborDayFrom2022,
|
143
|
+
USThanksgivingDayFrom2022,
|
144
|
+
]
|
145
|
+
),
|
146
|
+
),
|
147
|
+
]
|
@@ -13,14 +13,10 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
|
-
from
|
17
|
-
from .exchange_calendar_cme_globex_base import CMEGlobexBaseExchangeCalendar
|
16
|
+
from .cme_globex_base import CMEGlobexBaseExchangeCalendar
|
18
17
|
|
19
18
|
from datetime import time
|
20
|
-
from itertools import chain
|
21
19
|
|
22
|
-
import pandas as pd
|
23
|
-
from pandas import Timestamp
|
24
20
|
from pandas.tseries.holiday import AbstractHolidayCalendar #, GoodFriday, USLaborDay, USPresidentsDay, USThanksgivingDay
|
25
21
|
from pytz import timezone
|
26
22
|
|
@@ -28,19 +24,15 @@ from pytz import timezone
|
|
28
24
|
# USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay, USJuneteenthAfter2022,
|
29
25
|
# USNationalDaysofMourning, USNewYearsDay)
|
30
26
|
|
31
|
-
from .
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
ChristmasCME)
|
41
|
-
from .market_calendar import MarketCalendar
|
42
|
-
|
43
|
-
|
27
|
+
from pandas_market_calendars.holidays.cme_globex import (USMartinLutherKingJrFrom2022, USMartinLutherKingJrPre2022, USNewYearsDay,
|
28
|
+
USPresidentsDayFrom2022, USPresidentsDayPre2022,
|
29
|
+
GoodFriday,
|
30
|
+
USMemorialDayFrom2022, USMemorialDayPre2022,
|
31
|
+
USJuneteenthFrom2022,
|
32
|
+
USIndependenceDayFrom2022, USIndependenceDayPre2022,
|
33
|
+
USLaborDay,
|
34
|
+
USThanksgivingDayFrom2022, USThanksgivingDayPre2022, FridayAfterThanksgiving,
|
35
|
+
ChristmasCME)
|
44
36
|
|
45
37
|
|
46
38
|
class CMEGlobexEnergyAndMetalsExchangeCalendar(CMEGlobexBaseExchangeCalendar):
|
@@ -1,10 +1,10 @@
|
|
1
|
-
from .
|
1
|
+
from .cme_globex_base import CMEGlobexBaseExchangeCalendar
|
2
2
|
|
3
3
|
from datetime import time
|
4
4
|
from pandas.tseries.holiday import AbstractHolidayCalendar
|
5
5
|
from pytz import timezone
|
6
6
|
|
7
|
-
from pandas_market_calendars.
|
7
|
+
from pandas_market_calendars.holidays.cme import (
|
8
8
|
USMartinLutherKingJrAfter1998Before2015,
|
9
9
|
USMartinLutherKingJrAfter2015,
|
10
10
|
USPresidentsDayBefore2015,
|
@@ -26,7 +26,7 @@ from pandas_market_calendars.holidays_cme import (
|
|
26
26
|
USThanksgivingAfter2014,
|
27
27
|
USThanksgivingFriday,
|
28
28
|
)
|
29
|
-
from pandas_market_calendars.
|
29
|
+
from pandas_market_calendars.holidays.us import (
|
30
30
|
USNewYearsDay,
|
31
31
|
ChristmasEveInOrAfter1993,
|
32
32
|
Christmas,
|
@@ -1,10 +1,9 @@
|
|
1
|
-
from .
|
1
|
+
from .cme_globex_base import CMEGlobexBaseExchangeCalendar
|
2
2
|
|
3
3
|
from datetime import time
|
4
4
|
from pandas.tseries.holiday import AbstractHolidayCalendar
|
5
|
-
from pytz import timezone
|
6
5
|
|
7
|
-
from pandas_market_calendars.
|
6
|
+
from pandas_market_calendars.holidays.cme import (
|
8
7
|
USMartinLutherKingJrAfter1998Before2015,
|
9
8
|
USMartinLutherKingJrAfter1998Before2016FridayBefore,
|
10
9
|
USMartinLutherKingJrAfter2015,
|
@@ -30,7 +29,7 @@ from pandas_market_calendars.holidays_cme import (
|
|
30
29
|
USThanksgivingAfter2014,
|
31
30
|
USThanksgivingFriday,
|
32
31
|
)
|
33
|
-
from pandas_market_calendars.
|
32
|
+
from pandas_market_calendars.holidays.us import (
|
34
33
|
USNewYearsDay,
|
35
34
|
ChristmasEveInOrAfter1993,
|
36
35
|
Christmas,
|
@@ -2,8 +2,8 @@ from datetime import time
|
|
2
2
|
|
3
3
|
from pandas.tseries.holiday import AbstractHolidayCalendar
|
4
4
|
|
5
|
-
from pandas_market_calendars.
|
6
|
-
from pandas_market_calendars.
|
5
|
+
from pandas_market_calendars.calendars.cme_globex_base import CMEGlobexBaseExchangeCalendar
|
6
|
+
from pandas_market_calendars.holidays.cme import (
|
7
7
|
USMartinLutherKingJrAfter1998Before2022,
|
8
8
|
USPresidentsDayBefore2022,
|
9
9
|
GoodFridayBefore2021,
|
@@ -15,7 +15,7 @@ from pandas_market_calendars.holidays_cme import (
|
|
15
15
|
USThanksgivingBefore2022,
|
16
16
|
USThanksgivingFriday,
|
17
17
|
)
|
18
|
-
from pandas_market_calendars.
|
18
|
+
from pandas_market_calendars.holidays.us import (
|
19
19
|
USNewYearsDay,
|
20
20
|
ChristmasEveInOrAfter1993,
|
21
21
|
Christmas,
|
@@ -7,7 +7,7 @@ from datetime import time
|
|
7
7
|
from pandas.tseries.holiday import AbstractHolidayCalendar, EasterMonday, GoodFriday, Holiday, previous_friday
|
8
8
|
from pytz import timezone
|
9
9
|
|
10
|
-
from .market_calendar import (FRIDAY, MONDAY, MarketCalendar, THURSDAY, TUESDAY, WEDNESDAY)
|
10
|
+
from pandas_market_calendars.market_calendar import (FRIDAY, MONDAY, MarketCalendar, THURSDAY, TUESDAY, WEDNESDAY)
|
11
11
|
|
12
12
|
# New Year's Eve
|
13
13
|
EUREXNewYearsEve = Holiday(
|
@@ -6,9 +6,9 @@ from pandas.tseries.holiday import AbstractHolidayCalendar, EasterMonday, GoodFr
|
|
6
6
|
from pandas.tseries.offsets import LastWeekOfMonth, WeekOfMonth
|
7
7
|
from pytz import timezone
|
8
8
|
|
9
|
-
from pandas_market_calendars.
|
10
|
-
from .
|
11
|
-
from .market_calendar import MarketCalendar
|
9
|
+
from pandas_market_calendars.holidays.us import USNewYearsDay
|
10
|
+
from pandas_market_calendars.holidays.cn import bsd_mapping, dbf_mapping, dnf_mapping, maf_mapping, sf_mapping, tsd_mapping
|
11
|
+
from pandas_market_calendars.market_calendar import MarketCalendar
|
12
12
|
|
13
13
|
|
14
14
|
def process_date(dt, mapping=None, func=None, delta=None, offset=None):
|
@@ -5,9 +5,9 @@ from pandas import Timestamp
|
|
5
5
|
from pandas.tseries.holiday import AbstractHolidayCalendar, GoodFriday, USLaborDay, USPresidentsDay, USThanksgivingDay
|
6
6
|
from pytz import timezone
|
7
7
|
|
8
|
-
from .
|
9
|
-
|
10
|
-
from .market_calendar import MarketCalendar
|
8
|
+
from pandas_market_calendars.holidays.us import (Christmas, USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay,
|
9
|
+
USNationalDaysofMourning, USNewYearsDay)
|
10
|
+
from pandas_market_calendars.market_calendar import MarketCalendar
|
11
11
|
|
12
12
|
|
13
13
|
class ICEExchangeCalendar(MarketCalendar):
|
@@ -1,10 +1,10 @@
|
|
1
1
|
from datetime import time
|
2
2
|
from itertools import chain
|
3
|
-
from .
|
3
|
+
from .nyse import NYSEExchangeCalendar
|
4
4
|
from pandas.tseries.holiday import AbstractHolidayCalendar
|
5
5
|
from pytz import timezone
|
6
6
|
|
7
|
-
from pandas_market_calendars.
|
7
|
+
from pandas_market_calendars.holidays.nyse import (
|
8
8
|
USPresidentsDay,
|
9
9
|
GoodFriday,
|
10
10
|
USMemorialDay,
|
@@ -4,9 +4,9 @@ from itertools import chain
|
|
4
4
|
from pandas.tseries.holiday import AbstractHolidayCalendar
|
5
5
|
from pytz import timezone
|
6
6
|
|
7
|
-
from pandas_market_calendars.
|
8
|
-
from pandas_market_calendars.
|
9
|
-
from .market_calendar import MarketCalendar
|
7
|
+
from pandas_market_calendars.holidays.jp import *
|
8
|
+
from pandas_market_calendars.holidays.us import USNewYearsDay
|
9
|
+
from pandas_market_calendars.market_calendar import MarketCalendar
|
10
10
|
|
11
11
|
|
12
12
|
# TODO:
|
@@ -18,13 +18,13 @@ from datetime import time
|
|
18
18
|
from pandas.tseries.holiday import AbstractHolidayCalendar, EasterMonday, GoodFriday
|
19
19
|
from pytz import timezone
|
20
20
|
|
21
|
-
from .
|
21
|
+
from pandas_market_calendars.holidays.uk import (
|
22
22
|
BoxingDay, Christmas, ChristmasEve, LSENewYearsDay, LSENewYearsEve,
|
23
23
|
MayBank_pre_1995, MayBank_post_1995_pre_2020, MayBank_post_2020,
|
24
24
|
SpringBank_pre_2002, SpringBank_post_2002_pre_2012, SpringBank_post_2012_pre_2022, SpringBank_post_2022,
|
25
25
|
SummerBank, WeekendBoxingDay, WeekendChristmas, UniqueCloses,
|
26
26
|
)
|
27
|
-
from .market_calendar import MarketCalendar
|
27
|
+
from pandas_market_calendars.market_calendar import MarketCalendar
|
28
28
|
|
29
29
|
|
30
30
|
class LSEExchangeCalendar(MarketCalendar):
|
@@ -4,7 +4,7 @@ Imported calendars from the exchange_calendars project
|
|
4
4
|
GitHub: https://github.com/gerrymanoim/exchange_calendars
|
5
5
|
"""
|
6
6
|
|
7
|
-
from .market_calendar import MarketCalendar
|
7
|
+
from pandas_market_calendars.market_calendar import MarketCalendar
|
8
8
|
import exchange_calendars
|
9
9
|
|
10
10
|
|
@@ -106,7 +106,7 @@ for exchange in calendars:
|
|
106
106
|
cal = type(exchange, (TradingCalendar,), {'_ec_class': calendars[exchange],
|
107
107
|
'alias': [exchange],
|
108
108
|
'regular_market_times': regular_market_times})
|
109
|
-
locals()[exchange
|
109
|
+
locals()[f'{exchange}ExchangeCalendar'] = cal
|
110
110
|
|
111
111
|
|
112
112
|
|