I would like to backtest a strategy on a portfolio level with a watchlist of stocks. How exactly can I specify the position sizing to make sure at any bar, the entire available fund is utilized and position for all signals are taken equally with cash available?
if I have starting capital 100,000, and for simplicity lets say price of all stocks do not change and are at 10.
at bar 0, I have four signals, buy Stock1, buy Stocks2, Short stock3, short stock4
i.e at this point, I would allocate 25,000 to each of the above four positions, (qty 2500 each)
at bar 1, I have four signals, sell stock1, cover stock3, buy stock5, buy stock6
at this point, I would buy stock5 and stock6 with the proceeds from the exit of stock1 and stock3
i.e assuming no change in price of stocks, sell and cover 250 qty of stock1 and stock3 , and using the cash, buy equal amount of stock5 and stock6 ( in this case assuming no change of price from bar 0 to bar 1, that would mean 25000 worth of stock5 and stock6 each)
Positionsize here should be a function of number of entries and exits at each bar and available cash.
Is this possible without CBT?