Ejemplo n.º 1
0
def get_holidays_list(fromDate, toDate):
    """This is the function to get exchange holiday list between 2 dates.
        Args:
            fromDate (datetime.date): start date
            toDate (datetime.date): end date
        Returns:
            pandas.DataFrame : A pandas dataframe object
        Raises:
            ValueError:
                        1. From Date param is greater than To Date param
    """
    if fromDate > toDate:
        raise ValueError('Please check start and end dates')

    holidayscrape = holiday_list_url(fromDate.strftime("%d-%m-%Y"),
                                     toDate.strftime("%d-%m-%Y"))
    html_soup = BeautifulSoup(holidayscrape.text, 'lxml')
    sptable = html_soup.find("table")
    tp = ParseTables(
        soup=sptable,
        schema=[str, StrDate.default_format(format="%d-%b-%Y"), str, str],
        headers=["Market Segment", "Date", "Day", "Description"],
        index="Date")
    dfret = tp.get_df()
    dfret = dfret.drop(["Market Segment"], axis=1)
    return dfret
Ejemplo n.º 2
0
 def test_holiday_list_url(self):
     resp = holiday_list_url("01Jan2019", "31Mar2019")
     self.assertGreaterEqual(resp.text.find('Holi'), 0)