예제 #1
0
        public void RemoveRTData(RTDataRec RecIn)
        {
            RTDataRec Rec = GetRTDataRec(RecIn.Symbol, RecIn.ClusterName, false);

            if (Rec != null)
            {
                OnUnSubscribedSymbolEvent?.Invoke(Rec);
                RTDataDict.Remove(Rec.Symbol);
            }
        }
예제 #2
0
        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");
        }
예제 #3
0
        internal void OnForexQuote(ForexQuote quote)
        {
            RTDataRec Rec = GetRTDataRec(quote.p, PGClusterNames.Forex);

            Rec.AskTick = quote.a == 0 ? TickType.FlatTick
                                                : Rec.Ask > quote.a ? TickType.DownTick : TickType.UpTick;
            Rec.Ask     = quote.a;
            Rec.BidTick = quote.b == 0 ? TickType.FlatTick
                                                : Rec.Bid > quote.b ? TickType.DownTick : TickType.UpTick;
            Rec.Bid    = quote.b;
            Rec.Spread = (Rec.Ask - Rec.Bid).ToString("0.00000");
        }
예제 #4
0
        internal void OnEquitiesQuote(Quote quote)
        {
            RTDataRec Rec = GetRTDataRec(quote.sym, PGClusterNames.Equities);

            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.00");
        }
예제 #5
0
        internal RTDataRec GetRTDataRec(string Symbol, string ClusterName, bool Create = true)
        {
            RTDataRec Rec;

            if (!RTDataDict.TryGetValue(Symbol, out Rec) && Create)
            {
                Rec = new RTDataRec(Symbol, ClusterName);
                RTDataDict[Symbol] = Rec;

                OnSubscribedSymbolEvent?.Invoke(Rec);
                Rec.RequestLast = true;
            }
            return(Rec);
        }
예제 #6
0
        internal void OnEquitiesTrade(Trade trade)
        {
            RTDataRec Rec = GetRTDataRec(trade.sym, PGClusterNames.Equities);

            Rec.PriceTick = trade.p == 0 ? TickType.FlatTick
                                                        : Rec.Price > trade.p ? TickType.DownTick : TickType.UpTick;
            Rec.Price    = trade.p;
            Rec.LastSize = trade.s;
            string Change = (Math.Max(Rec.PreviousClose, trade.p) - Math.Min(Rec.PreviousClose, trade.p)).
                            ToString("F2");

            Rec.Change     = double.Parse(Change);
            Rec.ChangeTick = Rec.Change == 0 ? TickType.FlatTick
                                                        : Rec.Change < 0 ? TickType.DownTick : TickType.UpTick;
        }
예제 #7
0
        internal void OnCryptoTrade(CryptoTrade trade)
        {
            RTDataRec Rec = GetRTDataRec(trade.pair, PGClusterNames.Crypto);

            Rec.PriceTick = trade.p == 0 ? TickType.FlatTick
                                                : Rec.Price > trade.p ? TickType.DownTick : TickType.UpTick;
            Rec.Price      = trade.p;
            Rec.CryptoSize = trade.s;
            string Change = (Math.Max(Rec.PreviousClose, trade.p) - Math.Min(Rec.PreviousClose, trade.p)).
                            ToString("0:00");

            Rec.Change     = double.Parse(Change);
            Rec.ChangeTick = Rec.Change == 0 ? TickType.FlatTick
                                                        : Rec.Change < 0 ? TickType.DownTick : TickType.UpTick;
        }
예제 #8
0
        internal void OnSubscribe(string ClusterName, Dictionary <string, SubscribeSymbolRec> SubscribedSymbols)
        {
            var SubscribedSymbolsCopy = new Dictionary <string, SubscribeSymbolRec>(SubscribedSymbols);

            foreach (var kvPair in SubscribedSymbolsCopy)
            {
                string             Symbol       = kvPair.Key;
                SubscribeSymbolRec SubscribeRec = kvPair.Value;

                if (SubscribeRec.IsNew)
                {
                    RTDataRec Rec = GetRTDataRec(Symbol, ClusterName);
                    OnSubscribedSymbolEvent?.Invoke(Rec);
                }
            }
        }
예제 #9
0
        public void OnPreviousClose(string ClusterName, PreviousClose previousClose)
        {
            RTDataRec Rec = GetRTDataRec(previousClose.ticker, ClusterName);

            Rec.PreviousClose = previousClose.results.First().c;
        }
예제 #10
0
        internal void OnForexAgg(ForexAggregate forexAgg)
        {
            RTDataRec Rec = GetRTDataRec(forexAgg.pair, PGClusterNames.Crypto);

            Rec.LastSize = forexAgg.v;
        }