Пример #1
0
        public void GetSummary_AssetTest()
        {
            Account       acc  = Init.CreateAccountAsset1();
            SummaryReport summ = acc.GetSummary();

            Assert.IsTrue(
                summ.Count == 1 &&
                summ.Get(Init.Asset1()) == acc.Amount
                );
        }
Пример #2
0
        public void Update(AccountingData ad)
        {
            _Weights = new Dictionary <string, double> {
            };
            SummaryReport sr = ad.GetSummary();

            Rows.Clear();
            ColumnCount           = 4;
            Columns[0].HeaderText = "Ccy/Asset";
            Columns[1].HeaderText = "Total";
            Columns[2].HeaderText = "Total Converted";
            Columns[3].HeaderText = "Weight";

            for (int j = 0; j < ColumnCount; j++)
            {
                Columns[j].Width    = 75;
                Columns[j].SortMode = DataGridViewColumnSortMode.Programmatic;
            }
            foreach (var item in ad.CciesAndAssets)
            {
                double amount = sr.Get(item);
                if (amount != 0)
                {
                    double convAmount = ad.GetQuote(item, ad.Ccy) * amount;
                    double weight     = convAmount / ad.TotalValue;
                    _Weights[item.ToString()] = weight;

                    object[] values = { item.ToString(),
                                        ad.GetAmountToString(item,  amount),
                                        ad.GetAmountToString(ad.Ccy,convAmount),
                                        $"{Math.Round(weight * 100, 2)} %" };
                    Rows.Add(values);
                }
            }
            ClearSelection();
        }