Trading with automation (with IB)

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

  1. One of the many pros of automation is the fact that you have one (or more) obedient servants working even when you are asleep. This morning I found out that one of the players on the second layer of ES had been closed, with the "last event" window reporting:

    Code:
    Wed 16 Sep 2015 04:27:00:246 [ Tue 15 Sep 2015 22:27:00:246 edt ]
    ES FUT 201512 GLOBEX 50_L1 SELL 2 @ 1965 LMT DAY
    [Id: 752340, pId: 0, status: NoneReceived, 0/2]
    ES FUT 201512 GLOBEX 50_L1 ** Order placed (DU212781) **
    Last Bid / Ask: 1965 / 1965.5
    Request type: PlayerClose
    Player making close request: ID 4 CT_BUY 2 @ 1,947.50
    Entry mode was: Loading
    
    Wed 16 Sep 2015 04:27:00:641 [ Tue 15 Sep 2015 22:27:00:641 edt ]
    Received PermId: ES FUT 201512 GLOBEX 50_L1 SELL 2 @ 1965 LMT DAY
    [Id: 752340, pId: 534686584, status: NoneReceived, 0/2]
    
    Wed 16 Sep 2015 04:27:00:642 [ Tue 15 Sep 2015 22:27:00:642 edt ]
    Received first status: ES FUT 201512 GLOBEX 50_L1 SELL 2 @ 1965 LMT DAY
    [Id: 752340, pId: 534686584, status: Filled, 2/2 @ 1965]
    
    Wed 16 Sep 2015 04:27:00:695 [ Tue 15 Sep 2015 22:27:00:695 edt ]
    Order processing complete
    ES FUT 201512 GLOBEX 50_L1 SELL 2 @ 1965 LMT DAY
    [Id: 752340, pId: 534686584, status: Filled, 2/2 @ 1965]
    Request type: PlayerClose
    Player making close request: ID 4
    Order history:
    Place order (DU212781) [Tue 15 Sep 2015 22:27:00:245 edt]
    PermId received: 534686584 [Tue 15 Sep 2015 22:27:00:642 edt]
    First status received: Filled [Tue 15 Sep 2015 22:27:00:642 edt]
    
    Wed 16 Sep 2015 04:27:00:961 [ Tue 15 Sep 2015 22:27:00:961 edt ]
    Received commission: ES FUT 201512 GLOBEX 50_L1 SELL 2 @ 1965 LMT DAY
    [Id: 752340, pId: 534686584, status: Filled, 2/2 @ 1965]
    Commission update from IB: 4.04 [updated PNL]
    So the long player with size 2 was closed when ES went up and slightly "declined":

    ES_8.png

    In the meantime I have put under watch a few other assorted futures to observe liquidity and the shape of the fluctuation. Soon we will activate another pair of them.

    At this time, CL has 2 opposite players and I am leaving it alone for the moment. ES has momentarily 2 players short and one long. For the moment we can leave it alone and wait for some more significant moves.
     
    #21     Sep 16, 2015
  2. Ok I have now activated 2 layers of SIZ5:
    Code:
    SI FUT 201512 NYMEX 5000 NYMEX Silver Index  [ SIZ5 ]                                          
    with the usual long/short-position constraints:

    SI_1.png

    SI can often be a pretty wild ride, so it's not a bad idea to be careful and keep an eye on it.

    I have also cleaned up the unnecessary and unused layers, leaving, for CL, SI only the "next" contract, so that we can also keep an eye on liquidity for the rollover.

    I am currently just watching also some "representatives" of agricultural sector and some bond futures. Later we might want to add them too to our folio.
     
    #22     Sep 16, 2015
  3. I have added now 2 layers of ZL DEC 15:
    Code:
    ZL FUT 201512 ECBOT 60000 Soybean Oil Futures  [ ZL   DEC 15 ]                                  
    and cleaned up a bit the situation, so our folio begins to take a shape. We have active:

    CLV5, ESZ5, SIZ5 and ZL. Currently just "watching": 6SZ5 (CHF.USD), E7Z5 and ZN DEC 15 (which in case we may activate later on).

    Each of the 2 ZL layers have open a player pretty soon, so we are "actually" still "flat" on it.

    ZL_1.png

    One curiosity worth noticing here is that ZL, as most agricultural futs works with a price magnifier of 100. So while the contract multiplier is 60000, the application actually uses a "work multiplier" of 600. Clearly this "correction" is necessary otherwise all the PNL computation would get completely wrong (the application automatically takes into account any price magnifier, rescaling the multiplier).
     
    Last edited: Sep 16, 2015
    #23     Sep 16, 2015
  4. That's what I was talking about when I said SI can be a "wild beast". I just captured 3 frames of rapid action on it. The pictures represent players on the same layer. See how a very quick upmove has triggered 2 long players, immediately shut down at the first sign of "decline" to lock in the profits, and then a short player remained active.

    SI_2.png

    The instrument has just "risen its eyebrow" here. This kind of behavior, if continues or gets worse, may mean that this instrument can easily "play the role of the lion" in our folio. So it's not just the nominal value of the position that matters but also the instrument volatility.

    In such cases it may be useful to downgrade to the version with multiplier 1000, even if that means lousy liquidity.
     
    Last edited: Sep 16, 2015
    #24     Sep 16, 2015
  5. Approaching the end of the week, with the last 2 days dominated by a strong upmove of SI, which, as we expected, is making feel strongly its presence in the folio. Current situation is a positive balance with ES. CL is being hedged quite well. While SI has short players waiting for some reversal, and absorbing almost all ES profits, thus dragging down our PNL curve. ZL seemed asleep and only today seemed to wake up a bit.

    PNL_Folio_1.png

    CL is showing an higher volume on the next contract (CLX5). Time to roll it over.
    I will show how to roll over our 3 CL layers, without losing any trading information.
     
    #25     Sep 18, 2015
  6. In early times, the rollover procedure was imagined to simply roll over a layer to another one where the next contract was being traded.

    In time, as we developed the "layer overlay", it become readily apparent that in case of multiple layers it is more convenient to transfer the trading information of each layer, and use one additional "manual" layer to move the actual "physical" position, when necessary. This is the the most convenient and clean way to do it in case of multiple layers, so that we maintain separated orders due to automated games, and orders of different nature.

    In this particular case, we start from a situation where the 3 layers of CLV5 have an overall flat position. So we just need to move the trading information, and no "real orders" are actually needed to make the "rollover" (more properly, we should talk of "trading-information transfer"). So we just load the new 3 layers of CLX5 and apply the rollover to each layer of CLV5 to its own target, without placing any "real" order:

    CL_3.png

    Doing such a simple procedure we move all our trading info to the new 3 layers and the old layers (CLV5) are "merged" inside these new 3 layers of CLX5:

    CL_4.png
     
    Last edited: Sep 18, 2015
    #26     Sep 18, 2015
  7. Starting a new week. Last week was characterized by large moves up (about 8%) of SIZ5 (silver) which were hedged in a reasonable way, and did not cause excessive DD.

    I am currently entertaining a max of 3 layers per instrument. So far using the following approach:
    2 layers are initially started with opposite (long/short) "position constraint".
    Since the position constraint used is a "mild" one and actually allows some form of "violation", in case both layers take the same side (long/short), a 3-rd layer is started enforcing a slightly stricter position constraint (obviously with a position opposite to the existing ones).

    Clearly, one could just work with 2 layers, and stricter constraints. I am currently testing this way, which while is more "risky" (in the sense of intervening less aggressively to try "protect" against DD, allows more scalping action.)

    The reasons for a possible "violation" of position constraints can be:

    - some players (in the same direction of the position constraint) have reached their profit objective and want to be closed
    - players are being draw down and some new opposite "protective" players (in the opposite direction of the position constraint) need to be open to contain or "stop the bleeding"

    and these violations can be enabled or disabled optionally by the user.

    Current games allow generally a max position of 2 per layer, except for some particular cases of the "player cloud" development, where it can grow (to a max of 5). These limits are chosen by the user and can be modified at any time.

    PNL_5.png

    Code:
    AccruedCash                         0.00 USD                      [Min: 0.00, Max: 0.00]
    AccruedDividend                     0.00 USD                      [Min: 0.00, Max: 0.00]
    BuyingPower                10,013,575.65 USD                      [Min: 10,008,557.10, Max: 10,175,058.60]  (6.70 x 1,494,058.75)
    FullAvailableFunds          1,494,058.75 USD                      [Min: 1,493,600.85, Max: 1,526,258.79]
    FullExcessLiquidity         1,502,036.35 USD                      [Min: 1,500,268.45, Max: 1,526,258.79]
    FullInitMarginReq              32,688.00 USD                      [Min: 0.00, Max: 32,688.00]
    FullMaintMarginReq             24,710.40 USD                      [Min: 0.00, Max: 24,710.40]
    NetLiquidation              1,526,746.75 USD                      [Min: 1,522,138.85, Max: 1,529,583.50]
     
    Last edited: Sep 21, 2015
    #27     Sep 21, 2015
  8. This morning SIZ5 is finally moving in the direction favorable to the open players, so we are momentarily gaining something in terms of "unrealized". Of course, until the players can close, it can all be given back. SI is quite volatile, and the game is automatically taking into account such a feature of the instrument, by expanding the various distances (between players, take profits, etc.).

    PNL_6.png

    I am also "watching" NKDZ5 (Dollar Denominated Nikkei 225 Index), and I will probably activate it soon.

    Code:
     - Current values (received on: Tue 22 Sep 2015 11:49:52:735 [ Tue 22 Sep 2015 05:49:52:735 edt ]) -
    
    AccruedCash                         0.00 USD                      [Min: 0.00, Max: 0.00]
    AccruedDividend                     0.00 USD                      [Min: 0.00, Max: 0.00]
    BuyingPower                10,019,375.33 USD                      [Min: 9,971,782.43, Max: 10,175,058.60]  (6.71 x 1,494,166.20)
    FullAvailableFunds          1,494,166.20 USD                      [Min: 1,486,789.76, Max: 1,526,258.79]
    FullExcessLiquidity         1,502,906.30 USD                      [Min: 1,495,767.36, Max: 1,526,258.79]
    FullInitMarginReq              36,500.50 USD                      [Min: 0.00, Max: 38,875.50]
    FullMaintMarginReq             27,760.40 USD                      [Min: 0.00, Max: 29,660.40]
    NetLiquidation              1,530,666.70 USD                      [Min: 1,522,138.85, Max: 1,531,216.69]
    Here is SIZ5:

    SI_3.png

    Currently I am also watching other instruments, like CHF (and its "small brother" MSF) and ZN (10 Year US Treasury Note), but they look too much like "pachyderms" :) to me (especially ZN) and the thought of allocating so much value on so little volatility is not very attractive at the moment.
     
    Last edited: Sep 22, 2015
    #28     Sep 22, 2015
  9. I have started 2 (long/short) layers for NKDZ5. They pretty soon neutralized each other, taking opposite positions. Will see how it develops.

    NKD_1.png

    In the meantime, the unrealized continue its crazy run "pulled" by SIZ5:

    PNL_7.png

    There is a definite temptation to manually take these profits, but we must "resist" and let it go, even if it signifies to give them all back. After all, this is the meaning of automation...
     
    #29     Sep 22, 2015
  10. Let's see how is it going this morning. The new layers of NKD are fluctuating in a negative zone (it did not move much). ES, CL and ZL have been hedging and scalping ok. ZL is much less volatile though. SI has brought home part of the result of its investment in volatility, and pulled up a bit the PNL curve to about 8K.

    PNL_8.png

    Let's see the detail of the orders on the "best" ES layer, to see how it achieved that:

    ES_9.png

    So, apparently, in the last 2 weeks this layer made 13 fills. Therefore, 6 players could close, thus completing their "life cycle", and 1 sell player is currently alive (yellow circle).

    I have 3 layers for each active instrument (2 initially with "mild" long/short position constraint, and one, say, as "hedging helper" in case the first two take the same-sign position). Each layer (generally) limited to a max of 2 packets (in this case the "packet" is defined as 1 contract, but it can be defined at will by the fund manager). So far (about 2 weeks), total commissions amount to $188.45. Current maint. margin usage is $18,5K, while the max seen"peak" was: $29.6K.

    Code:
     - Current values (received on: Wed 23 Sep 2015 08:55:20:843 [ Wed 23 Sep 2015 02:55:20:843 edt ]) -
    
    AccruedCash                         0.00 USD                      [Min: 0.00, Max: 0.00]
    AccruedDividend                     0.00 USD                      [Min: 0.00, Max: 0.00]
    BuyingPower                10,100,153.53 USD                      [Min: 9,971,782.43, Max: 10,175,058.60]  (6.69 x 1,509,798.97)
    FullAvailableFunds          1,509,798.97 USD                      [Min: 1,486,789.76, Max: 1,526,258.79]
    FullExcessLiquidity         1,515,023.03 USD                      [Min: 1,495,767.36, Max: 1,526,258.79]
    FullInitMarginReq              23,720.30 USD                      [Min: 0.00, Max: 38,875.50]
    FullMaintMarginReq             18,496.24 USD                      [Min: 0.00, Max: 29,660.40]
    NetLiquidation              1,533,519.27 USD                      [Min: 1,522,138.85, Max: 1,534,809.00]
     
    Last edited: Sep 23, 2015
    #30     Sep 23, 2015