I do not use a custom broker for testing (I do but not for the purposes of account margin). Instead, I’ve abstracted the order placement into a custom method in which I pass to this method variables via a custom tag on each position settings. This method is then responsible for correctly determining the allocation and method based on the variables on the custom tag. Obviously, the allocation method, amount, etc. can be customized per order/system. Part of the allocation process is determining the amount of cash available before setting the allocation.
Setting the account margin to an arbitrary high number can easily skew the results, e.g., if my real trading margin factor is 2 and I set the margin factor to 10 for the purposes of testing, the only thing that would prevent the margin in the test from exceeding 2 is either code (paragraph above as an example) or limiting the number of open positions (via the Properties tab).
As a note, there have been previous posts - I don't remember if these issues have been fixed - where the margin of the account is not respected for back testing. For example, if the margin factor is 2, the cash in the account is $100,000 and a long is placed worth $101,000, the order was rejected stating that there is not enough cash. Since the margin factor is 2, the buying power is actually $200,000 and the order should be placed without issue.
Wednesday June 25 2014 by