Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
If order is not fully executed do remaining open positions follow the logic of the algo?

Say a long position is triggered through our algo and 100% of our capital is used to buy a certain low cap share. Volume is low and the order is not instantly fulfilled and the remaining shares are filled as volume becomes available. When the remaining shares are ordered do these positions follow the algo, meaning do they loop back through the logic again or they simply get executed because they were supposed to initially but due to low volume didn't?

If so, is there a way to prevent remaining positions from being executed automatically without going through the algorithm again as a completely new order.

2 responses

Marsel,

Your algo would trigger the order as defined in your code, quantopian allows a few order types (market, stop, limit, and stop/limit). Assuming you are placing market orders, which is the default, then the full order will continue to try to fill until the end of trading for the day, then will cancel itself.
It is not looping back through the algorithm, a market order will to try to fill until the end of the day. If you want to cancel it sooner, you have to code the cancellation process separately.

In most live markets you can process an order type "fill or kill", which tries to execute the entire order and if the entire order can't be placed, then it cancels it immediately, no partial fills.

You can approach the limited liquidity in a few ways:
1. code some trading logic to adjust your orders to match some percentage of the available volume, until your desired amount is filled. This can also help reduce slippage costs, keep you from pushing up the market on yourself.
2. place the full market order then use cancel_order timed to execute shortly after, although this will result in partial fills it would not continue to try to fill until the end of the day.

If you have some code to share, I can try to help you with it.

Best,
Cory

Thanks Cory,

You answered the question clearly and thoroughly. It seems to me that option 1 would make more sense, since the full order would be executed as volume becomes available. I have attached the algo below. It computes basic pattern indicators. I would appreciate any general comments you may have on the algorithm as I am new to this.

Also if you could kick off some of the coding for the limited liquidity issue, would be tremendously helpful.