예제 #1
0
        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);
        }
예제 #2
0
        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;
        }
예제 #3
0
        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;
        }
예제 #4
0
        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();
        }
예제 #5
0
파일: MakeLoans.cs 프로젝트: vdt/QLNet
        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());
        }
예제 #6
0
        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());
        }
예제 #7
0
        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;
            }
        }
예제 #8
0
파일: MakeLoans.cs 프로젝트: vdt/QLNet
 public MakeFloatingLoan withType(Loan.Type type)
 {
     type_ = type;
      return this;
 }
예제 #9
0
파일: MakeLoans.cs 프로젝트: vdt/QLNet
        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());
        }
예제 #10
0
파일: MakeLoans.cs 프로젝트: vdt/QLNet
 public MakeFixedLoan withType(Loan.Type type)
 {
     type_ = type;
      return this;
 }
예제 #11
0
파일: MakeLoans.cs 프로젝트: vdt/QLNet
 public MakeCommercialPaper withType(Loan.Type type)
 {
     type_ = type;
      return this;
 }
예제 #12
0
파일: MakeLoans.cs 프로젝트: vdt/QLNet
 public MakeCash withType(Loan.Type type)
 {
     type_ = type;
      return this;
 }
예제 #13
0
 public MakeFixedLoan withType(Loan.Type type)
 {
     type_ = type;
     return(this);
 }
예제 #14
0
 public MakeCash withType(Loan.Type type)
 {
     type_ = type;
     return(this);
 }
예제 #15
0
        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;
            }
        }
예제 #16
0
 public MakeCommercialPaper withType(Loan.Type type)
 {
     type_ = type;
     return(this);
 }
예제 #17
0
 public MakeFloatingLoan withType(Loan.Type type)
 {
     type_ = type;
     return(this);
 }