Currently I am using the following to calculate the number of shares to trade in a strategy:
NumContracts = Floor (CurrentAccountSize / Close)
where CurrentAccountSize = AccountStartSize + NetProfit + PositionProfit
Essentially, I am saying use all available capital to trade.
I would now like to code a version that uses an allocated percentage of the IB account size as follows:
How would I properly code this?
Code: Select all
NumContracts = Floor ((Net Liquidation Value of the IB account * (PctAllocation/100)) / Close)