Beispiel #1
0
    def is_holiday(self, date):
        """Determines if a date is a holiday.

        Parameters
        ----------
        date : datetime.date
        """
        if self.country_holidays is None:
            self.country_holidays = utils.get_holidays(self.country_str)

        if date in self.country_holidays:
            return True
        if self.country_str == 'US' and date in ADDL_US_HOLIDAYS:
            return True
        return False
Beispiel #2
0
    st.stop()

fig = go.Figure(data=[
    go.Candlestick(x=df.index,
                   open=df['Open'],
                   high=df['High'],
                   low=df['Low'],
                   close=df['Close'])
])

fig.update_xaxes(
    rangeslider_visible=True,
    rangebreaks=[
        dict(bounds=["sat", "mon"
                     ]),  # hide weekends, eg. hide sat to before mon
        dict(values=utils.get_holidays()
             )  # hide holidays (Christmas and New Year's, etc)
    ])

st.sidebar.subheader("Pattern date range")
slice_start_date = st.sidebar.date_input(label='From :',
                                         value=end_date - timedelta(days=3),
                                         key="slice_start_date")
slice_end_date = st.sidebar.date_input(label='To :',
                                       value=end_date,
                                       key="slice_end_date")

# fig.update_layout(title_text=slice_start_date.strftime("%Y-%m-%d") + "     " + slice_end_date.strftime("%Y-%m-%d"),
#                   title_font_size=20)

fig.update_layout(shapes=[
Beispiel #3
0
# -*- coding: utf-8 -*-
import QuantLib as ql
import utils

# get_holidays returns a list of string, e.g., ['20200415']
kr = utils.get_holidays('KR', days=365 * 2)
uk = utils.get_holidays('UK', days=365 * 2)
us = utils.get_holidays('US', days=365 * 2)
jp = utils.get_holidays('JP', days=365 * 2)
""" hk = get_holidays('HK', days=365*2) # 현재 hongkong 달력 업데이트 중지 """

#convert them to al.Date
convertor = utils.str2qldate
kr = list(map(convertor, kr))
uk = list(map(convertor, uk))
us = list(map(convertor, us))
jp = list(map(convertor, jp))
""" hk = list(map(convertor, hk)) # 같은 이유로 hk 작업 불 필요 """
# Now, we are ready to go. Define custome_calendar that has the holidays
cKR = ql.SouthKorea()
cUK = ql.UnitedKingdom()
cUS = ql.UnitedStates()
cJP = ql.Japan()
cHK = ql.HongKong()

for d in kr:
    cKR.addHoliday(d)
for d in uk:
    cUK.addHoliday(d)
for d in us:
    cUS.addHoliday(d)