public void UpdateFill(FillEvent fill) { var fillDir = GetNumericDirection(fill.Direction); var closePrice = this.bars.GetLastClosePrice(fill.Symbol); if (closePrice == null) { throw new InvalidOperationException($"Cannot find last price for {fill.Symbol}"); } var cost = fillDir * closePrice.Value * fill.Quantity; this.currentPositions[fill.Symbol] += fillDir * fill.Quantity; this.currentComission += fill.Comission; this.currentCash -= (cost + fill.Comission); }
public void ExecuteOrder(OrderEvent orderEvent) { // Simulate order execution delay var dateTime = orderEvent.OrderTime.AddSeconds(CONST_ExecutionDelaySeconds); var closePrice = this.bars.GetLastClosePrice(orderEvent.Symbol); var fillCost = closePrice * orderEvent.Quantity ?? decimal.Zero; var fillEvent = new FillEvent( dateTime, orderEvent.Symbol, "ARCA", orderEvent.Quantity, orderEvent.OrderDirection, fillCost); this.eventBus.Put(fillEvent); }