static float TotalWealth(Yobit.YobitApiClient yobitApiClient, string resultCoin) { resultCoin = resultCoin.ToLower(); var accountInfo = yobitApiClient.GetInfo(); if (accountInfo.success == 0) { throw new Exception("Метод GetInfo возвратил ошибку: " + accountInfo.error); } var accountCoinPairs = new CoinsPairs([email protected]_incl_orders.Select(pair => new CoinPair(pair.Key, resultCoin))); var ticker = yobitApiClient.Ticker(accountCoinPairs); float sumWealth = 0; foreach (var coin in [email protected]_incl_orders.Keys) { if (coin == resultCoin) { sumWealth += [email protected]_incl_orders[coin]; Console.WriteLine($"On balance: {[email protected]_incl_orders[resultCoin]}{resultCoin}"); continue; } var coinPair = new CoinPair(coin, resultCoin); var coinSumPrice = [email protected]_incl_orders[coin] * ticker[coinPair.ToString()].sell; if (coinPair.Reverted) { coinSumPrice = [email protected]_incl_orders[coin] / ticker[coinPair.ToString()].sell; // на случай usd_rur } sumWealth += coinSumPrice; Console.WriteLine($"{[email protected]_incl_orders[coin]}{coin} {(!coinPair.Reverted ? "*" : "/")} {ticker[coinPair.ToString()].sell}{resultCoin} = {coinSumPrice}{resultCoin}"); } Console.WriteLine($"Total: {sumWealth}{resultCoin}"); return(sumWealth); }
public string Trades(CoinsPairs pairs) { Logger.Log("Called 'Trades' method"); var methodUri = PublicMethodUri("trades", pairs); return(ProcessPublicRequest(methodUri)); }
public string Depth(CoinsPairs pairs) { Logger.Log("Called 'Depth' method"); var methodUri = PublicMethodUri("depth", pairs); return(ProcessPublicRequest(methodUri)); }
public TickerResponse Ticker(CoinsPairs pairs) { Logger.Log("Called 'Ticker' method"); var methodUri = PublicMethodUri("ticker", pairs); var _res = ProcessPublicRequest(methodUri); var response = JsonConvert.DeserializeObject <TickerResponse>(_res); return(response); }
private Uri PublicMethodUri(string method, CoinsPairs pairs) { var url = $"{PublicApiUrl}/{method}"; if (pairs != null && pairs.Count != 0) { url += $"/{pairs.UrlPath}"; } if (IgnoreInvalidPairs) { url += "?ignore_invalid=1"; } return(new Uri(url)); }