當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。