public static void PrintWeightings(List<OwnedFund> ownedFunds) { Dictionary<Weighting, List<OwnedFund>> categorized_funds = new Dictionary<Weighting,List<OwnedFund>>(); foreach(var fund in ownedFunds) { foreach (var weighting in mDesiredWeightings) { if (fund.Country == weighting.Country && fund.Type == weighting.Type) { if (categorized_funds.ContainsKey(weighting) == false) { categorized_funds.Add(weighting, new List<OwnedFund>()); } categorized_funds[weighting].Add(fund); } } } float total_portfolio_worth_current = 0.0f; foreach (var fund in ownedFunds) { total_portfolio_worth_current += fund.Buys.Sum(x => x.Units * fund.CurrentPrice); } Table table = new Table("Type", "Country", "Funds", "Current Weight", "Desired Weight", "$ amount off by"); foreach (var weighting in mDesiredWeightings) { table.AddCell(weighting.Type); table.AddCell(weighting.Country); if (categorized_funds.ContainsKey(weighting)) { table.AddCell(string.Join(",", categorized_funds[weighting].Select(x => x.Symbol).ToList())); float current_weight = categorized_funds[weighting].Sum(x => x.CurrentPercentageOfPortfolio); table.AddCell(current_weight); table.AddCell(weighting.Percent); float difference_needed = total_portfolio_worth_current * ((weighting.Percent - current_weight) / 100.0f); table.AddCell(difference_needed); } else { table.AddCell("-"); table.AddCell("-"); table.AddCell(weighting.Percent); float difference_needed = total_portfolio_worth_current * ((weighting.Percent) / 100.0f); table.AddCell(difference_needed); } } Console.WriteLine(table); }
public static void PrintLatestTrendActivityForAllFunds(DateTime endDate, List<OwnedFund> funds, int overDays, float fluctuationAllowed) { Console.WriteLine("Trends"); Table table = new Table("Symbol", "Start", "End", "Direction", "Change ( >" + fluctuationAllowed + "% )"); foreach (var fund in funds) { List<Trend> trends = RetrieveTrends(endDate, fund, overDays, fluctuationAllowed); Trend trend = trends.Last(); { table.AddCell(fund.Symbol); table.AddCell(trend.Start); table.AddCell(trend.End); table.AddCell(trend.Direction.ToString()); table.AddCell(trend.Change); } } Console.WriteLine(table); }
public static void PrintTrendActivityForFund(DateTime endDate, OwnedFund fund, int overDays, float fluctuationAllowed) { List<Trend> trends = RetrieveTrends(endDate, fund, overDays, fluctuationAllowed); Console.WriteLine("Trends for " + fund.Symbol); int index = 1; Table table = new Table("", "Start", "End", "Direction", "Change ( >" + fluctuationAllowed + "% )"); foreach (Trend trend in trends) { table.AddCell("Trend " + index++); table.AddCell(trend.Start); table.AddCell(trend.End); table.AddCell(trend.Direction.ToString()); table.AddCell(trend.Change); } Console.WriteLine(table); }