Preventing Duplicate Trade Fills Without Broker Lot IDs
Summary
The document addresses how to prevent an order-tracking system from recording the same execution more than once when a broker does not provide a separate identifier for each lot. The example includes fills with matching quantities and prices, showing why a hash of visible trade attributes can collide when two fills otherwise look identical.
The answers recommend using each fill’s unique execution identifier and linking it to the original order identifier. They also suggest assigning a client-side order ID or retrieving the broker’s assigned order ID so fills can be matched back to the submitted order. The discussion says duplicate fill records should not be expected from a functioning broker API. These recommendations depend on the API exposing stable execution and order identifiers; the document does not describe a fallback for APIs that omit both, and it names no particular broker or implementation.
Key ideas
- Use a unique execution identifier to distinguish individual fills, including fills with otherwise identical attributes.
- Associate executions with the original order using a client-generated or broker-assigned order ID.
- A hash of timestamp, quantity, symbol, and price may fail to distinguish genuinely separate but identical fills.
- Verify which identifiers the broker API exposes before designing order reconciliation.
Tags
Full text
# How do you handle order tracking (without unique Lot ID's) # How do you handle order tracking (without unique Lot ID's) Hypothetical Trade: I buy 10,000 shares of ASTC using a broker API. The order is filled in 4 similar lots; ``` 2500 shares at 0.80 2500 shares at 0.80 2500 shares at 0.77 2500 shares at 0.77 ``` The easiest way to record these lot fills is if the broker issues a UNIQUE "Lot ID" like this: ``` 2500 shares at 0.80 --- LOT ID# 3484HGK 2500 shares at 0.80 --- LOT ID# DFD38HF 2500 shares at 0.77 --- LOT ID# JJVKD89 2500 shares at 0.77 --- LOT ID# FJF9D93 ``` THE PROBLEM: Unfortunately, the broker does not issue LOT ID#'s (yet). A computer program will see the lot fills many times. WHAT LOGIC DO I USE TO PREVENT THE PROGRAM FROM RECORDING EACH LOT FILL MORE THAN ONCE? Suggestion 1: I can make a hash based on the attributes of the LOT. That may work, however, if everything matches (timestamp, number of shares, symbol, price) I will get duplicate hashes. Suggestion 2: Use the alert notifications. I am not sure the notifications are available from the API. I would like to know how others have handled this tracking issue. ## Answer by Clebson Derivan (score 1) https://quant.stackexchange.com/a/8609 you forgot to mention what broker or api you are using. AFAIK every broker/exchange provides a execution id, wich is unique for every trade on the trade session, with the execution id and your order id you can group the trades for the order sent. You could check the execution report of the FIX Protocol its based on the industry standard and the majority of brokers use it to deal with the exchanges/ecn. ## Answer by Matt Wolf (score 1) https://quant.stackexchange.com/a/8611 I think you are focusing on lots when you should focus on having the API return the original orderID, that is what really matters, not LotIDs (though every API of average quality should generate a unique ID for each individual fill as well). Chrisaycock is right in saying that each fill you receive should automatically be unique. So you are by definition not double counting even if you are not able to uniquely allocate each fill to the original order. However, you need to find a way to either a) tag your original order you send to your broker with your own unique orderID or b) if the API permits get the assigned original orderID from the order you submitted so you can later on match the fills that are tagged with either your original orderID or the one of the broker. To summarize, you should never get double counted fills from your broker. If that is the case you should definitely dump that API or change brokers. A fill you receive should be a unique fill, never anything else.
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.