static void Main(string[] args) { _services = ConfigureServices(); var loggerFactory = _services.GetRequiredService <IJ4JLoggerFactory>(); _logger = loggerFactory.CreateLogger(typeof(Program)); _context = _services.GetRequiredService <SimulationContext>(); if (!_context.Initialize(args)) { Environment.ExitCode = 1; return; } OutputAssumptions(); PressAnyKey("Press any key to run simulations"); _simulator = _services.GetRequiredService <Simulator>(); _simulator.Run(_context); OutputToExcel(_simulator); }
public bool Run(SimulationContext context) { IsValid = false; if (context == null) { _logger.Error($"Undefined {nameof(context)}"); return(false); } Context = context; Values = new double[Context.Years, Context.Investments, Context.Simulations]; InverseInvestmentGaussians = new InverseGaussian[Context.Investments]; var random = new Random(); for (var inv = 0; inv < Context.Investments; inv++) { InverseInvestmentGaussians[inv] = new InverseGaussian( Context.MeanMarketReturn * random.NextDouble(), Context.StdDevMarketReturn * random.NextDouble() ); } CalculateSimulations(); SummarizeRawGeometricReturns(); SummarizePortfolioReturnsByYear(); CalculatePortfolioReturnStandardDeviationsByYear(); CalculateGeometricMeanReturnsBySimulation(); IsValid = true; return(true); }
public BetaDistribution(SimulationContext simContext, IJ4JLoggerFactory loggerFactory) : base("beta", simContext) { _logger = loggerFactory?.CreateLogger(this.GetType()) ?? throw new NullReferenceException(nameof(loggerFactory)); }