예제 #1
0
        public bool getOrderInfoByID(OkexCoinType commodity, OkexCoinType currency, long orderID, out OkexStockOrderBriefInfo info)
        {
            string  c0     = OkexDefValueConvert.getCoinName(commodity);
            string  c1     = OkexDefValueConvert.getCoinName(currency);
            string  symbol = c0 + "_" + c1;
            string  str    = postRequest.order_info(symbol, orderID.ToString());
            JObject jo     = (JObject)JsonConvert.DeserializeObject(str);
            bool    ret    = (bool)jo["result"];

            info = new OkexStockOrderBriefInfo();
            if (ret)
            {
                JArray arr = JArray.Parse(jo["orders"].ToString());
                foreach (var item in arr)
                {
                    info.amount       = (double)item["amount"];
                    info.price        = (double)item["price"];
                    info.createDate   = (string)item["create_date"];
                    info.avgDealPrice = (double)item["avg_price"];
                    info.dealAmount   = (double)item["deal_amount"];
                    string strType = (string)item["type"];
                    info.tradeType = OkexDefValueConvert.parseStockTradeType(strType);

                    int nStatus = int.Parse((string)item["status"]);
                    if (nStatus == 3)
                    {
                        nStatus = 4;
                    }
                    info.status  = (OkexOrderStatusType)nStatus;
                    info.orderID = (long)item["order_id"];

                    info.commodity = commodity;
                    info.currency  = currency;

                    break;
                }
            }
            return(ret);
        }