示例#1
0
 public SolveYtm(Cashflow[] cashflows,
                 IDayCount dayCount,
                 Frequency frequency,
                 Date startDate,
                 Date valueDate,
                 double fullPrice,
                 TradingMarket tradeingMarket,
                 bool irregularPayment,
                 IBondYieldPricer bondYieldPricer = null)
 {
     _cashflows        = cashflows;
     _dayCount         = dayCount;
     _frequency        = frequency;
     _startDate        = startDate;
     _valueDate        = valueDate;
     _fullPrice        = fullPrice;
     _tradeingMarket   = tradeingMarket;
     _irregularPayment = irregularPayment;
     _bondYieldPricer  = bondYieldPricer ?? new BondYieldPricer();
 }
示例#2
0
        public static double GetModifiedDuration(Cashflow[] cashflows,
                                                 IDayCount dayCount,
                                                 Frequency frequency,
                                                 Date startDate,
                                                 Date valueDate,
                                                 double yield,
                                                 TradingMarket tradeingMarket,
                                                 bool irregularPayment            = false,
                                                 IBondYieldPricer bondYieldPricer = null)
        {
            const double dy = 1e-4;

            if (bondYieldPricer == null)
            {
                bondYieldPricer = new BondYieldPricer();
            }
            var priceUp   = bondYieldPricer.FullPriceFromYield(cashflows, dayCount, frequency, startDate, valueDate, yield - dy, tradeingMarket, irregularPayment);
            var priceDown = bondYieldPricer.FullPriceFromYield(cashflows, dayCount, frequency, startDate, valueDate, yield + dy, tradeingMarket, irregularPayment);

            return((priceUp - priceDown) / dy / (priceDown + priceUp));
        }
示例#3
0
 public BondEngineCn(IBondYieldPricer bondYieldPricer = null)
 {
     _bondYieldPricer = bondYieldPricer ?? new BondYieldPricer();
     _bondEngine      = new BondEngine(_bondYieldPricer);
 }
示例#4
0
文件: BondEngine.cs 项目: hjhan/Qdp
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="bondYieldPricer">债券收益率计算器</param>
 public BondEngine(IBondYieldPricer bondYieldPricer = null)
 {
     _bondYieldPricer = bondYieldPricer ?? new BondYieldPricerCn();
 }