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


C# Bond类代码示例

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


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

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

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

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

示例4: SendBondData

        public string SendBondData(Bond obj)
        {
            PropertyInfo[] properties = obj.GetType().GetProperties();

            if (obj == null)
                return "False";
            else
            {
                DataTable tempTable = new DataTable();
                List<string> columnList = DataAccessLayer.DAL.GetColumnNames("Bond", true);
                for (int i = 0; i < columnList.Count && columnList[i] != ""; i++)
                {
                    DataColumn dc = new DataColumn(columnList[i], typeof(string));
                    tempTable.Columns.Add(dc);
                }

                DataRow dr = tempTable.NewRow();
                foreach (PropertyInfo p in properties)
                {
                    dr[p.Name] = p.GetValue(obj, null);
                }
                tempTable.Rows.Add(dr);

                return DataAccessLayer.DAL.SendDataToDB(tempTable, "Bond").ToString();
            }
        }
开发者ID:abhipanorian,项目名称:Projects,代码行数:26,代码来源:OurService.svc.cs

示例5: Main

 static void Main(string[] args)
 {
     DependencyInversionTradeController ditc = new DependencyInversionTradeController();
     Gilt gilt = new Gilt() { value = 10 };
     Bond bond = new Bond() { value = 100 };
     ditc.TradeStock(gilt);
     ditc.TradeStock(bond);
 }
开发者ID:RajeevArora93,项目名称:Projects,代码行数:8,代码来源:Program.cs

示例6: BondHelper

        /*! \warning Setting a pricing engine to the passed bond from
                     external code will cause the bootstrap to fail or
                     to give wrong results. It is advised to discard
                     the bond after creating the helper, so that the
                     helper has sole ownership of it.
        */
        public BondHelper(Handle<Quote> cleanPrice, Bond bond) : base(cleanPrice) {
            bond_ = bond;

            latestDate_ = bond_.maturityDate();
            initializeDates();

            IPricingEngine bondEngine = new DiscountingBondEngine(termStructureHandle_);
            bond_.setPricingEngine(bondEngine);        
        }
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:15,代码来源:Bondhelpers.cs

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

示例8: SendBondData

        public string SendBondData(Bond obj)
        {
            if (obj == null)
                return "False";
            else
            {
                DataTable tempTable = new DataTable();
                List<string> columnList = DataAccessLayer.DAL.GetColumnNames("Bond");
                for (int i = 0; i < columnList.Count && columnList[i] != ""; i++)
                {
                    DataColumn dc = new DataColumn(columnList[i], typeof(string));
                    tempTable.Columns.Add(dc);
                }
                
                tempTable.Rows.Add(new Object[] { obj.securityName, obj.securityDescription, obj.assetType,obj.investmentType,
                    obj.tradingFactor,obj.pricingFactor,obj.isin,obj.bloombergTicker,
                    obj.bloombergUniqueID,obj.cusip,obj.sedol,obj.firstCouponDate,obj.cap,obj.floor,
                    obj.couponFrequency,obj.coupon,obj.couponType,obj.spread,
                    obj.callableFlag,obj.fixToFloatFlag,obj.putableFlag,obj.issueDate,
                    obj.lastResetDate,obj.maturity,obj.callNotificationMaxDays,obj.putNotificationMaxDays,
                    obj.penultimateCouponDate,obj.resetFrequency,obj.hasPosition,obj.macaulayDuration,
                    obj.thirtyDayVolatility,obj.ninetyDayVolatility,obj.convexity,obj.thirtyDayAvgVolume,
                    obj.formPFAssetClass,obj.formPFCountry,obj.formPFCreditRating,obj.formPFCurrency,
                    obj.formPFInstrument,obj.formPFLiquidityProfile,obj.formPFMaturity,obj.formPFNAICSCode,
                    obj.formPFRegion,obj.formPFSector,obj.formPFSubAssetClass,obj.bloombergIndustryGroup,
                    obj.bloombergIndustrySubGroup,obj.bloombergIndustrySector,obj.countryOfIssuance,obj.issueCurrency,
                    obj.issuer,obj.riskCurrency,obj.putDate,obj.putPrice,
                    obj.askPrice,obj.highPrice,obj.lowPrice,obj.openPrice,
                    obj.volume,obj.bidPrice,obj.lastPrice,obj.callDate,
                    obj.callPrice });

                Console.WriteLine(tempTable.Columns.Count);

                DataAccessLayer.DAL.SendDataToDB(tempTable, "Bond");
                return "True";
            }
        }
开发者ID:abhipanorian,项目名称:Visual-Studio-2010,代码行数:37,代码来源:OurService.svc.cs

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

示例10: testMASWWithGenericBond

        public void testMASWWithGenericBond()
        {
            // Testing market asset swap against par asset swap with generic bond...

             CommonVars vars = new CommonVars();

             Calendar bondCalendar = new TARGET();
             int settlementDays = 3;
             int fixingDays = 2;
             bool payFixedRate = true;
             bool parAssetSwap = true;
             bool mktAssetSwap = false;
             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);
             IPricingEngine swapEngine = new DiscountingSwapEngine(vars.termStructure);
             fixedBond1.setPricingEngine(bondEngine);

             double fixedBondMktPrice1 = 89.22 ; // market price observed on 7th June 2007
             double fixedBondMktFullPrice1=fixedBondMktPrice1+fixedBond1.accruedAmount();
             AssetSwap fixedBondParAssetSwap1= new AssetSwap(payFixedRate,
                                          fixedBond1, fixedBondMktPrice1,
                                          vars.iborIndex, vars.spread,
                                          null,
                                          vars.iborIndex.dayCounter(),
                                          parAssetSwap);
             fixedBondParAssetSwap1.setPricingEngine(swapEngine);
             double fixedBondParAssetSwapSpread1 = fixedBondParAssetSwap1.fairSpread();
             AssetSwap fixedBondMktAssetSwap1 = new AssetSwap(payFixedRate,
                                          fixedBond1, fixedBondMktPrice1,
                                          vars.iborIndex, vars.spread,
                                          null,
                                          vars.iborIndex.dayCounter(),
                                          mktAssetSwap);
             fixedBondMktAssetSwap1.setPricingEngine(swapEngine);
             double fixedBondMktAssetSwapSpread1 = fixedBondMktAssetSwap1.fairSpread();

             double tolerance = 1.0e-13;
             double error1 =
            Math.Abs(fixedBondMktAssetSwapSpread1-
                     100*fixedBondParAssetSwapSpread1/fixedBondMktFullPrice1);

             if (error1>tolerance)
            Assert.Fail("wrong asset swap spreads for fixed bond:" +
                        "\n  market asset swap spread: " + fixedBondMktAssetSwapSpread1 +
                        "\n  par asset swap spread:    " + fixedBondParAssetSwapSpread1 +
                        "\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 fixedBondMktPrice2 = 99.98 ; // market price observed on 7th June 2007
             double fixedBondMktFullPrice2=fixedBondMktPrice2+fixedBond2.accruedAmount();
             AssetSwap fixedBondParAssetSwap2= new AssetSwap(payFixedRate,
                                          fixedBond2, fixedBondMktPrice2,
                                          vars.iborIndex, vars.spread,
                                          null,
                                          vars.iborIndex.dayCounter(),
                                          parAssetSwap);
             fixedBondParAssetSwap2.setPricingEngine(swapEngine);
             double fixedBondParAssetSwapSpread2 = fixedBondParAssetSwap2.fairSpread();
             AssetSwap fixedBondMktAssetSwap2= new AssetSwap(payFixedRate,
                                          fixedBond2, fixedBondMktPrice2,
                                          vars.iborIndex, vars.spread,
                                          null,
                                          vars.iborIndex.dayCounter(),
//.........这里部分代码省略.........
开发者ID:akasolace,项目名称:qlnet,代码行数:101,代码来源:T_AssetSwap.cs

示例11: nextCashFlowDate

 public static Date nextCashFlowDate(Bond bond) {
   Date ret = new Date(NQuantLibcPINVOKE.BondFunctions_nextCashFlowDate__SWIG_1(Bond.getCPtr(bond)), true);
   if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
开发者ID:minikie,项目名称:test,代码行数:5,代码来源:BondFunctions.cs

示例12: isTradable

 public static bool isTradable(Bond bond) {
   bool ret = NQuantLibcPINVOKE.BondFunctions_isTradable__SWIG_1(Bond.getCPtr(bond));
   if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
开发者ID:minikie,项目名称:test,代码行数:5,代码来源:BondFunctions.cs

示例13: yieldValueBasisPoint

 public static double yieldValueBasisPoint(Bond bond, InterestRate yield) {
   double ret = NQuantLibcPINVOKE.BondFunctions_yieldValueBasisPoint__SWIG_1(Bond.getCPtr(bond), InterestRate.getCPtr(yield));
   if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
开发者ID:minikie,项目名称:test,代码行数:5,代码来源:BondFunctions.cs

示例14: basisPointValue

 public static double basisPointValue(Bond bond, InterestRate yield, Date settlementDate) {
   double ret = NQuantLibcPINVOKE.BondFunctions_basisPointValue__SWIG_0(Bond.getCPtr(bond), InterestRate.getCPtr(yield), Date.getCPtr(settlementDate));
   if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
开发者ID:minikie,项目名称:test,代码行数:5,代码来源:BondFunctions.cs

示例15: nextCouponRate

 public static double nextCouponRate(Bond bond) {
   double ret = NQuantLibcPINVOKE.BondFunctions_nextCouponRate__SWIG_1(Bond.getCPtr(bond));
   if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
开发者ID:minikie,项目名称:test,代码行数:5,代码来源:BondFunctions.cs


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