- ago
When backtesting futures, in the list of "Positions", the % fields (Profit %, MFE %, MAE%) seem to be calculated taking into account the leverage of the contract.

Is there any way to have them display the raw % of the trade instead?
5
1,501
18 Replies

Reply

Bookmark

Sort
Cone8
 ( 4.98% )
- ago
#1
You can turn off Futures Mode in Backtest settings, but obviously that will affect the backtest in a meaningful way.
0
- ago
#2
Hi Cone,

True, but then it is not futures backtesting anymore.

As it stands, the reported % metrics don't make sense, since the result will vary in function of the current margin - which, in volatile markets, changes very regularly, is broker dependent and currency dependent (IB even differentiates it depending on the account jurisdiction).

In my opinion, it would make more sense to report the % values under the Positions, in relation to the underlying variation. I like to use the MFE/MAE metrics to get a sense of where to place stops and, like this, they can't be used at all.

If NQ went from 4000 to 4400, that should simply display a 10% gain; and not:
- 40%, if the current margin is 20000 USD;
- 26.667%, if the current margin is 30000USD.
- 20%, if the current margin is 40000USD.

Any chance that this ever gets changed without a feature request, considering it is (kind of) an anomaly?

Thank you!
0
Cone8
 ( 4.98% )
- ago
#3
I see your point, it makes sense. I think we'll have to study it and if it's not an option to change the current properties, perhaps a new set can be added.
0
- ago
#4
That would be great!

Thank you very much for taking this into consideration.
0
Cone8
 ( 4.98% )
- ago
#5
Even though I see where you want to go, I'm not sure we'll get there. For the other readers not as familiar with the subject...

The profit of a futures trade is the number of points (entry price - exit price) multiplied by the contract's point value times the number of contracts.

Taking an example of the S&P 500 mini (ES) contract, the point value is $50 and the margin currently is roughly $20,000. That means to buy 1 contract, you need to have $20K in your account. If you buy ES at 4,000 and sell it at 4,400, the profit of that trade is 400 * 50 = $20,000 on 1 contract. The is a 100% gain for that contract's trade. Simply, if you had a $20K account, now it's worth $40K.

If the margin were only $10,000, then it would be a 200% gain for the same point value. This make sense, because only half the capital was required to achieve this profit.

On the other hand, if the 'futures margin' and point value is 1 (as it is for stocks), the Profit % is a constant 10%, no matter the trade size.

I don't think we disagree on this, but you're just looking for an easier way get at these "raw" point/percentage calculations for trading rules. At least for the time being, the answer is to just perform these simple calculations on the fly.
0
Cone8
 ( 4.98% )
- ago
#6
Because we aim to please, here's a leg-up for you - Extension methods. Just add this class (untested) to your Strategy and you can refer to them just like they were another built-in Position method, e.g., LastPosition.RawProfitPctAsOf(idx)

CODE:
   public static class PositionExtensions    {       public static double RawProfitPctAsOf(this Position p, int bar)       {          double result = (p.Bars.Close[bar] / p.EntryPrice - 1) * 100;          return p.PositionType == PositionType.Long ? result : -1 * result;       }       public static double RawMFEPctAsOf(this Position p, int bar)       {          double points = p.PositionType == PositionType.Long ? p.HighestHighAsOf(bar) - p.EntryPrice : p.EntryPrice - p.LowestLowAsOf(bar);          return (points / p.EntryPrice) * 100;       }       public static double RawMAEAsOf(this Position p, int bar)       {          double points = p.PositionType == PositionType.Long ? p.LowestLowAsOf(bar) - p.EntryPrice : p.EntryPrice - p.HighestHighAsOf(bar);          return (points / p.EntryPrice) * 100;       }    }
0
- ago
#7
I understand your point but, for futures traders, I don't think it makes sense to mix aspects of position sizing in the calculations of the gain/loss of a specific position.

Moreover, following your example, if the ES would go from 4,000 to 3,600; that would result in a loss of 400 points = $20K; therefore, for a margin of also $20K, it will display a loss of -100%!! Which one would normally associate with the account blown up, which is probably not the case, as it would depend on the account management.

Another example: let's say that the ES goes from 4,000 to 3,200 points and then up again to 4,400 points. Then the MAE would results in -200% and the gain 100%: how can it be that I lost 200% and still made a profit?!


It's not so much a matter of calculating those metrics on the fly (which is annoying but of course doable); it's more about them being useable at all. Like I mentioned above, both MFE/MAE are unusable like this to determine stop levels.
If I would try to use those metrics to calculate stops, I would have to re-calculate them every time the margin changes.

I don't know of any other software (including WL 6.9) that calculates the futures positions this way. I know this is not alone an argument to change (they could all be less right until now); and I also understand that there doesn't seem to be many futures traders using WL7.
0
- ago
#8
In any case, thank you very much for the code above.

I can try to print the gain to the "Tag" field and sort it; or to just disable futures mode.
0
Cone8
 ( 4.98% )
- ago
#9
QUOTE:
a margin of also $20K, it will display a loss of -100%!!
If you're only trading with a $20K account, then it is a blow up. In all cases, it's still a 100% loss with respect to the position size.

QUOTE:
...the MAE would results in -200% and the gain 100%: how can it be that I lost 200% and still made a profit?!
The effect of trading on margin. It's the same as if you had a short stock position at $50 that went to $150 and then to 0. As long as your account can handle it without a margin call, it works.

QUOTE:
I don't know of any other software (including WL 6.9)
Maybe this calls for a user survey. There's certainly a case for both sides.

fwiw, I just noticed the methods above don't include commissions.
0
- ago
#10
Thank you Cone,

If we are having this discussion, then obviously this is not as consensual nor as straightforward as I originally anticipated.

If it’s OK with you, I would then open a feature request with two options (adapting the % metrics or adding new ones); we can then gauge interest and take it from there…
0
Cone8
 ( 4.98% )
- ago
#11
Sure, that's fine.
0
Glitch8
 ( 10.62% )
- ago
#12
So I guess we need a "Mixed Futures Mode" so we can see Profit in Futures Mode but Profit % in non-Futures Mode??
0
- ago
#13
Hi Glitch,

Not necessary, I was trying to advocate that the % calculations should not depend on the margin; otherwise they keep changing. And I personally cannot think of a usage for the way they are at the moment; and so I started by suggesting to change the calculation of those 3 percentage metrics (as in WL6; and quite frankly in every other backtesting software that I know to support futures). But I understand that we all trade in different ways and there might be others that prefer it as it is; and hence the alternative to eventually add 3 parallel metrics.
0
Glitch8
 ( 10.62% )
- ago
#14
The percentage profit and other percentage metrics change when you change the margin because the cost basis of the position changes. If you have to "commit" $10,000 to buy 1 contract, and you gain $1,000 on the trade, isn't that a 10% gain? Whereas if you had to commit $100,000 in margin for the same 1 contract, isn't it a 1% gain?

But, I can see why someone might want to see the percentage values based on the change in the contract price so sure we can leave this in as a potential future backtest setting.
0
- ago
#15
Thank you. Again, I appreciate that this is still even being considered!

Like I wrote above, I perfectly understand that many will prefer it the way it is; moreover, there are probable not yet many futures traders using WL7.

As to reporting the gain/loss in regards to the committed capital: if this would also apply to stocks, then a 2:1 margin would result in the positions reporting double of the gain as opposed to 1:1 margin, since only half of the capital was stuck in the position.
0
Cone8
 ( 4.98% )
- ago
#16
'margin' is the same term, but you know that its use is different between stocks and futures. While 2:1 (or more) margin is available to trade stocks, it's not required that you use (commit) it on any individual trade. And, if you do, the percentage of the trade profit is still with respect to the amount of capital committed to the trade, borrowed or not.
0
Glitch8
 ( 10.62% )
- ago
#17
I think we need to flag this as a #FeatureRequest then?
0
Cone8
 ( 4.98% )
- ago
#18
Done!
0

Reply

Bookmark

Sort