Ejemplo n.º 1
0
def test_FinIborFRAsOnly():

    # TO DO FIX THIS
    valuation_date = Date(23, 2, 2018)

    spotDays = 0
    settlement_date = valuation_date.addWeekDays(spotDays)

    depoDCCType = DayCountTypes.ACT_360
    notional = 100.0

    payFixed = True

    calendar_type = CalendarTypes.TARGET
    fras = []

    # 1 x 4 FRA
    fraRate = 0.04
    fraSettlementDate = settlement_date.addMonths(1)
    fraMaturityDate = settlement_date.addMonths(4)
    fra = FinIborFRA(fraSettlementDate, fraMaturityDate, fraRate,
                      depoDCCType, notional, payFixed, calendar_type)
    fras.append(fra)

    # 4 x 7 FRA
    fraRate = 0.08
    fraSettlementDate = settlement_date.addMonths(4)
    fraMaturityDate = settlement_date.addMonths(7)
    fra = FinIborFRA(fraSettlementDate, fraMaturityDate, fraRate,
                      depoDCCType, notional, payFixed, calendar_type)
    fras.append(fra)

    depos = []
    swaps = []

    libor_curve = FinIborSingleCurveOLD(valuation_date,
                                       depos,
                                       fras,
                                       swaps)

    testCases.header("DATE", "MATDATE", "VALUE")

    """ Check calibration """
    for fra in fras:
        v = fra.value(settlement_date, libor_curve)
        testCases.print("FRA:", fra._maturity_date, v)
Ejemplo n.º 2
0
def test_FinOISFRAsOnly():

    # TO DO FIX THIS
    valuationDate = FinDate(23, 2, 2018)

    spotDays = 0
    settleDt = valuationDate.addWeekDays(spotDays)

    depoDCCType = FinDayCountTypes.ACT_360
    notional = 100.0

    payFixed = True

    calendarType = FinCalendarTypes.TARGET
    fras = []

    # 1 x 4 FRA
    fraRate = 0.04
    frasettleDt = settleDt.addMonths(1)
    fraMaturityDate = settleDt.addMonths(4)
    fra = FinIborFRA(frasettleDt, fraMaturityDate, fraRate,
                      depoDCCType, notional, payFixed, calendarType)
    fras.append(fra)

    # 4 x 7 FRA
    fraRate = 0.08
    frasettleDt = settleDt.addMonths(4)
    fraMaturityDate = settleDt.addMonths(7)
    fra = FinIborFRA(frasettleDt, fraMaturityDate, fraRate,
                      depoDCCType, notional, payFixed, calendarType)
    fras.append(fra)

    swaps = []

    liborCurve = FinOISCurve(settleDt,
                               fras,
                               swaps)

    testCases.header("DATE", "MATDATE", "VALUE")

    ''' Check calibration '''
    for fra in fras:
        v = fra.value(settleDt, liborCurve)
        testCases.print("FRA:", fra._maturityDate, v)
Ejemplo n.º 3
0
def buildIborSingleCurve(valuationDate):

    settlementDate = valuationDate.addDays(2)
    dcType = FinDayCountTypes.ACT_360

    depos = []
    fras = []
    swaps = []

    maturityDate = settlementDate.addMonths(1)
    depo1 = FinIborDeposit(valuationDate, maturityDate, -0.00251, dcType)
    depos.append(depo1)

    # Series of 1M futures
    startDate = settlementDate.nextIMMDate()
    endDate = startDate.addMonths(1)
    fra = FinIborFRA(startDate, endDate, -0.0023, dcType)
    fras.append(fra)

    startDate = startDate.addMonths(1)
    endDate = startDate.addMonths(1)
    fra = FinIborFRA(startDate, endDate, -0.00234, dcType)
    fras.append(fra)

    startDate = startDate.addMonths(1)
    endDate = startDate.addMonths(1)
    fra = FinIborFRA(startDate, endDate, -0.00225, dcType)
    fras.append(fra)

    startDate = startDate.addMonths(1)
    endDate = startDate.addMonths(1)
    fra = FinIborFRA(startDate, endDate, -0.00226, dcType)
    fras.append(fra)

    startDate = startDate.addMonths(1)
    endDate = startDate.addMonths(1)
    fra = FinIborFRA(startDate, endDate, -0.00219, dcType)
    fras.append(fra)

    startDate = startDate.addMonths(1)
    endDate = startDate.addMonths(1)
    fra = FinIborFRA(startDate, endDate, -0.00213, dcType)
    fras.append(fra)

    startDate = startDate.addMonths(1)
    endDate = startDate.addMonths(1)
    fra = FinIborFRA(startDate, endDate, -0.00186, dcType)
    fras.append(fra)

    startDate = startDate.addMonths(1)
    endDate = startDate.addMonths(1)
    fra = FinIborFRA(startDate, endDate, -0.00189, dcType)
    fras.append(fra)

    startDate = startDate.addMonths(1)
    endDate = startDate.addMonths(1)
    fra = FinIborFRA(startDate, endDate, -0.00175, dcType)
    fras.append(fra)

    startDate = startDate.addMonths(1)
    endDate = startDate.addMonths(1)
    fra = FinIborFRA(startDate, endDate, -0.00143, dcType)
    fras.append(fra)

    startDate = startDate.addMonths(1)
    endDate = startDate.addMonths(1)
    fra = FinIborFRA(startDate, endDate, -0.00126, dcType)
    fras.append(fra)

    startDate = startDate.addMonths(1)
    endDate = startDate.addMonths(1)
    fra = FinIborFRA(startDate, endDate, -0.00126, dcType)
    fras.append(fra)

    ###########################################################################
    ###########################################################################
    ###########################################################################
    ###########################################################################

    fixedFreq = FinFrequencyTypes.ANNUAL
    dcType = FinDayCountTypes.THIRTY_E_360
    fixedLegType = FinSwapTypes.PAY

    #######################################
    maturityDate = settlementDate.addMonths(24)
    swapRate = -0.001506
    swap1 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                        fixedFreq, dcType)
    swaps.append(swap1)

    #######################################
    maturityDate = settlementDate.addMonths(36)
    swapRate = -0.000185
    swap2 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                        fixedFreq, dcType)
    swaps.append(swap2)

    #######################################
    maturityDate = settlementDate.addMonths(48)
    swapRate = 0.001358
    swap3 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                        fixedFreq, dcType)
    swaps.append(swap3)

    #######################################
    maturityDate = settlementDate.addMonths(60)
    swapRate = 0.0027652
    swap4 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                        fixedFreq, dcType)
    swaps.append(swap4)

    #######################################
    maturityDate = settlementDate.addMonths(72)
    swapRate = 0.0041539
    swap5 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                        fixedFreq, dcType)
    swaps.append(swap5)

    #######################################
    maturityDate = settlementDate.addMonths(84)
    swapRate = 0.0054604
    swap6 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                        fixedFreq, dcType)
    swaps.append(swap6)

    #######################################
    maturityDate = settlementDate.addMonths(96)
    swapRate = 0.006674
    swap7 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                        fixedFreq, dcType)
    swaps.append(swap7)

    #######################################
    maturityDate = settlementDate.addMonths(108)
    swapRate = 0.007826
    swap8 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                        fixedFreq, dcType)
    swaps.append(swap8)

    #######################################
    maturityDate = settlementDate.addMonths(120)
    swapRate = 0.008821
    swap9 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                        fixedFreq, dcType)
    swaps.append(swap9)

    #######################################
    maturityDate = settlementDate.addMonths(132)
    swapRate = 0.0097379
    swap10 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                         fixedFreq, dcType)
    swaps.append(swap10)

    #######################################
    maturityDate = settlementDate.addMonths(144)
    swapRate = 0.0105406
    swap11 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                         fixedFreq, dcType)
    swaps.append(swap11)

    #######################################
    maturityDate = settlementDate.addMonths(180)
    swapRate = 0.0123927
    swap12 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                         fixedFreq, dcType)
    swaps.append(swap12)

    #######################################
    maturityDate = settlementDate.addMonths(240)
    swapRate = 0.0139882
    swap13 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                         fixedFreq, dcType)
    swaps.append(swap13)

    #######################################
    maturityDate = settlementDate.addMonths(300)
    swapRate = 0.0144972
    swap14 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                         fixedFreq, dcType)
    swaps.append(swap14)

    #######################################
    maturityDate = settlementDate.addMonths(360)
    swapRate = 0.0146081
    swap15 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                         fixedFreq, dcType)
    swaps.append(swap15)

    #######################################
    maturityDate = settlementDate.addMonths(420)
    swapRate = 0.01461897
    swap16 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                         fixedFreq, dcType)
    swaps.append(swap16)

    #######################################
    maturityDate = settlementDate.addMonths(480)
    swapRate = 0.014567455
    swap17 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                         fixedFreq, dcType)
    swaps.append(swap17)

    #######################################
    maturityDate = settlementDate.addMonths(540)
    swapRate = 0.0140826
    swap18 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                         fixedFreq, dcType)
    swaps.append(swap18)

    #######################################
    maturityDate = settlementDate.addMonths(600)
    swapRate = 0.01436822
    swap19 = FinIborSwap(settlementDate, maturityDate, fixedLegType, swapRate,
                         fixedFreq, dcType)
    swaps.append(swap19)

    ########################################

    liborCurve = FinIborSingleCurve(valuationDate, depos, fras, swaps)

    testCases.header("LABEL", "DATE", "VALUE")
    ''' Check calibration '''
    for depo in depos:
        v = depo.value(settlementDate, liborCurve)
        testCases.print("DEPO VALUE:", depo._maturityDate, v)

    for fra in fras:
        v = fra.value(settlementDate, liborCurve)
        testCases.print("FRA VALUE:", fra._maturityDate, v)

    for swap in swaps:
        v = swap.value(settlementDate, liborCurve)
        testCases.print("SWAP VALUE:", swap._maturityDate, v)

    return liborCurve