Esempio n. 1
0
        public bool getOrderInfoByID(OkexFutureInstrumentType instrument, OkexFutureContractType contract,
                                     long orderID, out OkexFutureOrderBriefInfo info)
        {
            //List<OkexFutureOrderBriefInfo> ordersBriefInfo = new List<OkexFutureOrderBriefInfo>();
            string str = postRequest.future_order_info(OkexDefValueConvert.getInstrumentStr(instrument), OkexDefValueConvert.getContractTypeStr(contract), orderID.ToString(), "1", "0", "1");

            JObject jo  = (JObject)JsonConvert.DeserializeObject(str);
            bool    ret = (bool)jo["result"];

            info = new OkexFutureOrderBriefInfo();
            if (ret)
            {
                JArray arr = JArray.Parse(jo["orders"].ToString());
                foreach (var item in arr)
                {
                    info.amount       = (long)item["amount"];
                    info.contractName = (string)item["contract_name"];
                    info.leverRate    = (int)item["lever_rate"];
                    info.price        = (double)item["price"];
                    info.tradeType    = (OkexContractTradeType)int.Parse((string)item["type"]);
                    info.status       = (OkexOrderStatusType)int.Parse((string)item["status"]);
                    info.orderID      = (long)item["order_id"];
                    break;
                }
            }

            return(ret);
        }
Esempio n. 2
0
        public bool getCurOrdersInfo(OkexFutureInstrumentType instrument, OkexFutureContractType contract,
                                     out List <OkexFutureOrderBriefInfo> briefInfo, bool finished = false)
        {
            List <OkexFutureOrderBriefInfo> ordersBriefInfo = new List <OkexFutureOrderBriefInfo>();
            string strFinished = "1";

            if (finished)
            {
                strFinished = "2";
            }
            string str = postRequest.future_order_info(OkexDefValueConvert.getInstrumentStr(instrument), OkexDefValueConvert.getContractTypeStr(contract), "-1", strFinished, "0", "1");

            briefInfo = new List <OkexFutureOrderBriefInfo>();
            JObject jo  = (JObject)JsonConvert.DeserializeObject(str);
            bool    ret = (bool)jo["result"];

            if (ret)
            {
                JArray arr = JArray.Parse(jo["orders"].ToString());
                foreach (var item in arr)
                {
                    OkexFutureOrderBriefInfo obi = new OkexFutureOrderBriefInfo();
                    obi.amount       = (long)item["amount"];
                    obi.contractName = (string)item["contract_name"];
                    obi.leverRate    = (int)item["lever_rate"];
                    obi.price        = (double)item["price"];
                    obi.tradeType    = (OkexContractTradeType)int.Parse((string)item["type"]);
                    obi.status       = (OkexOrderStatusType)int.Parse((string)item["status"]);
                    obi.orderID      = (long)item["order_id"];
                    briefInfo.Add(obi);
                }
            }

            return(ret);
        }