コード例 #1
0
 public void SendQuote()
 {
     if (isQuoteInitialized || VerifyQuote())
     {
         if (isRunning)
         {
             if (Symbol.QuoteType != QuoteType.Level1)
             {
                 if (!errorWrongLevel1Type)
                 {
                     log.Error("Received " + QuoteType.Level1 + " quote but " + Symbol + " is configured for QuoteType = " + Symbol.QuoteType + " in the symbol dictionary.");
                     errorWrongLevel1Type = true;
                 }
             }
             else if (Bid == 0D)
             {
                 log.Error("Found quote bid was set to " + Bid + " so skipping this tick.");
                 return;
             }
             else if (Ask == 0D)
             {
                 log.Error("Found quote ask was set to " + Ask + " so skipping this tick.");
                 return;
             }
             else
             {
                 tickIO.Initialize();
                 tickIO.SetSymbol(Symbol.BinaryIdentifier);
                 tickIO.SetTime(Time);
                 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;
                 quotesLatency.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 quote for " + Symbol + ": " + tickIO);
                 }
             }
         }
     }
 }
コード例 #2
0
 private Yield SendPlayBackTick()
 {
     LatencyManager.IncrementSymbolHandler();
     latency.TryUpdate(nextTick.lSymbol, nextTick.UtcTime.Internal);
     if (isFirstTick)
     {
         FillSimulator.StartTick(nextTick);
         isFirstTick = false;
     }
     else
     {
         if (FillSimulator.IsChanged)
         {
             FillSimulator.ProcessOrders();
         }
     }
     return(Yield.DidWork.Invoke(ProcessOnTickCallBack));
 }
コード例 #3
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);
            }
        }