private void OnCryptoLevel2(CryptoLevel2 cryptoLevel2)
        {
            string Text;

            if (IsJSONTextMode)
            {
                Text = JsonConvert.SerializeObject(cryptoLevel2);
            }
            else
            {
                Text = $"Trade: Pair: {cryptoLevel2.pair}, " +
                       $"Bid Prices: {cryptoLevel2.b.ToString()}" +
                       $"Ask Prices: {cryptoLevel2.a.ToString()}, " +
                       $"Exchange ID: {cryptoLevel2.xt}, " +
                       $"Time: {PGBase.UnixTimestampMillisToESTDateTime( cryptoLevel2.t )} EST";
            }
            AppendText(Text);
        }
Пример #2
0
 internal void OnCryptoLevel2(CryptoLevel2 cryptoLevel2)
 {
 }
Пример #3
0
        // =====>>>>>>>>>> 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);
            }
        }