Fully automated futures trading

Discussion in 'Journals' started by globalarbtrader, Feb 11, 2015.

  1. I do exactly that, and in fact by a weird coincidence I was refactoring the exact bit of code that does this calculation yesterday! However there are other ways of doing this, and there's a long discussion here.

    GAT
     
    #2391     Nov 27, 2020
  2. That's a double coincidence that you just gave me the link to the article that I was looking at today, because I remember reading it in the past and there were some hints:

    My favourite setup

    forecast_cost_estimates:

    use_pooled_costs: False
    use_pooled_turnover: True ## even when pooling I recommend doing this

    forecast_weight_estimate:
    apply_cost_weight: True
    ceiling_cost_SR: 0.13
    cost_multiplier: 0.0
    pool_gross_returns: True
    equalise_gross: False



    As you'll know from reading my book I like the idea of culling expensive trading rules. This leaves the optimiser with less to do. I really like the idea of applying cost weighting (versus say multiplying costs my some arbitrary figure); which means optimising on gross returns. Equalising the returns before costs seems a bit extreme to me; I'd still like the idea of really poor trading rules being downweighted, even if they are the cheap ones. Pooling gross returns but using instrument specific costs strikes me as the most logical route to take.

    I was actually thinking of the same approach:
    Pool rule returns from all instruments and run the rule weighting process for each instrument separately (but using the pooled data).
    For each instrument there would be different costs, so certain rules would be excluded (due to cost ceiling) and the rest - cost adjusted for the specific instrument. I would end up with distinct rule/variation weightings for each instrument.
    Then I would run the instrument weighting process using just the correlations (of what you refer to as "subsystems").

    I find this approach the most sensible. I believe this is exactly what you had in mind as well.
     
    #2392     Nov 27, 2020
  3. Well it's been a while since I've given you an update on what I'm up to.

    I won't discuss performance in too much detail, as I'll probably try and give you a few figures at the end of the year (plus my normal massive blogpost for the UK tax year ending in April). Fundseeder, which wasn't working for a while but is now, says I'm up 5.2% for the year. For the last couple of months I'm down slightly, and my drawdown remains at ~15%. For the UK tax year I reckon I'm at about -5%.

    And yes I did lose a bit in November when the good news came out, but against that my long only portfolio went absolutely gangbusters.

    That's because I've gradually been rerisking it back into equities since mid March (I'm down to 10% risk allocation in bonds from a high of 54% on the 20th March, and I've reduced my cash to a minimum), buying cheap UK equities, and higher yielding ETFs, plus it's always had a bit of a value tilt (you can get the current target risk allocations here).

    So not a huge surprise that my long only stuff did well last month. Since the start of the tax year I probably made something like 20% on my long only stuff even after , and the futures trading knocked about 1% off that. Net-net, that's pretty good. Compare and contrast to 2019-20 where long only was down 15% and futures trading improved it to -6.6%.

    Risk is pretty low, hovering between 9% and 12% annualised. So there's no strong conviction for my positions.

    Code:
    ********************************************************************************
                   Risk report produced on 2020-12-03 23:36:29.996169               
    ********************************************************************************
    
    
    Total risk across all strategies, annualised percentage 11.8
    
    ========================================
    Risk per strategy, annualised percentage
    ========================================
    
                                   risk
    _ROLL_PSEUDO_STRATEGY  0.000000e+00
    medium_speed_TF_carry  1.200000e+01
    ETFHedge               1.555608e+11
    
    
    ============================================================================================================================================================================================================================================================
                                                                                                                          Instrument risk                                                                                                                       
    ============================================================================================================================================================================================================================================================
    
             daily_price_stdev  annual_price_stdev   price  daily_perc_stdev  annual_perc_stdev  point_size_base  contract_exposure  daily_risk_per_contract  annual_risk_per_contract  position   capital  exposure_held_perc_capital  annual_risk_perc_capital
    EUROSTX               53.8               861.4  3486.0               1.5               24.7              9.0            31476.0                    486.1                    7778.0      -2.0  345002.7                       -18.2                      -4.5
    GAS_US                 0.1                 1.6     2.5               4.0               64.3           7436.4            18695.0                    751.5                   12024.0      -1.0  345002.7                        -5.4                      -3.5
    V2X                    0.8                12.3    21.6               3.5               56.8             90.3             1954.8                     69.4                    1110.3      -5.0  345002.7                        -2.8                      -1.6
    BOBL                   0.1                 2.2   135.3               0.1                1.6            902.9           122129.7                    122.4                    1958.1       1.0  345002.7                        35.4                       0.6
    WHEAT                  6.7               107.0   599.2               1.1               17.9             37.2            22281.2                    248.6                    3977.7       1.0  345002.7                         6.5                       1.2
    US10                   0.3                 5.4   137.7               0.2                3.9            743.6           102424.2                    249.4                    3989.8       1.0  345002.7                        29.7                       1.2
    AUD                    0.0                 0.1     0.7               0.6                9.3          74363.5            54657.2                    319.0                    5103.7       1.0  345002.7                        15.8                       1.5
    KR3                    0.1                 0.9   111.6               0.1                0.8            680.8            75956.7                     39.3                     628.2       9.0  345002.7                       198.1                       1.6
    EDOLLAR                0.0                 0.4    99.5               0.0                0.4           1859.1           185016.5                     46.2                     739.8       8.0  345002.7                       429.0                       1.7
    MXP                    0.0                 0.0     0.0               0.7               11.2         371817.7            18386.4                    128.3                    2053.3       3.0  345002.7                        16.0                       1.8
    JPY                    0.0                 0.0     0.0               0.5                8.2        9295442.6            89087.5                    457.4                    7319.2       1.0  345002.7                        25.8                       2.1
    OAT                    0.4                 6.0   167.4               0.2                3.6            902.9           151194.9                    339.1                    5425.2       2.0  345002.7                        87.6                       3.1
    PLAT                  18.7               299.9  1039.1               1.8               28.9             37.2            38635.6                    696.8                   11149.2       1.0  345002.7                        11.2                       3.2
    SOYBEAN                7.0               112.1  1039.2               0.7               10.8             37.2            38641.2                    260.4                    4166.6       4.0  345002.7                        44.8                       4.8
    
    
    =======================================================================================================
                                                 Correlations                                             
    =======================================================================================================
    
              KR3  US10   JPY  SOYBEAN   AUD  PLAT  EUROSTX   OAT  GAS_US  BOBL  WHEAT   MXP  EDOLLAR   V2X
    KR3      1.00  0.10  0.03    -0.05 -0.20 -0.05    -0.07  0.15   -0.01  0.08  -0.17 -0.17     0.07  0.10
    US10     0.10  1.00  0.33    -0.12 -0.18 -0.13    -0.44  0.50   -0.11  0.57  -0.20 -0.35     0.92  0.31
    JPY      0.03  0.33  1.00     0.13  0.31  0.27    -0.21  0.24   -0.07  0.22   0.04  0.14     0.29  0.05
    SOYBEAN -0.05 -0.12  0.13     1.00  0.35  0.20     0.23 -0.07   -0.06 -0.17   0.35  0.31    -0.10 -0.22
    AUD     -0.20 -0.18  0.31     0.35  1.00  0.53     0.49 -0.14   -0.19 -0.19   0.24  0.63    -0.18 -0.58
    PLAT    -0.05 -0.13  0.27     0.20  0.53  1.00     0.23 -0.11   -0.11 -0.17   0.15  0.28    -0.10 -0.32
    EUROSTX -0.07 -0.44 -0.21     0.23  0.49  0.23     1.00 -0.16   -0.11 -0.33   0.15  0.51    -0.44 -0.71
    OAT      0.15  0.50  0.24    -0.07 -0.14 -0.11    -0.16  1.00   -0.11  0.90  -0.27 -0.16     0.45  0.12
    GAS_US  -0.01 -0.11 -0.07    -0.06 -0.19 -0.11    -0.11 -0.11    1.00 -0.11  -0.03 -0.17    -0.03  0.07
    BOBL     0.08  0.57  0.22    -0.17 -0.19 -0.17    -0.33  0.90   -0.11  1.00  -0.23 -0.22     0.52  0.23
    WHEAT   -0.17 -0.20  0.04     0.35  0.24  0.15     0.15 -0.27   -0.03 -0.23   1.00  0.26    -0.21 -0.15
    MXP     -0.17 -0.35  0.14     0.31  0.63  0.28     0.51 -0.16   -0.17 -0.22   0.26  1.00    -0.38 -0.54
    EDOLLAR  0.07  0.92  0.29    -0.10 -0.18 -0.10    -0.44  0.45   -0.03  0.52  -0.21 -0.38     1.00  0.32
    V2X      0.10  0.31  0.05    -0.22 -0.58 -0.32    -0.71  0.12    0.07  0.23  -0.15 -0.54     0.32  1.00
    
    
    ********************************************************************************
                                   END OF RISK REPORT                               
    ********************************************************************************
    In terms of what I'm actually doing with my life, I've had quite a few webcasts (which mostly replaced planned physical conferences). One of these was interesting, as I had to create my system in a weird GUI environment which then got parsed into MT4. So if you're wondering if it's possible to run a continous futures trading system in MT4, it is.

    Much to my surprise (as university funding isn't in great shape), I've been asked to teach again next year, so there is some prep to do. There will be a lot of remote students so I have to try and make things a bit more interesting. Perhaps a live video of me backtesting a trading strategy? Or should I go down the youtube guru trader route and post videos of me driving my car:

    https://vcarsdna.com/images/vehicles/76/large/85c897154bfad55ab6ca78a3b5dc212d.jpg
    [​IMG]

    (This isn't my car, but it's the same age, model and colour. Actually, it's in better condition than my car and definitely cleaner. My wife has a nicer car. But it's not that nice).

    Mostly though I've been writing code. I basically finished 'stage 4' of working on psystemtrade. Now I'm doing quite a lot of refactoring, and documentation writing

    (Don't worry, I'm not turning into a proper programmer. I still have no tests)

    I also have a list of relatively small bits of functionality I want to add. After that, and hopefully not too far into next year I will start some very serious pieces of research into new trading systems. I'm limiting myself to futures, but there is still quite a lot of space I can fill with just futures ideas. I've talked a bit about them before but here's a list of the main ones:

    • Optimise positions for limited capital
    • Short term mean reversion strategy, possible with a daily trend following overlay
    • Intramarket spreads: probably on VIX or V2X, Eurodollar, Crude, maybe some Ags
    • Intermarket spreads: eg across 10 year bond futures, V2X vs VIX
    • Cross sectional momentum
    A challenge I'm still working on is how to trade a particular instrument as both an intramarket spread and an outright position (which will also cover intermarket spreads). The issue is my roll logic, and there are no easy solutions. I think the simplest is to partition the curve and say that these contracts are for spreads, whilst these are for outrights.

    Refactoring in itself doesn't make money (as any CTO will tell you), but will create a system that is flexible enough to trade all of these ideas. My hope is that these newer systems will improve the consistency of my trading profits a little, and make more efficient use of the cash in my trading account.

    Those improved profits will be nice, because the global cut in dividends has obviously hurt my cash (rather than mark to market) income, and it may take a few years to rebound.

    For this year at least I did have a large cash pile from futures trading profits last year which I knew I would probably need as a buffer to avoid having to sell equities at depressed prices. I've also made more money from other stuff and book royalties than in previous years. In fact in 2020 for the first time I have made enough money in royalties that it qualifies as a proper job, albeit not a super high paid one. But given I haven't written any books this year, my hourly rate is effectively infinity. So that's pretty good.

    I also plan next year to start thinking about my next book. I have a random list of ideas, which change in order of preference and content over time. I'd be curious to know which of these you guys think will sell a million copies and make me enough money to buy a youtube guru style car. Failing that, which you would like to read yourself:

    - a sort of Talebian style treatsie on uncertainty in financial markets, but with more formulas and practical advice
    - a book on ETF investing, factor investing for dummies. You know how my 3rd book is a simpler version of my 1st book? This would be a simpler version of my 2nd book, 'Smart Portfolios'. Love the symettery.
    - a book on quantitative futures trading. Think Schwager with more equations, and a bit of 'the global futures almanac' thrown in.
    - a book on writing and backtesting trading strategies in python. The differentation here is it won't use a predefined package, like Andreas' book uses zipline. Just pandas and the normal numpy/scipy stack. With a heavy focus on uncertainty and doing things properly.
    - a textbook for my university course
    - a sort of popular book on human and computer trading, and doing both

    Hope the rest of the year goes okay. All other things considered, 2020 is starting to improve I feel.

    GAT
     
    #2393     Dec 4, 2020
    wopr, .sigma, jtrader33 and 1 other person like this.
  4. sef88

    sef88

    @globalarbtrader

    Thanks for the update. I'm 'greedy' - would love to see 3rd, 4th, 5th and 1st book in that order of preference

    Personally, I'm not a fan of quantopian and quantconnect type of platforms (& zipline package). Perhaps I'm not skilled enough but I find it really hard to customize certain behaviours within the framework. And it's really hard to visualize the data structures and output of the functions within the platforms.

    Wanted to check in an institutional setting based on your experience, do people primarily use zipline framework for strategy development?

    JR
     
    #2394     Dec 4, 2020
    globalarbtrader likes this.
  5. People don't generally use off the shelf stuff at all, as I wrote about here.

    GAT
     
    #2395     Dec 4, 2020
    sef88 likes this.
  6. I almost forgot, I've been rationalising my computer setup and this is very exciting. As you may know I have a bit of a computer buying habit, so as well as one laptop per person, and a desktop, there are another four machines that sit in my homemade trading rack although only one of them is actually doing any trading.

    Anyway, I've recycled a few machines (one is too low power and I was planning to keep it for a hobby project that never materialised, another won't boot up beyond the BIOS banner, oh and I found a random dead laptop that also hit the scrapheap), and there is another machine that works find but has some weird firmware issue that means it boots to a grub menu; a bit of a pain for a headless trading server.

    So I now only have one active trading server, a 4gb mintbox celeron 1.4gz with a weedy 2mb cache. That runs the current system fine, but takes a while to do things like generate the overnight backtest.

    Still, worst case scenario if that fails in the next few weeks I can run my system daily off my laptop.

    So the big news is; after 7 years of trading with mostly low powered second hand machines I've decided to treat myself, and I've ordered a new PC with this spec: i7-9700 (3.0GHz) with 12mb cache, 32GB, 1TB SSD. It comes in this case... (ex the stupid stand)
    https://static.mini-itx.com/store/images/5404-MTX7-01XL.jpg

    [​IMG]
    .... which is a bit larger than my previous mint box or NUC sized jobs.

    I did consider RAIDing 2 disks, but I'd need a third to boot off and the PC builder only offers two; not sure if that's a motherboard limitation (I'm not an expert, or I'd build it myself).

    That should run the system even faster than my laptop (16gb i7-8550 8mb cache) and be up to the job of running a few more trading systems.

    Assuming no problems I plan to order another identical machine. I think they will look darn sexy racked on top of each other. Then I can have a machine that is powerful enough to do backtesting on (I normally do everything on my laptop) whilst also being an identical backup machine. Total cost will be about $1600 for both. I know it would probably be cheaper to run in the cloud, but I clearly have some weird fetish for physical hardward.

    After that I'll still have two spare mint boxes (current trading machine and weird grub booter). Suggestions for those are welcome...

    GAT
     
    #2396     Dec 4, 2020
    sef88 likes this.
  7. Elder

    Elder

    A book on ETF/Factor investing for dummies will probably sell the most I think. I wouldn't read it myself, as you set a high bar with your first book (would definitely read the Talebian style treatise on uncertainty - but that was of course not your question :)). I would probably buy it to help you on your way to reach those lofty sales goals.
     
    #2397     Dec 4, 2020
    globalarbtrader likes this.
  8. cafeole

    cafeole

    Being a programmer, this is the one I would covet. I tried Andreas' book and couldn't get zipline to work. I prefer using the existing stable libs in python.
     
    #2398     Dec 4, 2020
  9. Kernfusion

    Kernfusion

    Hi Rob,
    great stuff, very excited about the new strategies
    For the books, "quantitative futures trading" sounds pretty-cool for my taste :)

    Regarding the new computers - 1600 for 2 PCs with no extra effort of assembling them is I guess a good deal, but I'd still advocate for buying used server-grade hardware from a previous generation (from Aliexpress or ebay) and assembling it manually. Things like case, HDD\SSD, power-supply-unit and motherboard are better to buy locally from a reputable store, but Xeox CPU and RAM (at least the CPU!) is I think totally OK to buy used. I mean look at these:

    https://www.aliexpress.com/item/328...earchweb0_0,searchweb201602_,searchweb201603_

    https://www.aliexpress.com/item/329...earchweb0_0,searchweb201602_,searchweb201603_

    These are 14-core (28 threads) Xeon processors for 250$, which used to cost 4,000$+ !!! (you can put 2 of them in the same machine if you have a dual-socket motherboard). And a used CPU is not like a used car, there's no moving parts, so the thing will probably be working for another 20 years just fine (of course there's still a risk, like with any used thing, but for that price I think it's justified, I personally bought E5-1650V3 CPU on ebay for next to nothing years ago and still using it).
    Fun fact: I think George Hotz is training all his self-driving models on used hardware that they bought, and he is saying it's way cheaper than doing it in the cloud and you get a lot more bang for your buck..
    I appreciate that you're not a hardware guy, but you did build a garden house :), and assembling a computer is by far simpler than that :). I mean it's literally just connecting standardized parts together, almost impossible to do it incorrectly. Just need to make sure before buying that the motherboard has the same socket as the CPU(or simply supports that exact CPU), and supports the type of ram that you want (DDR4 is I think current standard), Xeons have a couple of additional things to check like V2 vs V3 (again motherboard should support and I'd go with V3) and only 2xxx models work in dual-socket configuration, basically that's it.
    But again, to save time, 1600$ for 2 PCs worry-free is probably ok too..
    Oh yes, and this monitor is really good: "43UN700-B" 43” 4K IPS - good size and resolution, good colours, matte screen and relatively inexpensive..
     
    Last edited: Dec 4, 2020
    #2399     Dec 4, 2020
  10. Regarding the computers: just like you I also prefer to have my own hardware instead of using the cloud. However, different from you I prefer to use a NUC style computer as the automated trading rig because of its low power requirements. I have my NUC powered via a UPS so that in case of a power outage my computer does not crash immediately. With the UPS I have the NUC can stay alive for another couple of hours. A desktop would consume much more power and the UPS would run out in minutes rather than hours.
    I don't run a backtest every night, but wouldn't mind having the NUC spend a lot of time on it: it was made to compute, not to sit idle.
     
    #2400     Dec 4, 2020