public void SetSymbol(string symbolString) { symbol = Factory.Symbol.LookupSymbol(symbolString); if (SyncTicks.Enabled) { tickSync = SyncTicks.GetTickSync(symbol.BinaryIdentifier); } }
public FillSimulatorPhysical(string name, SymbolInfo symbol, bool createSimulatedFills) { this.symbol = symbol; this.minimumTick = symbol.MinimumTick.ToLong(); this.tickSync = SyncTicks.GetTickSync(symbol.BinaryIdentifier); this.createSimulatedFills = createSimulatedFills; this.log = Factory.SysLog.GetLogger(typeof(FillSimulatorPhysical).FullName + "." + symbol.Symbol.StripInvalidPathChars() + "." + name); }
public OrderAlgorithmDefault(string name, SymbolInfo symbol, PhysicalOrderHandler brokerOrders) { this.log = Factory.SysLog.GetLogger(typeof(OrderAlgorithmDefault).FullName + "." + symbol.Symbol.StripInvalidPathChars() + "." + name); this.symbol = symbol; this.tickSync = SyncTicks.GetTickSync(symbol.BinaryIdentifier); this.physicalOrderHandler = brokerOrders; this.originalLogicals = new ActiveList <LogicalOrder>(); this.bufferedLogicals = new ActiveList <LogicalOrder>(); this.originalPhysicals = new ActiveList <PhysicalOrder>(); this.logicalOrders = new ActiveList <LogicalOrder>(); this.physicalOrders = new ActiveList <PhysicalOrder>(); }
public long Wait(SymbolInfo symbol, int expectedTicks, int timeout) { if (debug) { log.Debug("Wait"); } if (SyncTicks.Enabled) { tickSync = SyncTicks.GetTickSync(symbol.BinaryIdentifier); } long startTime = Factory.Parallel.TickCount; count = 0; while (Factory.Parallel.TickCount - startTime < timeout * 1000) { if (propagateException != null) { throw propagateException; } try { if (tickQueue.TryDequeue(ref tickBinary)) { tickIO.Inject(tickBinary); if (debug && countLog < 5) { log.Debug("Received a tick " + tickIO); countLog++; } count++; lastTick.Copy(tickIO); if (SyncTicks.Enabled) { tickSync.RemoveTick(); } if (count >= expectedTicks) { break; } } else { Thread.Sleep(100); } } catch (QueueException ex) { if (HandleQueueException(ex)) { break; } } } return(count); }
public bool VerifyState(BrokerState expectedBrokerState, ReceiverState expectedSymbolState, SymbolInfo symbol, int timeout) { if (debug) { log.Debug("VerifyFeed"); } if (SyncTicks.Enabled) { tickSync = SyncTicks.GetTickSync(symbol.BinaryIdentifier); } long startTime = Factory.TickCount; count = 0; TickBinary binary = new TickBinary(); while (Factory.TickCount - startTime < timeout * 1000) { if (propagateException != null) { throw propagateException; } try { if (!tickQueue.TryDequeue(ref binary)) { Thread.Sleep(100); } else { if (SyncTicks.Enabled) { tickSync.RemoveTick(); } } } catch (QueueException ex) { if (HandleQueueException(ex)) { break; } } if (brokerState == expectedBrokerState && receiverState == expectedSymbolState) { return(true); } } return(false); }
public FillSimulatorPhysical(string name, SymbolInfo symbol, bool createSimulatedFills, bool createActualFills, TriggerController triggers) { this.symbol = symbol; this.name = name; this.triggers = triggers; this.minimumTick = symbol.MinimumTick.ToLong(); this.tickSync = SyncTicks.GetTickSync(symbol.BinaryIdentifier); this.createSimulatedFills = createSimulatedFills; this.log = Factory.SysLog.GetLogger(typeof(FillSimulatorPhysical).FullName + "." + symbol.Symbol.StripInvalidPathChars() + "." + name); this.log.Register(this); this.createActualFills = createActualFills; fillLogic = new FillSimulatorLogic(name, symbol, FillCallback); IsChanged = true; PartialFillSimulation = symbol.PartialFillSimulation; }
public FIXServerSymbolHandler(FIXSimulatorSupport fixSimulatorSupport, bool isPlayBack, string symbolString, Func <Yield> onHeartbeat, Func <SymbolInfo, Tick, Yield> onTick, Action <PhysicalFill, int, int, int> onPhysicalFill, Action <PhysicalOrder, string> onRejectOrder) { this.fixSimulatorSupport = fixSimulatorSupport; this.isPlayBack = isPlayBack; this.onHeartbeat = onHeartbeat; this.onTick = onTick; this.symbol = Factory.Symbol.LookupSymbol(symbolString); reader = Factory.TickUtil.TickReader(); reader.Initialize("Test\\MockProviderData", symbolString); fillSimulator = Factory.Utility.FillSimulator("FIX", symbol, false); fillSimulator.OnPhysicalFill = onPhysicalFill; fillSimulator.OnRejectOrder = onRejectOrder; tickSync = SyncTicks.GetTickSync(symbol.BinaryIdentifier); tickSync.ForceClear(); queueTask = Factory.Parallel.Loop("FIXServerSymbol-" + symbolString, OnException, ProcessQueue); firstHearbeat = true; }
public SimulateSymbolSyncTicks(FIXSimulatorSupport fixSimulatorSupport, QuoteSimulatorSupport quoteSimulatorSupport, string symbolString, PartialFillSimulation partialFillSimulation, TimeStamp endTime, long id) { log.Register(this); this.id = id; this.fixSimulatorSupport = fixSimulatorSupport; this.quoteSimulatorSupport = quoteSimulatorSupport; this.onTick = quoteSimulatorSupport.OnTick; this.onEndTick = quoteSimulatorSupport.OnEndTick; this.PartialFillSimulation = partialFillSimulation; this.symbolString = symbolString; this.symbol = Factory.Symbol.LookupSymbol(symbolString); fillSimulator = Factory.Utility.FillSimulator("FIX", Symbol, false, true, null); fillSimulator.EnableSyncTicks = SyncTicks.Enabled; FillSimulator.OnPhysicalFill = fixSimulatorSupport.OnPhysicalFill; FillSimulator.OnRejectOrder = fixSimulatorSupport.OnRejectOrder; fillSimulator.PartialFillSimulation = partialFillSimulation; tickSync = SyncTicks.GetTickSync(Symbol.BinaryIdentifier); latency = new LatencyMetric("SimulateSymbolSyncTicks-" + symbolString.StripInvalidPathChars()); diagnoseMetric = Diagnose.RegisterMetric("Simulator"); if (debug) { log.Debug("Opening tick file for reading."); } reader = Factory.TickUtil.TickFile(); try { reader.Initialize("Test\\MockProviderData", symbolString, TickFileMode.Read); reader.EndTime = endTime; } catch (FileNotFoundException ex) { log.Info("File for symbol " + symbolString + " not found: " + ex.Message); } }
public long Verify(int expectedCount, Action <TickIO, TickIO, long> assertTick, SymbolInfo symbol, int timeout, Action action) { if (debug) { log.Debug("Verify"); } if (SyncTicks.Enabled) { tickSync = SyncTicks.GetTickSync(symbol.BinaryIdentifier); } long endTime = Factory.Parallel.TickCount + timeout * 1000; count = 0; while (Factory.Parallel.TickCount < endTime) { if (propagateException != null) { throw propagateException; } try { if (tickQueue.TryDequeue(ref tickBinary)) { tickIO.Inject(tickBinary); if (debug && countLog < 5) { log.Debug("Received a tick " + tickIO); countLog++; } startTime = Factory.TickCount; count++; if (count > 0 && assertTick != null) { assertTick(tickIO, lastTick, symbol.BinaryIdentifier); } lastTick.Copy(tickIO); if (!actionAlreadyRun && action != null) { actionAlreadyRun = true; action(); } if (SyncTicks.Enabled) { tickSync.RemoveTick(); } if (count >= expectedCount) { break; } } else { Thread.Sleep(100); } } catch (QueueException ex) { if (HandleQueueException(ex)) { break; } } } return(count); }
public VerifyFeedDefault(SymbolInfo symbol) { this.symbol = symbol; tickSync = SyncTicks.GetTickSync(symbol.BinaryIdentifier); tickPool = Factory.Parallel.TickPool(symbol); }