Best practice for backtesting futures based trading system

How do you calculate historical margin required for stock and index futures for backtesting. These margins change from time to time so it can't be a static value. Also in my country the lot size of a future contract changes every once in a while.
Do you calculate these factors using some formula (such as span margin formula) or do you have these values stored in price feed?
What is the best practice?


Depending on market/instrument the margin might be some fixed (at a time) value or percentage of contract price. Typically contacts have limited lifetime and specification of margin requirements don't change that often. The simplest approach is just to take maximum historical value per contract lifetime and use just use it for simplicity. That would err on the side of caution which is good approach anyway.

1 Like

i personally like to do this by employing constant leverage, not thinking about real margins.
Futures Backtesting - how to employ a constant leverage - AFL Programming - AmiBroker Community Forum
This way your risk in terms of leverage is the same