Exemplo n.º 1
0
        private void ChartDataUIEventManager_NewFileSelectedEvent(object sender, string reportXmlFile)
        {
            PortfolioValuationSummaryDataModel portfolioValuationSummaryDataModel = _portfolioModelDeserialiser.GetReportDataModel(reportXmlFile);

            var holdingsValuation = new Dictionary <string, List <IChartDataPoint <DateTime> > >();

            foreach (PortfolioValuationDataReportingModel reportingPoint in portfolioValuationSummaryDataModel.PortfolioValuationData)
            {
                foreach (HoldingValuationDataReportingModel holdingsDataPoint in reportingPoint.HoldingValuations)
                {
                    if (!holdingsValuation.ContainsKey(holdingsDataPoint.StockSymbol))
                    {
                        holdingsValuation.Add(holdingsDataPoint.StockSymbol, new List <IChartDataPoint <DateTime> >());
                    }

                    holdingsValuation[holdingsDataPoint.StockSymbol].Add(new ChartDataPoint <DateTime>(reportingPoint.ValuationDate, holdingsDataPoint.HoldingValue));
                }
            }

            IEnumerable <ChartDataSeries <DateTime> > holdingsDataSeries = holdingsValuation.Select(x =>
            {
                return(new ChartDataSeries <DateTime>(x.Key, x.Value, 1));
            });

            _chartDataSeriesCollection.Clear();
            _chartDataSeriesCollection.Add(GetPortfolioValuation(portfolioValuationSummaryDataModel));
            _chartDataSeriesCollection.AddRange(holdingsDataSeries);

            IEnumerable <DateTime> valuationDates = portfolioValuationSummaryDataModel.PortfolioValuationData.Select(x => x.ValuationDate);

            _chartDataSeriesCollection.ForEach(x => FillNa(x, valuationDates, 0));
        }
Exemplo n.º 2
0
        public IPortfolioValuationHistory GetPortfolioValuationHistory(string filePath)
        {
            PortfolioValuationSummaryDataModel portfolioModel = _portfolioModelDeserialiser.GetReportDataModel(filePath);

            var portfolioValuationHistory = new PortfolioValuationHistory(portfolioModel.MetaData.PortfolioName, (double)portfolioModel.MetaData.InitialBalance);
            IEnumerable <IValuationData> valuationData = portfolioModel.PortfolioValuationData.Select(x => new ValuationData(x.ValuationDate, (double)x.PortfolioValuation));

            valuationData.ToList().ForEach(portfolioValuationHistory.AddValuationData);

            return(portfolioValuationHistory);
        }