Exemple #1
0
        /// <summary>
        /// 查询用户某个品种的持仓
        /// </summary>
        /// <param name="_userId">用户ID</param>
        /// <param name="_symbol">商品编码</param>
        /// <returns></returns>
        public static Position QureyPosition(long _userId, string _coinSymbol)
        {
            string URL = "exchange/order/query_position";

            try
            {
                string      json = "{\"memberId\":" + _userId + ",\"productSymbol\":\"" + _coinSymbol + "\"}";
                RestRequest r    = new RestRequest(URL, Method.POST);
                r.AddParameter("application/json", json, ParameterType.RequestBody);
                IRestResponse restResponse = HttpRestQurey(r);
                if (restResponse == null)
                {
                    return(null);
                }

                string            resJson = restResponse.Content;
                response_Position rp      = JsonConvert.DeserializeObject <response_Position>(resJson);
                if (rp != null && rp.data != null)
                {
                    if (rp.data.Count > 0)
                    {
                        return(rp.data[0]);
                    }
                }
                return(null);
            }catch
            {
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// 根据用户ID 查询用户的所有持仓
        /// </summary>
        /// <param name="_userId">用户ID</param>
        /// <param name="_page">页码</param>
        /// <param name="_limit">每页大小</param>
        /// <returns>返回查询结果---Json 格式</returns>
        public static List <Position> QureyAllPosition(long _userId, int _page, int _limit)
        {
            string URL = "exchange/order/position/{memberId}/{page}/{limit}";

            try
            {
                RestRequest r = new RestRequest(URL, Method.GET);
                r.AddUrlSegment("memberId", _userId);
                r.AddUrlSegment("page", _page);
                r.AddUrlSegment("limit", _limit);

                IRestResponse response = HttpRestQurey(r);
                if (response == null)
                {
                    return(null);
                }

                string            json = response.Content;
                response_Position rp   = JsonConvert.DeserializeObject <response_Position>(json);
                if (rp != null && rp.code == 0 && rp.data != null)
                {
                    return(rp.data);
                }
                return(null);
            }catch
            {
                return(null);
            }
        }