Fully automated futures trading

Feels like it's time for a progress report, as it's my birthday and I'm feeling introspective.

Performance has been good; a quick check on the tape reveals my drawdown is down to less than 4% and I'm up more than 10% for the tax year (perhaps 8% for the calendar year because the first two months were down).

pysystemtrade is in a pretty stable condition, with both the production and sim code pretty decently refactored to the point where I'm confident I can keep it well maintained. Today I decided to release 'version 1.0'; about 5.5 years after it's first release - incredible how time flies!

Right now I'm working on adding lots of markets, as per the recent blog post. This is pretty tedious stuff which involves backfilling data from barchart, running a load of scripts, etc etc etc. I have another 75 (!) markets to do in the current batch (markets I can get data for, and which pass my trading filters). Then there another 100 or so markets for the next batch (markets I can get data for, but which don't currently pass my trading filters).

The main constraint is the 100 tickers a day I can download from barchart (eg two instruments with 12 years of quarterly rolls), and the fact I'd kill myself if I spent more than a couple of hours on this a day. I'm probably going to take at least 2 months to get through the curent batch, and another 3 months for the next batch (it could be quicker, as Barchart doesn't always have more than a few years of data, and it's possible there are markets that aren't on barchart at all). I could speed things up by looking at buying the data elsewhere, but the manual process means I actually check everything quite carefully.

The other thing I'm doing, also flagged up in the post, is to substitute several of my existing markets for the relevant micro or mini contract. This is slightly easier, but you just need to be a bit careful. First, I make sure I close my positions in the relevant contracts by setting my trade control to 'reduce only'. I now have to wait for all the positions to be closed. If it gets close to a roll, and they aren't closed, I'll have to close them manually.

Then once I have no active positions in the relevant instrument, I change the IB and instrument configuration so that it is using the new ticker and multiplier. I then get the prices to pull in manually and make sure there is no jump. This is also a good time to do a futures roll if one is due. Finally I turn off the 'reduce only' flag and check that the new positions are opened up okay. Obviously this means historic positions can't be compared, but that doesn't bother me.

Running alongside that I need to do some profiling and optimisation work (just got a copy of https://www.oreilly.com/library/view/high-performance-python/9781492055013/). With around 230 instruments pysystemtrade will be very slow indeed even on my 32GB/i7 trading servers, if it runs at all! Even so, I'd probably never run a fully blown backtest (up to 35 years of daily data plus 7 years of hourly data, 230 instruments, rolling optimisations...). Instead, I'll do things like run single instrument systems with one period optimisation to get the forecast weights and FDM; then with those fixed do a single period optimisation to get the instrument weights and IDM. In production I'll only pull in say the last two years of data for the nightly backtest.

Once I've sped things up a bit, but not neccessarily before I've finished eithier batch one or batch of adding new instruments, I'm going to look into my idea of modifying the system to make better use of limited capital. At the moment I have the very hacky solution I wrote about here. I probably get asked about this more than anything, and I'm as excited as anyone to see if my idea works, but the profiling has to come first!

Other projects to follow that are, in no particular order:

- I have a bunch of other changes and potential trading signals I want to look at putting into the core model. A lot of this is stuff I've blogged about over the last couple of years but not implemented.
- Some completely new systems: fast mean reversion, intermarket RV eg spreads, intramarket RV spreads (calendar spreads).
- The next book... :)

GAT
Happy birthday Rob, best wishes! :)

Yeah, adding new contracts is a lot of tedious work in my system too, probably no matter how you write that code, there's just a lot of things to do for each contract and then multiply it by 70+!

Btw, with the new 100 contracts of minimum average daily volume, looks like mini-Copper (QC) is out, in your table it has only 54 contracts ?
If I check CME, the most liquid expiration has between 100 and 400 daily volume, my system can probably hold up to 3 of these contracts (it most likely wouldn't buy all 3 on the same day but it might)., that means I'm risking to be up to 3% of daily trading volume.. Not sure how bad it is for such small orders, but I guess it's not good ?

upload_2021-5-11_13-4-39.png
 
Last edited:
Happy birthday Rob, best wishes! :)

Yeah, adding new contracts is a lot of tedious work in my system too, probably no matter how you write that code, there's just a lot of things to do for each contract and then multiply it by 70+!

Btw, with the new 100 contracts of minimum average daily volume, looks like mini-Copper (QC) is out, in your table it has only 54 contracts ?
If I check CME, the most liquid expiration has between 100 and 400 daily volume, my system can probably hold up to 3 of these contracts (it most likely wouldn't buy all 3 on the same day but it might)., that means I'm risking to be up to 3% of daily trading volume.. Not sure how bad it is for such small orders, but I guess it's not good ?

View attachment 258626

That's a good spot, thanks I'd missed that. Guess I'll be taking Copper out of the list of substitutes. For the record the others are:

NYMEX MINY Light Sweet Crude Oil
NYMEX MINY Natural Gas Index
E-Micro Gold
Mini KOSPI200 Index
Micro E-Mini Nasdaq-100 Index
Micro E-Mini S&P 500 Stock Price Index

... which I've doubled checked and all look fine.

(Was a mistake to say performance was good. Dropped over 2% yesterday!)

GAT
 
It will: on the days you roll over and have a maximum position size.
Don't forget Murphy's law: anything that can go wrong, will go wrong.
Agree. But even if I buy 3 contracts in something that has only 100 daily volume, why exactly is it bad., I guess because I'm risking to get a really bad execution?
I mean it's not the same problem as when a big institution is trading 3% out of 3 million contracts daily volume and therefore can move the whole world market in that commodity..
Probably the biggest worry in my case would be to get swindled by an HFT or another market maker because there's not enough competition in such a thin market and a single player can control the whole order-book...

Btw, yeah, today seems to be one of these crazy days, the futures system is loosing, S&P is down by a lot too.. Even Bitcoin and gold are down :)
 
Last edited:
Agree. But even if I buy 3 contracts in something that has only 100 daily volume, why exactly is it bad., I guess because I'm risking to get a really bad execution?
I mean it's not the same problem as when a big institution is trading 3% out of 3 million contracts daily volume and therefore can move the whole world market in that commodity..
Probably the biggest worry in my case would be to get swindled by an HFT or another market maker because there's not enough competition in such a thin market and a single player can control the whole order-book...

Btw, yeah, today seems to be one of these crazy days, the futures system is loosing, S&P is down by a lot too.. Even Bitcoin and gold are down :)
FWIW the reason I don't trade very low volume contracts despite my retail size is because I fear liquidity drying up completely when markets dislocate and everyone trying to rush for the same exit. Deep liquid markets also tend to dry up in such situations but they are more likely to have more diversification in terms of market views and trading goals so less likely to be all one way in times of crisis. I haven't scientifically tested this hypothesis but until I can firmly reject it I am not prepared to take the risk.
 
Hi all,

Incredible thread you have here! I have read most of it during the last days and it has been really helpful, thanks!
I'm a huge fan of Rob's work since I read Systematic Trading 3 years ago. I was head of a Quantitative Trading desk in the Proprietary Trading division of a bank back then and we redesigned all our strategies after I read Rob's book (increased diversification, avoid overfit, continuous signals...). We had trend following and carry rules, very similar to what Rob posted in the blog, but also we changed other type of strategies to fit into the framework.
We had different types of cointegration strategies (intermarket and calendar spreads and triplets) and what we called "value" strategies (forecasts based in macro/econometric models). Also, we used a modified version of HRP to compute portfolio weights.

I changed jobs a while back and in december I started to develop a similar system for trading my own money. Most of my problems have been related to get market data at a reasonable price. As I still work in a bank (but not directly in the trading desk), I have been categorized as professional investor and market data is ten times more expensive than what it costs to individual accounts.

I hope I will be able to share some research once I have my system in a good status!

Thanks,
Cholo
 
@globalarbtrader I have one question on targeting risk. You said your risk target (volatility normalization) is 25% per instrument and your system checks positions every hour. Do you have a buffer of X% when you change position size of an instrument? Let's say:
if (instrument_risk_target >=30 OR instrument_risk_target<=20) {
change position size to target risk of 25%
}

This can be quite difficult with futures as they have high notional value, one solution is using micro futures. Costs can also be high if you often do this with many instruments...
 
Last edited:
@globalarbtrader I have one question on targeting risk. You said your risk target (volatility normalization) is 25% per instrument and your system checks positions every hour. Do you have a buffer of X% when you change position size of an instrument? Let's say:
if (instrument_risk_target >=30 OR instrument_risk_target<=20) {
change position size to target risk of 25%
}

This can be quite difficult with futures as they have high notional value, one solution is using micro futures. Costs can also be high if you often do this with many instruments...

I have a buffer, discussed already, but it doesn't work exactly like that (I assume what you mean, which you haven't written, as that I back out the expected risk for a given position and then work out if that is different from the target risk). For starters, the target risk will vary depending on the forecast, and won't be exactly 25% because of the diversification multiplier.

What I actually do is compute a target position to achieve the required risk given forecasts, and then buffer around that position in position units; but the buffer is 10% of the position I'd have with an average forecast so it's effectively a buffer that's a fixed amount of risk: eg with 25% risk it would be effectively 22.5 - 27.5%. Buffers are calculated with decimal places and then rounded to nearest whole contract. For example:

Code:
Optimal vs actual
                                    current        optimal  breaks
medium_speed_TF_carry SMI               2.0    1.614/1.725   False
medium_speed_TF_carry SOYBEAN           2.0    2.032/2.335   False
medium_speed_TF_carry V2X              -4.0  -4.118/-3.217   False
medium_speed_TF_carry VIX              -1.0  -0.627/-0.538   False
medium_speed_TF_carry WHEAT             1.0    0.931/1.117   False
medium_speed_TF_carry BITCOIN           1.0    0.157/0.783   False

I'm well aware of the issues with notional size and costs I've written several blog posts and book chapters on the subject...

My portfolio is reasonably sized but actually I just introduced micro futures to get more granularity anyway (before when I had looked at them, the liquidity wasn't sufficient).

GAT
 
Back
Top