Fill corrections
ib_insync's filled quantity algorithm performs a sum of the quantity of all the trade's fills: https://github.com/erdewit/ib_insync/blob/20180813c2c768c408f1febe7e1373423dd9d0f0/ib_insync/wrapper.py#L436
These fills are communicated as "executions" by IB through the execDetails callback. However IB API's documentation indicates that an execution's ExecId field might indicate in some cases that it is not a new execution but a correction to a previous execution (https://interactivebrokers.github.io/tws-api/classIBApi_1_1Execution.html): " string ExecId The execution's identifier. Each partial fill has a separate ExecId. A correction is indicated by an ExecId which differs from a previous ExecId in only the digits after the final period, e.g. an ExecId ending in ".02" would be a correction of a previous execution with an ExecId ending in ".01". "
The documentation does not indicate if the correction is a replacement (ie it cancels and replaces the previous execution) or a delta (ie its quantities shall be added to the previous execution's quantities to correct them). ib_insync's code seems to assume the later. Is it a deliberate choice based on observing these cases, or is it a potential bug? I have not observed this case directly in my new logs (my old logs are not usable for such purpose) so maybe this potential bug is pedantic.
A correction to a fill is not handled properly right now: It is treated as an extra fill without discarding the erroneous older fill. This should be fixed.