Hello,
I am trying to back test a strategy which takes SHORT trade on some stock. To calculate the executed price I do
order_data = get_order(oid)
context.entry_price = context.portfolio.positions[symbol('VXX')].cost_basis -(order_data['commission']/order_data['filled'])
a minute after I place the orders. The orders I am placing are market orders. Everything is working fine and I am able to find out exact executed price for the SHORT entry order(i.e SELL) using the formula I am using. But while calculating the executed price for SHORT exit (i.e BUY) the cost_basis basis value reurned is 0 because of which I am unable to find out the exit executed price.
Why the cost_basis value is returning 0?
How can I compute the exit executed price?
Please assist me solving this.
Thanks.