public void testFairRate() { Calendar calendar = new TARGET(); Date settlementDate = new Date(10, Month.Mar, 2010); /********************* * LOAN TO BE PRICED * **********************/ // constant nominal 1,000,000 Euro double nominal = 1000000.0; // fixed leg Frequency fixedLegFrequency = Frequency.Monthly; BusinessDayConvention fixedLegConvention = BusinessDayConvention.Unadjusted; BusinessDayConvention principalLegConvention = BusinessDayConvention.ModifiedFollowing; DayCounter fixedLegDayCounter = new Thirty360(Thirty360.Thirty360Convention.European); double fixedRate = 0.04; // Principal leg Frequency pricipalLegFrequency = Frequency.Annual; int lenghtInMonths = 3; Loan.Type loanType = Loan.Type.Payer; Date maturity = settlementDate + new Period(lenghtInMonths, TimeUnit.Years); Schedule fixedSchedule = new Schedule(settlementDate, maturity, new Period(fixedLegFrequency), calendar, fixedLegConvention, fixedLegConvention, DateGeneration.Rule.Forward, false); Schedule principalSchedule = new Schedule(settlementDate, maturity, new Period(pricipalLegFrequency), calendar, principalLegConvention, principalLegConvention, DateGeneration.Rule.Forward, false); Loan testLoan = new FixedLoan(loanType, nominal, fixedSchedule, fixedRate, fixedLegDayCounter, principalSchedule, principalLegConvention); }
public MakeCash(Date startDate, Date endDate, double nominal) { startDate_ = startDate; endDate_ = endDate; nominal_ = nominal; frequency_ = Frequency.Once; type_ = Loan.Type.Loan; amortising_ = Loan.Amortising.Bullet; calendar_ = new TARGET(); convention_ = BusinessDayConvention.ModifiedFollowing; dayCounter_ = new Actual365Fixed(); rule_ = DateGeneration.Rule.Forward; endOfMonth_ = false; }
public MakeCommercialPaper(Date startDate, Date endDate, double fixedRate, Frequency frequency) { startDate_ = startDate; endDate_ = endDate; fixedRate_ = fixedRate; frequency_ = frequency; type_ = Loan.Type.Loan; amortising_ = Loan.Amortising.Bullet; nominal_ = 1.0; calendar_ = new TARGET(); convention_ = BusinessDayConvention.ModifiedFollowing; dayCounter_ = new Actual365Fixed(); rule_ = DateGeneration.Rule.Forward; endOfMonth_ = false; }
public MakeFloatingLoan(Date startDate, Date endDate, double spread, Frequency frequency) { startDate_ = startDate; endDate_ = endDate; spread_ = spread; frequency_ = frequency; type_ = Loan.Type.Loan; amortising_ = Loan.Amortising.Bullet; nominal_ = 1.0; calendar_ = new TARGET(); convention_ = BusinessDayConvention.ModifiedFollowing; dayCounter_ = new Actual365Fixed(); rule_ = DateGeneration.Rule.Forward; endOfMonth_ = false; index_ = new IborIndex(); }
public MakeCash(Date startDate, Date endDate, double nominal) { startDate_ = startDate; endDate_ = endDate; nominal_ = nominal; frequency_ = Frequency.Once; type_ = Loan.Type.Loan; amortising_ = Loan.Amortising.Bullet; calendar_ = new TARGET(); convention_ = BusinessDayConvention.ModifiedFollowing; dayCounter_ = new Actual365Fixed(); rule_ = DateGeneration.Rule.Forward; endOfMonth_ = false; //engine_ = new DiscountingSwapEngine(index.termStructure()); }
public MakeFixedLoan(Date startDate, Date endDate, double fixedRate, Frequency frequency) { startDate_ = startDate; endDate_ = endDate; fixedRate_ = fixedRate; frequency_ = frequency; type_ = Loan.Type.Loan; amortising_ = Loan.Amortising.Bullet; nominal_ = 1.0; calendar_ = new TARGET(); convention_ = BusinessDayConvention.ModifiedFollowing; dayCounter_ = new Actual365Fixed(); rule_ = DateGeneration.Rule.Forward; endOfMonth_ = false; //engine_ = new DiscountingSwapEngine(index.termStructure()); }
public CommercialPaper(Loan.Type type, double nominal, Schedule fixedSchedule, double fixedRate, DayCounter fixedDayCount, Schedule principalSchedule, BusinessDayConvention?paymentConvention) : base(2) { type_ = type; nominal_ = nominal; fixedSchedule_ = fixedSchedule; fixedRate_ = fixedRate; fixedDayCount_ = fixedDayCount; principalSchedule_ = principalSchedule; if (paymentConvention.HasValue) { paymentConvention_ = paymentConvention.Value; } else { paymentConvention_ = fixedSchedule_.businessDayConvention(); } List <CashFlow> principalLeg = new PricipalLeg(principalSchedule, fixedDayCount) .withNotionals(nominal) .withPaymentAdjustment(paymentConvention_) .withSign(type == Type.Loan ? -1 : 1); // temporary for (int i = 0; i < principalLeg.Count - 1; i++) { Principal p = (Principal)principalLeg[i]; notionals_.Add(p.nominal()); } List <CashFlow> fixedLeg = new FixedRateLeg(fixedSchedule) .withCouponRates(fixedRate, fixedDayCount) .withPaymentAdjustment(paymentConvention_) .withNotionals(notionals_); // Discounting Pricipal notionals_.Clear(); double n; for (int i = 0; i < fixedLeg.Count; i++) { FixedRateCoupon c = (FixedRateCoupon)fixedLeg[i]; n = i > 0 ? notionals_.Last() : c.nominal(); notionals_.Add(n / (1 + (c.rate() * c.dayCounter().yearFraction(c.refPeriodStart, c.refPeriodEnd)))); } // New Leg List <CashFlow> discountedFixedLeg = new FixedRateLeg(fixedSchedule) .withCouponRates(fixedRate, fixedDayCount) .withPaymentAdjustment(paymentConvention_) .withNotionals(notionals_); // Adjust Principal Principal p0 = (Principal)principalLeg[0]; p0.setAmount(notionals_.Last()); legs_[0] = discountedFixedLeg; legs_[1] = principalLeg; if (type_ == Type.Loan) { payer_[0] = +1; payer_[1] = -1; } else { payer_[0] = -1; payer_[1] = +1; } }
public MakeFloatingLoan withType(Loan.Type type) { type_ = type; return this; }
public MakeFloatingLoan(Date startDate, Date endDate, double spread, Frequency frequency) { startDate_ = startDate; endDate_ = endDate; spread_ = spread; frequency_ = frequency; type_ = Loan.Type.Loan; amortising_ = Loan.Amortising.Bullet; nominal_ = 1.0; calendar_ = new TARGET(); convention_ = BusinessDayConvention.ModifiedFollowing; dayCounter_ = new Actual365Fixed(); rule_ = DateGeneration.Rule.Forward; endOfMonth_ = false; index_ = new IborIndex(); //engine_ = new DiscountingSwapEngine(index.termStructure()); }
public MakeFixedLoan withType(Loan.Type type) { type_ = type; return this; }
public MakeCommercialPaper withType(Loan.Type type) { type_ = type; return this; }
public MakeCash withType(Loan.Type type) { type_ = type; return this; }
public MakeFixedLoan withType(Loan.Type type) { type_ = type; return(this); }
public MakeCash withType(Loan.Type type) { type_ = type; return(this); }
public CommercialPaper(Loan.Type type, double nominal, Schedule fixedSchedule, double fixedRate, DayCounter fixedDayCount, Schedule principalSchedule, BusinessDayConvention? paymentConvention) : base(2) { type_ = type; nominal_ = nominal; fixedSchedule_ = fixedSchedule; fixedRate_ = fixedRate; fixedDayCount_ = fixedDayCount; principalSchedule_ = principalSchedule; if (paymentConvention.HasValue) paymentConvention_ = paymentConvention.Value; else paymentConvention_ = fixedSchedule_.businessDayConvention(); List<CashFlow> principalLeg = new PricipalLeg(principalSchedule, fixedDayCount) .withNotionals(nominal) .withPaymentAdjustment(paymentConvention_) .withSign(type == Type.Loan ? -1 : 1); // temporary for (int i = 0; i < principalLeg.Count - 1; i++) { Principal p = (Principal)principalLeg[i]; notionals_.Add(p.nominal()); } List<CashFlow> fixedLeg = new FixedRateLeg(fixedSchedule) .withCouponRates(fixedRate, fixedDayCount) .withPaymentAdjustment(paymentConvention_) .withNotionals(notionals_); // Discounting Pricipal notionals_.Clear(); double n; for (int i = 0; i < fixedLeg.Count; i++) { FixedRateCoupon c = (FixedRateCoupon)fixedLeg[i]; n = i > 0 ? notionals_.Last() : c.nominal(); notionals_.Add(n / (1 + (c.rate() * c.dayCounter().yearFraction(c.refPeriodStart, c.refPeriodEnd)))); } // New Leg List<CashFlow> discountedFixedLeg = new FixedRateLeg(fixedSchedule) .withCouponRates(fixedRate, fixedDayCount) .withPaymentAdjustment(paymentConvention_) .withNotionals(notionals_); // Adjust Principal Principal p0 = (Principal)principalLeg[0]; p0.setAmount(notionals_.Last()); legs_[0] = discountedFixedLeg; legs_[1] = principalLeg; if (type_ == Type.Loan) { payer_[0] = +1; payer_[1] = -1; } else { payer_[0] = -1; payer_[1] = +1; } }
public MakeCommercialPaper withType(Loan.Type type) { type_ = type; return(this); }
public MakeFloatingLoan withType(Loan.Type type) { type_ = type; return(this); }