public double getBidPriceOffset(IOrderbook_Agent ob) { processOrderbook(ob); double y = SingletonRandomGenerator.Instance.NextUniform(0.0, 1.0); return(-_SteadySpread / 2.0 - XSCALE * CDFinv(y)); }
// receive a signal from the Matcher (via the Simulation, via the Population) that an order has been filled public void recvOrderNotification(IOrderbook_Agent ob, IOrderbookEvent evt) { // Fill order events if (evt is IOrderbookEvent_FillOrder) { IOrderbookEvent_FillOrder fillEvent = (IOrderbookEvent_FillOrder)evt; IOrder filledOrder = fillEvent.getOrder(); SingletonLogger.Instance().InfoLog(typeof(AbstractAgent), "AbstractAgent " + GetName() + " Fill " + filledOrder + " @ " + Scheduler.GetTime()); if (filledOrder.isBid()) { AccumulateHoldings(+1 * fillEvent.getVolume()); } else { AccumulateHoldings(-1 * fillEvent.getVolume()); } if (fillEvent.orderFilled()) { RemoveFromOpenOrderList(filledOrder); FilledOrderNotification(filledOrder, fillEvent.getExecutionPrice(), fillEvent.getVolume()); } else { PartialFilledOrderNotification(filledOrder, fillEvent.getExecutionPrice(), fillEvent.getVolume()); } } // Add and Cancel events are not forwarded to agents by the Population class }
public double getBidPrice(IOrderbook_Agent ob) { processOrderbook(ob); if (isMarket(ob)) { return(getMarketPrice(ob)); } else { return(Price + getBidPriceOffset(ob)); } }
public double getMarketPriceOffset(IOrderbook_Agent ob) { processOrderbook(ob); return(SingletonRandomGenerator.Instance.NextUniform(-_SteadySpread / 2.0 - _MarketPadding, +_SteadySpread / 2.0 + _MarketPadding)); }
public bool isMarket(IOrderbook_Agent ob) { processOrderbook(ob); return(SingletonRandomGenerator.Instance.NextDouble() <= MarketProb); }
private void processOrderbook(IOrderbook_Agent ob) { Price = ob.getPrice(); }
public double getMarketPrice(IOrderbook_Agent ob) { processOrderbook(ob); return(Price + getMarketPriceOffset(ob)); }