/// <summary> /// Performs the regression for a single date /// </summary> /// <param name="date">The date.</param> /// <param name="simulatedCFs">The simulated c fs.</param> /// <param name="simulatedRegs">The simulated regs.</param> /// <param name="subPortfolio">The sub portfolio.</param> /// <returns></returns> private double[] PerformRegression(Date date, SimulatedCashflows simulatedCFs, SimulatedRegressors simulatedRegs, List <int> subPortfolio) { double[] cfs = simulatedCFs.GetPathwisePV(date, subPortfolio); double[] fitted = simulatedRegs.FitCFs(date, cfs); return(fitted); }
/// <summary> /// Gets all the data that might be of interest after a simulation. /// </summary> /// <param name="portfolioIn">The portfolio in.</param> /// <param name="valueDate">The value date.</param> /// <param name="fwdValueDates">The forward value dates.</param> /// <returns></returns> public ResultStore GetValuePaths(Product[] portfolioIn, Date valueDate, Date[] fwdValueDates) { CalculateAll(portfolioIn, valueDate, fwdValueDates); ResultStore results = new ResultStore(); results.Add("regressedFwdsPVs", regressedValues); double[,] fwdCashflowPVs = new double[N, fwdValueDates.Count()]; for (int i = 0; i < fwdValueDates.Count(); i++) { fwdCashflowPVs.SetColumn(i, simulatedCFs.GetPathwisePV(fwdValueDates[i], originalTrades)); } results.Add("fwdCashflowPVs", fwdCashflowPVs); for (int regressorNumber = 0; regressorNumber < simulatedRegs.GetNumberOfRegressors(); regressorNumber++) { results.Add("regressor" + regressorNumber.ToString(), simulatedRegs.GetRegressors(regressorNumber, fwdValueDates)); } return(results); }
/// <summary> /// Gets all the data that might be of interest after a simulation. /// </summary> /// <param name="portfolioIn">The portfolio in.</param> /// <param name="valueDate">The value date.</param> /// <param name="fwdValueDates">The forward value dates.</param> /// <returns></returns> public ResultStore GetValuePaths(IProduct[] portfolioIn, Date valueDate, Date[] fwdValueDates) { CalculateAll(portfolioIn, valueDate, fwdValueDates); var results = new ResultStore(); results.Add("regressedFwdsPVs", _regressedValues); var fwdCashflowPVs = new double[_numberOfPaths, fwdValueDates.Count()]; for (var i = 0; i < fwdValueDates.Length; i++) { fwdCashflowPVs.SetColumn(i, _simulatedCFs.GetPathwisePV(fwdValueDates[i], _originalTrades)); } results.Add("fwdCashflowPVs", fwdCashflowPVs); for (var regressorNumber = 0; regressorNumber < _simulatedRegs.GetNumberOfRegressors(); regressorNumber++) { results.Add("regressor" + regressorNumber, _simulatedRegs.GetRegressors(regressorNumber, fwdValueDates)); } return(results); }