public bool UpdateUI(bool resize = false) { if (InvokeRequired) { UpdateUICallback d = new UpdateUICallback(UpdateUI); Invoke(d, new object[] { resize }); } else { List <ExchangeBalance> list = Balances.Where(item => item.Exchange == Exchange.Name && item.Balance > 0).OrderByDescending(item => item.TotalInBTC).ToList(); if (list.Sum(item => item.TotalInBTCOrders) > 0) { column_Orders.IsVisible = true; } else { column_Orders.IsVisible = false; } listView.RebuildColumns(); listView.SetObjects(list); toolStripLabel_title.Text = list.Count + " Balances"; toolStripLabel_totals.Text = "(" + list.Sum(item => item.TotalInUSD).ToString("C") + ") " + list.Sum(item => item.TotalInBTC).ToString("N8"); SetSymbolChart(); if (resize) { ResizeUI(); } } return(true); }
private void SetSymbolsChart() { List <ExchangeBalance> list = Balances.Where(item => item.Balance > 0).ToList(); List <ExchangeBalance> wallets = WalletManager.GetWalletBalances(); list.AddRange(wallets); var roots = list.OrderByDescending(item => item.TotalInBTC).Select(b => b.Symbol).Distinct(); List <string> symbols = new List <string>(); List <decimal> totals = new List <decimal>(); foreach (string symbol in roots) { //LogManager.AddLogMessage(Name, "InitializeChart2", symbol, LogManager.LogMessageType.DEBUG); symbols.Add(symbol); totals.Add(list.Where(balance => balance.Symbol == symbol).Sum(balance => balance.TotalInUSD)); } decimal[] yValues = totals.ToArray(); string[] xValues = symbols.ToArray(); Series series1 = chart.Series[0]; // Set the threshold under which all points will be collected series1["CollectedThreshold"] = "1"; // Set the threshold type to be a percentage of the pie // When set to false, this property uses the actual value to determine the collected threshold series1["CollectedThresholdUsePercent"] = "true"; // Set the label of the collected pie slice series1["CollectedLabel"] = "Below 1%"; // Set the legend text of the collected pie slice series1["CollectedLegendText"] = "Below 1%"; // Set the collected pie slice to be exploded //series1["CollectedSliceExploded"] = "true"; // Set the color of the collected pie slice series1["CollectedColor"] = "Red"; // Set the tooltip of the collected pie slice series1["CollectedToolTip"] = "Below 1%"; chart.Series["Default"].Font = PreferenceManager.GetFormFont(ParentForm); chart.Titles[0].Font = chart.Series["Default"].Font; chart.Titles[0].Text = symbols.Count + " SYMBOLS BY PERCENTAGE (" + list.Sum(balance => balance.TotalInUSD).ToString("C") + ")"; //chart.Series["Default"]. chart.Series["Default"].Points.DataBindXY(xValues, yValues); chart.Series["Default"].ChartType = SeriesChartType.Pie; chart.Series["Default"]["PieLabelStyle"] = "Outside"; chart.Series["Default"]["PieDrawingStyle"] = "SoftEdge"; chart.Series[0].ToolTip = "Percent: #PERCENT"; chart.Series[0].ToolTip = "#VALX" + " : " + "#PERCENT" + " (" + "#VALY{$#,##0.00}" + ")"; chart.Series[0].LabelToolTip = "#VALY{$#,##0.00}"; chart.Series[0].Label = "#VALX" + " (" + "#PERCENT" + ")"; chart.ChartAreas[0].Area3DStyle.Enable3D = true; chart.ChartAreas[0].Area3DStyle.Inclination = 0; }
private void SetSymbolChart(string symbol) { List <ExchangeBalance> list = Balances.Where(item => item.Balance > 0 && item.Symbol == symbol).ToList(); List <ExchangeBalance> wallets = WalletManager.GetWalletBalances(); list.AddRange(wallets.Where(wallet => wallet.Symbol == symbol)); List <string> exchanges = new List <string>(); List <decimal> totals = new List <decimal>(); foreach (ExchangeBalance balance in list.OrderByDescending(item => item.TotalInBTC)) { exchanges.Add(balance.Exchange); totals.Add(balance.TotalInUSD); } decimal[] yValues = totals.ToArray(); string[] xValues = exchanges.ToArray(); Series series1 = chart.Series[0]; series1["CollectedThreshold"] = "1"; series1["CollectedThresholdUsePercent"] = "true"; //series1["CollectedThresholdUsePercent"] = "false"; series1["CollectedLabel"] = "Below 1%"; series1["CollectedLegendText"] = "Below 1%"; series1["CollectedColor"] = "Red"; series1["CollectedToolTip"] = "Below 1%"; chart.Series["Default"].Font = PreferenceManager.GetFormFont(ParentForm); chart.Titles[0].Font = chart.Series["Default"].Font; chart.Titles[0].Text = exchanges.Count + " " + symbol + " BALANCES BY PERCENTAGE (" + list.Sum(balance => balance.TotalInUSD).ToString("C") + ")"; chart.Series["Default"].Points.DataBindXY(xValues, yValues); chart.Series["Default"].ChartType = SeriesChartType.Pie; chart.Series["Default"]["PieLabelStyle"] = "Outside"; chart.Series["Default"]["PieDrawingStyle"] = "SoftEdge"; /* * chart.Series[0].ToolTip = "Percent: #PERCENT"; * chart.Series[0].LabelToolTip = "#PERCENT"; * chart.Series[0].Label = "#VALX" + " (" + "#PERCENT" + ")"; */ chart.Series[0].ToolTip = "Percent: #PERCENT"; chart.Series[0].ToolTip = "#VALX" + " : " + "#PERCENT" + " (" + "#VALY{$#,##0.00}" + ")"; chart.Series[0].LabelToolTip = "#VALY{$#,##0.00}"; chart.Series[0].Label = "#VALX" + " (" + "#PERCENT" + ")"; chart.ChartAreas[0].Area3DStyle.Enable3D = true; chart.ChartAreas[0].Area3DStyle.Inclination = 0; }
public decimal GetBalanceForDate(DateTime date) { var lastBalanceBeforeDate = Balances.Where(x => x.Date <= date).OrderByDescending(x => x.Date).FirstOrDefault(); if (lastBalanceBeforeDate != null) { var sumExpences = Expences.Where(x => x.Date > lastBalanceBeforeDate.Date && x.Date <= date).Sum(x => x.Amount); var sumIncome = Income.Where(x => x.Date > lastBalanceBeforeDate.Date && x.Date <= date).Sum(x => x.Amount); var sum = sumIncome - sumExpences; return(lastBalanceBeforeDate.Amount + sum); } else { var sumExpences = Expences.Where(x => x.Date <= date).Sum(x => x.Amount); var sumIncome = Income.Where(x => x.Date <= date).Sum(x => x.Amount); return(sumIncome - sumExpences); } }
private void SetBalance() { List <ExchangeBalance> balances = Balances.Where(item => item.Symbol == symbol).ToList(); List <ExchangeBalance> wallets = WalletManager.GetWalletBalancesBySymbol(symbol); balances.AddRange(wallets); Decimal balance = balances.Sum(item => item.Balance); Decimal usd = balances.Sum(item => item.TotalInUSD); if (balance > 0) { balanceLabel.Text = balance.ToString("N8") + " (" + usd.ToString("C") + ")"; balanceLabel.Visible = true; } else { balanceLabel.Visible = false; } }
public void UpdateUI(bool resize = false) { if (InvokeRequired) { UpdateUICallback d = new UpdateUICallback(UpdateUI); Invoke(d, new object[] { resize }); } else { try { List <ExchangeBalance> list = Balances.Where(item => item.Balance > 0).ToList(); List <ExchangeBalance> wallets = GetWalletBalances(); list.AddRange(wallets); var roots = list.Select(b => b.Symbol).Distinct(); toolStripLabel_count.Text = roots.Count() + " Coins"; toolStripLabel_btc.Text = list.Sum(b => b.TotalInBTC).ToString("N8"); toolStripLabel_usd.Text = list.Sum(b => b.TotalInUSD).ToString("C"); //AddLogMessage(Name, "UpdateUI", PreferenceManager.preferences.BalanceView.GetHashCode().ToString() + " | " + tabControl.TabPages.Count, LogMessageType.DEBUG); //if (tabControl.TabPages.Count > 0) //{ tabControl.SelectedIndex = PreferenceManager.preferences.BalanceView.GetHashCode(); //tabControl.SelectedIndex = 1; //} //tabControl.SelectedIndex = PreferenceManager.preferences.BalanceView.GetHashCode(); //tabControl.SelectedIndex = 0; SetView(resize); if (resize) { ResizeUI(); } } catch (Exception ex) { AddLogMessage(Name, "UpdateUI", "EXCEPTION : " + ex.Message, LogMessageType.EXCEPTION); } } }
private void SetExchangesChart() { List <ExchangeBalance> list = Balances.Where(item => item.Balance > 0).ToList(); List <ExchangeBalance> wallets = WalletManager.GetWalletBalances(); list.AddRange(wallets); var roots = list.Select(b => b.Exchange).Distinct(); List <string> exchanges = new List <string>(); List <decimal> totals = new List <decimal>(); foreach (string exchange in roots) { //LogManager.AddLogMessage(Name, "InitializeChart", exchange, LogManager.LogMessageType.DEBUG); exchanges.Add(exchange); totals.Add(list.Where(balance => balance.Exchange == exchange).Sum(balance => balance.TotalInUSD)); } decimal[] yValues = totals.ToArray(); string[] xValues = exchanges.ToArray(); chart.Series["Default"].Font = PreferenceManager.GetFormFont(ParentForm); chart.Titles[0].Font = chart.Series["Default"].Font; chart.Titles[0].Text = exchanges.Count + " EXCHANGES BY PERCENTAGE (" + list.Sum(balance => balance.TotalInUSD).ToString("C") + ")"; chart.Series["Default"].Points.DataBindXY(xValues, yValues); chart.Series["Default"].ChartType = SeriesChartType.Pie; chart.Series["Default"]["PieLabelStyle"] = "Outside"; chart.Series["Default"]["PieDrawingStyle"] = "SoftEdge"; chart.Series[0].ToolTip = "Percent: #PERCENT"; chart.Series[0].ToolTip = "#VALX" + " : " + "#PERCENT" + " (" + "#VALY{$#,##0.00}" + ")"; chart.Series[0].LabelToolTip = "#VALY{$#,##0.00}"; chart.Series[0].Label = "#VALX" + " (" + "#PERCENT" + ")"; chart.ChartAreas[0].Area3DStyle.Enable3D = true; chart.ChartAreas[0].Area3DStyle.Inclination = 0; }
public Amount TotalIn(Currency currency) => Positions.Where(p => !p.Exclude).Sum(r => r.Position.ValueIn(currency)) + Balances.Where(b => !b.Exclude).Sum(r => r.Balance.ValueIn(currency));
public void UpdateUI(bool resize = false) { if (InvokeRequired) { UpdateUICallback d = new UpdateUICallback(UpdateUI); Invoke(d, new object[] { resize }); } else { try { List <ExchangeBalance> list = Balances.Where(item => item.Balance > 0).ToList(); List <ExchangeBalance> wallets = WalletManager.GetWalletBalances(); list.AddRange(wallets); //var roots = list.Select(b => b.Symbol).Distinct(); foreach (ExchangeBalance balance in list) { ExchangeBalance listItem = BalanceList.FirstOrDefault(item => item.Exchange == balance.Exchange && item.Symbol == balance.Symbol); if (listItem != null) { // update listItem.Balance = balance.Balance; listItem.OnOrders = balance.OnOrders; listItem.TotalInBTC = balance.TotalInBTC; listItem.TotalInBTCOrders = balance.TotalInBTCOrders; listItem.TotalInUSD = balance.TotalInUSD; } else { BalanceList.Add(balance); } } //listView.setO //listView.DataSource = list; listView.DataSource = BalanceList; //toolStripLabel_totals.Text = roots.Count() + " Coins | " + list.Sum(b => b.TotalInBTC).ToString("N8") + " | " + list.Sum(b => b.TotalInUSD).ToString("C"); //toolStripLabel_CoinCount.Text = roots.Count() + " Coins | " + list.Sum(b => b.TotalInBTC).ToString("N8") + " | " + list.Sum(b => b.TotalInUSD).ToString("C"); //LogManager.AddLogMessage(Name, "UpdateUI", "LISTVIEW COUNT=" + listView.Items.Count, LogManager.LogMessageType.DEBUG); /* * if (listView.Items.Count > 0) * { * listView.RefreshObjects(list); * //listView.Refresh(); * //listView.Refresh(); * //listView.RedrawItems(0, listView.Items.Count, true); * if (!initialized) * { * switch (view) * { * case BalanceViewType.symbol: * listView.Sort(column_Symbol, SortOrder.Ascending); * toolStripLabel_totals.Text = ""; * break; * * case BalanceViewType.exchange: * listView.Sort(column_Exchange, SortOrder.Ascending); * toolStripLabel_totals.Text = Exchanges.Count + " Exchanges"; * break; * * case BalanceViewType.balance: * listView.Sort(column_TotalInBTC, SortOrder.Descending); * toolStripLabel_totals.Text = ""; * break; * * default: * * break; * * } * listView.BuildList(); * initialized = true; * } * * UpdateGroups(); * //LogManager.AddLogMessage(Name, "UpdateUI", "REFRESHED=" + listView.Items.Count, LogManager.LogMessageType.DEBUG); * } * else * { * listView.SetObjects(list); * switch (view) * { * case BalanceViewType.symbol: * listView.Sort(column_Symbol, SortOrder.Ascending); * toolStripLabel_totals.Text = ""; * break; * * case BalanceViewType.exchange: * listView.Sort(column_Exchange, SortOrder.Ascending); * toolStripLabel_totals.Text = Exchanges.Count + " Exchanges"; * break; * * case BalanceViewType.balance: * listView.Sort(column_TotalInBTC, SortOrder.Descending); * toolStripLabel_totals.Text = ""; * break; * * default: * * break; * * } * //ResizeUI(); * } */ if (resize) { ResizeUI(); } } catch (Exception ex) { LogManager.AddLogMessage(Name, "UpdateUI", ex.Message, LogManager.LogMessageType.EXCEPTION); } } }
public void UpdateUI(bool resize = false) { if (InvokeRequired) { UpdateUICallback d = new UpdateUICallback(UpdateUI); Invoke(d, new object[] { resize }); } else { try { List <ExchangeBalance> list; if (PreferenceManager.preferences.HideZeroBalances) { list = Balances.Where(item => item.Balance > 0).ToList(); } else { list = Balances.ToList(); } //List<ExchangeBalance> list = Balances.Where(item => item.Balance > 0).ToList(); //List<ExchangeBalance> wallets = WalletManager.GetWalletBalances(); list.AddRange(WalletManager.GetWalletBalances()); list.AddRange(WalletManager.GetWalletForkBalances()); /* * list.AddRange(WalletManager.GetForkBalances()); */ listView.SetObjects(list.OrderByDescending(item => item.TotalInBTC)); switch (view) { case BalanceViewType.symbol: //listView.SetObjects(list.OrderByDescending(item => item.Symbol).ThenByDescending(item => item.TotalInBTC)); //listView.SetObjects(list.OrderByDescending(item => item.TotalInBTC)); listView.Sort(column_Symbol, SortOrder.Ascending); //listView.SetObjects(list.OrderByDescending(item => item.Symbol)); toolStripLabel_totals.Text = ""; break; case BalanceViewType.exchange: listView.SetObjects(list.OrderByDescending(item => item.Exchange).ThenByDescending(item => item.TotalInBTC)); listView.Sort(column_Exchange, SortOrder.Ascending); //listView.Sort(column_Name, SortOrder.Ascending); //listView.SetObjects(list.OrderByDescending(item => item.Name)); toolStripLabel_totals.Text = Exchanges.Count + " Exchanges"; break; case BalanceViewType.balance: //listView.SetObjects(list.OrderByDescending(item => item.TotalInBTC)); listView.Sort(column_TotalInBTC, SortOrder.Descending); //listView.SetObjects(list.OrderByDescending(item => item.TotalInBTC)); toolStripLabel_totals.Text = ""; break; default: break; } //listView.SetObjects(list); if (resize) { ResizeUI(); } } catch (Exception ex) { LogManager.AddLogMessage(Name, "UpdateUI", ex.Message, LogManager.LogMessageType.EXCEPTION); } } }