void fillOrderMaybe(Order order, Tick tick, Converter <Order, double> fillPrice, bool isClose) { if (order.canFill(tick.price, isClose)) { fillAt(order, fillPrice(order), tick.time); } }
void fillOrders(Symbol symbol, Tick tick, Converter <Order, double> fillPrice, bool isClose) { var fillable = accept(orders(symbol), order => isFillable(order, symbol, tick.price, isClose)); fillable = sort(fillable, (a, b) => { var fillA = Math.Abs(tick.price - fillPrice(a)); var fillB = Math.Abs(tick.price - fillPrice(b)); var priceOrder = fillB.CompareTo(fillA); return(priceOrder != 0 ? priceOrder : a.id.CompareTo(b.id)); }); each(fillable, order => fillOrderMaybe(order, tick, fillPrice, isClose)); }
internal void processTick(Tick tick, Symbol symbol) { lock (partialBars) { trades.Clear(); var price = tick.price; var runClose = bridge.runOnClose() && !hasRunLiveClose && now().CompareTo(symbol.closeAt()) >= 0; fillOrders(symbol, tick, order => price, runClose); bridge.processTick(symbol, tick); gottenTicks = true; if (runClose) { hasRunLiveClose = true; } } }
protected override void onNewTick(Bar partialBar, Tick tick) { }
public abstract void processTick(Symbol symbol, Tick tick);
void fillOrdersNotOpen(Symbol symbol, Tick tick, bool isClose) { fillOrders(symbol, tick, order => order.fillPrice(tick.price, false), isClose); }
protected override void onNewTick(Bar partialBar, Tick tick) { placeOrders(); }
public virtual void tickProcessed(Symbol symbol, Tick tick) { }
public override void tickProcessed(Symbol symbol, Tick tick) { positionMonitor.publishAll(); systemHeartbeat[symbol].tickProcessed(tick); }