/// <summary> /// Get User Account Info /// </summary> /// <param name="args">Add additional attributes for each exchange</param> /// <returns></returns> public override async Task <Balances> FetchBalances(Dictionary <string, object> args = null) { var _result = new Balances(); var _markets = await publicApi.LoadMarkets(); if (_markets.success == true) { privateClient.ExchangeInfo.ApiCallWait(TradeType.Private); var _params = privateClient.MergeParamsAndArgs(args); var _json_value = await privateClient.CallApiPost1Async("/userinfo.do", _params); #if DEBUG _result.rawJson = _json_value.Content; #endif var _json_result = privateClient.GetResponseMessage(_json_value.Response); if (_json_result.success == true) { var _json_data = privateClient.DeserializeObject <JObject>(_json_value.Content); { var _balances = _json_data["info"]["funds"]; foreach (var _currency_id in _markets.CurrencyNames) { if (_balances["free"].SelectToken(_currency_id.Key) == null) { continue; } var _balance = new OBalanceItem { free = _balances["free"][_currency_id.Key].Value <decimal>(), used = _balances["freezed"][_currency_id.Key].Value <decimal>() }; _balance.currency = _currency_id.Value; _balance.total = _balance.free + _balance.used; _result.result.Add(_balance); } } } _result.SetResult(_json_result); } else { _result.SetResult(_markets); } return(_result); }
/// <summary> /// Get User Account Info /// </summary> /// <param name="base_name">The type of trading base-currency of which information you want to query for.</param> /// <param name="quote_name">The type of trading quote-currency of which information you want to query for.</param> /// <param name="args">Add additional attributes for each exchange</param> /// <returns></returns> public override async Task <Balance> FetchBalance(string base_name, string quote_name, Dictionary <string, object> args = null) { var _result = new Balance(); var _currency_id = await publicApi.LoadCurrencyId(base_name); if (_currency_id.success == true) { privateClient.ExchangeInfo.ApiCallWait(TradeType.Private); var _params = privateClient.MergeParamsAndArgs(args); var _json_value = await privateClient.CallApiPost1Async("/userinfo.do", _params); #if DEBUG _result.rawJson = _json_value.Content; #endif var _json_result = privateClient.GetResponseMessage(_json_value.Response); if (_json_result.success == true) { var _json_data = privateClient.DeserializeObject <JObject>(_json_value.Content); { var _balances = privateClient.DeserializeObject <Dictionary <string, JObject> >(_json_data["info"]["funds"].ToString()); if (_balances["free"].ContainsKey(_currency_id.result) == true) { var _balance = new OBalanceItem() { free = _balances["free"][_currency_id.result].Value <decimal>(), // available fund used = _balances["freezed"][_currency_id.result].Value <decimal>() // frozen fund }; _balance.currency = base_name; _balance.total = _balance.free + _balance.used; _result.result = _balance; } else { _json_result.SetFailure(); } } } _result.SetResult(_json_result); } else { _result.SetResult(_currency_id); } return(_result); }