开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Closing SELL order being treated as SHORT order in the api


 

Has anyone else had this occur to them for stock trades?:

I take a long position, and then try to close out the position (as a in a stop-loss situation), and the closing SELL order is treated as a SHORT order, occasionally resulting in a security being 'hard to borrow' and not being able to close out my position!? This is a little unnerving...

I don't seem to have this problem doing things 'by hand', just with orders via the API.


I'm looking through the documentation to see if there's some 'closing trade' flag I can stick on an order, but it looks like 'BUY' and 'SELL' are my only options as far as side or 'action' as it's called in the docs.


I DID see this, but it's only for institutional clients:

string? ?[get, set]
? For institutional customers only. Valid values are?O (open) and C (close).
Available for institutional clients to determine if this order is to open or close a position.
When Action = "BUY" and OpenClose = "O" this will open a new position.
When Action = "BUY" and OpenClose = "C" this will close and existing short position.



any help would be appreciated!? thanks

https://interactivebrokers.github.io/tws-api/classIBApi_1_1Order.html

Join [email protected] to automatically receive all group messages.