/// <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="_lastPrice"> 行情Json 串</param> /// <returns></returns> public static LastPrice JsonToLastPrice(string _lastPrice) { try { string json = _lastPrice; LastPrice lp = JsonConvert.DeserializeObject <LastPrice>(json); if (lp != null) { return(lp); } return(null); }catch { return(null); } }