예제 #1
0
        public static MakeDetail FromString(string strResponseData)
        {
            Json.Array array = Json.ToArray(strResponseData);
            if (array == null)
            {
                return(null);
            }

            MakeDetail makeDetail = new MakeDetail();

            makeDetail.items = new System.Collections.Generic.List <Item>();
            foreach (string dataItem in array)
            {
                Json.Dictionary dataItemDict = Json.ToDictionary(dataItem);

                Item item = new Item();
                item.id      = long.Parse(dataItemDict["id"]);
                item.volume  = double.Parse(dataItemDict["volume"]);
                item.price   = double.Parse(dataItemDict["price"]);
                item.symbol  = dataItemDict["symbol"];
                item.type    = dataItemDict["type"];
                item.source  = dataItemDict["source"];
                item.orderId = long.Parse(dataItemDict["orderId"]);
                long.TryParse(Json.GetAt(dataItemDict, "bid_user_id"), out item.bid_user_id);
                long.TryParse(Json.GetAt(dataItemDict, "ask_user_id"), out item.ask_user_id);
                double.TryParse(Json.GetAt(dataItemDict, "buy_fee"), out item.buy_fee);
                double.TryParse(Json.GetAt(dataItemDict, "sell_fee"), out item.sell_fee);
                item.created = Int64.Parse(dataItemDict["created"]);

                makeDetail.items.Add(item);
            }

            return(makeDetail);
        }
예제 #2
0
        // 查询某个订单的成交明细
        // symbol  : 交易对, 形如 btcbitcny, bchbtc, eoseth...
        // order_id: 订单ID
        public static MakeDetail GetMakeDetail(Account account, string symbol, long order_id)
        {
            // 排序:order_id、symbol、time
            string strParam       = string.Format("order_id={0}&symbol={1}&time={2}", order_id, symbol, GetServerTime());
            string strSignedParam = string.Format("api_key={0}&{1}&sign={2}", account.apikey, strParam, Crypt.GetSignature(strParam, account.secret));
            string strResponse    = Http.Get(V2.URL + "/order/make_detail", strSignedParam);

            if (string.IsNullOrEmpty(strResponse))
            {
                return(null);
            }

            Response response = Response.FromString(strResponse);

            if (response == null || response.code != "0" || response.msg != "suc" || string.IsNullOrEmpty(response.data))
            {
                return(null);
            }

            MakeDetail makeDetail = MakeDetail.FromString(response.data);

            if (makeDetail == null || makeDetail.items == null)
            {
                return(null);
            }

            return(makeDetail);
        }