Beispiel #1
0
        public FuturesRateHelper(double price,
                                 Date iborStartDate,
                                 IborIndex i,
                                 double convAdj    = 0.0,
                                 Futures.Type type = Futures.Type.IMM)
            : base(price)
        {
            convAdj_ = new Handle <Quote>(new SimpleQuote(convAdj));

            switch (type)
            {
            case Futures.Type.IMM:
                Utils.QL_REQUIRE(IMM.isIMMdate(iborStartDate, false), () =>
                                 iborStartDate + " is not a valid IMM date");
                break;

            case Futures.Type.ASX:
                Utils.QL_REQUIRE(ASX.isASXdate(iborStartDate, false), () =>
                                 iborStartDate + " is not a valid ASX date");
                break;

            default:
                Utils.QL_FAIL("unknown futures type (" + type + ")");
                break;
            }
            earliestDate_ = iborStartDate;
            Calendar cal = i.fixingCalendar();

            maturityDate_ = cal.advance(iborStartDate, i.tenor(), i.businessDayConvention());
            yearFraction_ = i.dayCounter().yearFraction(earliestDate_, maturityDate_);
            pillarDate_   = latestDate_ = latestRelevantDate_ = maturityDate_;
        }
Beispiel #2
0
        public FuturesRateHelper(double price,
                                 Date iborStartDate,
                                 int lengthInMonths,
                                 Calendar calendar,
                                 BusinessDayConvention convention,
                                 bool endOfMonth,
                                 DayCounter dayCounter,
                                 double convexityAdjustment = 0.0,
                                 Futures.Type type          = Futures.Type.IMM)
            : base(price)
        {
            convAdj_ = new Handle <Quote>(new SimpleQuote(convexityAdjustment));

            switch (type)
            {
            case Futures.Type.IMM:
                Utils.QL_REQUIRE(IMM.isIMMdate(iborStartDate, false), () =>
                                 iborStartDate + " is not a valid IMM date");
                break;

            case Futures.Type.ASX:
                Utils.QL_REQUIRE(ASX.isASXdate(iborStartDate, false), () =>
                                 iborStartDate + " is not a valid ASX date");
                break;

            default:
                Utils.QL_FAIL("unknown futures type (" + type + ")");
                break;
            }
            earliestDate_ = iborStartDate;
            maturityDate_ = calendar.advance(iborStartDate, new Period(lengthInMonths, TimeUnit.Months), convention, endOfMonth);
            yearFraction_ = dayCounter.yearFraction(earliestDate_, maturityDate_);
            pillarDate_   = latestDate_ = latestRelevantDate_ = maturityDate_;
        }
Beispiel #3
0
        public FuturesRateHelper(double price,
                                 Date iborStartDate,
                                 Date iborEndDate,
                                 DayCounter dayCounter,
                                 double convAdj    = 0,
                                 Futures.Type type = Futures.Type.IMM)
            : base(price)
        {
            convAdj_ = new Handle <Quote>(new SimpleQuote(convAdj));

            switch (type)
            {
            case Futures.Type.IMM:
                Utils.QL_REQUIRE(IMM.isIMMdate(iborStartDate, false), () =>
                                 iborStartDate + " is not a valid IMM date");
                if (iborEndDate == null)
                {
                    // advance 3 months
                    maturityDate_ = IMM.nextDate(iborStartDate, false);
                    maturityDate_ = IMM.nextDate(maturityDate_, false);
                    maturityDate_ = IMM.nextDate(maturityDate_, false);
                }
                else
                {
                    Utils.QL_REQUIRE(iborEndDate > iborStartDate, () =>
                                     "end date (" + iborEndDate +
                                     ") must be greater than start date (" +
                                     iborStartDate + ")");
                    maturityDate_ = iborEndDate;
                }
                break;

            case Futures.Type.ASX:
                Utils.QL_REQUIRE(ASX.isASXdate(iborStartDate, false), () =>
                                 iborStartDate + " is not a valid ASX date");
                if (iborEndDate == null)
                {
                    // advance 3 months
                    maturityDate_ = ASX.nextDate(iborStartDate, false);
                    maturityDate_ = ASX.nextDate(maturityDate_, false);
                    maturityDate_ = ASX.nextDate(maturityDate_, false);
                }
                else
                {
                    Utils.QL_REQUIRE(iborEndDate > iborStartDate, () =>
                                     "end date (" + iborEndDate +
                                     ") must be greater than start date (" +
                                     iborStartDate + ")");
                    maturityDate_ = iborEndDate;
                }
                break;

            default:
                Utils.QL_FAIL("unknown futures type (" + type + ")");
                break;
            }
            earliestDate_ = iborStartDate;
            yearFraction_ = dayCounter.yearFraction(earliestDate_, maturityDate_);
            pillarDate_   = latestDate_ = latestRelevantDate_ = maturityDate_;
        }
Beispiel #4
0
        public FuturesRateHelper(Handle <Quote> price,
                                 Date iborStartDate,
                                 int lengthInMonths,
                                 Calendar calendar,
                                 BusinessDayConvention convention,
                                 bool endOfMonth,
                                 DayCounter dayCounter,
                                 Handle <Quote> convAdj = null,
                                 Futures.Type type      = Futures.Type.IMM)
            : base(price)
        {
            convAdj_ = convAdj ?? new Handle <Quote>();

            switch (type)
            {
            case QLCore.Futures.Type.IMM:
                Utils.QL_REQUIRE(QLCore.IMM.isIMMdate(iborStartDate, false), () =>
                                 iborStartDate + " is not a valid IMM date");
                break;

            case QLCore.Futures.Type.ASX:
                Utils.QL_REQUIRE(ASX.isASXdate(iborStartDate, false), () =>
                                 iborStartDate + " is not a valid ASX date");
                break;

            default:
                Utils.QL_FAIL("unknown futures type (" + type + ")");
                break;
            }
            earliestDate_ = iborStartDate;
            maturityDate_ = calendar.advance(iborStartDate, new Period(lengthInMonths, TimeUnit.Months), convention, endOfMonth);
            yearFraction_ = dayCounter.yearFraction(earliestDate_, maturityDate_);
            pillarDate_   = latestDate_ = latestRelevantDate_ = maturityDate_;

            convAdj_.registerWith(update);
        }
Beispiel #5
0
 public FuturesRateHelper(QuoteHandle price, Date iborStartDate, Date iborEndDate, DayCounter dayCounter, QuoteHandle convexityAdjustment, Futures.Type type) : this(NQuantLibcPINVOKE.new_FuturesRateHelper__SWIG_5(QuoteHandle.getCPtr(price), Date.getCPtr(iborStartDate), Date.getCPtr(iborEndDate), DayCounter.getCPtr(dayCounter), QuoteHandle.getCPtr(convexityAdjustment), (int)type), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #6
0
 public FuturesRateHelper(double price, Date iborStartDate, uint nMonths, Calendar calendar, BusinessDayConvention convention, bool endOfMonth, DayCounter dayCounter, double convexityAdjustment, Futures.Type type) : this(NQuantLibcPINVOKE.new_FuturesRateHelper__SWIG_2(price, Date.getCPtr(iborStartDate), nMonths, Calendar.getCPtr(calendar), (int)convention, endOfMonth, DayCounter.getCPtr(dayCounter), convexityAdjustment, (int)type), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #7
0
 public FuturesRateHelper(double price, Date iborStartDate, IborIndex index, double convexityAdjustment, Futures.Type type) : this(NQuantLibcPINVOKE.new_FuturesRateHelper__SWIG_12(price, Date.getCPtr(iborStartDate), IborIndex.getCPtr(index), convexityAdjustment, (int)type), true)
 {
     if (NQuantLibcPINVOKE.SWIGPendingException.Pending)
     {
         throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
     }
 }