Fully automated futures trading

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

  1. Code:
    ********************************************************************************
                Reconcile report produced on 2021-05-03 22:57:15.440012             
    ********************************************************************************
    
    
    
    =============================================================
                   Optimal versus actual positions               
    =============================================================
    
                                   current        optimal  breaks
    medium_speed_TF_carry AEX          0.0   -0.032/0.032   False
    medium_speed_TF_carry AUD          0.0   -0.075/0.215   False
    medium_speed_TF_carry BOBL        -2.0  -2.244/-1.905   False
    medium_speed_TF_carry BTP         -2.0  -2.554/-2.339   False
    medium_speed_TF_carry BUND         0.0   -0.055/0.055   False
    medium_speed_TF_carry CAC          2.0    1.524/1.689   False
    medium_speed_TF_carry COPPER       0.0   -0.050/0.050   False
    medium_speed_TF_carry CORN         1.0    1.027/1.322   False
    medium_speed_TF_carry CRUDE_W      0.0   -0.072/0.072   False
    medium_speed_TF_carry EDOLLAR      5.0    4.703/6.256   False
    medium_speed_TF_carry EUR          0.0   -0.112/0.112   False
    medium_speed_TF_carry EUROSTX      0.0    0.000/0.000   False
    medium_speed_TF_carry GAS_US       1.0    1.078/1.441   False
    medium_speed_TF_carry GBP          0.0   -0.157/0.157   False
    medium_speed_TF_carry GOLD         0.0   -0.054/0.054   False
    medium_speed_TF_carry JPY          1.0    0.200/0.559   False
    medium_speed_TF_carry KOSPI        0.0    0.083/0.134   False
    medium_speed_TF_carry KR10         0.0   -0.083/0.083   False
    medium_speed_TF_carry KR3          2.0    1.946/2.645   False
    medium_speed_TF_carry LEANHOG     -1.0  -0.713/-0.550   False
    medium_speed_TF_carry LIVECOW      0.0   -0.182/0.182   False
    medium_speed_TF_carry MXP          3.0    2.933/3.712   False
    medium_speed_TF_carry NASDAQ       0.0    0.362/0.391   False
    medium_speed_TF_carry NZD          0.0   -0.147/0.147   False
    medium_speed_TF_carry OAT          1.0    0.619/0.862   False
    medium_speed_TF_carry PALLAD       0.0   -0.016/0.016   False
    medium_speed_TF_carry PLAT         0.0    0.384/0.529   False
    medium_speed_TF_carry SHATZ        0.0  -0.001/-0.001   False
    medium_speed_TF_carry SMI          1.0    1.353/1.482   False
    medium_speed_TF_carry SOYBEAN      2.0    1.866/2.173   False
    medium_speed_TF_carry SP500        0.0    0.249/0.313   False
    medium_speed_TF_carry US10         0.0   -0.045/0.045   False
    medium_speed_TF_carry US2          0.0   -0.381/0.381   False
    medium_speed_TF_carry US20         0.0   -0.020/0.020   False
    medium_speed_TF_carry US5          0.0   -0.087/0.087   False
    medium_speed_TF_carry V2X         -7.0  -6.214/-5.017    True
    medium_speed_TF_carry VIX         -1.0  -1.434/-1.259   False
    medium_speed_TF_carry WHEAT        1.0    0.387/0.616   False
    
    
    ===============================================================
                            Positions in DB                       
    ===============================================================
    
       instrument_code contract_date          expiry_date  position
    6             BOBL      20210608  2021-06-08 00:00:00      -2.0
    13             BTP      20210608  2021-06-08 00:00:00      -2.0
    14             CAC      20210521  2021-05-21 00:00:00       2.0
    1             CORN      20211214  2021-12-14 00:00:00       1.0
    3          EDOLLAR      20231218  2023-12-18 00:00:00       4.0
    16         EDOLLAR      20240318  2024-03-18 00:00:00       1.0
    15          GAS_US      20210628  2021-06-28 00:00:00       1.0
    17             JPY      20210614  2021-06-14 00:00:00       1.0
    10             KR3      20210615  2021-06-15 00:00:00       2.0
    7          LEANHOG      20210614  2021-06-14 00:00:00      -1.0
    8              MXP      20210614  2021-06-14 00:00:00       3.0
    5              OAT      20210608  2021-06-08 00:00:00       1.0
    9              SMI      20210618  2021-06-18 00:00:00       1.0
    0          SOYBEAN      20211112  2021-11-12 00:00:00       2.0
    11             V2X      20210616  2021-06-16 00:00:00      -4.0
    4              V2X      20210519  2021-05-19 00:00:00      -3.0
    12             VIX      20210616  2021-06-16 00:00:00      -1.0
    2            WHEAT      20211214  2021-12-14 00:00:00       1.0
    
    
    ===============================================================
                           Positions broker                       
    ===============================================================
    
       instrument_code contract_date          expiry_date  position
    11            BOBL      20210608  2021-06-08 00:00:00      -2.0
    15             BTP      20210608  2021-06-08 00:00:00      -2.0
    0              CAC      20210521  2021-05-21 00:00:00       2.0
    8             CORN      20211214  2021-12-14 00:00:00       1.0
    4          EDOLLAR      20240318  2024-03-18 00:00:00       1.0
    1          EDOLLAR      20231218  2023-12-18 00:00:00       4.0
    9           GAS_US      20210628  2021-06-28 00:00:00       1.0
    12             JPY      20210614  2021-06-14 00:00:00       1.0
    6              KR3      20210615  2021-06-15 00:00:00       2.0
    16         LEANHOG      20210614  2021-06-14 00:00:00      -1.0
    2              MXP      20210614  2021-06-14 00:00:00       3.0
    14             OAT      20210608  2021-06-08 00:00:00       1.0
    7              SMI      20210618  2021-06-18 00:00:00       1.0
    5          SOYBEAN      20211112  2021-11-12 00:00:00       2.0
    3              V2X      20210616  2021-06-16 00:00:00      -4.0
    17             V2X      20210519  2021-05-19 00:00:00      -3.0
    13             VIX      20210616  2021-06-16 00:00:00      -1.0
    10           WHEAT      20211214  2021-12-14 00:00:00       1.0
    
    Breaks Optimal vs actual ['medium_speed_TF_carry V2X']
    Breaks Instrument vs Contract []
    Breaks Broker vs Contract []
    
    ===============
    Trades in DB 
    ===============
    
    Empty DataFrame
    Columns: [strategy_name, contract_date, fill_datetime, fill, filled_price]
    Index: []
    
    
    ==================
    Trades from broker
    ==================
    
    Empty DataFrame
    Columns: [strategy_name, contract_date, fill_datetime, fill, filled_price]
    Index: []
    
    
    ********************************************************************************
                                  END OF STATUS REPORT                             
    ********************************************************************************
    
     
    #2681     May 4, 2021
    blink18 likes this.
  2. Interesting post. You have approached it in a much more structural way than I did when I looked to add instruments.
    I may be biased because I live in Asia, but I feel that you have insufficient Asian equity indexes in your universe. Your universe consists mostly of European and US equity index futures. Which is why I added China, Nikkei, and Nifty (India) from SGX to my universe. These don't seem to show up in your lists of instruments which you downloaded from IB, but are available through IB.
    You also mention that "However one issue with using IB to provide price data is that they don't give you prices for expired contracts!" This is not entirely true. For any futures instrument can you ask for a list of conid's, including those which expired within the last two years. This can be done by using the code contract.includeExpired(true); the default value is false. Of this list of conid's you can get the historical data.
     
    #2683     May 7, 2021
  3. Thanks for the heads up about expired contracts; that will be useful if I can't get the prices from barchart.

    The SGX futures are indeed in my master list (rows 163 onwards). But I don't subscribe to the data. However I can see that the feed only costs SGD2 a month, so it's probably worth adding these at some point. Also the Osaka indices, which are only Y200 a month. I probably won't bother with Hong Kong, although it's only £2.30 a month there are only 4 indices. But definitely not Australia! (£12 a month!).

    GAT
     
    #2684     May 7, 2021
  4. Why do you have two values for the optimal position under the "Optimal versus actual positions" section? E.g. "-0.075/0.215" for "medium_speed_TF_carry AUD". Is it some sort of position buffering?
     
    #2685     May 7, 2021
  5. Yes

    GAT
     
    #2686     May 7, 2021
  6. blink18

    blink18

    Do you use two position sizing decisions (i.e. 25 instruments -> each gets 4% of portfolio) and then also based on volatility (Sd) to fit into these 4%?

    How exactly you make buy/sell decisions, I read you use continuous system, does this mean you buy (+rollover every X months) and rebalance based on volatility (Sd) each hour/day/week/month and you're invested all the time?
     
    #2687     May 7, 2021
  7. (i.e. 25 instruments -> each gets 4% of portfolio) Yes
    and then also based on volatility (Sd) to fit into these 4%? Yes, though not sure what 'fit into' means.

    Buy/sell is based on forecasts of different trading rules, and yes I am not invested all the time (well not quite but only because you can't buy a fraction of a future), rebalance is daily.

    GAT
     
    #2688     May 7, 2021
    blink18 likes this.
  8. I did not find NIFTY, SGXNK and XINA50 in your list of SGX products. I might have overlooked them? Those are the contracts I use. I use the Korean KOSPI index (K200 at IB) as I already have that market subscription for the Korean bond futures. I do admit that NIFTY and XINA50 have a disadvantage: they need to be rolled over every month. Only the front month has decent trading volume and rollover needs to be done about 3 days before expiry.
    I had the same consideration about market data fee versus how much I would use it. As you see, I use multiple instruments from SGX, so this SGD2 per month is certainly worth it. From Hong Kong and Osaka I was considering only one product each, which is why I decided against it.
     
    #2689     May 7, 2021
  9. blink18

    blink18

    With 'fit into' I meant - position size based on volatility (Sd) with maximum weight of 4% of your trading account.

    Since you're so well diversified, do you also apply leverage to your portfolio (i.e. 1.5x/2x/3x of your trading account)?
     
    #2690     May 7, 2021