ConeA
 ( 2.74% )
- ago
Long term backtesting on futures contracts is very difficult due to changing margin requirements - especially for index futures like ES and NQ.

Consider this graph -


I'm not aware of a source for historical contract margin (maybe it exists), but I propose a more flexible alternative to fixed margin requirements for contracts - a CalculatedMargin override for SymbolInfo.Margin.

Something like this would allow a user to calculate a better margin estimate on a given date based on a contract's price, current Margin, volatility, etc.
For example -
CODE:
      public override double GetFuturesMargin(DateTime dt, BarHistory contractBars, double currentMargin)       {          int n = GetCurrentIndex(contractBars);          return Math.Max(500, currentMargin * contractBars[n] / contractBars.LastValue);       }

Note! This also has big repercussions on futures ProfitPct calculations as well.
6
960
5 Replies

Reply

Bookmark

Sort
- ago
#1
The formula is an interesting approximation, makes sense to me.

A source of historical margins surely exists but data is presented as PDF which isn't very parser friendly:
https://www.cmegroup.com/solutions/risk-management/margin-services/historical-margins.html
0
- ago
#2
Anything that removes the pain points of backtesting futures has my vote.

It is difficult enough to keep the current margins up to date: brokers are now much more active at updating them, based on their risk assessments. But to deal with the historical margin variations is much worse. Your proposal, although not leading to precise margin numbers, would definitely result in much more reasonable approximations and render the long term simulations so much better. At the moment (and this happens with all the backtesting software that I know), the problem you described makes the long-term simulations very difficult to analyse: over a period o 10y some of the margins changed 10x…

As to the effects on the Pct metrics, I am still convinced that these should be changed back to the way they were in previous Wealth-Lab versions (i.e. raw); and the corresponding change request is very slowly moving up, so hopefully this will be reconsidered one day:
https://www.wealth-lab.com/Discussion/Percentage-calculations-for-futures-trading-7514

0
GlitchA
 ( 5.77% )
- ago
#3
There would need to be a new metric added. Position Profit and Position Profit Percent is unambiguous. You’re looking for a new metric perhaps called Change in Underlying and Change in Underlying Percent.
1
ConeA
 ( 2.74% )
- ago
#4
QUOTE:
Your proposal, although not leading to precise margin numbers, would definitely result in much more reasonable approximations and render the long term simulations so much better.
My proposal allows for the possibility to gather precise historical margin data and use it.

QUOTE:
Position Profit and Position Profit Percent is unambiguous.
The proposal for changing futures margin requires taking into account the margin values at the time of each Position's entry for the calculation of these metrics.
0
- ago
#5
Hi, I recognize this is over a year old but I'm just now seeing it. I too had issues with longer-term backtesting with futures and position sizing that utilizes current margin requirements rather than dynamic, historical requirements. The solution (ableit imperfect) that I employ may not directly address your proposal for historical contract margin (which I did upvote), but it has worked well enough for me.

Instead of considering an 100% of equity position to be a fully leveraged futures position (leading to a high leverage ratio due to futures' highly leveraged nature), you can alter that assumption to mean you're putting up 100% of the capital required to cover the notional exposure of your position (1:1 leverage ratio, or close to it).

In other words, instead of 100% of equity meaning the maximum amount of futures contracts you can buy based off of the margin requirement (ignoring the notional exposure), it becomes the number of contracts required to control a position that is equal to 100% of your equity (much more conservative).

This helps to accomplish two primary things: one - perhaps more/simpler control over your true amount of leverage utilization (200% of equity = 2:1 leverage, etc), and two - it bypasses the issue of potentially unknown historical margin requirements and simply utilizes the known notional exposure at any given time (= futures price x contract multiplier).

So, ultimately, I created a new custom position sizer that simply detects when futures mode is on and then takes your desired capital usage input (using fixed $ or % of equity) and then divides it by the notional exposure of the contract rather than its margin requirement to get the number of contracts to trade.

This has helped me to conduct longer-term backtests when using futures with greater risk-control continuity. Hope it helps you too!
0

Reply

Bookmark

Sort