Hello,
I am trying to back test my strategy with initial capital as $10000. My algorithm does some signal generating stuff and places and takes appropriate trades according to the signals.
Explaining with an example.
1) When position is 0 a LONG trade triggers and my algorithm must buy a stock of quantity (my_capital(i.e context.portfolio.cash) / stock's current price).
2) Next SHORT's entry will be LONG's exit at that time My algorithm must first square of the LONG which is by selling the same stock of same quantity which as placed earlier in long And then it should enter the short by placing a sell order of quantity (cash remaining in my portfolio / stock's current price) .
Now, the problem I am facing is that I am unable to find out (cash remaining in my portfolio / stock's current price). Actual problem is that portfolio.cash seems like updating every minute because of which I am unable to find out the actual balance in my account. Also, I am unable to find out the executed price of the first sell order. I know that (cost_basis-comission) will give me executed price But seems like even the cost_basis updates next minute. How can i find (cash remaining in my portfolio / stock's current price) ??
Thanks.