public double YieldFromPrice(double coupon, DateTime maturityDate, DateTime settlementDate, double price) { int tHIMaturityDate = TechHackersAnalyst.THIdate(maturityDate.Year, maturityDate.Month, maturityDate.Day, null); int tHISettlementDate = TechHackersAnalyst.THIdate(settlementDate.Year, settlementDate.Month, settlementDate.Day, null); double [] couponArray = new double[1]; couponArray[0] = coupon; int [] maturityDateArray = new int[1]; maturityDateArray[0] = tHIMaturityDate; return(TechHackersAnalyst.THIbyld(couponArray, couponArray.Length, maturityDateArray, maturityDateArray.Length, tHISettlementDate, price, null, null, null, null, 0, null, null, null, null, null, null, null, null, 0, null, null, 0, null, 0, null, null, null, null)); }
public static decimal PriceFromYield ( decimal coupon, DateTime maturityDate, DateTime settlementDate, decimal price ) { int tHIMaturityDate = TechHackersAnalyst.THIdate(maturityDate.Year, maturityDate.Month, maturityDate.Day, null); int tHISettlementDate = TechHackersAnalyst.THIdate(settlementDate.Year, settlementDate.Month, settlementDate.Day, null); double [] couponArray = new double[1]; couponArray[0] = Convert.ToDouble(coupon); int [] maturityDateArray = new int[1]; maturityDateArray[0] = tHIMaturityDate; return(Convert.ToDecimal(TechHackersAnalyst.THIbyld(couponArray, couponArray.Length, maturityDateArray, maturityDateArray.Length, tHISettlementDate, Convert.ToDouble(price), null, null, null, null, 0, null, null, null, null, null, null, null, null, 0, null, null, 0, null, 0, null, null, null, null))); }