Skip to content

Commit

Permalink
Optimize imports
Browse files Browse the repository at this point in the history
  • Loading branch information
rsheftel committed Nov 4, 2019
1 parent 17dfa08 commit 2d39d75
Show file tree
Hide file tree
Showing 35 changed files with 583 additions and 718 deletions.
8 changes: 5 additions & 3 deletions pandas_market_calendars/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .market_calendar import MarketCalendar
from .calendar_registry import get_calendar, get_calendar_names
from .calendar_utils import merge_schedules, date_range, convert_freq
import pkg_resources

from .calendar_registry import get_calendar, get_calendar_names
from .calendar_utils import convert_freq, date_range, merge_schedules
from .market_calendar import MarketCalendar

# if running in development there may not be a package
try:
__version__ = pkg_resources.get_distribution('pandas_market_calendars').version
Expand All @@ -28,6 +29,7 @@
__all__ = [
'MarketCalendar',
'get_calendar',
'get_calendar_names',
'merge_schedules',
'date_range',
'convert_freq'
Expand Down
13 changes: 0 additions & 13 deletions pandas_market_calendars/calendar_registry.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@

from .market_calendar import MarketCalendar
from .exchange_calendar_bmf import BMFExchangeCalendar
from .exchange_calendar_cfe import CFEExchangeCalendar
from .exchange_calendar_cme import CMEExchangeCalendar
from .exchange_calendar_eurex import EUREXExchangeCalendar
from .exchange_calendar_ice import ICEExchangeCalendar
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_six import SIXExchangeCalendar
from .exchange_calendar_tsx import TSXExchangeCalendar
from .exchange_calendar_sse import SSEExchangeCalendar
from .exchange_calendar_hkex import HKEXExchangeCalendar


def get_calendar(name, open_time=None, close_time=None):
Expand Down
6 changes: 4 additions & 2 deletions pandas_market_calendars/calendar_utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""
Utilities to use with market_calendars
"""
import pandas as pd

################## >>> Deprecated (remove in future releases)
import warnings
from collections.abc import MutableMapping

import pandas as pd

from . import calendar_registry


class DeprecatedRegistry(MutableMapping):

def __init__(self):
Expand Down
14 changes: 3 additions & 11 deletions pandas_market_calendars/exchange_calendar_bmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,11 @@
# limitations under the License.

from datetime import time
from pandas.tseries.holiday import (
Holiday,
Easter,
Day,
GoodFriday,
)

from pandas.tseries.holiday import AbstractHolidayCalendar, Day, Easter, GoodFriday, Holiday
from pytz import timezone
from pandas.tseries.holiday import AbstractHolidayCalendar

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

# Universal Confraternization (new years day)
ConfUniversal = Holiday(
Expand Down
18 changes: 3 additions & 15 deletions pandas_market_calendars/exchange_calendar_cfe.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
from datetime import time

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

from .holidays_us import (Christmas, USBlackFridayInOrAfter1993, USIndependenceDay, USMartinLutherKingJrAfter1998,
USMemorialDay, USNewYearsDay)
from .market_calendar import MarketCalendar
from pandas.tseries.holiday import AbstractHolidayCalendar
from .holidays_us import (
USMartinLutherKingJrAfter1998,
USMemorialDay,
USBlackFridayInOrAfter1993,
USNewYearsDay,
USIndependenceDay,
Christmas
)


class CFEExchangeCalendar(MarketCalendar):
Expand Down
26 changes: 7 additions & 19 deletions pandas_market_calendars/exchange_calendar_cme.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,18 @@

from datetime import time

from pandas.tseries.holiday import (
USPresidentsDay,
USLaborDay,
USThanksgivingDay,
GoodFriday
)
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


# Useful resources for making changes to this file:
# http://www.cmegroup.com/tools-information/holiday-calendar.html

from .market_calendar import MarketCalendar
from pandas.tseries.holiday import AbstractHolidayCalendar
from .holidays_us import (
USNewYearsDay,
Christmas,
ChristmasEveBefore1993,
ChristmasEveInOrAfter1993,
USBlackFridayInOrAfter1993,
USNationalDaysofMourning,
USMartinLutherKingJrAfter1998,
USMemorialDay,
USIndependenceDay)


class CMEExchangeCalendar(MarketCalendar):
"""
Expand Down
15 changes: 4 additions & 11 deletions pandas_market_calendars/exchange_calendar_eurex.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
#

from datetime import time
from pandas.tseries.holiday import (
Holiday,
previous_friday,
GoodFriday,
EasterMonday,
)

from pandas.tseries.holiday import AbstractHolidayCalendar, EasterMonday, GoodFriday, Holiday, previous_friday
from pytz import timezone
from pandas.tseries.holiday import AbstractHolidayCalendar
from .market_calendar import (
MarketCalendar,
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY
)

from .market_calendar import (FRIDAY, MONDAY, MarketCalendar, THURSDAY, TUESDAY, WEDNESDAY)

# New Year's Eve
EUREXNewYearsEve = Holiday(
Expand Down
9 changes: 3 additions & 6 deletions pandas_market_calendars/exchange_calendar_hkex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
from functools import partial

from pandas import DateOffset, Timestamp
from pandas.tseries.holiday import AbstractHolidayCalendar, EasterMonday, GoodFriday, Holiday, sunday_to_monday
from pandas.tseries.offsets import LastWeekOfMonth, WeekOfMonth
from pandas.tseries.holiday import Holiday, GoodFriday, EasterMonday, sunday_to_monday
from pytz import timezone

from pandas.tseries.holiday import AbstractHolidayCalendar
from pandas_market_calendars.holidays_us import USNewYearsDay

from pandas_market_calendars import MarketCalendar
from .holidays_cn import sf_mapping, tsd_mapping, bsd_mapping,\
dbf_mapping, maf_mapping, dnf_mapping
from pandas_market_calendars.holidays_us import USNewYearsDay
from .holidays_cn import bsd_mapping, dbf_mapping, dnf_mapping, maf_mapping, sf_mapping, tsd_mapping


def process_date(dt, mapping=None, func=None, delta=None, offset=None):
Expand Down
17 changes: 3 additions & 14 deletions pandas_market_calendars/exchange_calendar_ice.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
from datetime import time
from itertools import chain

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

from .holidays_us import (Christmas, USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay,
USNationalDaysofMourning, USNewYearsDay)
from .market_calendar import MarketCalendar
from pandas.tseries.holiday import AbstractHolidayCalendar
from .holidays_us import (
USNewYearsDay,
Christmas,
USMartinLutherKingJrAfter1998,
USMemorialDay,
USIndependenceDay,
USNationalDaysofMourning)


class ICEExchangeCalendar(MarketCalendar):
Expand Down
Loading

0 comments on commit 2d39d75

Please sign in to comment.