Fully automated futures trading

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

  1. OK

    [​IMG]

    I got 0.89 for the correlation which is higher than I expected (though perhaps not as high as you got). I used equal weights for the optimisation for speed, but I wouldn't expect much difference with more complex techniques.

    Partly this might be because using the classic set of 5 instruments, for most of the time there aren't many instruments with data except for US10, CORN and EUROSTX, and these instruments happen to have more correlation between the breakout and ewmac rules. Anyway I'm running with all 37 instruments to see what that looks like.

    Here's the code I ran (using the very latest version)

    Code:
    from syscore.accounting import account_test
    
    from syscore.pdutils import turnover
    from sysdata.configdata import Config
    
    from systems.provided.futures_chapter15.estimatedsystem import futures_system
    from systems.provided.moretradingrules.morerules import breakout
    
    import pandas as pd
    import numpy as np
    from matplotlib.pyplot import show, legend, matshow
    
    bvariations=["breakout"+str(ws) for ws in [10, 20, 40, 80, 160, 320]]
    evariations=["ewmac%d_%d" % (fast, fast*4) for fast in [2,4,8,16,32, 64]]
    
    
    my_config = Config("examples.breakout.breakoutfuturesestimateconfig.yaml")
    
    ## old system has ewmac only
    my_config.rule_variations=evariations
    my_config.forecast_weight_estimate["method"]="equal_weights"
    system_old = futures_system(config=my_config, log_level="on")
    
    ## new system has breakouts
    new_config = Config("examples.breakout.breakoutfuturesestimateconfig.yaml")
    new_config.rule_variations=bvariations
    new_config.forecast_weight_estimate["method"]="equal_weights"
    
    system_new = futures_system(config=new_config, log_level="on")
    
    curve1=system_old.accounts.portfolio()
    curve2=system_new.accounts.portfolio()
    
    print(curve1.stats())
    print(curve2.stats())
    
    print(account_test(curve2, curve1))
    
    
    curves_to_plot=pd.concat([curve1.as_df(), curve2.as_df()], axis=1)
    curves_to_plot.columns=["ewmac", "breakout"]
    
    print(curves_to_plot.corr())
    curves_to_plot.cumsum().plot()
    show()
    
    
    GAT
     
    #391     May 24, 2016
    isotope1 and AvantGarde like this.
  2. isotope1

    isotope1

    I'm just working backwards to try and simulate rolling the contracts over on historical data, looking at corn one year out and rolling 12 months forwards, using spread trades. It seems the 'prudent' way to do this would be an 'open interest crossover', passively before the crossover and forced afterwards. For corn, it looks like you have a window of a few months to make the roll.

    According to your blog post, you mention price action as being a factor in choosing when to roll. As best as I can tell, this is a random process, so catching a favourable spread is akin to 'getting lucky'. Doesn't it make sense here to use optimal stopping theory to decide the roll date, rather than guessing? (explained in a fun way here: http://www.npr.org/sections/krulwic...-marry-the-right-girl-a-mathematical-solution)

    Also:
    If you had to measure the quality of a discretionary roll, what statistic would you use?

    Lastly, in the managed futures world, is rolling fully automated or is there still a discretionary element?

    Sorry for all the questions, just trying to make sure I understand every bit! Thank you!
     
    #392     May 24, 2016
  3. I don't use "price action" myself, I just mentioned it in passing and said I don't believe that the price action of different contracts is meaningfully different.

    By the way when I talked about "price action" I wasn't talking about trying to roll at a time when the spread was favourable (this is seperate from being in the contract with the best carry which I do look at). And I don't look at this eithier.

    I suppose one could model the spread - you wouldn't need such a fancy model to do this as you mention it, it would be just like predicting any other price. The spread tends to trend in the short term and mean revert in the long term. It's also often driven by the overall direction of spot.

    I'm happy to answer your questions, but this isn't a subject I personally pay a lot of attention to. I view the spread I get on the roll as pure luck.

    I can only speak of one fund, and the situation a couple of years ago, but rolling is still a very discretionary call.


    GAT
     
    #393     May 25, 2016
  4. isotope1

    isotope1

    So, for someone rolling a contract for the first time, the key things to look at are:
    • Liquidity of contracts
    • Carry between them
    ?
     
    #394     May 25, 2016
  5. Yes, mostly. The blog article is pretty detailed, there's nothing I can add to it here that will be of any further help.

    GAT
     
    #395     May 25, 2016
  6. BobbieJ

    BobbieJ

    Hi GAT, i was looking at one of the earlier posts on this thread and it looks like you allocate more to the breakout system than the traditional momentum if you were to consider the ewmac as that. How come? Is this driven by the optimizer or is it driven by you/your gut? :)

    Great thread by the way.
     
    #396     May 25, 2016
  7. More by the optimiser. I run some other trading rules in my system that are more similar to ewmac, whereas breakout is a bit different.

    GAT
     
    #397     May 26, 2016
  8. BobbieJ

    BobbieJ

    Thanks for the prompt reply. I think I get what you mean. Choosing which trading rules to include is your decision, optimizer decides the proportions.

    Do you intend to discuss what those other trading rules are at some point, or is that the "secret sauce"? I am curious as to what made you decide to include rules that are similar to each other.
     
    #398     May 26, 2016

  9. Here it is with 37 instruments

    [​IMG]
    Correlation is 0.91 actually slightly higher than with 5 instruments. Again using equal weights after screening for things that have costs which are too high.

    It looks like your correlation is closer to 1.0, which suggests something very strange is going on.... Although my correlation is higher later in the period.

    Code:
    from syscore.accounting import account_test
    
    from syscore.pdutils import turnover
    from sysdata.configdata import Config
    
    from systems.provided.futures_chapter15.estimatedsystem import futures_system
    from systems.provided.moretradingrules.morerules import breakout
    
    import pandas as pd
    import numpy as np
    from matplotlib.pyplot import show, legend, matshow
    
    bvariations=["breakout"+str(ws) for ws in [10, 20, 40, 80, 160, 320]]
    evariations=[
                "ewmac%d_%d" % (fast, fast*4) for fast in [2,4,8,16,32, 64]]
    
    
    
    my_config = Config("examples.breakout.breakoutfuturesestimateconfig.yaml")
    ## will do all instruments we have data for
    del(my_config.instruments)
    
    ## temporarily remove breakout rules
    my_config.rule_variations=evariations
    my_config.forecast_weight_estimate["method"]="equal_weights"
    system_old = futures_system(config=my_config, log_level="on")
    
    ## new system has all trading rules
    new_config = Config("examples.breakout.breakoutfuturesestimateconfig.yaml")
    new_config.rule_variations=bvariations
    new_config.forecast_weight_estimate["method"]="equal_weights"
    del(new_config.instruments)
    
    system_new = futures_system(config=new_config, log_level="on")
    
    curve1=system_old.accounts.portfolio()
    curve2=system_new.accounts.portfolio()
    
    print(curve1.stats())
    print(curve2.stats())
    
    print(account_test(curve2, curve1))
    
    
    curves_to_plot=pd.concat([curve1.as_df(), curve2.as_df()], axis=1)
    curves_to_plot.columns=["ewmac", "breakout"]
    
    print(curves_to_plot.corr())
    curves_to_plot.cumsum().plot()
    show()
    
    GAT
     
    #399     May 26, 2016
  10. I'll discuss most of them at some point. One or two are copies of stuff I developed whilst at my former employer. If I put those in the public domain I'll get sued.

    I'm happy to include things that are around 90% correlated or less. There is almost no penalty in having additional rules as a fully automated trader.

    GAT
     
    #400     May 26, 2016