Exemple #1
0
        /// <summary>
        /// Get all balance-affecting executions. This includes each trade, insurance charge, and settlement.
        /// </summary>
        /// <param name="symbol">Instrument symbol. Send a bare series (e.g. XBT) to get data for the nearest expiring contract in that series.</param>
        /// <param name="count">maximum number of items</param>
        /// <returns></returns>
        public async ValueTask <MyTrades> GetTrades(string symbol, int count)
        {
            var _result = new MyTrades();

            var _params = new Dictionary <string, object>();
            {
                _params.Add("symbol", symbol);
                if (count > 0)
                {
                    _params.Add("count", count);
                }
                _params.Add("reverse", true);
            }

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

            if (_response != null)
            {
#if RAWJSON
                _result.rawJson = _response.Content;
#endif
                if (_response.IsSuccessful == true)
                {
                    var _trades = privateClient.DeserializeObject <List <BMyTradeItem> >(_response.Content);
                    if (_trades != null)
                    {
                        foreach (var _t in _trades)
                        {
                            _t.amount = _t.price * _t.quantity;
                        }

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

            return(_result);
        }
        /// <summary>
        /// 주문 리스트 조회: 주문 리스트를 조회한다.
        /// </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>
        /// <returns></returns>
        public async ValueTask <MyTrades> GetTrades(string base_name, string quote_name)
        {
            var _result = new MyTrades();

            var _params = new Dictionary <string, object>();
            {
                _params.Add("market", $"{quote_name}-{base_name}");
                _params.Add("state", "done");
                _params.Add("page", 1);
                _params.Add("order_by", "asc");
            }

            var _response = await privateClient.CallApiGet2Async("/orders", _params);

            if (_response != null)
            {
#if RAWJSON
                _result.rawJson = _response.Content;
#endif
                if (_response.IsSuccessful == true)
                {
                    var _trades = privateClient.DeserializeObject <List <UMyTradeItem> >(_response.Content);
                    {
                        foreach (var _t in _trades)
                        {
                            _t.amount = _t.price * _t.quantity;
                        }
                        _result.result = _trades.ToList <IMyTradeItem>();
                    }
                    _result.SetSuccess();
                }
                else
                {
                    var _message = privateClient.GetResponseMessage(_response);
                    _result.SetFailure(_message.message);
                }
            }

            return(_result);
        }