public void StartSymbol(Receiver receiver, SymbolInfo symbol, object eventDetail) { TickIO tickIO = Factory.TickUtil.TickIO(); tickIO.Initialize(); tickIO.SetSymbol(symbol.BinaryIdentifier); tickIO.SetTime(new TimeStamp(2000, 1, 1)); tickIO.SetQuote(100D, 100D); while (!receiver.OnEvent(symbol, (int)EventType.StartHistorical, symbol)) { Factory.Parallel.Yield(); } var binaryBox = tickPool.Create(); binaryBox.TickBinary = tickIO.Extract(); while (!receiver.OnEvent(symbol, (int)EventType.Tick, binaryBox)) { Factory.Parallel.Yield(); } tickIO.Initialize(); tickIO.SetSymbol(symbol.BinaryIdentifier); tickIO.SetTime(new TimeStamp(2000, 1, 2)); tickIO.SetQuote(101D, 101D); binaryBox = tickPool.Create(); binaryBox.TickBinary = tickIO.Extract(); while (!receiver.OnEvent(symbol, (int)EventType.Tick, binaryBox)) { Factory.Parallel.Yield(); } while (!receiver.OnEvent(symbol, (int)EventType.EndHistorical, symbol)) { Factory.Parallel.Yield(); } }
private bool TryAddLevel1() { if (lastAsk == 0 || lastBid == 0 || lastAskSize == 0 || lastBidSize == 0) { return(false); } tick.SetQuote(lastBid, lastAsk, (ushort)lastBidSize, (ushort)lastAskSize); if (trace) { log.Trace("Level1 SetQuote()"); } return(true); }
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); } } } } }
public void SendQuote() { if (isInitialized) { if (symbol.QuoteType == QuoteType.Level1) { tickIO.Initialize(); tickIO.SetSymbol(symbol.BinaryIdentifier); tickIO.SetTime(TimeStamp.UtcNow); tickIO.SetQuote(Bid, Ask, (ushort)BidSize, (ushort)AskSize); TickBinary binary = tickIO.Extract(); receiver.OnSend(ref binary); } } else { VerifyInitialized(); } }
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(); box.TickBinary = tickIO.Extract(); receiver.OnEvent(symbol, (int)EventType.Tick, box); if (trace) { log.Trace("Sent tick for " + symbol + ": " + tickIO); } } } } }