コード例 #1
0
        static void Main(string[] args)
        {
            var wireData = new WireData <Round>();

            string file1 = @"c:\temp\losses_small_better";
            string file2 = @"c:\temp\losses_small_better";

            var joiner  = new LossJoiner();
            var limiter = new LossLimiter();

            List <Round> roundsFromSource1 = wireData.ReadAll(file1);

            joiner.AddData(roundsFromSource1);

            List <Round> roundsFromSource2 = wireData.ReadAll(file2);

            joiner.AddData(roundsFromSource2);

            var allRounds = joiner.GetRounds();

            var limitedRounds = limiter.Limit(allRounds, 30000);

            var average = RiskMeasures.Average(limitedRounds);
            var maxLoss = RiskMeasures.MaxLoss(limitedRounds);
            var tvar10  = RiskMeasures.TailValueAtRisk(limitedRounds, 0.9);


            Console.WriteLine($"Average: {average}");
            Console.WriteLine($"maxLoss: {maxLoss}");
            Console.WriteLine($"tvar10: {tvar10}");

            Console.ReadKey();
        }
コード例 #2
0
        public void Generate()
        {
            LossSimulator lossSimulator = new LossSimulator();
            var           fileName      = @"c:\temp\losses_small_all";
            var           fileName2     = @"c:\temp\losses_large_all";

            var losses  = lossSimulator.GenerateStatic(20000, 100);
            var losses2 = lossSimulator.GenerateStatic(100000, 100);

            var betterLosses = lossSimulator.GenerateRandom(1000000, 1000);

            var protobufData = new ProtobufData <Trial>();
            var wireData     = new WireData <Trial>();

            //wireData.WriteAll(betterLosses.ToList(), @"c:\temp\losses_small_better", Console.WriteLine);
            protobufData.WriteStreamedData(@"c:\temp\losses_large_streamed", betterLosses, Console.WriteLine);
            wireData.WriteStreamedData(@"c:\temp\losses_large_streamed", betterLosses, Console.WriteLine);

            //protobufData.WriteAll(losses.ToList(), fileName, Console.WriteLine);
            //protobufData.WriteAll(losses2.ToList(), fileName2, Console.WriteLine);
            //wireData.WriteAll(losses.ToList(), fileName, Console.WriteLine);
            //wireData.WriteAll(losses2.ToList(), fileName2, Console.WriteLine);

            List <Trial> r  = protobufData.ReadAll(fileName);
            List <Trial> r2 = protobufData.ReadAll(fileName2);

            List <Trial> r3 = wireData.ReadAll(fileName);
            List <Trial> r4 = wireData.ReadAll(fileName2);


            //int roundCount = protobufData.WriteStreamedData(fileName + ".pb", losses, Console.WriteLine);
            //int roundCount2 = wireData.WriteStreamedData(fileName + ".wir", losses, Console.WriteLine);

            // IEnumerable<Trial> allData = wireData.GetStreamedData(fileName + ".wir", roundCount2);
            //IEnumerable<Trial> allData2 = protobufData.GetStreamedData(fileName + ".pb", roundCount);
        }