Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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,
[ 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:
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() ]
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)
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)
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
)
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
)
[ 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:
[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(
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