当前位置: 首页>>代码示例>>C#>>正文


C# Bond.settlementDate方法代码示例

本文整理汇总了C#中Bond.settlementDate方法的典型用法代码示例。如果您正苦于以下问题:C# Bond.settlementDate方法的具体用法?C# Bond.settlementDate怎么用?C# Bond.settlementDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bond的用法示例。


在下文中一共展示了Bond.settlementDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: previousCashFlow

      public static CashFlow previousCashFlow(Bond bond, Date refDate = null)
      {
         if (refDate == null)
            refDate = bond.settlementDate();

         return CashFlows.previousCashFlow(bond.cashflows(), false, refDate);
      }
开发者ID:minikie,项目名称:test,代码行数:7,代码来源:BondFunctions.cs

示例2: nextCashFlowDate

      public static Date nextCashFlowDate(Bond bond, Date refDate = null)
      {
         if (refDate == null)
            refDate = bond.settlementDate();

         return CashFlows.nextCashFlowDate(bond.cashflows(), false, refDate);
      }
开发者ID:minikie,项目名称:test,代码行数:7,代码来源:BondFunctions.cs

示例3: isTradable

      public static bool isTradable(Bond bond, Date settlementDate = null)
      {
         if (settlementDate == null)
            settlementDate = bond.settlementDate();

         return bond.notional(settlementDate) != 0.0;
      }
开发者ID:minikie,项目名称:test,代码行数:7,代码来源:BondFunctions.cs

示例4: accrualStartDate

        public static Date accrualStartDate(Bond bond, Date settlementDate = null)
        {
            if (settlementDate == null)
            settlementDate = bond.settlementDate();

             Utils.QL_REQUIRE(BondFunctions.isTradable(bond, settlementDate),
                   "non tradable at " + settlementDate +
                   " (maturity being " + bond.maturityDate() + ")");

             return CashFlows.accrualStartDate(bond.cashflows(), false, settlementDate);
        }
开发者ID:huxletic,项目名称:qlnet,代码行数:11,代码来源:BondFunctions.cs

示例5: 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

示例6: zSpread

      public static double zSpread(Bond bond, double cleanPrice, YieldTermStructure discount, DayCounter dayCounter, Compounding compounding,
                             Frequency frequency, Date settlementDate = null, double accuracy = 1.0e-10, int maxIterations = 100,
                             double guess = 0.0)
      {
         if (settlementDate == null)
            settlementDate = bond.settlementDate();

         Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
                   "non tradable at " + settlementDate +
                   " (maturity being " + bond.maturityDate() + ")");

         double dirtyPrice = cleanPrice + bond.accruedAmount(settlementDate);
         dirtyPrice /= 100.0 / bond.notional(settlementDate);

         return CashFlows.zSpread(bond.cashflows(),
                                  discount,
                                  dirtyPrice,
                                  dayCounter, compounding, frequency,
                                  false, settlementDate, settlementDate,
                                  accuracy, maxIterations, guess);
      }
开发者ID:minikie,项目名称:test,代码行数:21,代码来源:BondFunctions.cs

示例7: cleanPrice

      public static double cleanPrice(Bond bond, YieldTermStructure discount, double zSpread, DayCounter dayCounter, Compounding compounding,
                                Frequency frequency, Date settlementDate = null)
      {
         if (settlementDate == null)
            settlementDate = bond.settlementDate();

         Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
                   "non tradable at " + settlementDate +
                   " (maturity being " + bond.maturityDate() + ")");

         double dirtyPrice = CashFlows.npv(bond.cashflows(), discount, zSpread, dayCounter, compounding, frequency, false, settlementDate) *
                             100.0 / bond.notional(settlementDate);
         return dirtyPrice - bond.accruedAmount(settlementDate);
      }
开发者ID:minikie,项目名称:test,代码行数:14,代码来源:BondFunctions.cs

示例8: nextCouponRate

      public static double nextCouponRate(Bond bond, Date settlementDate = null)
      {
         if (settlementDate == null)
            settlementDate = bond.settlementDate();

         return CashFlows.nextCouponRate(bond.cashflows(), false, settlementDate);
      }
开发者ID:minikie,项目名称:test,代码行数:7,代码来源:BondFunctions.cs

示例9: duration

      public static double duration(Bond bond, InterestRate yield, Duration.Type type = Duration.Type.Modified,
                                     Date settlementDate = null)
      {
         if (settlementDate == null)
            settlementDate = bond.settlementDate();

         Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
                   "non tradable at " + settlementDate +
                   " (maturity being " + bond.maturityDate() + ")");

         return CashFlows.duration(bond.cashflows(), yield, type, false, settlementDate);
      }
开发者ID:minikie,项目名称:test,代码行数:12,代码来源:BondFunctions.cs

示例10: dirtyPrice

      public static double dirtyPrice(Bond bond, InterestRate yield, Date settlementDate = null)
      {
          if (settlementDate == null)
              settlementDate = bond.settlementDate();

          Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
                    "non tradable at " + settlementDate +
                    " (maturity being " + bond.maturityDate() + ")");

          double dirtyPrice = CashFlows.npv(bond.cashflows(), yield, false, settlementDate) *
                              100.0 / bond.notional(settlementDate);
          return dirtyPrice;
      }
开发者ID:minikie,项目名称:test,代码行数:13,代码来源:BondFunctions.cs

示例11: atmRate

      public static double atmRate(Bond bond, YieldTermStructure discountCurve, Date settlementDate = null, double? cleanPrice = null)
      {
         if (settlementDate == null)
            settlementDate = bond.settlementDate();

         Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
                   "non tradable at " + settlementDate +
                   " (maturity being " + bond.maturityDate() + ")");

         double? dirtyPrice = cleanPrice == null ? null : cleanPrice + bond.accruedAmount(settlementDate);
         double currentNotional = bond.notional(settlementDate);
         double? npv = dirtyPrice / 100.0 * currentNotional;

         return CashFlows.atmRate(bond.cashflows(), discountCurve, false, settlementDate, settlementDate, npv);
      }
开发者ID:minikie,项目名称:test,代码行数:15,代码来源:BondFunctions.cs

示例12: bps

      public static double bps(Bond bond, YieldTermStructure discountCurve, Date settlementDate = null)
      {
         if (settlementDate == null)
            settlementDate = bond.settlementDate();

         Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
                   "non tradable at " + settlementDate +
                   " (maturity being " + bond.maturityDate() + ")");

         return CashFlows.bps(bond.cashflows(), discountCurve, false, settlementDate) * 100.0 / bond.notional(settlementDate);
      }
开发者ID:minikie,项目名称:test,代码行数:11,代码来源:BondFunctions.cs

示例13: accruedAmount

      public static double accruedAmount(Bond bond, Date settlementDate = null)
      {
         if (settlementDate == null)
            settlementDate = bond.settlementDate();

         Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
                   "non tradable at " + settlementDate +
                   " (maturity being " + bond.maturityDate() + ")");

         return CashFlows.accruedAmount(bond.cashflows(), false, settlementDate) * 100.0 / bond.notional(settlementDate);
      }
开发者ID:minikie,项目名称:test,代码行数:11,代码来源:BondFunctions.cs

示例14: referencePeriodEnd

      public static Date referencePeriodEnd(Bond bond, Date settlementDate = null)
      {
         if (settlementDate == null)
            settlementDate = bond.settlementDate();

         Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
                   "non tradable at " + settlementDate +
                   " (maturity being " + bond.maturityDate() + ")");

         return CashFlows.referencePeriodEnd(bond.cashflows(), false, settlementDate);
      }
开发者ID:minikie,项目名称:test,代码行数:11,代码来源:BondFunctions.cs

示例15: testZSpreadWithGenericBond

        public void testZSpreadWithGenericBond()
        {
            // Testing clean and dirty price with null Z-spread against theoretical prices...

             CommonVars vars = new CommonVars();

             Calendar bondCalendar = new TARGET();
             int settlementDays = 3;
             int fixingDays = 2;
             bool inArrears = false;

             // Fixed Underlying bond (Isin: DE0001135275 DBR 4 01/04/37)
             // maturity doesn't occur on a business day

             Date fixedBondStartDate1 = new Date(4,Month.January,2005);
             Date fixedBondMaturityDate1 = new Date(4,Month.January,2037);
             Schedule fixedBondSchedule1= new Schedule(fixedBondStartDate1,
                                    fixedBondMaturityDate1,
                                    new Period(Frequency.Annual), bondCalendar,
                                    BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted,
                                    DateGeneration.Rule.Backward, false);
             List<CashFlow> fixedBondLeg1 = new FixedRateLeg(fixedBondSchedule1)
            .withCouponRates(0.04, new ActualActual(ActualActual.Convention.ISDA))
            .withNotionals(vars.faceAmount);
             Date fixedbondRedemption1 = bondCalendar.adjust(fixedBondMaturityDate1,
                                                         BusinessDayConvention.Following);
             fixedBondLeg1.Add(new SimpleCashFlow(100.0, fixedbondRedemption1));
             Bond fixedBond1 = new Bond(settlementDays, bondCalendar, vars.faceAmount, fixedBondMaturityDate1, fixedBondStartDate1,
                  fixedBondLeg1);
             IPricingEngine bondEngine = new DiscountingBondEngine(vars.termStructure);
             fixedBond1.setPricingEngine(bondEngine);

             double fixedBondImpliedValue1 = fixedBond1.cleanPrice();
             Date fixedBondSettlementDate1= fixedBond1.settlementDate();
             // standard market conventions:
             // bond's frequency + coumpounding and daycounter of the YieldCurve
             double fixedBondCleanPrice1 = BondFunctions.cleanPrice(fixedBond1, vars.termStructure, vars.spread,
            new Actual365Fixed(), vars.compounding, Frequency.Annual, fixedBondSettlementDate1);
             double tolerance = 1.0e-13;
             double error1 = Math.Abs(fixedBondImpliedValue1-fixedBondCleanPrice1);
             if (error1>tolerance) {
            Assert.Fail("wrong clean price for fixed bond:"
                        + "\n  market asset swap spread: "
                        + fixedBondImpliedValue1
                        + "\n  par asset swap spread: " + fixedBondCleanPrice1
                        + "\n  error:                 " + error1
                        + "\n  tolerance:             " + tolerance);
             }

             // Fixed Underlying bond (Isin: IT0006527060 IBRD 5 02/05/19)
             // maturity occurs on a business day

             Date fixedBondStartDate2 = new Date(5,Month.February,2005);
             Date fixedBondMaturityDate2 = new Date(5,Month.February,2019);
             Schedule fixedBondSchedule2= new Schedule(fixedBondStartDate2,
                                    fixedBondMaturityDate2,
                                    new Period(Frequency.Annual), bondCalendar,
                                    BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted,
                                    DateGeneration.Rule.Backward, false);
             List<CashFlow> fixedBondLeg2 = new FixedRateLeg(fixedBondSchedule2)
            .withCouponRates(0.05, new Thirty360(Thirty360.Thirty360Convention.BondBasis))
            .withNotionals(vars.faceAmount);
             Date fixedbondRedemption2 = bondCalendar.adjust(fixedBondMaturityDate2, BusinessDayConvention.Following);
             fixedBondLeg2.Add(new SimpleCashFlow(100.0, fixedbondRedemption2));
             Bond fixedBond2 = new Bond(settlementDays, bondCalendar, vars.faceAmount,
                  fixedBondMaturityDate2, fixedBondStartDate2, fixedBondLeg2);
             fixedBond2.setPricingEngine(bondEngine);

             double fixedBondImpliedValue2 = fixedBond2.cleanPrice();
             Date fixedBondSettlementDate2= fixedBond2.settlementDate();
             // standard market conventions:
             // bond's frequency + coumpounding and daycounter of the YieldCurve

             double fixedBondCleanPrice2 = BondFunctions.cleanPrice(fixedBond2, vars.termStructure, vars.spread,
            new Actual365Fixed(), vars.compounding, Frequency.Annual, fixedBondSettlementDate2);
             double error3 = Math.Abs(fixedBondImpliedValue2-fixedBondCleanPrice2);
             if (error3>tolerance) {
            Assert.Fail("wrong clean price for fixed bond:"
                        + "\n  market asset swap spread: "
                        + fixedBondImpliedValue2
                        + "\n  par asset swap spread: " + fixedBondCleanPrice2
                        + "\n  error:                 " + error3
                        + "\n  tolerance:             " + tolerance);
             }

             // FRN Underlying bond (Isin: IT0003543847 ISPIM 0 09/29/13)
             // maturity doesn't occur on a business day

             Date floatingBondStartDate1 = new Date(29,Month.September,2003);
             Date floatingBondMaturityDate1 = new Date(29,Month.September,2013);
             Schedule floatingBondSchedule1= new Schedule(floatingBondStartDate1,
                                       floatingBondMaturityDate1,
                                       new Period(Frequency.Semiannual), bondCalendar,
                                       BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted,
                                       DateGeneration.Rule.Backward, false);
             List<CashFlow> floatingBondLeg1 = new IborLeg(floatingBondSchedule1, vars.iborIndex)
            .withPaymentDayCounter(new Actual360())
            .withFixingDays(fixingDays)
            .withSpreads(0.0056)
            .inArrears(inArrears)
//.........这里部分代码省略.........
开发者ID:akasolace,项目名称:qlnet,代码行数:101,代码来源:T_AssetSwap.cs


注:本文中的Bond.settlementDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。