private void notifyAllAgentEvaluationFactories(ISimulationEvent se) { foreach (IAgentEvaluationFactory af in _aflist) { af.recvSimulationNotification(this, se); } }
public void recvSimulationNotification(ISimulationParameters sim, ISimulationEvent se) { SingletonLogger.Instance().DebugLog(typeof(AbstractPassiveTrajectoryFactory), "AbstractPassiveTrajectoryFactory recvSimulationNotification"); // events received from ISimulation if (se.OrderbookEvent == null) { if (se is ISimulationStart) { SingletonLogger.Instance().DebugLog(typeof(AbstractPassiveTrajectoryFactory), "AbstractPassiveTrajectoryFactory SET Sim!"); _sim = sim; reset(); SimulationStartNotification(); } if (se is ISimulationEnd) { SimulationEndNotification(); SingletonLogger.Instance().DebugLog(typeof(AbstractPassiveTrajectoryFactory), "AbstractPassiveTrajectoryFactory CLEAR Sim!"); _sim = null; } } else { if (_sim == null) { // too late SingletonLogger.Instance().DebugLog(typeof(AbstractPassiveTrajectoryFactory), "AbstractPassiveTrajectoryFactory Too Late!"); return; } if (se.OrderbookEvent is IOrderbookEvent_FillOrder) { IOrderbookEvent_FillOrder fillEvent = (IOrderbookEvent_FillOrder)se.OrderbookEvent; IOrder filledOrder = fillEvent.getOrder(); if (fillEvent.orderFilled()) { FilledOrderNotification(filledOrder, fillEvent.getExecutionPrice(), fillEvent.getVolume()); } else { PartialFilledOrderNotification(filledOrder, fillEvent.getExecutionPrice(), fillEvent.getVolume()); } } else if (se.OrderbookEvent is IOrderbookEvent_AddOrder) { IOrderbookEvent_AddOrder addEvent = (IOrderbookEvent_AddOrder)se.OrderbookEvent; IOrder newOrder = addEvent.getOrder(); NewOrderNotification(newOrder); } else if (se.OrderbookEvent is IOrderbookEvent_CancelOrder) { IOrderbookEvent_CancelOrder cancelEvent = (IOrderbookEvent_CancelOrder)se.OrderbookEvent; IOrder cancelledOrder = cancelEvent.getOrder(); CancelOrderNotification(cancelledOrder); } } }
private void notifyAllTrajectoryFactories(ISimulationEvent se) { foreach (IPassiveTrajectoryFactory tf in _tflist) { SingletonLogger.Instance().DebugLog(typeof(Simulation), "notifyAllTrajectoryFactories"); tf.recvSimulationNotification(this, se); } }
public void recvSimulationNotification(ISimulationParameters sim, ISimulationEvent se) { // events received from ISimulation if (se.OrderbookEvent == null) { if (se is ISimulationStart) { SingletonLogger.Instance().DebugLog(typeof(AbstractAgentEvaluationFactory), "*** AbstractAgentEvaluationFactory got ISimulationStart"); _sim = sim; reset(); SimulationStartNotification(); } if (se is ISimulationEnd) { SingletonLogger.Instance().DebugLog(typeof(AbstractAgentEvaluationFactory), "*** AbstractAgentEvaluationFactory got ISimulationEnd"); SimulationEndNotification(); _sim = null; } } else { SingletonLogger.Instance().DebugLog(typeof(AbstractAgentEvaluationFactory), "*** AbstractAgentEvaluationFactory got ISimulationEvent with non-null Orderbook"); if (se.OrderbookEvent is IOrderbookEvent_FillOrder) { IOrderbookEvent_FillOrder fillEvent = (IOrderbookEvent_FillOrder)se.OrderbookEvent; IOrder filledOrder = fillEvent.getOrder(); if (fillEvent.orderFilled()) { FilledOrderNotification(filledOrder, fillEvent.getExecutionPrice(), fillEvent.getVolume()); } else { PartialFilledOrderNotification(filledOrder, fillEvent.getExecutionPrice(), fillEvent.getVolume()); } } else if (se.OrderbookEvent is IOrderbookEvent_AddOrder) { IOrderbookEvent_AddOrder addEvent = (IOrderbookEvent_AddOrder)se.OrderbookEvent; IOrder newOrder = addEvent.getOrder(); NewOrderNotification(newOrder); } else if (se.OrderbookEvent is IOrderbookEvent_CancelOrder) { IOrderbookEvent_CancelOrder cancelEvent = (IOrderbookEvent_CancelOrder)se.OrderbookEvent; IOrder cancelledOrder = cancelEvent.getOrder(); CancelOrderNotification(cancelledOrder); } } }
// handle events from simulation public void recvSimulationNotification(ISimulationParameters sim, ISimulationEvent se) { if (se.OrderbookEvent == null) { if (se is ISimulationStart) { SingletonLogger.Instance().InfoLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " Start @ " + Scheduler.GetTime()); _sim = sim; SimulationStartNotification(sim.Population); } if (se is ISimulationEnd) { SingletonLogger.Instance().InfoLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " End @ " + Scheduler.GetTime()); SimulationEndNotification(); //CancelAllOpenOrders(); _sim = null; } } }
// delegate signals from the Simulation to appropriate agents public void recvSimulationNotification(ISimulationParameters sim, ISimulationEvent se) { if (se.OrderbookEvent == null) { // start and end events go to all agents if (se is ISimulationStart) { foreach (IAgent ag in _agents) { ag.recvSimulationNotification(sim, se); } } else if (se is ISimulationEnd) { foreach (IAgent ag in _agents) { ag.recvSimulationNotification(sim, se); } } } else { // fill events go to the order owner only if (se.OrderbookEvent is IOrderbookEvent_FillOrder) { IOrderbookEvent_FillOrder fillEvent = (IOrderbookEvent_FillOrder)se.OrderbookEvent; IOrderOwner owner = fillEvent.getOrder().getOwner(); if (_agents.Contains((IAgent)owner)) { owner.recvOrderNotification(sim.Orderbook, fillEvent); } else { throw new Exception("Population is attempting to forward signal to an unrecognized IAgent"); } } // Add and Cancel events are ignored by the Population class } }
public void AddSimulationEvent(ISimulationEvent simulationEvent, int atTick) { SnapshotsRingBuffer[GetSnapshotIndexForTick(atTick)].SimulationEvents.Add(simulationEvent); }
private void notifyPopulation(ISimulationEvent se) { _pop.recvSimulationNotification(this, se); }
public void broadcast(ISimulationEvent se) { notifyPopulation(se); notifyAllAgentEvaluationFactories(se); notifyAllTrajectoryFactories(se); }