예제 #1
0
        public BasisSwap value()
        {
            Date startDate;

            if (effectiveDate_ != null)
            {
                startDate = effectiveDate_;
            }
            else
            {
                int  fixingDays    = iborIndex1_.fixingDays();
                Date referenceDate = Settings.evaluationDate();
                Date spotDate      = float1Calendar_.advance(referenceDate, new Period(fixingDays, TimeUnit.Days));
                startDate = spotDate + forwardStart_;
            }

            Date endDate;

            if (terminationDate_ != null)
            {
                endDate = terminationDate_;
            }
            else
            {
                endDate = startDate + swapTenor_;
            }


            Schedule float1Schedule = new Schedule(startDate, endDate,
                                                   float1Tenor_, float1Calendar_,
                                                   float1Convention_, float1TerminationDateConvention_,
                                                   float1Rule_, float1EndOfMonth_,
                                                   float1FirstDate_, float1NextToLastDate_);

            Schedule float2Schedule = new Schedule(startDate, endDate,
                                                   float2Tenor_, float2Calendar_,
                                                   float2Convention_, float2TerminationDateConvention_,
                                                   float2Rule_, float2EndOfMonth_,
                                                   float2FirstDate_, float2NextToLastDate_);


            BasisSwap swap = new BasisSwap(type_, nominal_,
                                           float1Schedule, iborIndex1_, float1Spread_, float1DayCount_,
                                           float2Schedule, iborIndex2_, float2Spread_, float2DayCount_);

            swap.setPricingEngine(engine_);
            return(swap);
        }
예제 #2
0
        public SwapRateHelper(double rate,
                              Period tenor,
                              Calendar calendar,
                              Frequency fixedFrequency,
                              BusinessDayConvention fixedConvention,
                              DayCounter fixedDayCount,
                              IborIndex iborIndex,
                              Handle <Quote> spread = null,
                              Period fwdStart       = null,
                              // exogenous discounting curve
                              Handle <YieldTermStructure> discount = null,
                              int?settlementDays         = null,
                              Pillar.Choice pillarChoice = Pillar.Choice.LastRelevantDate,
                              Date customPillarDate      = null)
            : base(rate)
        {
            settlementDays_  = settlementDays;
            tenor_           = tenor;
            pillarChoice_    = pillarChoice;
            calendar_        = calendar;
            fixedConvention_ = fixedConvention;
            fixedFrequency_  = fixedFrequency;
            fixedDayCount_   = fixedDayCount;
            spread_          = spread ?? new Handle <Quote>();
            fwdStart_        = fwdStart ?? new Period(0, TimeUnit.Days);
            discountHandle_  = discount ?? new Handle <YieldTermStructure>();

            if (settlementDays_ == null)
            {
                settlementDays_ = iborIndex.fixingDays();
            }

            // take fixing into account
            iborIndex_ = iborIndex.clone(termStructureHandle_);
            // We want to be notified of changes of fixings, but we don't
            // want notifications from termStructureHandle_ (they would
            // interfere with bootstrapping.)
            iborIndex_.registerWith(update);
            spread_.registerWith(update);
            discountHandle_.registerWith(update);

            pillarDate_ = customPillarDate;
            initializeDates();
        }
예제 #3
0
        public MakeVanillaSwap(Period swapTenor, IborIndex index, double?fixedRate = null, Period forwardStart = null)
        {
            swapTenor_      = swapTenor;
            iborIndex_      = index;
            fixedRate_      = fixedRate;
            forwardStart_   = forwardStart ?? new Period(0, TimeUnit.Days);
            settlementDays_ = iborIndex_.fixingDays();
            fixedCalendar_  = floatCalendar_ = index.fixingCalendar();

            type_            = VanillaSwap.Type.Payer;
            nominal_         = 1.0;
            floatTenor_      = index.tenor();
            fixedConvention_ = fixedTerminationDateConvention_ = BusinessDayConvention.ModifiedFollowing;
            floatConvention_ = floatTerminationDateConvention_ = index.businessDayConvention();
            fixedRule_       = floatRule_ = DateGeneration.Rule.Backward;
            fixedEndOfMonth_ = floatEndOfMonth_ = false;
            fixedFirstDate_  = fixedNextToLastDate_ = floatFirstDate_ = floatNextToLastDate_ = null;
            floatSpread_     = 0.0;
            floatDayCount_   = index.dayCounter();
        }
예제 #4
0
        public ForwardRateAgreement(Date valueDate, Date maturityDate, Position.Type type, double strikeForwardRate,
                                    double notionalAmount, IborIndex index, Handle <YieldTermStructure> discountCurve)
            : base(
                index.dayCounter(), index.fixingCalendar(), index.businessDayConvention(), index.fixingDays(), new Payoff(),
                valueDate, maturityDate, discountCurve)
        {
            fraType_        = type;
            notionalAmount_ = notionalAmount;
            index_          = index;

            Utils.QL_REQUIRE(notionalAmount > 0.0, () => "notional Amount must be positive");

            // do I adjust this ?
            Date fixingDate = calendar_.advance(valueDate_, -settlementDays_, TimeUnit.Days);

            forwardRate_       = new InterestRate(index.fixing(fixingDate), index.dayCounter(), Compounding.Simple, Frequency.Once);
            strikeForwardRate_ = new InterestRate(strikeForwardRate, index.dayCounter(), Compounding.Simple, Frequency.Once);
            double strike = notionalAmount_ * strikeForwardRate_.compoundFactor(valueDate_, maturityDate_);

            payoff_ = new ForwardTypePayoff(fraType_, strike);
            // incomeDiscountCurve_ is irrelevant to an FRA
            incomeDiscountCurve_ = discountCurve_;
            // income is irrelevant to FRA - set it to zero
            underlyingIncome_ = 0.0;

            index_.registerWith(update);
        }