Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
BUY and SELL LimitOrder within a minute timeframe

Hi,

Is it possible to enter a BUY and SELL LimitOrder within a minute time frame and get it successfully executed.
If my limit prices of buy and sell are within the High and Low of the minute will my orders get successfully executed.
If not what is the fill price which I will be getting.
Please show me a sample code if you have one.

Regards,
Anand

5 responses

Anand,

If the slippage model is turned off, I think that the backtester uses exact minutely closing prices for all orders (I'd need to write some sample code to confirm). The same is true, I believe, of the Q simulated live trading (again, I'd write some code to confirm). For real-money live trading, orders are sent as they are encountered in code (aynchronously), and the broker fills them as they come in (within the minute). Are you interested in simulation or real-world trading?

Grant

Hi Grant,

I am right now back testing a simple algorithm which sends out a buy and sell limit order and want to see if I can get a fill for both the orders(buy,sell) within my specified price in the next minute bar. I will be adding further logic once I am able to get the fills for my specified price.
I have shared the back test results in my first post. In my back test results I observe that
1. BUY and SELL orders are not getting executed in the same minute for all orders
2. The price at which the orders are getting filled have no correlation to the price shown in the Log results(where I have OHLCV printed for my reference)
For eg: When I backtested for the date range 3/10/2016-3/11/2016 on minute data my first order is shown as getting executed with price 200.00 at 8:02. My buy and sell limit orders would have been entered with limit price limit price(price of previous minute) which is 199.745.

Thank you for helping me solving the problem.

Regards,
Anand

Hi Anand,

I don't have time now, but I do recall that there may be a bug, with the slippage applied before the limit trigger. I suggest disabling the slippage to see what you get.

Grant

Thank you Grant.
I also found the following thread. I am going to see if I can use the fixed slippage to override default slippage model.

https://www.quantopian.com/posts/slippage