Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How to retrieve order filled price?

Hi guys,

I am writing an algo and want to check the filled price, such that if current price is DELTA below the filled price, I will initiate stop loss. I was using 'cost_basis' from positions object,

f_cost = self.portfolio.positions[sid]['cost_basis']

I don't think this is correct though, see,
{'GOOG': Position({'amount': 9, 'last_sale_price': nan, 'cost_basis': nan, 'sid': 'GOOG'})}

Can you guys help?

Thank you.

3 responses

I found the problem. I am using HFT data and I didn't fill the NAs before submitting to Zipline.

I have the same question too, but I do not understand your answer. Is the price the order was filled at a property of the order itself?

Thanks.

Hi Michael,

How did you backtest? Online in Quantopian browser or offline?
In backtest, we must understand the slippage and commission models, for my case, offline backtest with my own data,
1) All market orders
2) FixedSlippage
3) PerShare commission model
Then my filled price is the market price of next bar, adding above on top

Previously since it was my own data, I didn't cleansing (e.g. resample and fillna) but only align two time series. So there were a lot of NaNs in the data frame.

Do you trace zipline source code? I think that will help you a lot, if you read the zipline-0.5.10\zipline\finance\slippage.py.

Cheers