I'm coding in python a backtester for trading the Futures markets (equity futures, precious metals, bond futures, etc..). When I open a position long or short, I need to deduct an appropriate amount from the portfolio. I believe this amount should be the margin requirement as calculated by CME's SPAN algorithm.

So in simulated trading, what is best practice to calculate or derive the amount to deduct from the account? (i.e. margin requirement)

Are there any data sources to import this information? (i.e. python modules, SPAN calculators, metadata files, etc..) Quandl provides a metadata file for Futures instruments, but its missing margin requirements.

  • 1
    $\begingroup$ If you have options on futures, or complicated futures spreads (long crude, short gasoline) then a SPAN calculator is indeed necessary. If you just have straightforward futures positions, then just applying a fixed margin for each contract ( based on historically valid margins) is probably sufficient. And this is what the typical backtest engines do, in my experience. In fact some just use the current margin (e.g. 4620 per emini contract). $\endgroup$ – noob2 Jun 16 '16 at 12:07

Some exchanges do provide their historic margin requirements.

For CME: http://www.cmegroup.com/clearing/risk-management/historical-margins.html

Caveat for above link is that this is the margin imposed by the exchange on their members. May or may not be the margin your broker imposes on your account.

Hope this helps.

  • 1
    $\begingroup$ Hi, thanks for commenting . Like noob2 said, I suppose backtest engines probably just hard codes any given historical margins for each contract. $\endgroup$ – jersey bean Jun 17 '16 at 2:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.