public static double GetFixedSidePV(DateTime valuationDate, List <AmortisingResultItem> fixedCFs, List <AmortisingResultItem> floatCFs, IDayCounter dayCounter, RateCurve curve, double floatRateMargin, double fixedRate, DateTime bulletPaymentDate, double bulletPaymentValue) { // solve for the fixed rate // var objectiveFunction = new BillSwapPricer2SwapParRateObjectiveFunction(valuationDate, fixedCFs, floatCFs, curve, dayCounter, floatRateMargin, bulletPaymentDate, bulletPaymentValue); double presentValueOfFixedSide = -objectiveFunction.Value(fixedRate); return(presentValueOfFixedSide); }
public static double GetFixedSideSensitivity(DateTime valuationDate, List <AmortisingResultItem> fixedCFs, List <AmortisingResultItem> floatCFs, IDayCounter dayCounter, RateCurve originalCurve, RateCurve perturbedCurve, double floatRateMargin, double fixedRate, DateTime bulletPaymentDate, double bulletPaymentValue) { // solve for the fixed rate // var objectiveFunction = new BillSwapPricer2SwapParRateObjectiveFunction(valuationDate, fixedCFs, floatCFs, originalCurve, dayCounter, floatRateMargin, bulletPaymentDate, bulletPaymentValue); double originalPV = objectiveFunction.Value(fixedRate); var objectiveFunctionWithPerturbedCurve = new BillSwapPricer2SwapParRateObjectiveFunction(valuationDate, fixedCFs, floatCFs, perturbedCurve, dayCounter, floatRateMargin, bulletPaymentDate, bulletPaymentValue); double perturbedPV = objectiveFunctionWithPerturbedCurve.Value(fixedRate); return(perturbedPV - originalPV); }
public static double GetFixedRate(DateTime valuationDate, List <AmortisingResultItem> fixedCFs, List <AmortisingResultItem> floatCFs, IDayCounter dayCounter, RateCurve curve, double floatRateMargin, DateTime bulletPaymentDate, double bulletPaymentValue) { // solve for the fixed rate // IObjectiveFunction objectiveFunction = new BillSwapPricer2SwapParRateObjectiveFunction(valuationDate, fixedCFs, floatCFs, curve, dayCounter, floatRateMargin, bulletPaymentDate, bulletPaymentValue); const double accuracy = 10e-14; const double guess = 0.1; //Are these min and max reasonable? var min = -.01; var max = .10; var solver = new Newton(); return(solver.Solve(objectiveFunction, accuracy, guess, min, max)); }