protected override void query() { lock (m_lock) { if (!m_valid) { return; } if (m_orderID == 0) { onTradeEvent(m_orderID, TradeQueryResult.TQR_Timeout, null); return; } OkexStockOrderBriefInfo info; if (m_resultTimer != null) { m_resultTimer.Start(); } bool ret = OkexStockTrader.Instance.getOrderInfoByID(m_commodity, m_currency, m_orderID, out info); if (ret) { if (m_resultTimer != null) { m_resultTimer.Stop(); } TradeQueryResult tqr = getResultType(info.status); onTradeEvent(m_orderID, tqr, info); if (tqr == TradeQueryResult.TQR_Finished) { stop(); } } } }
public void onTradeEvent(long orderID, TradeQueryResult result, OkexStockOrderBriefInfo info) { if (m_stockTradeEventHandler != null) { m_stockTradeEventHandler(orderID, result, info); } }
static void stockTradeCallback(long orderID, TradeQueryResult result, OkexStockOrderBriefInfo info) { string infoStatus = "Unknown"; if (info != null) { infoStatus = info.status.ToString(); } string str = "ID: " + orderID.ToString() + ", Status: " + result.ToString() + ", Info: " + infoStatus; output(str); }
protected static TradeQueryResult getResultType(OkexOrderStatusType status) { TradeQueryResult ret = TradeQueryResult.TQR_Unfinished; if (status == OkexOrderStatusType.OS_AllTraded || status == OkexOrderStatusType.OS_Canceled) { ret = TradeQueryResult.TQR_Finished; } return(ret); }
private void updateFutureEntities() { List <int> eraseList = new List <int>(); for (int i = 0; i < m_entityList.Count; i++) { TradeQueryResult status = m_entityList[i].getStatus(); if (status == TradeQueryResult.TQR_Finished || status == TradeQueryResult.TQR_Failed) { eraseList.Add(i); } } if (eraseList.Count > 0) { for (int i = eraseList.Count - 1; i >= 0; i--) { m_entityList.RemoveAt(eraseList[i]); } } }