Trading with automation (with IB)

Discussion in 'Journals' started by fullautotrading, Sep 8, 2015.

  1. After a pause of reflection and some developments of our trading application, it's finally time to resume our trading tests and illustrations.
    As you know, I always come back to ET for these illustrations, as this is my preferred site, and lately it has also undergone significant functional improvements which make it even more attractive.

    In this thread, I will be carrying another illustration, which can be useful also to those who don't know our previous development work, that is it will be self contained, and starting from scratch.
    Before starting, I will also make a brief summary of what we have learnt so far, or at least what we can infer from our previous experiences.

    In previous threads we have shown, in full transparency, both moments of relative success and also excruciating defeats (in the last thread we have shown how to bust an entire account) and errors, and those can certainly be useful as lesson to try avoid them in the future.

    Looking in retrospect, the greatest problems have often been caused by excessive sizes, relative to the available resources. That is, the situation where there is a disproportion between the available funds and the positions.

    This disproportion appears to have 2 main causes:

    - the positions actually are relatively "too large"
    - the instruments have too large margin requirements

    Now for the first problem, we need more capital and/or we need to take smaller positions.
    Obviously, the problem is that with some instruments such as futures, there is an inferior limit to the nominal value of the position which often is already quite large. On the other hand, while with ETFs you can go small as you like, there is instead a problem of margin requirements (and also larger trading expenses).

    So, in brief (as to margin requirements), we have:

    Futures (and their options):
    pro: less margin requirements
    con: large minimum nominal size: therefore possibility of relatively large DD

    ETFs:
    pro: possibility to trade smaller amounts (but with larger trading expenses)
    con: larger margin requirements (even with "Portfolio Margin")

    (other instruments, such as STKs and CFDs, are not even worth considering in our approach, as we have experienced in the previous tests)

    However, in our previous experiments, we have also seen that the ETFs may present a lot of more critical problems, which if useful I may recall in a next post, so, personally, I'd suggest to make a marginal, or no use at all, of these instruments.

    Given, this (personal) conviction, we essentially remain with futures and their options. A consequence of that is that in order to be able to trade we need a "decent capital", or else we will be easily finishing up our resources and be forced to take losses, in an imploding spiral (with increasing and inexorable trading expenses) which soon becomes irreversible.

    What is "decent capital"? Clearly, after a certain minimum absolute capital threshold, the question is rather the proportion between the position and the available resources.

    We will start in this thread with an account with 1.5M. But we will be using only a portion of this amount, so when we need to evaluate our performance in relative terms, we will rather look at the max margin usage. Here is the values coming from the account and queried through the API:

    Code:
     - Current values (received on: Tue 08 Sep 2015 12:08:40:905 [ Tue 08 Sep 2015 06:08:40:905 edt ]) -
    
    AccruedCash                         0.00 USD   
    AccruedDividend                     0.00 USD   
    BuyingPower                10,167,799.80 USD   
    FullAvailableFunds          1,525,169.97 USD   
    FullExcessLiquidity         1,525,169.97 USD   
    FullInitMarginReq                   0.00 USD   
    FullMaintMarginReq                  0.00 USD   
    NetLiquidation              1,525,169.97 USD            
     
    Last edited: Sep 8, 2015
  2. rmorse

    rmorse Sponsor

    Don't forget about the better tax treatment for futures over ETFs.
     
    fullautotrading likes this.
  3. Hi rmorse,

    thank you for pointing that out.
    I am not much into tax matters, but if you could elaborate just a bit on the topic, I think it would be very interesting.

    [ The list of cons for ETFs is quite large actually, as we have seen previously, and it's certainly useful to recall them (just remember, for starters, all the problems we experienced due to non-shortability, overnight gaps, trading expenses, short interests, etf decay, ... and so on). ]
     
    Last edited: Sep 8, 2015
    shuraver and zhaoyun like this.
  4. rmorse

    rmorse Sponsor

    In the USA, I'm not sure where you live, all futures and cash settled index options are treated to 60% cap gains and 40% short term gains. We have different tax rates here.

    It's not clear to me that trading expenses are higher for ETFs over futures. Too many variables. The difficulty of getting a locate can be an issue with ETFs and the cost of carrying shorts over night. The futures trade in a longer session that ETFs but many ETFs are very liquid during trading hours. Without knowing more about your strategy, it's hard to direct you in one directions. It would depend on where you get your edge.
     
    fullautotrading likes this.
  5. d08

    d08

    He's in Italy, tax treatment for futures is irrelevant as it is for any non-Americans.

    Futures have bigger spreads, for example ES is 0.25 at 1950 which means 0.0128% vs 0.01 at 196 for SPY which means 0.0051%, that equals huge amounts over the years. With PM at IB you can get around 11:1 leverage for SPY, that's decent leverage, although it's still poor for volatility instruments.
     
    shuraver and fullautotrading like this.
  6. Ok. I am just "starting" a few instruments. Instruments can be added or removed dynamically: so it's not big deal how we start.

    Anyway, I am right now using the following "ticker file", that is the file used to load the instruments:

    Code:
    # some futures:
    
    SI      FUT 201510 NYMEX 1000 NYMEX Silver Index                       
    SI      FUT 201511 NYMEX 1000 NYMEX Silver Index                                   
    SI      FUT 201512 NYMEX 1000 NYMEX Silver Index
    
    CL      FUT 201510 NYMEX 1000          Light Sweet Crude Oil
    CL      FUT 201511 NYMEX 1000          Light Sweet Crude Oil
    CL      FUT 201512 NYMEX 1000          Light Sweet Crude Oil
    
    NQ      FUT 201512 GLOBEX_USD 20       E-mini NASDAQ 100 Futures
    
    ES      FUT 201512 GLOBEX 50           E-mini S&P 500
    
    
    # repetition of same futures :
    
    SI      FUT 201510 NYMEX 1000 NYMEX Silver Index                       
    SI      FUT 201511 NYMEX 1000 NYMEX Silver Index                                   
    SI      FUT 201512 NYMEX 1000 NYMEX Silver Index
    
    CL      FUT 201510 NYMEX 1000          Light Sweet Crude Oil
    CL      FUT 201511 NYMEX 1000          Light Sweet Crude Oil
    CL      FUT 201512 NYMEX 1000          Light Sweet Crude Oil
    
    NQ      FUT 201512 GLOBEX_USD 20       E-mini NASDAQ 100 Futures
    
    ES      FUT 201512 GLOBEX 50           E-mini S&P 500 
    InitialList.png

    Since I checked to option to create "clones" if a symbol is repeated, this gives rise to the following situation:

    InitialScreen.png

    So we have loaded on the trading monitor:

    CL with 3 expiration dates (CLV5, CLX5, CLZ5) and in "double copy"
    SI with 3 expiration dates (SILV5, SILX5, SILZ5) and in "double copy"

    we also have:

    ESZ5 with a "clone"
    NQZ5 with a "clone"

    and then a bunch of ETFs, just to monitor the mkt.

    For now we are "pausing", and just let the tickdata flow. We just watch, and think about the next moves. At this time, a good thing could be to take a look at the respective historical charts, at least to get an idea of where we are "on the map".

    The reason why I have loaded the futures instruments in pairs, is that this time I would like to take a look at the possibility of starting the "pair" with opposite (long/short) "position constraints".
     
    Last edited: Sep 8, 2015
  7. rmorse

    rmorse Sponsor

    I would stick with futures from what you are telling me.
     
  8. d08

    d08

    Have your previous trading experiments been successful?
     
  9. Mostly not, in terms of "profits".

    (They have been, however, invaluable in terms of development. So, I guess, they might be considered the necessary price one has to pay to make experience and advances in this area.)

    [​IMG]
     
    Last edited: Sep 8, 2015
    shuraver, ybfjax, gonzatti and 2 others like this.
  10. Ok. So looking at the historic chart for ES/NQ, CL, SI (on the barchart) site we get:

    ES.png

    CL.png

    SI.png

    which gives an idea of where these instruments currently are, in relation to the past.

    Clearly, NQ and ES, are "the same" thing, and we might have to chose one of the two: for now, we are just exploring.

    Also, looking at the tickdata coming in, it appears immediately clear that SILV5 and SILX5 have to be immediately discarded, as the spread is prohibitive (evidently illiquid stuff). SILZ5 would appear workable, but still not much volume (according to the figures sent by IB).

    It appears that there is also the "version" with multiplier 5000 (instead of 1000), which evidently is the one more liquid. So, I also loaded SIV5, SIX5, SIZ5, to take a look. 5000 might be however excessive as multiplier for our account.

    About the 3 CL contracts we have under watch, CLV5 (the "closest" one) reports the highest volume.
     
    Last edited: Sep 8, 2015
    #10     Sep 8, 2015