Skip to content

Is there a way to sell specific shares, or "lots", through the TWS API, ideally using ib_async? #112

Answered by mattsta
6nc0r6-1mp6r0 asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for all those details, but sadly, the answer is just: No.

The IBKR APIs do not let you close specific instrument holdings at the API level because IBKR doesn't report historical holding details at all.

Every position in your portfolio is only reported with an avgPrice (or is it avgCost? multiple names get used for the same concept in different places) field which is updated every time new quantities are added to a position. IBKR APIs only let you close using position detail of (contract, quantity,) and there's no place for "historical lot" since there's no way to view or address historical lots at all (or even would be useful: "attempt to close N quantity for C contract if N were a…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by 6nc0r6-1mp6r0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants