Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
close position : how to get the Filled price to calcuate real realized pnl of a single trade

Hi everyone,I want to calcuate the realized pnl for a trade. buy the filled price of closing position is the close price of next bar.
data.current(sid,'close') and position[sid].last_sale_price return the price of current bar.

for example, i close position in 10:10,
data.current(sid,'close') and position[sid].last_sale_price return the price ruturn the price of 10:10
but in fact, the order is filled with close price of 10:11 in full backtest.
how can i get the real filld price of next bar in backtest?

thanks for your help.

2 responses

Thank you Hawk,i have checked the get_order method before, which it returned doesn't include the filled price information of market order.