Exemple #1
0
        private BarGraphSeries stressTestMarketRiseSeries(Dictionary<int, ReturnData> prices, string seriesName, string colourHex, XElement rpt)
        {
            var test1 = new StressTest("bull", rpt);

            // Bull
            var start1 = test1.PreDate ? prices.Last(p => p.Key < test1.FromIntegerDate).Value : prices[test1.FromIntegerDate];
            var end1 = prices[test1.ToIntegerDate];
            double return1 = (end1.Value - start1.Value) / start1.Value;

            // Bear
            var test3 = new StressTest("bear", rpt);
            var start3 = test3.PreDate ? prices.Last(p => p.Key < test3.FromIntegerDate).Value : prices[test3.FromIntegerDate];
            var end3 = prices[test3.ToIntegerDate];
            double return3 = (end3.Value - start3.Value) / start3.Value;

            // Ten Year Return
            var test2 = new StressTest("ten-year", rpt);
            var start2 = prices.ElementAt(prices.Count() - 121);
            var end2 = prices.Last();

            double return2 = Math.Log(end2.Value.Value / start2.Value.Value);
            test2.FromDate = start2.Value.DateFromInteger;
            test2.ToDate = end2.Value.DateFromInteger;

            var series = new BarGraphSeries
            {
                Name = seriesName,
                ColourHex = colourHex,
                PointNames = new string[] { test1.PointName, test3.PointName, test2.PointName },
                Values = new double[] { return1, return3, return2 }
            };

            return series;
        }
Exemple #2
0
        private BarGraphSeries stressTestMarketCrashSeries(Dictionary<int, ReturnData> prices, string seriesName, string colourHex, XElement rpt)
        {
            //new StressTest("russian-debt-crisis", rpt);

            var tests = new StressTest[]  {
                new StressTest("economic-slowdown", rpt),
                new StressTest("technology-bubble-burst", rpt),
                new StressTest("zeros-collapse", rpt),
                new StressTest("credit-crunch", rpt)
            };

            var pointNames = new string[tests.Length];
            var values = new double[tests.Length];

            for (int i = 0; i < tests.Length; i++) {
                var t = tests[i];
                var start = t.PreDate ? prices.Last(p => p.Key < t.FromIntegerDate).Value : prices[t.FromIntegerDate];
                var end = prices[t.ToIntegerDate];
                double rtrn = (end.Value - start.Value) / start.Value;
                pointNames[i] = t.PointName;
                values[i] = rtrn;
            }

            var series = new BarGraphSeries
            {
                Name = seriesName,
                ColourHex = colourHex,
                PointNames = pointNames,
                Values = values
            };

            return series;
        }