internal void OnCryptoQuote(CryptoQuote quote) { RTDataRec Rec = GetRTDataRec(quote.pair, PGClusterNames.Crypto); Rec.AskTick = quote.ap == 0 ? TickType.FlatTick : Rec.Ask > quote.ap ? TickType.DownTick : TickType.UpTick; Rec.Ask = quote.ap; Rec.BidTick = quote.bp == 0 ? TickType.FlatTick : Rec.Bid > quote.bp ? TickType.DownTick : TickType.UpTick; Rec.Bid = quote.bp; Rec.Spread = (Rec.Ask - Rec.Bid).ToString("0.00000"); }
private void OnCryptoQuote(CryptoQuote quote) { string Text; if (IsJSONTextMode) { Text = JsonConvert.SerializeObject(quote); } else { Text = $"Trade: Pair: {quote.pair}, " + $"Last Trade: {quote.lp}, Last Trade Size: {quote.ls}, " + $"Bid: {quote.bp}, Bid Size: {quote.bs}, " + $"Ask: {quote.ap}, Ask Size: {quote.asz}, " + $"Exchange ID: {quote.xt}, " + $"Exchange Timestamp: {PGBase.UnixTimestampMillisToESTDateTime( quote.t )} EST"; } AppendText(Text); }
// =====>>>>>>>>>> JSONText Message Received public override void OnWebSocketJSONText(string JSONText) { try { string ObjJSONText; List <object> PGBaseList = JsonConvert.DeserializeObject <List <object> >(JSONText); foreach (var PGBase in PGBaseList) { ObjJSONText = PGBase.ToString(); PolygonBase pGBase = JsonConvert.DeserializeObject <PolygonBase>(ObjJSONText); switch (pGBase.ev) { case "XQ": CryptoQuote quote = JsonConvert.DeserializeObject <CryptoQuote>(ObjJSONText); if (quote != null) { OnCryptoQuoteEvent?.Invoke(quote); } break; case "XT": CryptoTrade trade = JsonConvert.DeserializeObject <CryptoTrade>(ObjJSONText); if (trade != null) { OnCryptoTradeEvent?.Invoke(trade); } break; case "XA": CryptoAggregate cryptoAgg = JsonConvert.DeserializeObject <CryptoAggregate>(ObjJSONText); if (cryptoAgg != null) { OnCryptoAggEvent?.Invoke(cryptoAgg); } break; case "XS": CryptoSIP CryptoSIPRef = JsonConvert.DeserializeObject <CryptoSIP>(ObjJSONText); if (CryptoSIPRef != null) { OnCryptoSIPEvent?.Invoke(CryptoSIPRef); } break; case "XL2": CryptoLevel2 cryptoLevel2 = JsonConvert.DeserializeObject <CryptoLevel2>(ObjJSONText); if (cryptoLevel2 != null) { OnCryptoLevel2Event?.Invoke(cryptoLevel2); } break; case "status": Status StatusIn = JsonConvert.DeserializeObject <Status>(ObjJSONText); HandleStatusMessage(StatusIn); break; default: break; } } } catch (System.Exception ex) { HandleJSONTextException("websocket_MessageReceived", JSONText, ex); } }