public double PriceToYield() { var bond = new FixedDateCouonAdjustedBondInfo("313100015") { StartDate = "2015-03-23", MaturityDate = "2018-11-17", PaymentFrequency = "Quarterly", Notional = 32000, AccrualDayCount = "Act365", AccrualBusinessDayConvention = "None", DayCount = "Act365", PaymentBusinessDayConvention = "None", FirstPaymentDate = "2015-06-21", Index = "Lrb5Y", FloatingRateMultiplier = 0.9, FixedDateCouponAdjustedStyle = "SpecifiedDates", AdjustMmDd = "11-18", AmoritzationInDate = new Dictionary <string, double> { { "2015-06-20", 0.125 }, //percentage of initial Notional { "2015-12-20", 0.125 }, { "2016-06-20", 0.125 }, { "2016-12-20", 0.125 }, { "2017-06-20", 0.125 }, { "2017-12-20", 0.125 }, { "2018-06-20", 0.125 }, { "2018-11-17", 0.125 }, }, }; var bondVf = new BondVf(bond); var result = bondVf.ValueTrade(_market, PricingRequest.Ytm); return(result.Ytm); }
public BondCalculator() { var bond = new FixedDateCouonAdjustedBondInfo("313100015") { StartDate = "2015-03-23", MaturityDate = "2018-11-17", PaymentFrequency = "Quarterly", Notional = 32000, AccrualDayCount = "Act365", AccrualBusinessDayConvention = "None", DayCount = "Act365", PaymentBusinessDayConvention = "None", FirstPaymentDate = "2015-06-21", Index = "Lrb5Y", FloatingRateMultiplier = 0.9, FixedDateCouponAdjustedStyle = "SpecifiedDates", AdjustMmDd = "11-18", AmoritzationInDate = new Dictionary <string, double> { { "2015-06-20", 0.125 }, //percentage of initial Notional { "2015-12-20", 0.125 }, { "2016-06-20", 0.125 }, { "2016-12-20", 0.125 }, { "2017-06-20", 0.125 }, { "2017-12-20", 0.125 }, { "2018-06-20", 0.125 }, { "2018-11-17", 0.125 }, }, }; _market = TestMarket("2015-03-23", new BondMktData(bond.TradeId, "Dirty", bond.Notional)); }
public void TestFixedDateCouponAdjustedBond1() { var bond = new FixedDateCouonAdjustedBondInfo("313100015") { StartDate = "2015-03-23", MaturityDate = "2018-11-17", PaymentFreq = "Quarterly", Notional = 32000, AccrualDC = "Act365", AccrualBD = "None", DayCount = "Act365", PaymentBD = "None", FirstPaymentDate = "2015-06-21", Index = "Lrb5Y", FloatingRateMultiplier = 0.9, FixedDateCouponAdjustedStyle = "SpecifiedDates", AdjustMmDd = "11-18", AmoritzationInDate = new Dictionary <string, double> { { "2015-06-20", 0.125 }, //percentage of initial Notional { "2015-12-20", 0.125 }, { "2016-06-20", 0.125 }, { "2016-12-20", 0.125 }, { "2017-06-20", 0.125 }, { "2017-12-20", 0.125 }, { "2018-06-20", 0.125 }, { "2018-11-17", 0.125 }, }, //Settlment = "+0BD", //PaymentStub = "ShortEnd", //Calendar = "chn_ib", //Currency = "CNY", //TradingMarket = "ChinaInterBank", //IsZeroCouponBond = false, //IssuePrice = 100, //ValuationParamters = new SimpleCfValuationParameters("Fr007", "", "Fr007") }; var marketInfo = TestMarket("2015-03-23", new BondMktData(bond.TradeId, "Dirty", bond.Notional)); var bondVf = new BondVf(bond); var result = bondVf.ValueTrade(marketInfo, PricingRequest.Cashflow); var expectedResults = new[] { "Coupon 459.9715 CNY@2015-06-20", "Coupon 4.5222 CNY@2015-06-21", "Coupon 416.0416 CNY@2015-09-21", "Coupon 392.6367 CNY@2015-12-20", "Coupon 3.4915 CNY@2015-12-21", "Coupon 317.7271 CNY@2016-03-21", "Coupon 317.7271 CNY@2016-06-20", "Coupon 2.9096 CNY@2016-06-21", "Coupon 267.6822 CNY@2016-09-21", "Coupon 261.863 CNY@2016-12-20", "Coupon 2.3277 CNY@2016-12-21", "Coupon 209.4904 CNY@2017-03-21", "Coupon 211.8181 CNY@2017-06-20", "Coupon 1.7458 CNY@2017-06-21", "Coupon 160.6093 CNY@2017-09-21", "Coupon 157.1178 CNY@2017-12-20", "Coupon 1.1638 CNY@2017-12-21", "Coupon 104.7452 CNY@2018-03-21", "Coupon 105.909 CNY@2018-06-20", "Coupon 0.5819 CNY@2018-06-21", "Coupon 53.5364 CNY@2018-09-21", "Coupon 33.1693 CNY@2018-11-17", "Principal 4000 CNY@2015-06-20", "Principal 4000 CNY@2015-12-20", "Principal 4000 CNY@2016-06-20", "Principal 4000 CNY@2016-12-20", "Principal 4000 CNY@2017-06-20", "Principal 4000 CNY@2017-12-20", "Principal 4000 CNY@2018-06-20", "Principal 4000 CNY@2018-11-17", }; for (var i = 0; i < result.Cashflows.Length; ++i) { Assert.AreEqual(result.Cashflows[i].ToString(), expectedResults[i]); } }
public void TestFixedDateCouponAdjustedBond2() { var bond = new FixedDateCouonAdjustedBondInfo("1141100129") { StartDate = "2015-03-23", MaturityDate = "2018-04-24", PaymentFreq = "Quarterly", Notional = 4000, AccrualDC = "Act365", AccrualBD = "None", DayCount = "Act365", PaymentBD = "None", FirstPaymentDate = "2015-06-21", Index = "Lrb5Y", FloatingRateMultiplier = 1.0, FixedDateCouponAdjustedStyle = "Follow", AdjustMmDd = "11-08", AmoritzationInDate = new Dictionary <string, double> { { "2015-05-18", 0.25 }, //percentage of initial Notional { "2015-11-19", 0.25 }, { "2016-05-18", 0.5 } }, //Settlment = "+0BD", //PaymentStub = "ShortEnd", //Calendar = "chn_ib", //Currency = "CNY", //TradingMarket = "ChinaInterBank", //IsZeroCouponBond = false, //IssuePrice = 100, //ValuationParamters = new SimpleCfValuationParameters("Fr007", "", "Fr007") }; var marketInfo = TestMarket("2015-03-23", new BondMktData(bond.TradeId, "Dirty", bond.Notional)); var bondVf = new BondVf(bond); var result = bondVf.ValueTrade(marketInfo, PricingRequest.Cashflow); var expectedResults = new[] { "Coupon 36.2082 CNY@2015-05-18", "Coupon 16.4877 CNY@2015-06-21", "Coupon 44.6137 CNY@2015-09-21", "Coupon 28.611 CNY@2015-11-19", "Coupon 10.3452 CNY@2015-12-21", "Coupon 29.4192 CNY@2016-03-21", "Coupon 18.7507 CNY@2016-05-18", "Coupon 0 CNY@2016-06-21", "Coupon 0 CNY@2016-09-21", "Coupon 0 CNY@2016-12-21", "Coupon 0 CNY@2017-03-21", "Coupon 0 CNY@2017-06-21", "Coupon 0 CNY@2017-09-21", "Coupon 0 CNY@2017-12-21", "Coupon 0 CNY@2018-03-21", "Coupon 0 CNY@2018-04-24", "Principal 1000 CNY@2015-05-18", "Principal 1000 CNY@2015-11-19", "Principal 2000 CNY@2016-05-18", }; for (var i = 0; i < result.Cashflows.Length; ++i) { Assert.AreEqual(result.Cashflows[i].ToString(), expectedResults[i]); } }