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(); }
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)); }
public BondEngineCn(IBondYieldPricer bondYieldPricer = null) { _bondYieldPricer = bondYieldPricer ?? new BondYieldPricer(); _bondEngine = new BondEngine(_bondYieldPricer); }
/// <summary> /// 构造函数 /// </summary> /// <param name="bondYieldPricer">债券收益率计算器</param> public BondEngine(IBondYieldPricer bondYieldPricer = null) { _bondYieldPricer = bondYieldPricer ?? new BondYieldPricerCn(); }