public static Decimal getUSDValue(string symbol, Decimal value = 0) { CoinMarketCapTicker ticker = PreferenceManager.CoinMarketCapPreferences.Tickers.FirstOrDefault(item => item.symbol == symbol); /* * foreach(CoinMarketCapTicker t in Tickers) * { * LogManager.AddLogMessage(Name, "getUSDValue", t.rank + " | " + t.price_usd + " | " + t.symbol); * } */ //LogManager.AddLogMessage(Name, "getUSDValue", Tickers.Count + " | " + symbol + " | " + value + " | "); if (ticker != null) { if (value > 0) { // figure out the value in USD //Decimal total = value * return(value * ticker.price_usd); } else { return(ticker.price_usd); } } else { return(0); } }
private void toolStripButton_save_Click(object sender, EventArgs e) { foreach (Fork fork in forks) { WalletBalance listItem = PreferenceManager.WalletPreferences.WalletForks.FirstOrDefault(item => item.Name == wallet.Name && item.Symbol == fork.ticker.ToUpper()); if (listItem == null) { //fork.id = wallet.Name; Decimal balance = Decimal.Parse(fork.balance.expected.ToString(), System.Globalization.NumberStyles.Float) / 100000000; CoinMarketCapTicker ticker = PreferenceManager.CoinMarketCapPreferences.Tickers.FirstOrDefault(item => item.symbol == fork.ticker.ToUpper() && item.name == fork.name); //decimal btcTotal = 0; //decimal usdTotal = 0; if (ticker != null) { fork.TotalInBTC = balance * ticker.price_btc; fork.TotalInUSD = balance * ticker.price_usd; } WalletBalance newBalance = new WalletBalance() { Address = fork.addr, Balance = balance, CoinName = fork.name, IsForkBalance = true, Name = wallet.Name, Symbol = fork.ticker.ToUpper(), TotalInBTC = fork.TotalInBTC, TotalInUSD = fork.TotalInUSD, WalletName = wallet.WalletName, Verified = true }; PreferenceManager.WalletPreferences.WalletForks.Add(newBalance); } else { Decimal balance = Decimal.Parse(fork.balance.expected.ToString(), System.Globalization.NumberStyles.Float) / 100000000; CoinMarketCapTicker ticker = PreferenceManager.CoinMarketCapPreferences.Tickers.FirstOrDefault(item => item.symbol == fork.ticker.ToUpper() && item.name == fork.name); if (ticker != null) { listItem.Address = fork.addr; listItem.Verified = true; listItem.Balance = balance; listItem.TotalInBTC = balance * ticker.price_btc; listItem.TotalInUSD = balance * ticker.price_usd; } } PreferenceManager.UpdatePreferenceFile(PreferenceManager.PreferenceType.Wallet); FormManager.UpdateBalanceManager(true); //FormManager.UpdateWalletManager(); if (ParentForm != null) { ParentForm.Close(); } } }
public object aspect_btc(object rowObject) { Fork listItem = (Fork)rowObject; Decimal balance = Decimal.Parse(listItem.balance.expected.ToString(), System.Globalization.NumberStyles.Float) / 100000000; CoinMarketCapTicker ticker = PreferenceManager.CoinMarketCapPreferences.Tickers.FirstOrDefault(item => item.symbol == listItem.ticker.ToUpper() && item.name == listItem.name); decimal total = 0; if (ticker != null) { total = balance * ticker.price_btc; } /* * else * { * CryptoCompareCoin coin = PreferenceManager.CryptoComparePreferences.CoinList.FirstOrDefault(item => item.Name == listItem.ticker.ToUpper() && item.CoinName == listItem.name); * if (coin != null) * { * LogManager.AddLogMessage(Name, "aspect_btc", "coin=" + coin.Name, LogManager.LogMessageType.DEBUG); * } * } */ if (total > 0) { return(total.ToString("N8")); } else { return(String.Empty); } }
public static Decimal GetMarketCapCoinAmount(string symbol, string market, Decimal amount) { Decimal value = 0; CoinMarketCapTicker listItem = PreferenceManager.CoinMarketCapPreferences.Tickers.FirstOrDefault(item => item.symbol.ToLower() == symbol.ToLower()); if (listItem != null) { //LogManager.AddLogMessage(Name, "GetMarketCapUSDAmount", "PRICE_USD=" + listItem.price_usd + " | " + symbol, LogManager.LogMessageType.DEBUG); if (market.Contains("USD")) { // GET AMOUNT FROM USD value = amount / listItem.price_usd; } else { // GET AMOUNT FROM BTC value = amount / listItem.price_btc; } //value = amount * listItem.price_usd; } //LogManager.AddLogMessage(Name, "GetMarketCapUSDAmount", "symbol=" + symbol + " |amount=" + amount + " |value=" + value, LogManager.LogMessageType.DEBUG); return(value); }
public static Decimal GetMarketCapBTCAmount(string symbol, Decimal amount) { if (symbol.ToUpper() != "BTC") { Decimal value = 0; CoinMarketCapTicker listItem = PreferenceManager.CoinMarketCapPreferences.Tickers.FirstOrDefault(item => item.symbol.ToLower() == symbol.ToLower()); if (listItem != null) { //LogManager.AddLogMessage(Name, "GetMarketCapBTCAmount", "PRICE_BTC=" + listItem.price_btc + " | " + symbol, LogManager.LogMessageType.DEBUG); value = amount * listItem.price_btc; } else { //LogManager.AddLogMessage(Name, "GetMarketCapBTCAmount", "IS NULL : symbol=" + symbol + " |amount=" + amount + " |tCount=" + Tickers.Count, LogManager.LogMessageType.DEBUG); } //LogManager.AddLogMessage(Name, "GetMarketCapBTCAmount", "symbol=" + symbol + " |amount=" + amount + " |value=" + value, LogManager.LogMessageType.DEBUG); return(value); } else { return(amount); } }
private void numericUpDown_usd_ValueChanged(object sender, EventArgs e) { CoinMarketCapTicker priceItem = PreferenceManager.CoinMarketCapPreferences.Tickers.FirstOrDefault(item => item.symbol == label_symbol.Text); if (priceItem != null) { numericUpDown_symbol.Value = numericUpDown_usd.Value / priceItem.price_usd; } UpdateUI(); }
private List <IDataRow> UpdateCoinMarketCapTicker() { var li = CoinMarketCapTicker.GetList(); List <IDataRow> li2 = new List <IDataRow>(); foreach (var item in li) { li2.Add(item as IDataRow); } return(li2); }
public object aspect_value(object rowObject) { CalculatorItem listItem = (CalculatorItem)rowObject; CoinMarketCapTicker priceItem = PreferenceManager.CoinMarketCapPreferences.Tickers.FirstOrDefault(item => item.symbol == listItem.symbol); Decimal total = 0; if (priceItem != null) { total = numericUpDown_usd.Value / priceItem.price_usd; } return(total.ToString("N8")); }
public object aspect_icon(object rowObject) { CoinMarketCapTicker e = (CoinMarketCapTicker)rowObject; if (e != null) { return(ContentManager.ResizeImage(ContentManager.GetSymbolIcon(e.symbol), listView.RowHeightEffective, listView.RowHeightEffective)); } else { return(ContentManager.ResizeImage(Properties.Resources.ConnectionStatus_DISABLED, listView.RowHeightEffective, listView.RowHeightEffective)); } }
private void ListView_FormatCell(object sender, FormatCellEventArgs e) { CoinMarketCapTicker ticker = (CoinMarketCapTicker)e.Model; if (e.ColumnIndex == column_24hchange.Index) { if (ticker.percent_change_24h > 0) { e.SubItem.BackColor = PreferenceManager.preferences.Theme.Green; } else { e.SubItem.BackColor = PreferenceManager.preferences.Theme.Red; } } }
public object aspect_usd(object rowObject) { Fork listItem = (Fork)rowObject; Decimal balance = Decimal.Parse(listItem.balance.expected.ToString(), System.Globalization.NumberStyles.Float) / 100000000; CoinMarketCapTicker ticker = PreferenceManager.CoinMarketCapPreferences.Tickers.FirstOrDefault(item => item.symbol == listItem.ticker.ToUpper() && item.name == listItem.name); decimal total = 0; if (ticker != null) { total = balance * ticker.price_usd; } if (total > 0) { return(total.ToString("C")); } else { return(String.Empty); } }
/// <summary>/ticker/{id}/ /// <para>Return a tickers based on the id (ex. bitcoin)</para> /// <para>Required : none</para> /// <para>Optional : [NOT IN USE] convert - return price, 24h volume, and market cap in terms of another currency. Valid values are: 'AUD', 'BRL', 'CAD', 'CHF', 'CLP', 'CNY', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'JPY', 'KRW', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PKR', 'PLN', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'ZAR'</para> /// </summary> public static CoinMarketCapTicker getTicker(string id) { try { var request = new RestRequest("/v1/ticker/" + id, Method.GET); var response = client.Execute(request); //LogManager.AddLogMessage(thisClassName, "getTicker", "response.Content=" + response.Content, LogManager.LogMessageType.DEBUG); var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; var jsonArray = JsonConvert.DeserializeObject <List <CoinMarketCapTicker> >(response.Content, settings); CoinMarketCapTicker ticker = jsonArray[0] as CoinMarketCapTicker; return(ticker); } catch (Exception ex) { LogManager.AddLogMessage(Name, "getTicker", ex.Message, LogManager.LogMessageType.EXCEPTION); return(null); } }
public object aspect_24hchange(object rowObject) { CoinMarketCapTicker ticker = (CoinMarketCapTicker)rowObject; return(ticker.percent_change_24h + "%"); }
private void aboutToCreateGroups(object sender, CreateGroupsEventArgs e) { //LogManager.AddLogMessage(Name, "aboutToCreateGroups", "view=" + view + " | group.count=" + e.Groups.Count, LogManager.LogMessageType.OTHER); try { List <ExchangeBalance> balances = GetBalances(); switch (view) { case BalanceViewType.symbol: //LogManager.AddLogMessage(Name, "aboutToCreateGroups", "Group Count=" + e.Groups.Count + " | view=" + view + " | params=" + e.Parameters + " | " + e.Groups, LogManager.LogMessageType.OTHER); listView.GroupImageList = ContentManager.SymbolIconList; foreach (OLVGroup group in e.Groups) { string key = group.Key.ToString(); if (!groupStates.ContainsKey(key)) { groupStates.Add(key, false); } //LogManager.AddLogMessage(Name, "aboutToCreateGroups", "GroupId=" + group.GroupId + " | Header=" + group.Header + " | id=" + group.Id + " | Key=" + group.Key + " | name=" + group.Name + " | " + group.Collapsed, LogManager.LogMessageType.OTHER); List <ExchangeBalance> symbalances = balances.Where(item => item.Symbol == key.ToString() && item.Balance > 0).ToList(); decimal usdTotal = symbalances.Sum(b => b.TotalInUSD); decimal btcTotal = symbalances.Sum(b => b.TotalInBTC); decimal coinTotal = symbalances.Sum(b => b.Balance); CryptoCompareCoin coin = PreferenceManager.CryptoComparePreferences.CoinList.FirstOrDefault(item => item.Symbol == group.Key.ToString()); CoinMarketCapTicker priceItem = PreferenceManager.CoinMarketCapPreferences.Tickers.FirstOrDefault(item => item.symbol == key); //LogManager.AddLogMessage(Name, "aboutToCreateGroups", "HEADER=" + group.Header + " | id=" + group.Id + " | Key=" + group.Key + " | name=" + group.Name + " | itemcount=" + group.Items.Count, LogManager.LogMessageType.OTHER); string price = ""; if (priceItem != null) { price = " " + priceItem.price_usd.ToString("C"); } if (coin != null) { group.Header = coin.FullName + price; } else { group.Header = key + price; } group.TitleImage = key; if (balances.Count > 1) { group.Task = "[" + symbalances.Count + "] " + usdTotal.ToString("C"); } else { group.Task = usdTotal.ToString("C"); } group.Subtitle = "(" + coinTotal.ToString("N8") + ")"; group.Collapsed = groupStates[key]; } break; case BalanceViewType.exchange: listView.GroupImageList = ContentManager.ExchangeIconList; foreach (OLVGroup group in e.Groups) { string key = group.Key.ToString(); if (!groupStates.ContainsKey(key)) { groupStates.Add(key, false); } //LogManager.AddLogMessage(Name, "aboutToCreateGroups", "GroupId=" + group.Items.Count + " | Header=" + group.Header + " | id=" + group.Id + " | Key=" + group.Key + " | name=" + group.Name + " | " + group.Collapsed); decimal usdTotal = balances.Where(item => item.Exchange == group.Key.ToString() && item.Balance > 0).Sum(b => b.TotalInUSD); decimal btcTotal = balances.Where(item => item.Exchange == group.Key.ToString() && item.Balance > 0).Sum(b => b.TotalInBTC); group.Header = group.Header.ToUpper(); group.TitleImage = group.Key; if (group.Items.Count > 1) { group.Task = "[" + group.Items.Count + "] " + usdTotal.ToString("C"); } else { group.Task = usdTotal.ToString("C"); } group.Subtitle = "(" + btcTotal.ToString("N8") + ")"; group.Collapsed = groupStates[key]; } break; case BalanceViewType.balance: // DO NOTHING break; default: // DO NOTHING break; } } catch (Exception ex) { LogManager.AddLogMessage(Name, "aboutToCreateGroups", ex.Message, LogManager.LogMessageType.EXCEPTION); } }
private string GetThemeString() { StringBuilder builder = new StringBuilder(); builder.Append("var cccTheme = "); //CryptoCompare.CryptoCompareChartTheme theme = new CryptoCompare.CryptoCompareChartTheme(); //CryptoCompareChartTheme theme = PreferenceManager.preferences.Theme.cryptoCompareChartTheme.ShallowCopy(); string json = JsonConvert.SerializeObject(PreferenceManager.preferences.Theme.cryptoCompareChartTheme); CryptoCompareChartTheme theme = JsonConvert.DeserializeObject <CryptoCompareChartTheme>(json); CoinMarketCapTicker priceItem = PreferenceManager.CoinMarketCapPreferences.Tickers.FirstOrDefault(item => item.symbol == symbol); if (PreferenceManager.ArbitragePreferences.ChartPeriod == CryptoCompareChartPeriod.Day_1D) { if (priceItem != null) { //LogManager.AddLogMessage(Name, "", symbol + " | " + market + " | 1h=" + priceItem.percent_change_1h + " | " + priceItem.percent_change_24h + " | " + priceItem.percent_change_7d, LogManager.LogMessageType.DEBUG); if (priceItem.percent_change_24h > 0) { theme.Chart.borderColor = theme.Trend.colorUp; } else if (priceItem.percent_change_24h < 0) { theme.Chart.borderColor = theme.Trend.colorDown; } } ; } else if (PreferenceManager.ArbitragePreferences.ChartPeriod == CryptoCompareChartPeriod.Week_1W) { if (priceItem != null) { //LogManager.AddLogMessage(Name, "", symbol + " | " + market + " | 1h=" + priceItem.percent_change_1h + " | " + priceItem.percent_change_24h + " | " + priceItem.percent_change_7d, LogManager.LogMessageType.DEBUG); if (priceItem.percent_change_7d > 0) { theme.Chart.borderColor = theme.Trend.colorUp; } else if (priceItem.percent_change_7d < 0) { theme.Chart.borderColor = theme.Trend.colorDown; } } ; } string themeData = JsonConvert.SerializeObject(theme); //string json = JsonConvert.SerializeObject(theme); //string json = JsonConvert.SerializeObject(PreferenceManager.preferences.Theme.cryptoCompareChartTheme); //LogManager.AddLogMessage(Name, "toolStripButton_OrderTotal_Click", json, LogManager.LogMessageType.DEBUG); builder.Append(themeData); builder.Append(";"); return(builder.ToString()); /* * if (PreferenceManager.preferences.Theme.type != PreferenceManager.ThemeType.Default) * { * * StringBuilder builder = new StringBuilder(); * builder.Append("var cccTheme = "); * builder.Append("{\"General\":{\"background\":\"#333\",\"borderColor\":\"#545454\",\"borderRadius\":\"4px 4px 0 0\"},"); * builder.Append("\"Header\":{\"background\":\"#000\",\"color\":\"#FFF\",\"displayFollowers\":false},"); * builder.Append("\"Followers\":{\"background\":\"#f7931a\",\"color\":\"#FFF\",\"borderColor\":\"#e0bd93\",\"counterBorderColor\":\"#fdab48\",\"counterColor\":\"#f5d7b2\"},"); * builder.Append("\"Data\":{\"priceColor\":\"#FFF\",\"infoLabelColor\":\"#CCC\",\"infoValueColor\":\"#CCC\"},"); * builder.Append("\"Chart\":{\"fillColor\":\"rgba(86,202,158,0.5)\",\"borderColor\":\"#56ca9e\"},\"Conversion\":{\"background\":\"#000\",\"color\":\"#999\"}};"); * * * return builder.ToString(); * } * else * { * return String.Empty; * } */ //return String.Empty; }