pandas-market-calendars 4.3.0__py3-none-any.whl → 4.3.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. pandas_market_calendars/calendars/__init__.py +0 -0
  2. pandas_market_calendars/calendars/asx.py +63 -0
  3. pandas_market_calendars/calendars/bmf.py +227 -0
  4. pandas_market_calendars/calendars/bse.py +409 -0
  5. pandas_market_calendars/calendars/cboe.py +115 -0
  6. pandas_market_calendars/calendars/cme.py +240 -0
  7. pandas_market_calendars/calendars/cme_globex_agriculture.py +103 -0
  8. pandas_market_calendars/calendars/cme_globex_base.py +103 -0
  9. pandas_market_calendars/calendars/cme_globex_crypto.py +147 -0
  10. pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +138 -0
  11. pandas_market_calendars/calendars/cme_globex_equities.py +104 -0
  12. pandas_market_calendars/calendars/cme_globex_fixed_income.py +113 -0
  13. pandas_market_calendars/calendars/cme_globex_fx.py +78 -0
  14. pandas_market_calendars/calendars/eurex.py +119 -0
  15. pandas_market_calendars/calendars/hkex.py +408 -0
  16. pandas_market_calendars/calendars/ice.py +65 -0
  17. pandas_market_calendars/calendars/iex.py +98 -0
  18. pandas_market_calendars/calendars/jpx.py +103 -0
  19. pandas_market_calendars/calendars/lse.py +91 -0
  20. pandas_market_calendars/calendars/mirror.py +114 -0
  21. pandas_market_calendars/calendars/nyse.py +1127 -0
  22. pandas_market_calendars/calendars/ose.py +150 -0
  23. pandas_market_calendars/calendars/sifma.py +297 -0
  24. pandas_market_calendars/calendars/six.py +114 -0
  25. pandas_market_calendars/calendars/sse.py +290 -0
  26. pandas_market_calendars/calendars/tase.py +195 -0
  27. pandas_market_calendars/calendars/tsx.py +159 -0
  28. pandas_market_calendars/holidays/__init__.py +0 -0
  29. pandas_market_calendars/holidays/cme.py +340 -0
  30. pandas_market_calendars/holidays/cme_globex.py +198 -0
  31. pandas_market_calendars/holidays/cn.py +1436 -0
  32. pandas_market_calendars/holidays/jp.py +396 -0
  33. pandas_market_calendars/holidays/jpx_equinox.py +147 -0
  34. pandas_market_calendars/holidays/nyse.py +1472 -0
  35. pandas_market_calendars/holidays/oz.py +65 -0
  36. pandas_market_calendars/holidays/sifma.py +321 -0
  37. pandas_market_calendars/holidays/uk.py +180 -0
  38. pandas_market_calendars/holidays/us.py +360 -0
  39. {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/METADATA +1 -1
  40. pandas_market_calendars-4.3.1.dist-info/RECORD +49 -0
  41. pandas_market_calendars-4.3.0.dist-info/RECORD +0 -11
  42. {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/LICENSE +0 -0
  43. {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/NOTICE +0 -0
  44. {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/WHEEL +0 -0
  45. {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,91 @@
1
+ #
2
+ # Copyright 2016 Quantopian, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ from datetime import time
17
+
18
+ from pandas.tseries.holiday import AbstractHolidayCalendar, EasterMonday, GoodFriday
19
+ from pytz import timezone
20
+
21
+ from pandas_market_calendars.holidays.uk import (
22
+ BoxingDay, Christmas, ChristmasEve, LSENewYearsDay, LSENewYearsEve,
23
+ MayBank_pre_1995, MayBank_post_1995_pre_2020, MayBank_post_2020,
24
+ SpringBank_pre_2002, SpringBank_post_2002_pre_2012, SpringBank_post_2012_pre_2022, SpringBank_post_2022,
25
+ SummerBank, WeekendBoxingDay, WeekendChristmas, UniqueCloses,
26
+ )
27
+ from pandas_market_calendars.market_calendar import MarketCalendar
28
+
29
+
30
+ class LSEExchangeCalendar(MarketCalendar):
31
+ """
32
+ Exchange calendar for the London Stock Exchange
33
+
34
+ Open Time: 8:00 AM, GMT
35
+ Close Time: 4:30 PM, GMT
36
+
37
+ Regularly-Observed Holidays:
38
+ - New Years Day (observed on first business day on/after)
39
+ - Good Friday
40
+ - Easter Monday
41
+ - Early May Bank Holiday (first Monday in May)
42
+ - Spring Bank Holiday (last Monday in May)
43
+ - Summer Bank Holiday (last Monday in August)
44
+ - Christmas Day
45
+ - Dec. 27th (if Christmas is on a weekend)
46
+ - Boxing Day
47
+ - Dec. 28th (if Boxing Day is on a weekend)
48
+ """
49
+ aliases = ['LSE']
50
+ regular_market_times = {
51
+ "market_open": ((None, time(8)),),
52
+ "market_close": ((None, time(16,30)),),
53
+
54
+ }
55
+
56
+ @property
57
+ def name(self):
58
+ return "LSE"
59
+
60
+ @property
61
+ def tz(self):
62
+ return timezone('Europe/London')
63
+
64
+ @property
65
+ def regular_holidays(self):
66
+ return AbstractHolidayCalendar(rules=[
67
+ LSENewYearsDay,
68
+ GoodFriday,
69
+ EasterMonday,
70
+ MayBank_pre_1995, MayBank_post_1995_pre_2020, MayBank_post_2020,
71
+ SpringBank_pre_2002, SpringBank_post_2002_pre_2012, SpringBank_post_2012_pre_2022, SpringBank_post_2022,
72
+ SummerBank,
73
+ Christmas,
74
+ WeekendChristmas,
75
+ BoxingDay,
76
+ WeekendBoxingDay
77
+ ])
78
+
79
+ @property
80
+ def adhoc_holidays(self):
81
+ return UniqueCloses
82
+
83
+ @property
84
+ def special_closes(self):
85
+ return [(
86
+ time(12, 30),
87
+ AbstractHolidayCalendar(rules=[
88
+ ChristmasEve,
89
+ LSENewYearsEve,
90
+ ])
91
+ )]
@@ -0,0 +1,114 @@
1
+ """
2
+ Imported calendars from the exchange_calendars project
3
+
4
+ GitHub: https://github.com/gerrymanoim/exchange_calendars
5
+ """
6
+
7
+ from pandas_market_calendars.market_calendar import MarketCalendar
8
+ import exchange_calendars
9
+
10
+
11
+ class TradingCalendar(MarketCalendar):
12
+ """
13
+ This class provides access to all the information on opens, breaks and closes that are available
14
+ in the exchange_calendars package, it will receive the correctly formatted regular_market_times
15
+ dictionary in the for-loop below.
16
+
17
+ The initialization of calendars from exchange_calendars, is bypassed until the `.ec` property is used,
18
+ which returns the initialized exchange_calendar calendar, which is only initialized the first time.
19
+ """
20
+ # flag indicating that offset still needs to be checked.
21
+ # A class attribute so we only do this once per class and not per instance
22
+ _FINALIZE_TRADING_CALENDAR = True
23
+
24
+ def __new__(cls, *args, **kwargs):
25
+ self = super().__new__(cls)
26
+ self._ec = super().__new__(cls._ec_class)
27
+ # flag indicating that mirrored class is not initialized yet, which we only want to do
28
+ # once per instance, if and only if the public `.ec` property is used.
29
+ self._EC_NOT_INITIALIZED = True
30
+
31
+ # offsets of exchange_calendar_mirrors are only available through the instance
32
+ if cls._FINALIZE_TRADING_CALENDAR:
33
+ if self._ec.open_offset:
34
+ cls.regular_market_times._set("market_open", tuple(
35
+ (t[0], t[1], self._ec.open_offset) for t in cls.regular_market_times["market_open"]))
36
+
37
+ if self._ec.close_offset:
38
+ cls.regular_market_times._set("market_close", tuple(
39
+ (t[0], t[1], self._ec.close_offset) for t in cls.regular_market_times["market_close"]))
40
+ cls._FINALIZE_TRADING_CALENDAR = False
41
+
42
+ self.__init__(*args, **kwargs)
43
+ return self
44
+
45
+ def __init__(self, open_time=None, close_time=None):
46
+ super().__init__(open_time, close_time)
47
+
48
+ @property
49
+ def ec(self):
50
+ if self._EC_NOT_INITIALIZED:
51
+ self._ec.__init__()
52
+ self._EC_NOT_INITIALIZED = False
53
+
54
+ return self._ec
55
+
56
+ @property
57
+ def name(self):
58
+ return self._ec.name
59
+
60
+ @property
61
+ def tz(self):
62
+ return self._ec.tz
63
+
64
+ @property
65
+ def regular_holidays(self):
66
+ return self._ec.regular_holidays
67
+
68
+ @property
69
+ def adhoc_holidays(self):
70
+ return self._ec.adhoc_holidays
71
+
72
+ @property
73
+ def special_opens(self):
74
+ return self._ec.special_opens
75
+
76
+ @property
77
+ def special_opens_adhoc(self):
78
+ return self._ec.special_opens_adhoc
79
+
80
+ @property
81
+ def special_closes(self):
82
+ return self._ec.special_closes
83
+
84
+ @property
85
+ def special_closes_adhoc(self):
86
+ return self._ec.special_closes_adhoc
87
+
88
+
89
+ calendars = exchange_calendars.calendar_utils._default_calendar_factories # noqa
90
+
91
+ time_props = dict(open_times= "market_open",
92
+ close_times= "market_close",
93
+ break_start_times= "break_start",
94
+ break_end_times= "break_end")
95
+
96
+ for exchange in calendars:
97
+ cal = calendars[exchange]
98
+
99
+ # this loop will set up the newly required regular_market_times dictionary
100
+ regular_market_times = {}
101
+ for prop, new in time_props.items():
102
+ times = getattr(cal, prop)
103
+ if times is None or isinstance(times, property): continue
104
+ regular_market_times[new] = times
105
+
106
+ cal = type(exchange, (TradingCalendar,), {'_ec_class': calendars[exchange],
107
+ 'alias': [exchange],
108
+ 'regular_market_times': regular_market_times})
109
+ locals()[f'{exchange}ExchangeCalendar'] = cal
110
+
111
+
112
+
113
+
114
+