示例#1
0
def AddHoliday(cal, newHolDate):
    '''
    Input:
    cal        -- calendar对象
    newHolDate -- 新节假日
    
    Output:
    新的calendar对象
    '''
    newHolDate = pd.Timestamp(newHolDate)
    calDate = __parsePYDate__(newHolDate)
    cal.addHoliday(calDate)
    return cal
示例#2
0
def RemoveHoliday(cal, targetHolDate):
    '''
    Input:
    cal        -- calendar对象
    targetHolDate -- 旧节假日
    
    Output:
    新的calendar对象
    '''
    targetHolDate = pd.Timestamp(targetHolDate)
    calDate = __parsePYDate__(targetHolDate)
    cal.removeHoliday(calDate)
    return cal
示例#3
0
def HolDatesList(cal, startDate, endDate):
    '''
    Input:
    cal       -- calendar对象
    startDate -- 参考时间段起始
    enDate    -- 参考时间段结束
    
    Output:
    节假日列表
    '''
    totalDateRange = pd.date_range(startDate, endDate)   
    holDates = []    
    for sampleDate in totalDateRange[:-1]:
        calDate = __parsePYDate__(sampleDate)
        if not cal.isBusinessDay(calDate):
            holDates.append(sampleDate)   
    return holDates
示例#4
0
def AdvanceDate(cal, todayDate, period, convention, endOfMonth = False):
    periodObj = PeriodParser.parse(period)
    todayDate = pd.Timestamp(todayDate)
    calDate = __parsePYDate__(todayDate)
    res = cal.advance(calDate, periodObj.length(), periodObj.units(), convention, endOfMonth)
    return __parseCALDate__(res)
示例#5
0
def IsMonthEnd(cal, testDate):
    testDate = pd.Timestamp(testDate)
    calDate = __parsePYDate__(testDate)
    return cal.isEndOfMonth(calDate)
示例#6
0
def IsHoliday(cal, testDate):
    testDate = pd.Timestamp(testDate)
    calDate = __parsePYDate__(testDate)
    return cal.isHoliday(calDate)
示例#7
0
def IsBizDay(cal, testDate):
    testDate = pd.Timestamp(testDate)
    calDate = __parsePYDate__(testDate)
    return cal.isBusinessDay(calDate)