Fully automated futures trading

The downside is that on average, you hold a lot more positions, for the same backtest, average positions held is 22 for Rob's method vs 29 for my modified .

No this is good. That's the point of DO - more positions when you can afford them

Rob
 
I've been playing with DO implementation, and stumbled upon what could be a slight improvement so wanted to share.

I've been trading Rob's implementation of DO for about 2 years now, and I've been noticing that I would sometimes have a position on in an instrument that has optimal unrounded, eg. 0.17, and have nothing on in something with optimal unrounded 1.7. Digging into this, I think it is because since the algo is greedy, if the 0.17 one has a big notional, it will take that as that will reduce the tracking error the most in that step. Then it never gets to the 1.7 one, as the notional is much smaller.

I've made the following modification: instead of starting from 0 weights for all instruments as the starting point for the DO, start from the
Code:
round(unrounded_optimal_position)
. I then increase/decrease the weight towards optimal unrounded weight in the DO iterations.
That does indeed reduce the occurrences I've mentioned above. It also prevents the situation of forecast flipping - when forecast is around 0, original implementation has to switch position (I believe buffering deals with that to an extent). The reason it prevents that situation is that if the optimal unrounded is [-0.49, 0.49], we'll start from 0 anyways, so variations around 0 forecast/optimal unrounded are not as impactful.

Running a backtest on 104 instruments, about 20 years of data, I get lower average tracking error, 3.81% vs 4.65% with the original method.
Here's a chart with difference over time.
View attachment 337794

The downside is that on average, you hold a lot more positions, for the same backtest, average positions held is 22 for Rob's method vs 29 for my modified version.

Risk is almost exactly the same, slightly smaller for my method.

Has anybody played with something similar? Would be interested to see if anyone could replicate these results.

I've just ran a quick backtest where DO starts with the ideal rounded positions instead of zeros, the PnL and Sharpe stayed roughly the same, but the number of trades jumped from 6558 to 8631, so by 30%.. The overall costs also jumped, but apparently a slightly higher return compensated for it? I wouldn't trust my costs 100%, but the number of trades should be somewhat reliable in my backtest..
 
Last edited:
I've just ran a quick backtest where DO starts with the ideal rounded positions instead of zeros, the PnL and Sharpe stayed roughly the same, but the number of trades jumped from 6558 to 8631, so by 30%.. The overall costs also jumped, but apparently a slightly higher return compensated for it? I wouldn't trust my costs 100%, but the number of trades should be somewhat reliable in my backtest..

Also, it seems that my margin usage and net exposure went up somewhat (I'll double check it just in case..):

original DO with starting zero weights (margin usage then notional exposure):
upload_2024-4-9_12-11-7.png

upload_2024-4-9_12-11-15.png


New DO where with starting rounded ideal weights:
upload_2024-4-9_12-12-17.png

upload_2024-4-9_12-12-26.png
 
Last edited:
I get lower average tracking error, 3.81% vs 4.65%
Btw, how do you calculate tracking error in percentage?
I normally calculate tracking error in currency, e.g. an actual value could be 1,077$, how would you convert it to % ?

I see 2 options:
- divide 1077$ by my system's base capital (e.g. 300,000$)
- or divide 1077$ by the total notional cost of my current portfolio (e.g. I might currently own 3 contracts with the notional 300k each and 2 contracts with the notional 400k each, so the total notional value of my portfolio is 3*300k + 2*400k=1.7million, so I'll divide 1,077$ by 1.7mil).

(Even with the first option my tracking error is mostly under 1%, but I'll rerun the backtest to double-check..)
 
Last edited:
For me, SR is about 10% better for the modified version. That's all after costs, for exact same set of instruments and forecasts.

Btw, how do you calculate tracking error in percentage?
I normally calculate tracking error in currency, e.g. an actual value could be 1,077$, how would you convert it to % ?
I use Rob's method of having everything in weights. At that point in the process (DO stage), I don't want to have to deal with exchange rates and stuff. So I think that's your Option 1.

Interesting that your tracking error is much lower, mine hovers around 3-4% almost all the time, sometimes dips below 3%.
 
As I said about 4 posts ago:

Personally I think the absolute minimum account size to trade futures is probably around the 50k mark

Rob
Good Morning globalarbtrader,

Yes, I agree with you. $50K is needed for 1 or 2 trading systems if running the future instruments.

How many systems are you running in your portfolio?

How do you know when a system not work anymore to make you money?
 
Last edited:
For me, SR is about 10% better for the modified version. That's all after costs, for exact same set of instruments and forecasts.


I use Rob's method of having everything in weights. At that point in the process (DO stage), I don't want to have to deal with exchange rates and stuff. So I think that's your Option 1.

Interesting that your tracking error is much lower, mine hovers around 3-4% almost all the time, sometimes dips below 3%.
hmm, interesting.. I reran my backtest, there was a small error, but the result didn't change much, still the number of trades and margin\notional usage gets ~35% higher, when starting from the rounded weights...
You're not seining an increase in the number of trades\capital usage?

I run this backtest with 37 instruments, 15-30y of data, at 300k capital. The DO tracking-error threshold below which I don't reoptimize comes out to 956.25$, which is 0.3% of the base capital., My actual tracking error hovers around 1.1k, or 0.35% of the base capital., although I do see a decrease in the average tracking error from 0.359 to 0.327 when using rounded weights as a start

tracking error from zero vs from rounded:
upload_2024-4-10_11-30-28.png


Btw, the way I calculate (gap)portfolio sigma (tracking error) is this:

var weightedStds = new List<double>(stdWeightInfo.Select(stw => stw.stDev * ( (Math.Abs(stw.unitPriceUSD) * stw.unitsBought) / totPortfPriceUSD ) ));

var varience = (weightedStds * correlationMatrix * weightedStds.Transpose())[0, 0];
var sigmaUsd = Math.Sqrt(varience) * totPortfPriceUSD;

so weightedStds is a vector of instruments' standard deviations multiplied by the proportion of that instrument(by notional) in the current portfolio..
 
Good Morning globalarbtrader,

Yes, I agree with you. $50K is needed for 1 or 2 trading systems if running the future instruments.

How many systems are you running in your portfolio?

How do you know when a system not work anymore to make you money?

1) What is a system?
2) I don't know

Rob
 
1) What is a system?
2) I don't know

Rob
Hello globalarbtrader,

Those trading systems you have and have been talking about.

How many trading systems do you run together?

And do you wish you can just have 1 trading system?

Thank you,
 
Last edited:
hmm, interesting.. I reran my backtest, there was a small error, but the result didn't change much, still the number of trades and margin\notional usage gets ~35% higher, when starting from the rounded weights...
You're not seining an increase in the number of trades\capital usage?

I run this backtest with 37 instruments, 15-30y of data, at 300k capital. The DO tracking-error threshold below which I don't reoptimize comes out to 956.25$, which is 0.3% of the base capital., My actual tracking error hovers around 1.1k, or 0.35% of the base capital., although I do see a decrease in the average tracking error from 0.359 to 0.327 when using rounded weights as a start

tracking error from zero vs from rounded:
View attachment 337984

Btw, the way I calculate (gap)portfolio sigma (tracking error) is this:

var weightedStds = new List<double>(stdWeightInfo.Select(stw => stw.stDev * ( (Math.Abs(stw.unitPriceUSD) * stw.unitsBought) / totPortfPriceUSD ) ));

var varience = (weightedStds * correlationMatrix * weightedStds.Transpose())[0, 0];
var sigmaUsd = Math.Sqrt(varience) * totPortfPriceUSD;

so weightedStds is a vector of instruments' standard deviations multiplied by the proportion of that instrument(by notional) in the current portfolio..
Our tracking errors could be different because mine is "daily" and maybe yours is "annual", I feed daily standard deviations into the calculations, if I convert it to annual (0.359*16=5.7%) it becomes much closer to yours..

(also, compared to my regular target daily risk, which is 4687.5$, my tracking error of ~1.1k is actually not that small..)
 
Back
Top