ChrisCScott / forecaster

A personal finances forecasting tool for Canadian retirement planning
Other
1 stars 2 forks source link

Add Monte Carlo simulations #75

Open ChrisCScott opened 5 years ago

ChrisCScott commented 5 years ago

A user should be able to set up some initial conditions (accounts, plannees, strategies) and then instruct Forecaster to run multiple simulations, varying only the values of Scenario. This should be easy to do with the existing structure of Forecaster - the major task is finding a good way to vary Scenario.

One can imagine varying Scenario in various ways. A user should be able to provide a mechanism for generating various Scenario objects. Consider implementing an iterable class (ScenarioSampler) which yields Scenario objects according to some internal logic. Perhaps it should have a sample() method which generates a Scenario object in some sensible way.

Consider implementing ScenarioSamplerABC as an abstract base class and leaving it to subclasses to implement sample(), since most reasonable implementations are likely to contribute some complexity (and require some imports - e.g. of numpy). That will add a lot of weight to the class that we really don't want to flow down to every subclass.

For example, a subclass of ScenarioSamplerABC might use numpy to construct a (joint) probability distribution based on historical returns data and then sample from the distribution to generate new Scenario objects. A simpler implementation might simply generate pseudorandom values within a range.