Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Tracking order details

Suppose I have the following code executing on the 1st minute of a trading day

order_target_value(sid(24),100000,style=LimitOrder(100))  

This order may or may not go through, and if it will, it may only be partially filled. Is there an out of-the-box way to figure out at the end of the trading day (or on the day after before trading starts) how many stocks were purchased, and at what price?

2 responses

Hi Boris, when you make an order, it returns an id. You can save this id in context and later use get_order() to check the status. Orders are closed at the end of day unless you are using zipline in daily mode. Assuming you are using minute mode, you should look at the order object returned by get_order for amount filled and context.portfolio.positions[symbol(ticker)].last_sale_price (kind of long, eh?) for the last price paid for a security.

In daily mode (which is what I'm using now) check here:
https://github.com/quantopian/zipline/issues/1489

I'm going to just manually close all orders daily and keep a running total in context.trades, subtracting current amount from last amount to get fills.

Thank you Zippy!