Beispiel #1
0
        public void ParseAndDispatch(string[] args)
        {
            var pArgs = GenericArgsParser.Parse(args);

            if (!string.IsNullOrEmpty(pArgs.ErrorMessage))
            {
                WriteManager.Write(pArgs.ErrorMessage);
                return;
            }
            switch (pArgs.DispatchMode)
            {
            case DispatchModes.Test:
                new DispatchTest().Execute(pArgs);
                break;

            case DispatchModes.Input:
                new DispatchInputData().Execute(pArgs);
                break;

            case DispatchModes.Help:
                new DispatchHelp().Execute(pArgs);
                break;

            case DispatchModes.Create:
                new DispatchCreateFile().Execute(pArgs);
                break;

            //TODO Help.
            default:
                WriteManager.Write($"Invalid Mode: {pArgs.DispatchMode}");
                return;
            }
        }
Beispiel #2
0
        protected InputData ArgsToInputData(GenericArgsParser args)
        {
            var path = args.InputFilePath;

            var data = Input.FromFileSafe(path, new InputData());

            if (File.Exists(args.ReturnsInputFile))
            {
                data.FilePath = args.ReturnsInputFile;
            }

            return(data);
        }
Beispiel #3
0
        public void Execute(GenericArgsParser args)
        {
            var input = ArgsToInputData(args);

            var method        = args.EvaluationMethod;
            var defaultMethod = "AllYears";

            if (method == null || !Simulation.ContainsKey(method))
            {
                WriteManager.Write($"Invalid evaluation method '{method}'.  Replacing with '{defaultMethod}'");
                method = defaultMethod;
            }
            Simulation[method].Mode = args.Mode;
            Simulation[method].ExecuteSimulate(input);
        }
Beispiel #4
0
        public void Execute(GenericArgsParser args)
        {
            Write("Version: " + System.Reflection.Assembly.GetCallingAssembly().GetName().Version);

            Write("Program Execution:");
            Write(" - Args: ");
            Write(" 'Help' - Displays this help prompt");
            Write(" 'EvalMethod' - Provides ability to evaluate performance by different means." +
                  "  Supported methods: AllYears, RandomOrder");
            Write(" 'InputFile' - The JSON input file that defines the scenario.");
            Write(" 'ReturnsInputFile' - The file used to define the returns.  Overrides input file value.");
            Write(" 'Create' - Creates a sample JSON input file.");
            Write(" 'Output' - The output generated by the program.  " +
                  $"Supported modes: {String.Join(", ", Enum.GetNames(typeof(OutputMode))) }.  " +
                  "Files outputs many CSVs, one for each simulation.  " +
                  "Verbose gives details of each simulation and the two GiantCsv outputs are similar data, but in CSV format.");
            Write("Program Examples:");
            Write(@"program.exe InputFile=""C:\fi\le.json"" EvalMethod=""RandomOrder""");
            Write(@"program.exe -InputFile=""C:\fi\le.json""");
            Write(@"program.exe -Create:""C:\valid\file\path\newFile.json""");
            Write(@"program.exe --help");
            Write(@"program.exe InputFile=""C:\fi\le.json"" EvalMethod=""AllYears"" -Output:GiantCsvConsole");
        }
Beispiel #5
0
        public void Execute(GenericArgsParser args)
        {
            var input = new InputData();

            input.IncomeAndExpenses.Add(
                new ExpenseOffset()
            {
                OffsetAmount = (((InputData.InitialAmt * .043M) / 12) * -1).AsMoney()
            });


            input.IncomeAndExpenses.Add(new ExpenseOffset()
            {
                StartMonth   = 380,
                OffsetAmount = 1099.AsMoney(),
            });

            input.IncomeAndExpenses.Add(new ExpenseOffset()
            {
                StartMonth   = 40,
                EndMonth     = 200,
                OffsetAmount = 800.AsMoney(),
            });

            input.FilePath = "";
            input.Adjustments.Clear();

            input.AdjustmentTranslation = new List <AdjustmentTranslationData>()
            {
                new AdjustmentTranslationData()
                {
                    Type = "AdjustByGlide",
                    NameToStringValue = new Dictionary <string, List <string> >
                    {
                        { "from", new List <string>()
                          {
                              "Equity"
                          } },
                        { "to", new List <string>()
                          {
                              "Bond"
                          } },
                    },
                    NameToDecimalValue = new Dictionary <string, decimal>()
                    {
                        { "glide", 5m / 12 }
                    }
                },

                new AdjustmentTranslationData()
                {
                    Type = "AdjustByMaxValues",
                    NameToDecimalValue = new Dictionary <string, decimal>()
                    {
                        { "Equity", 75 }
                    }
                },
                new AdjustmentTranslationData()
                {
                    Type = "AdjustByMinValues",
                    NameToDecimalValue = new Dictionary <string, decimal>()
                    {
                        { "Bond", 5 },
                        { "Equity", 20 },
                        { "Gold", 15 },
                    }
                },
                new AdjustmentTranslationData()
                {
                    Type = "AdjustByCapeRatio",
                    NameToStringValue = new Dictionary <string, List <string> >
                    {
                        { "from", new List <string>()
                          {
                              "Bond"
                          } },
                        { "to", new List <string>()
                          {
                              "Equity"
                          } },
                    },
                    NameToDecimalValue = new Dictionary <string, decimal>()
                    {
                        { "max_cape_before_action", 20 },
                        { "percentage_to_adjust_by", .2M },
                        { "amount_of_cape_excess_to_increase_adjustment", 10M }
                    }
                }
            };

            Input.ToFile(input, args.InputFilePath);

            WriteManager.Write("Execution Completed.");
        }
Beispiel #6
0
        public void Execute(GenericArgsParser args)
        {
            var input = new InputData();

            input.IncomeAndExpenses.Add(
                new ExpenseOffset()
            {
                OffsetAmount = (((InputData.InitialAmt * .043M) / 12) * -1).AsMoney()
            });


            input.IncomeAndExpenses.Add(new ExpenseOffset()
            {
                StartMonth   = 380,
                OffsetAmount = 1099.AsMoney(),
            });

            input.IncomeAndExpenses.Add(new ExpenseOffset()
            {
                StartMonth   = 40,
                EndMonth     = 200,
                OffsetAmount = 800.AsMoney(),
            });



            input.FilePath = "";
            input.AdjustmentTranslation = new List <AdjustmentTranslationData>()
            {
                new AdjustmentTranslationData()
                {
                    Type = "AdjustByDoingNothing"
                },
                new AdjustmentTranslationData()
                {
                    Type = "AdjustByGlide",
                    NameToStringValue = new Dictionary <string, List <string> >
                    {
                        { "from", new List <string>()
                          {
                              "Bond"
                          } },
                        { "to", new List <string>()
                          {
                              "Equity"
                          } },
                    },
                    NameToDecimalValue = new Dictionary <string, decimal>()
                    {
                        { "glide", 5m / 12m }
                    }
                },

                new AdjustmentTranslationData()
                {
                    Type = "AdjustByMaxMinValues"
                },
                new AdjustmentTranslationData()
                {
                    Type = "AdjustByCapeRatio",
                    NameToStringValue = new Dictionary <string, List <string> >
                    {
                        { "from", new List <string>()
                          {
                              "Bond"
                          } },
                        { "to", new List <string>()
                          {
                              "Equity"
                          } },
                    },
                    NameToDecimalValue = new Dictionary <string, decimal>()
                    {
                        { "max_cape_before_action", 20 },
                        { "percentage_to_adjust_by", .2M },
                        { "amount_of_cape_excess_to_increase_adjustment", 10M }
                    }
                }
            };

            var path = @"c:\tmp\Input.json";

            Input.ToFile(input, path);

            var data = Input.FromFileSafe(path, null);


            var comp = data.Compare(input);


            Simulation["AllYears"].ExecuteSimulate(input);
        }