public double PriceFromYield(double coupon, DateTime maturityDate, DateTime settlementDate, double yield) { double[] couponArray = new double[1]; couponArray[0] = coupon; int tHIMaturityDate = TechHackersAnalyst.THIdate(maturityDate.Year, maturityDate.Month, maturityDate.Day, null); int tHISettlementDate = TechHackersAnalyst.THIdate(settlementDate.Year, settlementDate.Month, settlementDate.Day, null); int[] maturityDateArray = new int[1]; maturityDateArray[0] = tHIMaturityDate; return(TechHackersAnalyst.THIbpr(couponArray, couponArray.Length, maturityDateArray, maturityDateArray.Length, tHISettlementDate, yield, 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 YieldFromPrice ( decimal coupon, DateTime maturityDate, DateTime settlementDate, decimal yield ) { double[] couponArray = new double[1]; couponArray[0] = Convert.ToDouble(coupon); int tHIMaturityDate = TechHackersAnalyst.THIdate(maturityDate.Year, maturityDate.Month, maturityDate.Day, null); int tHISettlementDate = TechHackersAnalyst.THIdate(settlementDate.Year, settlementDate.Month, settlementDate.Day, null); int[] maturityDateArray = new int[1]; maturityDateArray[0] = tHIMaturityDate; return(Convert.ToDecimal(TechHackersAnalyst.THIbpr(couponArray, couponArray.Length, maturityDateArray, maturityDateArray.Length, tHISettlementDate, Convert.ToDouble(yield), null, null, null, null, 0, null, null, null, null, null, null, null, null, 0, null, null, 0, null, 0, null, null, null, null))); }