Fully automated futures trading

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

  1. Trades

    Code:
            code contractid     filled_datetime  filledtrade  filledprice
    2884      AEX     201503 2015-03-06 08:02:31           -1    488.15000
    2878      ASX     201503 2015-03-06 01:00:49           -2   5870.00000
    2881    AUS10     201503 2015-03-06 01:14:04           -1     97.40500
    2880     AUS3     201503 2015-03-06 01:15:24           -1     98.08000
    2879  AUSSTIR     201606 2015-03-06 02:12:19            3     97.90000
    2882  AUSSTIR     201606 2015-03-06 02:23:32           -3     97.89000
    2883     BUND     201506 2015-03-06 07:36:48            1    156.99000
    2887     BUND     201506 2015-03-06 14:46:53           -1    156.57000
    2886     CORN     201512 2015-03-06 14:30:00           -1    410.75000
    2885   NASDAQ     201503 2015-03-06 14:05:22           -1   4447.00000
    2888     US10     201506 2015-03-06 15:16:13           -1    126.03125
    
    Slippage in GBP, for entire trade
    
             code  gbpt_slippage_process  gbpt_slippage_bidask  gbpt_slippage_execution  gbpt_slippage_all_trading  gbpt_slippage_total
    2879  AUSSTIR                 -37.06                 37.06                   -74.12                     -37.06               -74.12
    2887     BUND                 -21.91                  3.65                    -7.30                      -3.65               -25.56
    2883     BUND                   7.30                  3.65                    -7.30                      -3.65                 3.65
    2886     CORN                  -4.09                 -0.00                     8.18                       8.18                 4.09
    2880     AUS3                  -7.70                  7.70                    15.41                      23.11                15.41
    2888     US10                  30.69                  5.11                    10.23                      15.34                46.03
    2881    AUS10                  34.78                 11.59                    23.19                      34.78                69.56
    2882  AUSSTIR                  37.06                 37.06                    -0.00                      37.06                74.12
    2884      AEX                  94.93                  7.30                    -0.00                       7.30               102.23
    2885   NASDAQ                  83.47                  1.64                    36.00                      37.64               121.11
    2878      ASX                 371.01                 12.79                   -51.17                     -38.38               332.63
    
    Total slippage: process 588.480000; bidask 127.550000; execution -46.880000; all trading 80.670000; grand total 669.150000
    
    Most of these trades make sense; post NFP sell off reducing positions in both bonds and stocks, including selling the Bund I'd bought in the morning. The AUSSTIR is a little more perplexing. The system shouldn't just buy and then sell 3 lots, only one tick apart on price.

    I've dug into it a bit and I can't find any obvious bug or explanation. This is one of the reasons why I use trade limits - caps on the numbers of trades done in each day. I will watch carefully to see if this happens again.

    P&L: -£1153. I was actually up until the NFP came out when I dropped £4k quite quickly. Still could have been a lot worse.

    Here is another issue which was easier to diagnose and fix. On friday morning one of my regular 'health checks' highlighted an issue (actually it was Thursday night, but I had better things to do than sort it out then).

    Heres an extract:

    Code:
           code contractid  ib_position locked  my_position problem
    
    7   LIVECOW     201510            1  False            0    True
    Basically IB thinks I am long one october contract live cattle, whereas I think I am flat.

    It's vital that this issue is resolved. If I think my optimal position is 1 lot, which if IB is actually at I already have, then I'll buy an extra lot to bring me into line. For this reason whenever one of these health checks fails in this way it will lock that instrument so it won't trade until I manually unlock it. Heres an extra from the same regular report:

    Code:
    Instruments with trade control:
    
    LIVECOW NOOPEN
    AUS10 NOINCREASE
    AUS3 NOINCREASE
    KR10 NOINCREASE
    ....
    
    You can see that LIVECOW is in a state NOOPEN, which means no new trades will be placed until the state is changed. In the other contracts I am not allowing myself to increase my position, though will do reducing trades. Other valid states are OK, NOREDUCTION, STOP (cancel any existing orders and do not issue new ones), CLOSE (issue trades to immediately close the position).

    The first order of business is to have a look at Thursdays trades.

    Code:
    Code             contract_id  orderid        submit       fill   fill_date                   
    LIVECOW  LIVECOW     201510     2874             1            0    np.nan                    
    LIVECOW  LIVECOW     201510     2875             1            1   2015-03-05 16:45:21
    
    There is a shortfall in the first trade. Comparing this with IB account management I can see that both orders were actually filled. So the fill data didn't come back from the API, or was lost somehow.

    I run a function that inserts the fill into my database at the correct price, then run a report to make sure that the positions in my database now match, and then change the status of the LIVECOW instrument so that normal trading can begin again.

    The important thing here is that knowing what your position is, and what orders have been filled or not, is crucial. We have two sources for this information and by comparing them we can avoid problems. Relying on just one source would be dangerous, unless you can be 100% confident in it. That hasn't been my experience with IB. Sometimes the status of positions that comes back is wrong (which means my database is correct), and sometimes its fills that are missed (which means IB positions are right and my database is wrong).

    (Such problems are not uncommon in large funds eithier, where fortunately there are middle office staff to track down and solve the problems).

    The small downtime and work this creates is manageable with relatively slow trading. With quicker trading you'd need to think differently.

    That's what I would have expected. I'd be curious as to what kind of characteristics / correlations do work. Is your timing basically 'momentum' (systems that work continue to do so) or 'reversion' (bet against systems that have worked). I can think of examples where 'momentum' might work. For example if there is a secular trend then trend followers who are faster than that slow trend will pick up on it and outperformance will be repeated. I wouldn't bother as its simpler to capture the effect with another, slower, trend following model.
     
    #61     Mar 7, 2015
  2. Todays trades

    Code:
    Trades take 1
    
             code contractid     filled_datetime  filledtrade  filledprice
    2892      ASX     201503 2015-03-09 02:14:43           -1   5813.00000
    2891     AUS3     201503 2015-03-09 02:39:17           -2     98.02000
    2890  AUSSTIR     201606 2015-03-09 02:39:01           -4     97.84000
    2893     BOBL     201506 2015-03-09 07:35:23           -1    129.17000
    2904  EDOLLAR     201809 2015-03-09 12:18:35           -1     97.41000
    2906   NASDAQ     201503 2015-03-09 14:06:30           -1   4405.50000
    2903     PLAT     201504 2015-03-09 12:06:45           -1   1155.60000
    2905      US2     201506 2015-03-09 14:02:03           -1    109.09375
    2900      VIX     201504 2015-03-09 11:46:13            1     17.60000
    
    
    Slippage in GBP, for entire trade
    
    
             code  gbpt_slippage_process  gbpt_slippage_bidask  gbpt_slippage_execution  gbpt_slippage_all_trading  gbpt_slippage_total
    2905      US2                 -41.36                  5.17                   -10.34                      -5.17               -46.53
    2893     BOBL                 -36.13                  3.61                    -7.23                      -3.61               -39.75
    2890  AUSSTIR                  -0.00                 24.75                   -49.51                     -24.75               -24.75
    2900      VIX                   0.00                 16.54                   -33.09                     -16.54               -16.54
    2891     AUS3                  -0.00                 15.44                   -30.88                     -15.44               -15.44
    2904  EDOLLAR                   4.14                  8.27                   -16.54                      -8.27                -4.14
    2892      ASX                  32.05                 12.82                    -0.00                      12.82                44.86
    2906   NASDAQ                  46.32                  1.65                     3.31                       4.96                51.28
    2903     PLAT                  74.44                  9.93                    -0.00                       9.93                84.37
    
    Some nice fills there.

    Not so nice P&L: LOSS £2,303.
     
    #62     Mar 9, 2015
  3. Hello globalarbtrader,

    Very interesting thread and lots to learn from your experience.
    Could you post the profit factor you achieved in real money trading ?
     
    #63     Mar 10, 2015
  4. I'd never heard of that performance metric until just now. Googling it seems to be defined as gross profits over gross losses. Since I don't track individual 'bets' as such I can only do this in terms of days (I'm also not sure what 'gross' means). So I calculated the sum of profits achieved on up days, divided by the sum of losses on down days. And I get 1.62.
     
    #64     Mar 10, 2015
  5. jj1111

    jj1111

    Outside of "is the resultant P&L positive," what metric(s) matter most to you?
     
    #65     Mar 10, 2015
  6. In order:

    Realised volatlility versus expectations
    Costs versus expectations
    Skew, and related statistics like average gain to loss.
    Last, and least, Sharpe Ratio; as over short periods of time this has the largest variance.
     
    #66     Mar 10, 2015
  7. jj1111

    jj1111

    I'd be interested in hearing more about your thoughts re: volatility if you care to elaborate i.e., how you view a scenario such as realized vol > expected vol, how it might impact your trading, how you might tweak, etc.
     
    #67     Mar 10, 2015
  8. Todays trades
    Code:
             code contractid     filled_datetime  filledtrade  filledprice
    2913      AUD     201506 2015-03-10 06:52:56           -3     0.760800
    2919     BOBL     201506 2015-03-10 07:39:31            1   129.310000
    2924      CAC     201503 2015-03-10 11:27:32           -1  4888.500000
    2930     CORN     201512 2015-03-10 15:15:35           -1   408.250000
    2932     CORN     201512 2015-03-10 16:38:15            1   412.250000
    2907      EUR     201503 2015-03-10 06:41:10            1     1.086000
    2908      EUR     201506 2015-03-10 06:41:10           -1     1.087250
    2909      EUR     201506 2015-03-10 06:50:05           -1     1.080800
    2927   GAS_US     201506 2015-03-10 12:15:52           -1     2.781000
    2918      GBP     201506 2015-03-10 07:25:53           -4     1.507900
    2910      JPY     201503 2015-03-10 06:50:56            1     0.008251
    2911      JPY     201506 2015-03-10 06:50:56           -1     0.008260
    2915      JPY     201506 2015-03-10 06:56:43           -3     0.008224
    2931  LIVECOW     201510 2015-03-10 15:32:37           -1   146.975000
    2917      MXP     201506 2015-03-10 07:27:43           -5     0.063990
    2912      NZD     201506 2015-03-10 06:52:27           -1     0.724500
    2929    SP500     201503 2015-03-10 14:04:16           -1  2058.250000
    2920      V2X     201505 2015-03-10 08:15:39          -10    21.250000
    2925      V2X     201504 2015-03-10 11:35:50            1    21.550000
    2926      V2X     201505 2015-03-10 11:42:46            3    21.750000
    2928      V2X     201505 2015-03-10 13:44:51           -1    21.750000
    2923      VIX     201504 2015-03-10 10:06:53           -1    18.000000
    2933    WHEAT     201512 2015-03-10 16:41:51            1   521.250000
    
    
    Slippage in GBP, for entire trade
    
    
             code  gbpt_slippage_process  gbpt_slippage_bidask  gbpt_slippage_execution  gbpt_slippage_all_trading  gbpt_slippage_total
    2932     CORN                 -49.63                  4.14                    -8.27                      -4.14               -53.76
    2923      VIX                 -33.09                 16.54                   -33.09                     -16.54               -49.63
    2918      GBP                 -41.36                 16.54                    -0.00                      16.54               -24.81
    2928      V2X                  -3.61                  3.61                    -7.23                      -3.61                -7.23
    2925      V2X                   0.00                  3.61                    -7.23                      -3.61                -3.61
    2933    WHEAT                   0.00                  8.27                     0.00                       8.27                 8.27
    2919     BOBL                   0.00                  3.61                     7.23                      10.84                10.84
    2930     CORN                  -0.00                  4.14                     8.27                      12.41                12.41
    2924      CAC                  43.36                  1.81                    -3.61                      -1.81                41.55
    2931  LIVECOW                 109.18                  3.31                    -0.00                       3.31               112.49
    2910      JPY                  57.90                  4.14                   289.50                     293.63               351.53
    2912      NZD                 387.10                  3.31                    -6.62                      -3.31               383.79
    2907      EUR                   8.27                  4.14                   562.45                     566.58               574.86
    2917      MXP                 612.08                 24.81                   -49.63                     -24.81               587.26
    2929    SP500                 752.69                  4.14                    -8.27                      -4.14               748.55
    2913      AUD                 803.97                 19.85                    -0.00                      19.85               823.82
    2908      EUR                    NaN                 -4.14                  -566.58                    -570.72                  NaN
    2909      EUR                    NaN                  8.27                    -0.00                       8.27                  NaN
    2911      JPY                    NaN                 -4.14                  -289.50                    -293.63                  NaN
    2915      JPY                    NaN                 12.41                   -24.81                     -12.41                  NaN
    2920      V2X                    NaN                 72.27                  -144.53                     -72.27                  NaN
    2926      V2X                    NaN                 10.84                   -21.68                     -10.84                  NaN
    2927   GAS_US                    NaN                  9.93                    -6.62                       3.31                  NaN
    
    Total slippage: process 2646.860000; bidask 231.410000; execution -310.220000; all trading -78.830000; grand total 3516.330000
    Quite a bit of trading today. The vast majority was related to rolling, and to 'legging in' trades, as I continue to let the system adjust to the new parameters I put in last week. As new contracts become liquid I'm allowing the system to move to its full position. All this is creating a fair bit of noise, and things should settle down.

    PROFIT: £5039.

    Hit a new HWM today, though had a pullback during US trading and now £3800 below HWM.



    Depends on the strength of the difference, and how widespread it is.

    If its just one instrument and doesn't make the overall performance too variable I'd be relaxed . So the move in SMI when CHF depegged was about 4 sigma. This pushed me into a down day, but the overall p&l barely registered on the standard deviation scale.

    99.9999% of the time if risk spikes then the system will react by cutting positions (also on unexpected profits, though not by as much). Risk spikes are just part of life. You can reduce their effect using risk management, eg not leveraging up on really low vol; not targeting too high an overall risk; diversifying. And you can avoid them by not trading things with really nasty negative skew, like unhedged naked straddles.

    0.0001% of the time if I saw a massive move and the system not reacting as it should then and only then I'd manually cut the risk, say in half.

    I'd never 'tweak'. I might fix the system if the move unearthed a bug in my position scaling code.
     
    #68     Mar 10, 2015
  9. Todays trades

    Code:
             code contractid     filled_datetime  filledtrade  filledprice
    2934      AUD     201506 2015-03-11 01:57:19           -1       0.7592
    2940     BUND     201506 2015-03-11 14:47:33            1     158.6400
    2939  CRUDE_W     201512 2015-03-11 14:25:55           -1      56.2600
    2942   GAS_US     201505 2015-03-11 15:30:14            1       2.8430
    2943      MXP     201506 2015-03-11 16:30:35            1       0.0644
    2935      NZD     201506 2015-03-11 03:15:52           -1       0.7177
    2936      OAT     201506 2015-03-11 07:37:43            1     156.0600
    2938     PLAT     201504 2015-03-11 12:13:32           -1    1126.9000
    2937      V2X     201505 2015-03-11 09:05:44           -1      21.2500
    2941      V2X     201505 2015-03-11 15:00:59            1      21.6000
    
    
    Slippage in GBP, for entire trade
    
    
             code  gbpt_slippage_process  gbpt_slippage_bidask  gbpt_slippage_execution  gbpt_slippage_all_trading  gbpt_slippage_total
    2939  CRUDE_W                 -53.03                  9.94                   -19.89                      -9.94               -62.98
    2934      AUD                  -6.63                  6.63                    -6.63                      -0.00                -6.63
    2941      V2X                   0.00                  3.58                    -7.16                      -3.58                -3.58
    2942   GAS_US                   0.00                  3.31                    -6.63                      -3.31                -3.31
    2943      MXP                  -6.63                  3.31                     0.00                       3.31                -3.31
    2937      V2X                  -0.00                  1.79                    -0.00                       1.79                 1.79
    2935      NZD                  13.26                  9.94                   -19.89                      -9.94                 3.31
    2940     BUND                   7.16                  3.58                    -7.16                      -3.58                 3.58
    2938     PLAT                  -4.97                 11.60                    -0.00                      11.60                 6.63
    2936      OAT                  10.74                  3.58                     0.00                       3.58                14.33
    
    Total slippage: process -40.100000; bidask 57.260000; execution -67.360000; all trading -10.070000; grand total -50.170000
    Slightly choppy on the V2X today; buying and selling for the massive loss of..... 35 euros (plus commission).

    PROFIT: £6015. Good profits from EURUSD and GBPUSD shorts. So another HWM achieved today.

    An interesting pyschological note; I hadn't realised yesterday had seen quite a big down move on the FTSE. Trading systematically really does detach you from that kind of day to day noise.
     
    #69     Mar 11, 2015
  10. Yesterdays trades

    Code:
    Trades take 1
    
             code contractid     filled_datetime  filledtrade  filledprice
    2950      AUD     201506 2015-03-12 08:18:01            1       0.7620
    2945    AUS10     201506 2015-03-12 02:21:37            1      97.4575
    2948     AUS3     201506 2015-03-12 03:20:18            1      98.2000
    2944  AUSSTIR     201606 2015-03-12 03:17:13            1      97.9600
    2951  CRUDE_W     201512 2015-03-12 12:21:48            1      57.5600
    2954  CRUDE_W     201512 2015-03-12 16:52:50           -1      56.5800
    2952  EDOLLAR     201809 2015-03-12 12:25:25            1      97.5450
    2949      NZD     201506 2015-03-12 07:05:03            1       0.7297
    
    
    Slippage in GBP, for entire trade
    
    
             code  gbpt_slippage_process  gbpt_slippage_bidask  gbpt_slippage_execution  gbpt_slippage_all_trading  gbpt_slippage_total
    2951  CRUDE_W                 -29.83                  6.63                   -13.26                      -6.63               -36.46
    2950      AUD                  -3.31                  6.63                     0.00                       6.63                 3.31
    2952  EDOLLAR                   8.29                  4.14                    -8.29                      -4.14                 4.14
    2949      NZD                  19.89                  9.94                   -19.89                      -9.94                 9.94
    2954  CRUDE_W                  23.20                  6.63                   -19.89                     -13.26                 9.94
    2944  AUSSTIR                  -6.14                  6.14                    24.57                      30.71                24.57
    2948     AUS3                  19.15                  3.83                     7.66                      11.49                30.64
    2945    AUS10                  97.98                  5.76                     0.00                       5.76               103.75
    
    Total slippage: process 129.230000; bidask 49.700000; execution -29.100000; all trading 20.620000; grand total 149.830000
    
    Yesterdays LOSS £1289
     
    #70     Mar 13, 2015