示例#1
0
        /// <summary>
        /// 전체 계좌 조회: 내가 보유한 자산 리스트를 보여줍니다.
        /// </summary>
        /// <returns></returns>
        public async ValueTask <Balances> GetBalances()
        {
            var _result = new Balances();

            var _response = await privateClient.CallApiGet2Async("/accounts");

            if (_response != null)
            {
#if RAWJSON
                _result.rawJson = _response.Content;
#endif
                if (_response.IsSuccessful == true)
                {
                    var _balances = privateClient.DeserializeObject <List <UBalanceItem> >(_response.Content);
                    {
                        foreach (var _balance in _balances)
                        {
                            _balance.total = _balance.free + _balance.used;
                        }

                        _result.result = _balances.ToList <IBalanceItem>();
                    }
                    _result.SetSuccess();
                }
                else
                {
                    var _message = privateClient.GetResponseMessage(_response);
                    _result.SetFailure(_message.message);
                }
            }

            return(_result);
        }
示例#2
0
        /// <summary>
        /// Get account balance
        /// </summary>
        /// <param name="args">Add additional attributes for each exchange</param>
        /// <returns></returns>
        public override async ValueTask <Balances> FetchBalancesAsync(Dictionary <string, object> args = null)
        {
            var _result = new Balances();

            var _markets = await publicApi.LoadMarketsAsync();

            if (_markets.success == true)
            {
                if (args.ContainsKey("account-id") && args["account-id"].ToString() != "")
                {
                    privateClient.ExchangeInfo.ApiCallWait(TradeType.Private);

                    var _params = privateClient.MergeParamsAndArgs(args);

                    var _json_value = await privateClient.CallApiGet1Async($"/v1/account/accounts/{args["account-id"].ToString()}/balance", _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 <HBalances>(_json_value.Content);
                        {
                            foreach (var _currency_id in _markets.CurrencyNames)
                            {
                                var _balances = _json_data.result.Where(b => b.currency == _currency_id.Key);
                                foreach (var _balance in _balances)
                                {
                                    _balance.currency = _currency_id.Value;
                                    _balance.total    = _balance.free + _balance.used;

                                    _result.result.Add(_balance);
                                }
                            }
                        }
                    }

                    _result.SetResult(_json_result);
                }
                else
                {
                    _result.SetFailure("account-id required. args[account-id]");
                }
            }
            else
            {
                _result.SetResult(_markets);
            }

            return(_result);
        }
示例#3
0
        /// <summary>
        /// Get your account's margin status.
        /// </summary>
        /// <returns></returns>
        public async ValueTask <Balances> GetUserMargins()
        {
            var _result = new Balances();

            var _params = new Dictionary <string, object>();
            {
                _params.Add("currency", "all");
            }

            var _response = await privateClient.CallApiGet2Async("/api/v1/user/margin", _params);

            if (_response != null)
            {
#if RAWJSON
                _result.rawJson = _response.Content;
#endif
                if (_response.IsSuccessful == true)
                {
                    var _balances = privateClient.DeserializeObject <List <BBalanceItem> >(_response.Content);
                    if (_balances != null)
                    {
                        foreach (var _balance in _balances)
                        {
                            _balance.used = _balance.total - _balance.free;
                        }

                        _result.result = _balances.ToList <IBalanceItem>();
                        _result.SetSuccess();
                    }
                }
                else
                {
                    var _message = privateClient.GetResponseMessage(_response);
                    _result.SetFailure(_message.message);
                }
            }

            return(_result);
        }