Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Fill corrections #364

Open
dmoklaf opened this issue Apr 30, 2021 · 1 comment
Open

Fill corrections #364

dmoklaf opened this issue Apr 30, 2021 · 1 comment

Comments

@dmoklaf
Copy link

dmoklaf commented Apr 30, 2021

ib_insync's filled quantity algorithm performs a sum of the quantity of all the trade's fills:

def execDetails(

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.

@dmoklaf dmoklaf changed the title Fills corrections Fill corrections Apr 30, 2021
@erdewit
Copy link
Owner

erdewit commented May 3, 2021

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants