public Balances GetBalances() { url = string.Format("https://bittrex.com/api/v1.1/account/getbalances?apikey={0}&nonce={1}", key, nonce); apisign = HashHmac(url, secret); var request = new HttpRequestMessage() { RequestUri = new Uri(url), Method = HttpMethod.Get }; request.Headers.Add("apisign", apisign); HttpResponseMessage response = client.SendAsync(request).Result; string message = response.Content.ReadAsStringAsync().Result; Balances balances = JsonConvert.DeserializeObject <Balances>(message); return(balances); }
private static void PrintBalances(Balances balances) { Console.SetCursorPosition(0, 2); double totalbits = 0; int num = 0; foreach (var b in balances.result) { if (b.Currency == "BTC") { totalbits += b.Available; var busdval = Math.Round(btcvalue * b.Available, 2); Console.Write("BTC : "); Console.ForegroundColor = ConsoleColor.DarkGray; Console.Write("----------------------"); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(" : {0,15:F10} : N/A : N/A : ${1,9:F2} : ${2,9:F2}", b.Available, busdval, btcvalue); continue; } if ((int)b.Balance == 0) { continue; } Console.ForegroundColor = colors[num % 7]; Console.Write($"{b.Currency,-5}: "); var trades = bit.GetTrades($"BTC-{b.Currency}"); totalbits += trades.result[0].Price * b.Balance; for (var i = 0; i < 22; i++) { var last = trades.result[i + 1].Price; var t = trades.result[i]; if (t.OrderType.Contains("BUY")) { Console.ForegroundColor = ConsoleColor.Green; Console.Write("↑"); } else if (t.OrderType.Contains("SELL")) { Console.ForegroundColor = ConsoleColor.Red; Console.Write("↓"); } Console.ForegroundColor = ConsoleColor.Gray; } var tradebal = trades.result[0].Price * b.Balance; var usdval = Math.Round(btcvalue * tradebal, 2); var usdpc = Math.Round(btcvalue * trades.result[0].Price, 2); var btcpc = trades.result[0].Price; Console.ForegroundColor = colors[num % 7]; Console.WriteLine(" : {0,15:F10} : {2,15:F10} : {1,15:F10} : ${3,9:F2} : ${4,9:F2}", b.Available, btcpc, tradebal, usdval, usdpc); num++; } Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine("\nTotal BTC value: {0}", totalbits); Console.WriteLine("Total USD value: ${0:F2}", Math.Round(btcvalue * totalbits, 2)); Console.WriteLine("\nUpdating every minute.\n{0}", DateTime.Now); }