Adventures in Algorithms

Discussion in 'Journals' started by Raphael, Sep 23, 2015.

  1. Thanks!
     
    #11     Sep 26, 2015
  2. Raphael

    Raphael

    Its been almost a month since my last post. How time flies.

    In the mean time I've been busy coding up a systematic trading environment in Python with futures stitching, backtesting at the portfolio level and bootstrapping to measure statistical significance. I've been reading through Systematic Trading by @globalarbtrader which is a fantastic book and gives a really good framework for risk management and diversification of both instruments and trading rules.

    Speaking of books Algorithmic Trading by Ernest Chan has some interesting ideas. However there are a few big liberties taken, for example the performance of mean reversion pairs trading is done on the same data set that was used to compute the hedge ratios that formed the stationary portfolio. This is major overfitting / curve fitting. In general the book gives specific examples where the techniques presented worked, which may or may not be cherry picked, but it would have been nice to see more extensive backtesting. I'm also a little concerned about the negative skew of mean reversion which is the basis for most of the trading strategies in the book.

    So back to the plan. I'm going to be focusing on futures to start, since they're a relatively affordable way to trade in terms of spread, leverage and tax treatment. Quandl has turned out to be a great source of free historical data for futures.

    I'll be using interactive brokers, executing trades manually initially based on the algorithm output. I'm trading on quite slow time frames so the latency isn't really an issue here. Once things are up and running I might consider automating the execution.

    I'm starting out with a small account of around $20k to exercise the system. Most contracts are pretty large so are out of the question given my target volatility of around 25%. Now I need to decide whether to trade a single future like Hang Seng index minis. This would be simple, although given the large contract size I'd really only be trading 1 or 2 contracts which will make things pretty lumpy.

    Alternatively I could use a portfolio of futures with smaller contract sizes for better diversification. Some promising options are e-micro currencies, mini-corn, Globex euro-dollars, 2 year T-notes and Nikkei minis and volatility. Because these are much smaller I could trade several contracts of each future as part of a portfolio and have similar volatility as with a single Hang Seng index mini.

    There's still a bit of work to be done to come up with some reasonable portfolio weights and backtest to see if the added diversification of the second route will lead to a higher Sharpe ratio. With an account of this size I'd be happy to achieve a post-cost Sharpe of 0.5. Getting 0.6 would be fantastic.

    Anyway, that's it for now. My funds will clear at Interactive Brokers next week so I have a fair bit of work to do between now and then to fully backtest.
     
    Last edited: Oct 22, 2015
    #12     Oct 22, 2015
  3. Raphael

    Raphael

    So I've setup my portfolio which is weighted as follows:
    Code:
    AUD      2015-12   33%
    EDOLLAR  2017-12   17%
    TU       2015-12   17%
    NK225M   2015-12   33%
    

    I'm limited here to the smaller contracts because I'm trading a small account initially and have a low target volatility.

    Today's trades are:

    Code:
    Account balance:   $20,000.00
    Target volatility: $5,000.00
    
    Trades
    -1 AUD      0.72386
    +1 EDOLLAR  Pending
    +1 TU       109.555
     0 NK225M
    
    Positions
    -1 AUD
    +1 EDOLLAR
    +1 TU
     0 NK225M
    
     
    Last edited: Oct 26, 2015
    #13     Oct 26, 2015
  4. Raphael

    Raphael

    A quick update:

    Code:
    Account balance:      $20,000.00
    Target volatility:    $5,000.00
    Expected volatility:  $5,062.88
    
    Trades
    -1 AUD      0.72386
    +1 EDOLLAR  98.590
    +1 TU       109.555
     0 NK225M
    
    Positions
    -1 AUD
    +1 EDOLLAR
    +1 TU
     0 NK225M
    
     
    Last edited: Oct 26, 2015
    #14     Oct 26, 2015
  5. Raphael

    Raphael

    No trades today.
    Code:
    2015-10-26
    account value: 20117.00
    
    GE (ED)
      contract:             EDZ2017
      settle:                $98.59
      volatility:           $126.20
      target volatility:     $53.44
      previous position:          1
      new position:               1
    
    action: none
    
    N225M (NK)
      contract:             NKZ2015
      settle:             $19035.00
      volatility:           $242.59
      target volatility:    $103.73
      previous position:          0
      new position:               0
    
    action: none
    
    ZT (TU)
      contract:             TUZ2015
      settle:               $109.55
      volatility:           $133.01
      target volatility:     $53.44
      previous position:          1
      new position:               1
    
    action: none
    
    M6A (AD)
      contract:             ADZ2015
      settle:                 $0.72
      volatility:            $45.77
      target volatility:    $103.73
      previous position:         -1
      new position:              -1
    
    action: none
    
     
    Last edited: Oct 26, 2015
    #15     Oct 26, 2015
  6. gkishot

    gkishot

    What rate of return are you expecting to achieve?
     
    #16     Oct 27, 2015
  7. Raphael

    Raphael

    This is a small account so I don't have a significant amount of diversification. For this reason I don't think I'll get a post-cost Sharpe ratio much higher than 0.5. With a target volatility of 25% that will give a return of 12.5%.

    If this works well I'll scale the account up and trade a more diverse set of contracts. That might get me up to a Sharpe of 0.7 which would be a return of 17.5%.
     
    #17     Oct 27, 2015
  8. promagma

    promagma

    The market doesn't lend itself to such a neat analysis, you should say I'd be happy to achieve a positive Sharpe and getting 1.0 would be fantastic. You didn't mention how you decided on your first trades, have you found some algorithms with your backtesting?
     
    #18     Oct 27, 2015
    gkishot likes this.
  9. Raphael

    Raphael

    No. As I said I'd be happy to achieve a post-cost Sharpe of 0.5 and getting 0.6 would be fantastic. You're probably confusing the Sharpe ratio with the information ratio.

    Yes.
     
    #19     Oct 27, 2015
  10. Raphael

    Raphael

    No trades today.

    Code:
    2015-10-27
    account value: 20275.00
    
    GE (ED)
      contract:               EDZ2017
      settle:                $98.6350
      volatility:             $124.42
      target volatility:       $53.86
      previous position:            1
      new position:                 1
    
    action: none
    
    ZT (TU)
      contract:               TUZ2015
      settle:               $109.6016
      volatility:             $131.17
      target volatility:       $53.86
      previous position:            1
      new position:                 1
    
    action: none
    
    M6A (AD)
      contract:               ADZ2015
      settle:                 $0.7175
      volatility:              $48.05
      target volatility:      $104.54
      previous position:           -1
      new position:                -1
    
    action: none
    
    NK225M (NK225M)
      contract:           NK225MZ2015
      settle:             $18840.0000
      volatility:             $234.87
      target volatility:      $104.54
      previous position:            0
      new position:                 0
    
    action: none
    
     
    #20     Oct 27, 2015