Ejemplo n.º 1
0
        public void SendOptionPrice()
        {
            if (!isRunning)
            {
                return;
            }
            if (Symbol.OptionChain != OptionChain.Complete)
            {
                if (!errorOptionChainType)
                {
                    log.Error("Received option price but " + Symbol + " is configured for TimeAndSales = " + Symbol.OptionChain + " in the symbol dictionary.");
                    errorOptionChainType = true;
                }
                return;
            }
            if (!isQuoteInitialized && !VerifyQuote())
            {
                return;
            }

            if (strikePrice == 0D || utcOptionExpiration == default(TimeStamp))
            {
                if (!errorStrikeAndExpiration)
                {
                    log.Error("Received option price but strike or expiration was blank: Strike " + strikePrice + ", " + utcOptionExpiration);
                    errorStrikeAndExpiration = true;
                }
                return;
            }
            tickIO.Initialize();
            tickIO.SetSymbol(Symbol.BinaryIdentifier);
            tickIO.SetTime(Time);
            tickIO.SetOption(optionType, strikePrice, utcOptionExpiration);
            if (Last != 0D)
            {
                tickIO.SetTrade(Last, LastSize);
            }
            if (Bid != 0 && Ask != 0 && BidSize != 0 && AskSize != 0)
            {
                tickIO.SetQuote(Bid, Ask, (short)BidSize, (short)AskSize);
            }
            var box    = tickPool.Create(tickPoolCallerId);
            var tickId = box.TickBinary.Id;

            box.TickBinary    = tickIO.Extract();
            box.TickBinary.Id = tickId;
            if (tickIO.IsTrade && tickIO.Price == 0D)
            {
                log.Warn("Found trade tick with zero price: " + tickIO);
            }
            salesLatency.TryUpdate(box.TickBinary.Symbol, box.TickBinary.UtcTime);
            var eventItem = new EventItem(symbol, EventType.Tick, box);

            agent.SendEvent(eventItem);
            Interlocked.Increment(ref tickCount);
            if (Diagnose.TraceTicks)
            {
                Diagnose.AddTick(diagnoseMetric, ref box.TickBinary);
            }
            if (trace)
            {
                log.Trace("Sent trade tick for " + Symbol + ": " + tickIO);
            }
        }