I would like to create a variable that shows the available cash on hand for purchasing shares. Meaning, if the initial capital is $100 then that variable should be equal to 100. If $50 worth of shares are purchased with a trade commission of $2 then this variable should become 48.
I am trying to create a “counter” variable like this: v = v – positionprice * countofposition – 2 within the BUY if-loop but it’s not working. The idea is to use this variable to create a condition for buying (long positions) whereby if there is not enough cash on hand to buy to not buy. Otherwise the code is selling at market price to avail cash for executing buys. This is driving me nuts…