How to use the quantlib.time.api.ModifiedFollowing function in QuantLib

To help you get started, we’ve selected a few QuantLib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github enthought / pyql / examples / swap.py View on Github external
for n,m in FRAs.keys():
    FRAs[(n,m)] = SimpleQuote(FRAs[(n,m)])
for d in futures.keys():
    futures[d] = SimpleQuote(futures[d])
for s in swaps.keys():
    swaps[s] = SimpleQuote(swaps[s])
#for n,unit in swaps.keys():
#    swaps[(n,unit)] = SimpleQuote(swaps[(n,unit)])

# build rate helpers

day_counter = Actual360()
settlementDays = 2
depositHelpers = [ DepositRateHelper(v,
                                     Period(n,unit), settlementDays,
                                     calendar, ModifiedFollowing,
                                     False, day_counter)
                   for (n, unit), v in deposits.items()]

day_counter = Actual360()
settlementDays = 2
fraHelpers = [ FraRateHelper(v,
                             n, m, settlementDays,
                             calendar, ModifiedFollowing,
                             False, day_counter)
               for (n, m), v in FRAs.items() ]

day_counter = Actual360()
months = 3
futuresHelpers = [ FuturesRateHelper(futures[d],
                                     d, months,
                                     calendar, ModifiedFollowing,
github enthought / pyql / examples / make_zc.py View on Github external
[ 4, Years, 'Swap4Y'],
                [ 5, Years, 'Swap5Y'],
                [ 7, Years, 'Swap7Y'],
                [ 10, Years,'Swap10Y'],
                [ 30, Years,'Swap30Y']]

    rate_helpers = []

    end_of_month = True

    for m, period, label in depositData:
        tenor = Period(m, Months)
        rate = df_libor.get_value(dtObs, label)
        helper = DepositRateHelper(float(rate/100), tenor,
                 settlement_days,
                 calendar, ModifiedFollowing, end_of_month,
                 Actual360())

        rate_helpers.append(helper)

    endOfMonth = True

    liborIndex = Libor('USD Libor', Period(6, Months),
                       settlement_days,
                       USDCurrency(), calendar,
                       ModifiedFollowing,
                       endOfMonth, Actual360())

    spread = SimpleQuote(0)
    fwdStart = Period(0, Days)

    for m, period, label in swapData:
github enthought / pyql / examples / swap.py View on Github external
False, day_counter)
                   for (n, unit), v in deposits.items()]

day_counter = Actual360()
settlementDays = 2
fraHelpers = [ FraRateHelper(v,
                             n, m, settlementDays,
                             calendar, ModifiedFollowing,
                             False, day_counter)
               for (n, m), v in FRAs.items() ]

day_counter = Actual360()
months = 3
futuresHelpers = [ FuturesRateHelper(futures[d],
                                     d, months,
                                     calendar, ModifiedFollowing,
                                     True, day_counter)
                   for d in futures.keys() ]

settlementDays = 2
fixedLegFrequency = Annual
fixedLegTenor = Period(1,Years)
fixedLegAdjustment = Unadjusted
fixedLegDayCounter = Thirty360()
floatingLegFrequency = Semiannual
floatingLegTenor = Period(6,Months)
floatingLegAdjustment = ModifiedFollowing
swapHelpers = [ SwapRateHelper.from_tenor(swaps[(n,unit)],
                               Period(n,unit), calendar,
                               fixedLegFrequency, fixedLegAdjustment,
                               fixedLegDayCounter, Euribor6M())
                for n, unit in swaps.keys() ]
github enthought / pyql / quantlib / util / rates.py View on Github external
USDCurrency(), calendar, Actual360()
        )
        spread = SimpleQuote(0)
        fwdStart = Period(0, Days)
        helper = SwapRateHelper.from_tenor(
            SimpleQuote(rate),
            Period(tenor, Years),
            calendar, Annual,
            Unadjusted, Thirty360(),
            liborIndex, spread, fwdStart)
    elif((rate_type == 'LIBOR') & (period == 'M')):
        helper = DepositRateHelper(SimpleQuote(rate),
                                   Period(tenor, Months),
                                   settlement_days,
                                   calendar,
                                   ModifiedFollowing,
                                   end_of_month,
                                   Actual360())
    else:
        raise Exception("Rate type %s not supported" % label)

    return (helper)
github enthought / pyql / examples / bonds.py View on Github external
effective_date, 10, Years, convention=Unadjusted
)


settlement_days = 3
face_amount = 100.0
coupon_rate = 0.05
redemption = 100.0

fixed_bond_schedule = Schedule.from_rule(
    effective_date,
    termination_date,
    Period(Annual),
    calendar,
    ModifiedFollowing,
    ModifiedFollowing,
    Backward
)

issue_date = effective_date
bond = FixedRateBond(
    settlement_days,
    face_amount,
    fixed_bond_schedule,
    [coupon_rate],
    ActualActual(ISMA),
    Following,
    redemption,
    issue_date
)

discounting_term_structure = YieldTermStructure(relinkable=True)
github enthought / pyql / examples / swap.py View on Github external
day_counter = Actual360()
months = 3
futuresHelpers = [ FuturesRateHelper(futures[d],
                                     d, months,
                                     calendar, ModifiedFollowing,
                                     True, day_counter)
                   for d in futures.keys() ]

settlementDays = 2
fixedLegFrequency = Annual
fixedLegTenor = Period(1,Years)
fixedLegAdjustment = Unadjusted
fixedLegDayCounter = Thirty360()
floatingLegFrequency = Semiannual
floatingLegTenor = Period(6,Months)
floatingLegAdjustment = ModifiedFollowing
swapHelpers = [ SwapRateHelper.from_tenor(swaps[(n,unit)],
                               Period(n,unit), calendar,
                               fixedLegFrequency, fixedLegAdjustment,
                               fixedLegDayCounter, Euribor6M())
                for n, unit in swaps.keys() ]

### Curve building 

ts_daycounter = ActualActual(ISDA)

# term-structure construction
helpers = depositHelpers + swapHelpers
depoSwapCurve = PiecewiseYieldCurve.from_reference_date(
    BootstrapTrait.Discount, Interpolator.LogLinear, settlementDate, helpers, ts_daycounter
)
github enthought / pyql / examples / bonds.py View on Github external
termination_date = calendar.advance(
    effective_date, 10, Years, convention=Unadjusted
)


settlement_days = 3
face_amount = 100.0
coupon_rate = 0.05
redemption = 100.0

fixed_bond_schedule = Schedule.from_rule(
    effective_date,
    termination_date,
    Period(Annual),
    calendar,
    ModifiedFollowing,
    ModifiedFollowing,
    Backward
)

issue_date = effective_date
bond = FixedRateBond(
    settlement_days,
    face_amount,
    fixed_bond_schedule,
    [coupon_rate],
    ActualActual(ISMA),
    Following,
    redemption,
    issue_date
)
github enthought / pyql / examples / scripts / LiborRiskFactors.py View on Github external
[ 4, Years, 'Swap4Y'],
                [ 5, Years, 'Swap5Y'],
                [ 7, Years, 'Swap7Y'],
                [ 10, Years,'Swap10Y'],
                [ 30, Years,'Swap30Y']]

    rate_helpers = []

    end_of_month = True

    for m, period, label in depositData:
        tenor = Period(m, Months)
        rate = df_libor.get_value(dtObs, label)
        helper = DepositRateHelper(float(rate/100), tenor,
                 settlement_days,
                 calendar, ModifiedFollowing,
                 end_of_month,
                 Actual360())

        rate_helpers.append(helper)

    endOfMonth = True

    liborIndex = Libor('USD Libor', Period(6, Months),
                       settlement_days,
                       USDCurrency(), calendar,
                       Actual360())

    spread = SimpleQuote(0)
    fwdStart = Period(0, Days)

    for m, period, label in swapData:
github enthought / pyql / examples / scripts / make_zero_coupon.py View on Github external
[4, Years, 'Swap4Y'],
                [5, Years, 'Swap5Y'],
                [7, Years, 'Swap7Y'],
                [10, Years, 'Swap10Y'],
                [30, Years, 'Swap30Y']]

    rate_helpers = []

    end_of_month = True

    for m, period, label in depositData:
        tenor = Period(m, Months)
        rate = df_libor.get_value(dtObs, label)
        helper = DepositRateHelper(SimpleQuote(rate / 100.0), tenor,
                                   settlement_days,
                                   calendar, ModifiedFollowing,
                                   end_of_month,
                                   Actual360())

        rate_helpers.append(helper)

    liborIndex = Libor('USD Libor', Period(3, Months),
                       settlement_days,
                       USDCurrency(), calendar,
                       Actual360())

    spread = SimpleQuote(0)
    fwdStart = Period(0, Days)

    for m, period, label in swapData:
        rate = df_libor.get_value(dtObs, label)
        helper = SwapRateHelper.from_tenor(
github enthought / pyql / examples / scripts / make_zero_coupon.py View on Github external
liborIndex = Libor('USD Libor', Period(3, Months),
                       settlement_days,
                       USDCurrency(), calendar,
                       Actual360())

    spread = SimpleQuote(0)
    fwdStart = Period(0, Days)

    for m, period, label in swapData:
        rate = df_libor.get_value(dtObs, label)
        helper = SwapRateHelper.from_tenor(
            SimpleQuote(rate / 100.0),
            Period(m, Years),
            calendar, Semiannual,
            ModifiedFollowing, Thirty360(),
            liborIndex, spread, fwdStart)

        rate_helpers.append(helper)

    ts_day_counter = ActualActual(ISDA)
    tolerance = 1.0e-15

    ts = PiecewiseYieldCurve.from_reference_date(BootstrapTrait.Discount,
                                                 Interpolator.LogLinear,
                                                 settlement_date,
                                                 rate_helpers,
                                                 ts_day_counter,
                                                 tolerance)
    ts.extrapolation = True
    return ts