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 -
Note! This also has big repercussions on futures ProfitPct calculations as well.
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.
Rename
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
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
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
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
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.
QUOTE:My proposal allows for the possibility to gather precise historical margin data and use it.
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.
QUOTE: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.
Position Profit and Position Profit Percent is unambiguous.
Your Response
Post
Edit Post
Login is required