开云体育

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

Long on the stock, want to exit but: Order rejected The contract is not available for short sale


 

Hi,

My algo took a long position on a stock and when target was reached and wanted to exit I got this message:
201 Order rejected - reason:The contract is not available for short sale.

I'm aware of? this message if I want to go short on a stock.
But if I bought and own the shares why does this happen?

The algo runs in paper trading account so is it related?
Can this really happen live?

Thanks
A


 

Is your algorithm trying to sell more shares than what the position holds? Maybe the fill quantity was slightly smaller than what the algorithm had ordered?

JR


On Thu, Apr 29, 2021 at 09:02 PM, Ace wrote:
Hi,

My algo took a long position on a stock and when target was reached and wanted to exit I got this message:
201 Order rejected - reason:The contract is not available for short sale.

I'm aware of? this message if I want to go short on a stock.
But if I bought and own the shares why does this happen?

The algo runs in paper trading account so is it related?
Can this really happen live?

Thanks
A


 

No, it tried to sell half the position.
A


 

A,? If it's in your paper account, welcome to IB..

If it's production, check that the contractID is the same, and the exchange is right (SMART, or whatever came on the Position record itself). If IB were to think it was a different security, your sell would be from a basis of 0 making it a short.

Otherwise report it IB, and send in your logs.

-Peter


 

Hi Peter,

I found the paper trading testing of algo to be pretty good...up to now.

Are there other major quirks of the paper trading I should be aware of?

Thank you


 

开云体育

Ace, my experience of the paper-trading system, which I actively use all day every trading day, would lead me to suggest that it's unlikely that what you describe indicates a flaw in the system. My bet would be that there's something you've overlooked in your program.

?

As a ?general suggestion, I'd say that if you cannot prove from your logs that your position was exactly what you think it was and that your closing order was for exactly that quantity, then you're probably not logging enough information.

?

And if you can prove it from your logs, then you should raise it with IB because I'm quite certain that they'd be keen to know of such a flaw.

?

Richard

?

?

From: [email protected] <[email protected]> On Behalf Of Ace
Sent: 30 April 2021 18:48
To: [email protected]
Subject: Re: [TWS API] Long on the stock, want to exit but: Order rejected The contract is not available for short sale

?

Hi Peter,

I found the paper trading testing of algo to be pretty good...up to now.

Are there other major quirks of the paper trading I should be aware of?

Thank you


 

On Fri, Apr 30, 2021 at 07:47 PM, Ace wrote:
Are there other major quirks of the paper trading I should be aware of?
In fairness, it's likely one of the best paper systems out there these days.? I just seem to have a nack for finding it's flaws.? Often where permissions from the prod account don't map the same to the paper one.? Family account permissions, and Volatility/leveraged eft trading auth were recent troubles.? Had troubles last week with short term VWAP orders where the orders were canceled instead of filled if they were small (100 shares) with a short duration (1 minute).? I'm also often using Prime accounts, which is likely a small subset of the overall account base.? Helps with market data lines (+30k is typical), but some bits are less polished than other vendors in the Prime world.??

-Peter


 

I know this is an old post, but this happened to me today. I'm testing my code using a paper account and running TWS so I can see the positions in TWS. For testing it only opens positions of a single share, long only. And I have it set up to cancel all open orders and sell all open positions just before the close of the regular trading hours. There were 17 open positions and all but one were closed as expected. Just one position, a stock with ticker BTOG, was not closed. I received several errors saying: "Order rejected - reason:The contract is not available for short sale."? This was despite the fact that the open position was long 1 share and the closing order was a MARKET order to sell 1 share. After stopping my code I placed a LIMIT order manually to sell 1 share. It was filled to close the position.
?
The error message makes no sense, but I suspect the market order was rejected because it could not be filled immediately on this illiquid stock whereas the limit order waited for a bid to show up.?