Ejemplo n.º 1
0
        private static void Symbol_NewLevel2(Symbol symbol, Level2Quote level2, DOMQuote dom)
        {
            // Snapshot level2 update
            if (dom != null)
            {
                List <Level2Quote> bids = dom.Bids;
                List <Level2Quote> asks = dom.Asks;
            }

            // Incremental level2 update
            if (level2 != null)
            {
                QuotePriceType priceType = level2.PriceType; // Bid or Ask
                double         price     = level2.Price;
                double         size      = level2.Size;

                if (level2.Closed)
                {
                    // If level is closed and should be deleted
                }
            }

            // Get market depth info from symbol
            var depthOfMarket = symbol.DepthOfMarket.GetDepthOfMarketAggregatedCollections();
        }
Ejemplo n.º 2
0
        private IEnumerable <Level2Quote> CreateLevel2Quotes(QuotePriceType priceType, HitOrderBookLevel[] hitLevels, string symbol, DateTime dateTime)
        {
            foreach (var item in hitLevels)
            {
                string id    = $"MMID_{item.Price}";
                double price = (double)item.Price;
                double size  = (double)item.Size;

                yield return(new Level2Quote(priceType, symbol, id, price, size, dateTime));
            }
        }
Ejemplo n.º 3
0
        private Level2Quote CreateLevel2Quote(BitfinexBookItem bitfinexBookItem)
        {
            QuotePriceType priceType = bitfinexBookItem.Amount > 0 ? QuotePriceType.Bid : QuotePriceType.Ask;
            string         symbol    = bitfinexBookItem.Pair;
            string         id        = $"MMID_{bitfinexBookItem.Price}";
            double         price     = (double)bitfinexBookItem.Price;
            double         size      = bitfinexBookItem.Count == 0 ? 0 : Math.Abs((double)bitfinexBookItem.Amount);
            DateTime       utcNow    = Core.Instance.TimeUtils.DateTimeUtcNow;

            return(new Level2Quote(priceType, symbol, id, price, size, utcNow));
        }
Ejemplo n.º 4
0
        public void ProcessQuote(MarketType market, string assetPair, QuotePriceType priceType, double price, DateTime timestamp)
        {
            var topic   = $"quote.{market.ToString().ToLower()}.{assetPair.ToLower()}.{priceType.ToString().ToLower()}";
            var subject = _realm.Services.GetSubject <QuoteClientMessage>(topic);

            subject.OnNext(new QuoteClientMessage
            {
                AssetPairId = assetPair,
                Market      = market,
                PriceType   = priceType,
                Timestamp   = timestamp,
                Price       = price
            });
        }