If for example, the current position is 40 units, and an execution for 40 units happen, the Position instance will still say 40 for quantity.
When tracking a specific position for an account and instrument, one must subscribe to the PositionUpdate event and handle when the values coming in for the position are 0.
Position trackingPosition; private void Account_PositionUpdate(object sender, PositionEventArgs e) { if(e.Position.Instrument == desiredInstrument) { if(e.Quantity == 0) { // At this point e.Quantity != e.Position.Quantity trackingPosition = null; } else { trackingPosition = e.Position; } } }
Comment