コード例 #1
0
ファイル: PathAnalysis.cs プロジェクト: mjheller/Folio
        public static List<decimal> GetMinimumPath(PortfolioPath[] paths, int steps)
        {
            IEnumerable<decimal> endingValues = paths.Select(x => (decimal)x.endingPortfolioValue).ToArray();
            decimal minEndingValue = endingValues.Min();
            var minPathQuery = paths.Where(path => (decimal)path.endingPortfolioValue == minEndingValue).ToArray();
            List<decimal> minPathSequence = minPathQuery[0].portfolioValueList;

            return minPathSequence;
        }
コード例 #2
0
ファイル: MonteCarlo.cs プロジェクト: mjheller/Folio
 public static PortfolioPath[] RunSimulation(int yearsUntilRetirement, 
     int nPaths, double expectedReturn, double variance, double initialPortfolioValue, 
     double annualContributions, double incomeDraw, int yearsPlannedRetirement)
 {
     PortfolioPath[] paths = new PortfolioPath[nPaths];
     Func<int, PortfolioPath> creator = x => new PortfolioPath(yearsUntilRetirement, expectedReturn, variance, initialPortfolioValue, annualContributions, incomeDraw, yearsPlannedRetirement);
     IEnumerable<int> indices = Enumerable.Range(0, nPaths - 1);
     paths = indices.AsParallel().Select(creator).ToArray();
     
     return paths;
 }
コード例 #3
0
ファイル: PathAnalysis.cs プロジェクト: mjheller/Folio
 public static List<decimal> GetAveragePath(PortfolioPath[] paths, int steps)
 {
     List<decimal> avgPathSequence = new List<decimal>();
     for (int i = 0; i < steps - 1; i++)
     {
         decimal[] avgValuesArray = paths.Select(x => (decimal)x.portfolioValueList[i]).ToArray();
         decimal avgValue = avgValuesArray.Average();
         avgPathSequence.Add(avgValue);
     }
     return avgPathSequence;
 }
コード例 #4
0
        public static PortfolioPath[] RunSimulation(int yearsUntilRetirement,
                                                    int nPaths, double expectedReturn, double variance, double initialPortfolioValue,
                                                    double annualContributions, double incomeDraw, int yearsPlannedRetirement)
        {
            PortfolioPath[]           paths   = new PortfolioPath[nPaths];
            Func <int, PortfolioPath> creator = x => new PortfolioPath(yearsUntilRetirement, expectedReturn, variance, initialPortfolioValue, annualContributions, incomeDraw, yearsPlannedRetirement);
            IEnumerable <int>         indices = Enumerable.Range(0, nPaths - 1);

            paths = indices.AsParallel().Select(creator).ToArray();

            return(paths);
        }