Hi all,
As you know, Q cancels any open orders every night. There are times, however, when one might want to have limit orders persist for longer.
Take for example a stock that is subject to wild swings, up and down. You might want to take profits if the stock unexpectedly hits a given high, say at 2 levels of divergence above the norm. Pipeline apps do not run intra day. Typically, you might have a given function running once a day, but rarely more frequently than that. At whatever time of day you are running your "daily" routine, the trigger point may not have been reached. But it might reach it temporarily during the day, then fall back below it, so it would not trigger it on the next daily routine either. Obviously, that's where a limit order makes sense
I am confused about their treatment in live IB run applications: it is not clear to me how Q handles the non-fulfillment of limit orders.
If you've ordered to buy 100 shares of XYZ stock and 62 filled at days end, doesn't IB continue trying to fill the remaining 38 regardless of Q?
Or does Q see that only 62 were filled out of 100, and therefore send an order to cancel the limit order to IB, so it will never fill remaining 38?
If my understanding is correct, in pipeline based apps, one would have to take the following approach:
1) set up your pipelines, with their daily /weekly/monthly routines as usual
but regardless run your algo every minute, using a timer to examine the market in whatever intervals make sense (5 minutes/15 minutes/ hourly, etc)
use context variables to store your symbol/ limit combinations that can persist overnight.
run an app every day before market opens to reinstate your limit orders
But if my understanding is incorrect, this would cause a doubling of limit orders, and unwanted buys/sells and probable margin calls.
I appreciate any input or thoughts from others on this.