/// <summary> /// 行情信息通知 /// </summary> /// <param name="_verCode"></param> /// <param name="_data"></param> public void OnMarket(int _verCode, string json) { if (json == null) { return; } try { if (_verCode == 20023) { LastPrice lp = Action.JsonToLastPrice(json); string loc = "lock"; lock (loc) { if (lp != null) { lastPrice = lp; if (lastPrice.price != null) { newPrice = (double)decimal.Round((decimal)lp.price, 2); } } } } if (_verCode == 20024) { string loc = "lock"; lock (loc) { QuoteDepth quote = Action.JsonToQuoteDepth(json); if (quote.direction == "BUY") { QuoteItem[] tmp = quote.items.ToArray(); realQuoteBuy = tmp; } else { QuoteItem[] tmp = quote.items.ToArray(); realQuoteSell = tmp; } productFakeQuote(); } } } catch (Exception ex) { Print(ex.ToString()); } }
/// <summary> /// 把 json 格式的盘口深度转成对象 /// </summary> /// <param name="_quoteDepth">盘口Json 串</param> /// <returns></returns> public static QuoteDepth JsonToQuoteDepth(string _quoteDepth) { try { string json = _quoteDepth; QuoteDepth qd = JsonConvert.DeserializeObject <QuoteDepth>(json); if (qd != null) { return(qd); } return(null); }catch { return(null); } }