def test_create_ibor_index(self): euribor6m = IborIndex("Euribor", Period(6, Months), 2, EURCurrency(), TARGET(), ModifiedFollowing, True, Actual360()) default_euribor6m = Euribor6M() for attribute in [ "business_day_convention", "end_of_month", "fixing_calendar", "tenor", "fixing_days", "day_counter", "family_name", "name" ]: self.assertEqual(getattr(euribor6m, attribute), getattr(default_euribor6m, attribute))
def create_fixed_float_swap(self, settlement_date, length, fixed_rate, floating_spread, **kwargs): """ Create a fixed-for-float swap given: - settlement date - length in years - additional arguments to modify market default parameters """ _params = self._params._replace(**kwargs) index = IborIndex.from_name(self._market, self._forecast_term_structure, **kwargs) swap_type = Payer nominal = 100.0 fixed_convention = \ BusinessDayConvention.from_name(_params.fixed_leg_convention) floating_convention = \ BusinessDayConvention.from_name(_params.floating_leg_convention) fixed_frequency = \ Period(_params.fixed_leg_period) floating_frequency = Period(_params.floating_leg_period) fixed_daycount = DayCounter.from_name(_params.fixed_leg_daycount) float_daycount = DayCounter.from_name(_params.floating_leg_daycount) calendar = calendar_from_name(_params.calendar) maturity = calendar.advance(settlement_date, length, Years, convention=floating_convention) fixed_schedule = Schedule.from_rule(settlement_date, maturity, fixed_frequency, calendar, fixed_convention, fixed_convention, Rule.Forward, False) float_schedule = Schedule.from_rule(settlement_date, maturity, floating_frequency, calendar, floating_convention, floating_convention, Rule.Forward, False) swap = VanillaSwap(swap_type, nominal, fixed_schedule, fixed_rate, fixed_daycount, float_schedule, index, floating_spread, float_daycount, fixed_convention) engine = DiscountingSwapEngine(self._discount_term_structure, False, settlement_date=settlement_date, npv_date=settlement_date) swap.set_pricing_engine(engine) return swap
def create_fixed_float_swap(self, settlement_date, length, fixed_rate, floating_spread, **kwargs): """ Create a fixed-for-float swap given: - settlement date - length in years - additional arguments to modify market default parameters """ _params = self._params._replace(**kwargs) index = IborIndex.from_name(self._market, self._forecast_term_structure, **kwargs) swap_type = Payer nominal = 100.0 fixed_convention = \ BusinessDayConvention.from_name(_params.fixed_leg_convention) floating_convention = \ BusinessDayConvention.from_name(_params.floating_leg_convention) fixed_frequency = \ code_to_frequency(_params.fixed_leg_period) floating_frequency = code_to_frequency(_params.floating_leg_period) fixed_daycount = DayCounter.from_name(_params.fixed_leg_daycount) float_daycount = DayCounter.from_name(_params.floating_leg_daycount) calendar = calendar_from_name(_params.calendar) maturity = calendar.advance(settlement_date, length, Years, convention=floating_convention) fixed_schedule = Schedule(settlement_date, maturity, Period(fixed_frequency), calendar, fixed_convention, fixed_convention, Forward, False) float_schedule = Schedule(settlement_date, maturity, Period(floating_frequency), calendar, floating_convention, floating_convention, Forward, False) swap = VanillaSwap(swap_type, nominal, fixed_schedule, fixed_rate, fixed_daycount, float_schedule, index, floating_spread, float_daycount, fixed_convention) engine = DiscountingSwapEngine(self._discount_term_structure, False, settlementDate=settlement_date, npvDate=settlement_date) swap.set_pricing_engine(engine) return swap
def __init__(self, name, market, **kwargs): params = SwapData.params(market) params = params._replace(**kwargs) self._params = params self._name = name self._market = market # floating rate index index = IborIndex.from_name(market, **kwargs) self._floating_rate_index = index self._deposit_daycount = params.floating_leg_daycount self._termstructure_daycount = 'ACT/365' self._eval_date = None self._quotes = None self._termstructure = None self._discount_term_structure = None self._forecast_term_structure = None
def __init__(self, name, market, **kwargs): params = swap_params(market) params = params._replace(**kwargs) self._params = params self._name = name self._market = market # floating rate index index = IborIndex.from_name(market, **kwargs) self._floating_rate_index = index self._deposit_daycount = params.floating_leg_daycount self._termstructure_daycount = 'ACT/365' self._eval_date = None self._quotes = None self._termstructure = None self._discount_term_structure = None self._forecast_term_structure = None self._rate_helpers = [] self._quotes = []