コード例 #1
0
ファイル: RateHelpers.cs プロジェクト: OpenDerivatives/QLCore
        public BMASwapRateHelper(Handle <Quote> liborFraction,
                                 Period tenor,
                                 int settlementDays,
                                 Calendar calendar,
                                 Period bmaPeriod,
                                 BusinessDayConvention bmaConvention,
                                 DayCounter bmaDayCount,
                                 BMAIndex bmaIndex,
                                 IborIndex iborIndex)
            : base(liborFraction)
        {
            tenor_          = tenor;
            settlementDays_ = settlementDays;
            calendar_       = calendar;
            bmaPeriod_      = bmaPeriod;
            bmaConvention_  = bmaConvention;
            bmaDayCount_    = bmaDayCount;
            bmaIndex_       = bmaIndex;
            iborIndex_      = iborIndex;

            iborIndex_.registerWith(update);
            bmaIndex_.registerWith(update);

            initializeDates();
        }
コード例 #2
0
ファイル: forwardrateagreement.cs プロジェクト: zhangz/QLNet
        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);
        }
コード例 #3
0
        public BasisSwapHelper(Handle <Quote> spreadQuote,
                               int settlementDays,
                               Period swapTenor,
                               Calendar settlementCalendar,
                               BusinessDayConvention rollConvention,
                               IborIndex shortIndex,
                               IborIndex longIndex,
                               Handle <YieldTermStructure> discount = null,
                               bool eom           = true,
                               bool spreadOnShort = true)
            : base(spreadQuote)
        {
            settlementDays_     = settlementDays;
            settlementCalendar_ = settlementCalendar;
            swapTenor_          = swapTenor;
            rollConvention_     = rollConvention;
            shortIndex_         = shortIndex;
            longIndex_          = longIndex;
            spreadOnShort_      = spreadOnShort;
            eom_            = eom;
            discountHandle_ = discount ?? new Handle <YieldTermStructure>();

            bool shortIndexHasCurve = !shortIndex_.forwardingTermStructure().empty();
            bool longIndexHasCurve  = !longIndex_.forwardingTermStructure().empty();

            Utils.QL_REQUIRE(!(shortIndexHasCurve && longIndexHasCurve), () => "Have all curves, nothing to solve for.");

            /* Link the curve being bootstrapped to the index if the index has
             * no projection curve */
            if (!shortIndexHasCurve)
            {
                shortIndex_ = shortIndex_.clone(termStructureHandle_);
                //shortIndex_.unregisterWith(termStructureHandle_.link.update);
            }
            else if (!longIndexHasCurve)
            {
                longIndex_ = longIndex_.clone(termStructureHandle_);
                //longIndex_.unregisterWith(termStructureHandle_.link.update);
            }
            else
            {
                Utils.QL_FAIL("Need one leg of the basis swap to have its forward curve.");
            }

            shortIndex_.registerWith(update);
            longIndex_.registerWith(update);
            discountHandle_.registerWith(update);

            initializeDates();
        }
コード例 #4
0
ファイル: Swapindex.cs プロジェクト: tzhdingli/qlnet
        public SwapIndex(string familyName, Period tenor, int settlementDays, Currency currency,
                         Calendar calendar, Period fixedLegTenor, BusinessDayConvention fixedLegConvention,
                         DayCounter fixedLegDayCounter, IborIndex iborIndex) :
            base(familyName, tenor, settlementDays, currency, calendar, fixedLegDayCounter)
        {
            tenor_              = tenor;
            iborIndex_          = iborIndex;
            fixedLegTenor_      = fixedLegTenor;
            fixedLegConvention_ = fixedLegConvention;
            exogenousDiscount_  = false;
            discount_           = new Handle <YieldTermStructure>();

            iborIndex_.registerWith(update);
        }