Beispiel #1
0
        public string DrawPlot(InputShortTermModel shortTermModel)
        {
            InitializeWithSTM(shortTermModel);

            var fundT = Enumerable.Range(0, STM.T).Select(x => ApplyInflationProcess(ComputeFinancialState(x), x));

            var plotLines = new List <PlotLine>
            {
                new("Current fund",
                    Enumerable.Range(0, STM.T).Select(x => (double)x).ToArray(),
                    fundT.ToArray())
            };

            var path = Directory.GetCurrentDirectory() + $"\\plots\\{Guid.NewGuid()}.png";

            PlotService.PlotService.MakePlot(path, plotLines, "Moments of time(stochastic)", "fund");
            DrawSelectionPlot();
            return(path);
        }
Beispiel #2
0
        private void InitializeWithSTM(InputShortTermModel shortTermModel)
        {
            STM.V = (int)(STM.N * shortTermModel.Q);

            STM.Bs = Enumerable.Range(0, STM.N)
                     .Select(_ => new Random().NextDouble() * (shortTermModel.BThreshold - shortTermModel.NThreshold) + shortTermModel.NThreshold).ToList();

            // Randomly insurance case
            STM.BVs = Enumerable.Range(0, STM.V).Select(_ => STM.Bs[(int)(new Random().NextDouble() * STM.Bs.Count)])
                      .ToList();

            // Computing desired premium
            // where 0.2 - payload, 1.645 - quantile, M - expectation
            double M = 1 * shortTermModel.Q + (1 - shortTermModel.Q);

            STM.Ps = STM.Bs
                     .Select(b => (b * (1.645 * Math.Sqrt(STM.N * (M - (M * M))) + shortTermModel.Q * STM.N) / 100) / (1 - 0.2))
                     .ToList();
        }