Profile Picture

Profit target limit not cancelled properly when closing position

Posted By Zora 8 Years Ago

Profit target limit not cancelled properly when closing position

Message
Posted Monday June 01 2009
(System setup: IB/TWS, IQFeed, RE1 build 384, live system using stocks)

I noticed a funny thing recently when closing position for a stock. I work with long positions, each of which has a stop loss and a profit target sell order associated with it. When the stop loss is triggered and the position closes, the limit sell corresponding to the profit target is supposed to be cancelled, right? Well, that's not always the case.

The problem arises for stocks that do not have shortable shares available. After the stop loss sell order has been filled, RE attempts to cancel the pending limit sell order (call it order XXX). However, when the MySymbolScript.OrderCancelled() method is called, the information message parameter says:

"Shares for this order are not immediately available for short sale.
The order will be held while we attempt to locate the shares." (not sure why there are html tags, but that's not relevant)

At the same time, the order status is reported as "Rejected". TWS continues to display the order as active. Attempting to cancel the order again from RE returns a code that says "Order ID XXX not found for position ID YYY". So... it appears as though RE thinks the order has been cancelled, whereas in reality it's still active.

After seeing this message, I went into TWS and tried to manually open a short position for this same symbol. Sure enough I got the same message - "Shares for this order are not immediately available for short sale. The order will be held while we attempt to locate the shares." Ok, I thought, at least there's some consistency, but what do I do about my orders not being cancelled? It looks like TWS interprets a limit sell for X shares as an attempt to open a short position if you are not already holding X or more shares (which is the case right after the position is closed). If there are shares available for shorting, the order just hangs there until RE cancels it, assuming the market price is below the limit. Usually, the cancellation is quick, a second or two, so the order goes away and everything is peachy keen. But for stocks that don't have shares to short, a request to cancel the order results in the response from TWS described above. And the order doesn't get cancelled. Is this something that can be resolved/configured in TWS? Have you guys seens this before?

Sorry for being long winded. Thanks!


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems