/// <summary> /// Calculating reserve by discounting cash flow with relevant zero coupon bond prices. /// </summary> public double ReserveCalculator(int timePoint, double shortRate, double[] cashFlows) { var reserve = 0.0; // We minus with one, cause we are integrating over intervals (t_{i}, t_{i+1}], ..., (t_{n-1}, t_{n}]. for (var i = timePoint; i < TimePointToIndex(cashFlows.Length, true) - 1; i++) { reserve += EcoScenarioGenerator.ZeroCouponBondPrices(shortRate, ProjectionIndexToTimeInYear(timePoint), ProjectionIndexToTimeInYear(i + 0.5)) * (cashFlows[TimePointToIndex(i + 1)] - cashFlows[TimePointToIndex(i)]) * 0.5 * ProjectionStepSize; } return(reserve); }
/// <summary> /// Projecting for all economic scenarios. /// </summary> public Balance Project() { for (var i = 0; i < NumberOfEconomicScenarios; i++) { var ecoResult = new StateIndependentProjectionResult( Input.Policies.Keys, NumberOfProjectionTimes, EcoScenarioGenerator.SimulateMarket()); ProjectPerEconomicScenario(ecoResult); ProjectionResult.Add(ecoResult); } return(CalculateBalance()); }
/// <summary> /// Calculate controls for current time point. /// </summary> private void CalculateControlsForCurrentTimePoint(StateIndependentProjectionResult ecoResult, int timePoint) { //TODO OLIVER foreach (var portfolio in ecoResult.PortfolioResults) { var x = 0.0; if (timePoint % 12 == 0) { if (portfolio.Value.AssetProcess[timePoint] - portfolio.Value.PortfolioWideTechnicalReserve[timePoint] > 0) { x = 0.003 * (portfolio.Value.AssetProcess[timePoint] - portfolio.Value.PortfolioWideTechnicalReserve[timePoint]); } else { x = -(portfolio.Value.AssetProcess[timePoint] - portfolio.Value.PortfolioWideTechnicalReserve[timePoint]); } } else { x = 0; } var h1 = new double(); //Use "Tax- and expense-modified risk-minimization for insurance payment processes" p.24 with gamma=delta=0 var rt = ecoResult.EconomicScenario[Assets.ShortRate][TimePointToIndex(timePoint)]; //todo - unsure if this is the right timePoint conversion here. var timePointYear = ProjectionIndexToTimeInYear(timePoint); var Y = 0.0; for (var t = timePoint; t <= ProjectionTimeInYearToIndex(ProjectionEndTime); t++) { Y = (Input.MarketOriginalCashFlows[portfolio.Key][t] + portfolio.Value.QProcess[timePoint] * Input.MarketBonusCashFlows[portfolio.Key][t]) - (Input.MarketOriginalCashFlows[portfolio.Key][timePoint] + portfolio.Value.QProcess[timePoint] * Input.MarketBonusCashFlows[portfolio.Key][timePoint]); h1 = h1 + EcoScenarioGenerator.ZeroCouponBondPriceDerivatives(rt, timePointYear, ProjectionIndexToTimeInYear(t)) / EcoScenarioGenerator.ZeroCouponBondPriceDerivatives(rt, timePointYear, ProjectionEndTime) * Y * ProjectionStepSize; } portfolio.Value.TransactionProcess[Index.Zero][timePoint] = 0.0; portfolio.Value.TransactionProcess[Index.One][timePoint] = x; //take 0.3% of "surplus" if positive, otherwise, transfer so surplus is non-negative portfolio.Value.DividendProcess[Index.Zero][timePoint] = 0.01; portfolio.Value.DividendProcess[Index.One][timePoint] = 0.01; portfolio.Value.ShareInRiskyStockAssetProcess[timePoint] = h1; } ecoResult.EquityResults.ShareInRiskyAssetEquity[timePoint] = 0.0; }