當前位置: 首頁>>代碼示例>>C#>>正文


C# Schedule.dates方法代碼示例

本文整理匯總了C#中QLNet.Schedule.dates方法的典型用法代碼示例。如果您正苦於以下問題:C# Schedule.dates方法的具體用法?C# Schedule.dates怎麽用?C# Schedule.dates使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在QLNet.Schedule的用法示例。


在下文中一共展示了Schedule.dates方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AssetSwap

        public AssetSwap(bool parAssetSwap,
                       Bond bond,
                       double bondCleanPrice,
                       double nonParRepayment,
                       double gearing,
                       IborIndex iborIndex,
                       double spread = 0.0,
                       DayCounter floatingDayCount = null,
                       Date dealMaturity = null,
                       bool payBondCoupon = false)
            : base(2)
        {
            bond_ = bond;
             bondCleanPrice_ = bondCleanPrice;
             nonParRepayment_ = nonParRepayment;
             spread_ = spread;
             parSwap_ = parAssetSwap;

             Schedule tempSch = new Schedule(bond_.settlementDate(),
                                         bond_.maturityDate(),
                                         iborIndex.tenor(),
                                         iborIndex.fixingCalendar(),
                                         iborIndex.businessDayConvention(),
                                         iborIndex.businessDayConvention(),
                                         DateGeneration.Rule.Backward,
                                         false); // endOfMonth

             if (dealMaturity == null)
            dealMaturity = bond_.maturityDate();

             Utils.QL_REQUIRE( dealMaturity <= tempSch.dates().Last(), () =>
                     "deal maturity " + dealMaturity +
                     " cannot be later than (adjusted) bond maturity " +
                     tempSch.dates().Last());
             Utils.QL_REQUIRE( dealMaturity > tempSch.dates()[0], () =>
                     "deal maturity " + dealMaturity +
                     " must be later than swap start date " +
                     tempSch.dates()[0]);

             // the following might become an input parameter
             BusinessDayConvention paymentAdjustment = BusinessDayConvention.Following;

             Date finalDate = tempSch.calendar().adjust(dealMaturity, paymentAdjustment);
             Schedule schedule = tempSch.until(finalDate);

             // bondCleanPrice must be the (forward) clean price
             // at the floating schedule start date
             upfrontDate_ = schedule.startDate();
             double dirtyPrice = bondCleanPrice_ +
                             bond_.accruedAmount(upfrontDate_);

             double notional = bond_.notional(upfrontDate_);
             /* In the market asset swap, the bond is purchased in return for
            payment of the full price. The notional of the floating leg is
            then scaled by the full price. */
             if (!parSwap_)
            notional *= dirtyPrice / 100.0;

             if (floatingDayCount == null)
            legs_[1] = new IborLeg(schedule, iborIndex)
                  .withSpreads(spread)
                  .withGearings(gearing)
                  .withNotionals(notional)
                  .withPaymentAdjustment(paymentAdjustment);
             else
            legs_[1] = new IborLeg(schedule, iborIndex)
                  .withSpreads(spread)
                  .withGearings(gearing)
                  .withPaymentDayCounter(floatingDayCount)
                  .withNotionals(notional)
                  .withPaymentAdjustment(paymentAdjustment);

             foreach (CashFlow c in legs_[1])
            c.registerWith(update);

             List<CashFlow> bondLeg = bond_.cashflows();
             // skip bond redemption
             int i;
             for (i = 0; i < bondLeg.Count && bondLeg[i].date() <= dealMaturity; ++i)
             {
            // whatever might be the choice for the discounting engine
            // bond flows on upfrontDate_ must be discarded
            bool upfrontDateBondFlows = false;
            if (!bondLeg[i].hasOccurred(upfrontDate_, upfrontDateBondFlows))
               legs_[0].Add(bondLeg[i]);
             }
             // if the first skipped cashflow is not the redemption
             // and it is a coupon then add the accrued coupon
             if (i < bondLeg.Count - 1)
             {
            Coupon c = bondLeg[i] as Coupon;
            if (c != null)
            {
               CashFlow accruedCoupon = new SimpleCashFlow(c.accruedAmount(dealMaturity), finalDate);
               legs_[0].Add(accruedCoupon);
            }
             }
             // add the nonParRepayment_
             CashFlow nonParRepaymentFlow = new SimpleCashFlow(nonParRepayment_, finalDate);
             legs_[0].Add(nonParRepaymentFlow);
//.........這裏部分代碼省略.........
開發者ID:Yenyenx,項目名稱:qlnet,代碼行數:101,代碼來源:AssetSwap.cs

示例2: genDates

        //public ObservableCollection<DateTime> dates(int addingDays = 0)
        public void genDates(int addingDays = 0)
        {
            

            this.dates_.Clear();

            //Period tenor = new Period(this.tenor_);
            
            QLNet.Calendar calendar = new SouthKorea();

            Period tenor = new Period(this.frequencyEnum_);
            BusinessDayConvention bdc = this.businessDayConvEnum_;
            DateGeneration.Rule dateGen = this.dateGenEnum_;

            try
            {
                Schedule schedule = new Schedule(new Date(initialDate_),
                                             new Date(endDate_),
                                             tenor,
                                             calendar,
                                             bdc,
                                             bdc,
                                             dateGen,
                                             false);

                List<Date> ql_d = schedule.dates();

                for (int i = 0; i < ql_d.Count; i++)
                {
                    this.dates_.Add(ql_d[i]);
                }
            }
            catch (Exception)
            {

                OutputLogViewModel.addResult("schedule gen error");
            }
            

            //test

            //for (int i = 0; i < 6; i++)
            //{
            //    this.dates_.Add(new DateTime());    
            //}

            //this.dates_ = d;

            //return d;

        }
開發者ID:minikie,項目名稱:OTCDerivativesCalculatorModule,代碼行數:52,代碼來源:ScheduleGeneratorViewModel.cs


注:本文中的QLNet.Schedule.dates方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。