开云体育

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

Close Orders Rejected


 

?
Hi,
?
This is not a twsapi issue, but If you can give me any help I would appreciate it.
?
I use a real margin account, trading stocks with TWS.? I have issues with closing the positions.
?
Attached you can find the orders for NVDA.
Starting from bottom to top you can see that
1. I've opened a short position with 92 shares with a limit order
2. Closed the position with a Buy Market
3. Opened a new short position with 92 shares using a limit order
4. Triggered a Buy Mkt order that is rejected :
?? with the message that " I don't have enough funds ... etc"

How is this possible, it is "buy to close" not a buy to open a new position, for me the situation is perplexing.
I have to exit other trades to be able to close that one...
IBKR support keeps telling me that I don't have enough funds.
No funds to exit the trade?
?
Thank you,
Flaviu
?
?


 

开云体育

I think you need to look at??excess liquidity before and after vs the initial and maintenance margin requirements. If due to the buy to close your excess liquidity becomes too loo (since your cash position will reduce) vs initial margin then you??can’t do the purchase while you may be able to hold the position as-is without violating margin requirement since that will be based on maintenance margin which will be lower than initial margin.?
You did several other transactions between the sell to open and the buy to close of this instrument so??margin position will have changed.?
Without the margin / excess liquidity info it’s hard to make any conclusion.?
Also it will be different depending on the margin mode of your account (reg T vs??portfolio margin in the US).?

rgds, Bart
On Oct 11, 2024 at 11:40?PM -0700, Flaviu Paul via groups.io <flaviupaul@...>, wrote:

?
Hi,
?
This is not a twsapi issue, but If you can give me any help I would appreciate it.
?
I use a real margin account, trading stocks with TWS.? I have issues with closing the positions.
?
Attached you can find the orders for NVDA.
Starting from bottom to top you can see that
1. I've opened a short position with 92 shares with a limit order
2. Closed the position with a Buy Market
3. Opened a new short position with 92 shares using a limit order
4. Triggered a Buy Mkt order that is rejected :
?? with the message that " I don't have enough funds ... etc"

How is this possible, it is "buy to close" not a buy to open a new position, for me the situation is perplexing.
I have to exit other trades to be able to close that one...
IBKR support keeps telling me that I don't have enough funds.
No funds to exit the trade?
?
Thank you,
Flaviu
?
?


 

Thank you Bart.
I don't know how to get the historical excess liquidity or initial margin.
The Daily PNL was positive when I tried to close the position and had unused cash.?
You mentioned that "since your cash position will reduce", my cash position would increase as I close the position as I exit the trade I transform the
shares back into cash.


 

开云体育

I don’t think you can retrieve historical margin or excess liquidity. You can only see it for the current time in TWS in the account window. You can do a what-if order to see impact on margin situation at the present time, in TWS or via API.?
I thought you were trying to close out a short position. So for that you would need to buy back the stock so spend cash.?

rgds, Bart
On Oct 12, 2024 at 1:36?AM -0700, Flaviu Paul via groups.io <flaviupaul@...>, wrote:

Thank you Bart.
I don't know how to get the historical excess liquidity or initial margin.
The Daily PNL was positive when I tried to close the position and had unused cash.?
You mentioned that "since your cash position will reduce", my cash position would increase as I close the position as I exit the trade I transform the
shares back into cash.


 

I will use the what-if order, thank you, but I would want to use it when I try to buy a new stock so that I don't get into a situation where I am no longer able
to exit the current position on other stock.?
?
Is the formula something like this:
equityWithLoanAfter - initMarginAfter > buffer
?
"I thought you were trying to close out a short position. So for that you would need to buy back the stock so spend cash. "
?
It is a short position and I have to buy back the stock, but isn't the cash already taken when I open the trade and used as collateral?
?
?


 

开云体育

To check the impact of an order on margin, you can do a what-if in TWS or via the API before you enter the order and see the impact on margin requirement. Pls check the IBKR docs. It's not that easy to give a formula since it will depend on a few factors incl margin mode of the account and??IBKR's margin calculation at the time (they've made some changes after the vol spike on August 5 for portfolio margin to make it more stringent due to wider bid/ask spreads).?

You're right the cash is reserved as collateral for a short position but the impact on margin may not be 0 by closing the position. Best is to always keep sufficient 'margin cushion'. I believe they show a warning in TWS when that goes below 10% but better to keep significantly higher than that especially when holding volatile products (options, tech stocks etc)

rgds, Bart
On Oct 12, 2024 at 11:44?AM -0700, Flaviu Paul via groups.io <flaviupaul@...>, wrote:

I will use the what-if order, thank you, but I would want to use it when I try to buy a new stock so that I don't get into a situation where I am no longer able
to exit the current position on other stock.?
?
Is the formula something like this:
equityWithLoanAfter - initMarginAfter > buffer
?
"I thought you were trying to close out a short position. So for that you would need to buy back the stock so spend cash. "
?
It is a short position and I have to buy back the stock, but isn't the cash already taken when I open the trade and used as collateral?
?
?


 

Normally you should always be able to reduce risk (including closing short positions). What time of day were the trades at? Maybe you were outside RTH (Regular Trading Hours) - there's a flag for that?


 

It is my intuition as well, that closing a position reduces risk and something isn't right. I only trade during Regular Hours, this was between 5-6 but I have daily examples
like this.


 

Sorry: 10-11 AM Session Hours,?? 5-6 in my timezone


 

This can happen due to portfolio margin calculation, if for example you hold long QQQ and short NVDA, that will have a lower margin requirement than naked short NVDA, as the positions partly cancel each other's risk.
Also, as noted above, when you sell NVDA short, you got your cash position increase (you just sold shares you borrowed), and if later you somehow tied this cash or used it, you can't close your short as it requires buying shares back with cash.


 

I think bespalex is on the right path. Do you know what your net beta exposure is? There's a Risk Navigator tool that will show you how your positions add up. Managing margin for multiple instruments is not trivial as it is not additive.
?
I would recommend giving this a go: https://www.interactivebrokers.com/campus/trading-course/ibkrs-risk-navigator/


 

Thank you all for the valuable information. I knew that I would get more information here than from IBKR support. I've just lowered the trading size until
It didn't happen anymore.