Trading FUTURES with IB

Discussion in 'Journals' started by fullautotrading, Jun 14, 2011.

  1. Have restarted. only 11 hours.

    Have been doing a lot of simulations last week. I have some (small) performance improvement: so am running a parallel test with the new strategic variation (making use of the 2 additional strategic layers). For now they are "aligned".

    It's not a large improvement, but for the first time (after several months of attempts) i have been able to reduce the dd while keeping the same or an improved reward/risk ratio. (This is providing new insight on how to correctly overlay the hedging layer.)

    This is good, because, at folio level, it allows us to contain better the runaways while the fluctuating instruments keep realizing.

    I am keeping running simulations to find further improvements.


    Tom

    <img src="http://www.elitetrader.com/vb/attachment.php?s=&postid=3220857" width="1200" />
     
    #21     Jun 27, 2011
  2. Here the situation now of the 2 instances (1.5 days).

    Above is the previous strategy. Below the new variation (with the 2 additional layers). Looks like the rookie got lucky, so far.

    The previous strat has a nice realized but mostly (6K) heavily reinvested in RB (short), which i am not stopping, causing a negative PNL.

    <img src="http://www.elitetrader.com/vb/attachment.php?s=&postid=3221752" />
     
    #22     Jun 28, 2011
  3. Last week run, continued fine. But i am going to shut it down to focus on the new developments and tests.

    <img src="http://www.elitetrader.com/vb/attachment.php?s=&postid=3221760" width="1200" />
     
    #23     Jun 28, 2011
  4. Yesterday Reuters headline was <b>"Wall Street ends biggest 3-day surge in three months"</b>
    http://www.reuters.com/article/2011/06/29/us-markets-stocks-idUSTRE75512M20110629
    http://economictimes.indiatimes.com...surge-in-three-months/articleshow/9045648.cms

    So nothing better than this "exceptional" situation to test drawdowns (or "investment").

    I let the gasoline go up to almost 30K (unbalancing the folio) without trading manually against the bot to hedge (this was actually an ideal situation to trade against the bot with a "manual clone"), to compare with new strategy variation.
    The new strategy variation had a significant smaller investment (<b>20K</b> instead of <b>50K</b>). Realized is about 8K for both. So, so far all according to expectations.

    It should take now quite a while for this large investment to generate profits. Anyway, let's see how it proceeds ...

    Tom

    <img src="http://www.elitetrader.com/vb/attachment.php?s=&postid=3224717" />
     
    #24     Jun 30, 2011
  5. Hi

    No big news so far for this run. We are still in the "investment" (dd) phase. And we need to be patient at this time. After all, any investment needs time to work and trading, although sometimes does allow quick profits (as we have seen in several trading sessions before), is not much different from other types of investment.

    It is interesting, however, to examine how the bot deals with this situation.

    Clearly, it's not going to "stop" as stopping would result in an unrecoverable (and pretty stupid) waste of the investment.

    What it does it keeping "alive" the investment in the minimal terms possible, so that it will have in any case the possibility to turn it profitable.

    The mechanisms which allow that are:

    - Scalping capabilities even in deep drawdown
    - Minimal investment to be able to capture a relatively small (with respect to entire move) reversal.
    [ - Other folio instances (or clones) to continue raise the realized, according to the available capital ]

    In essence, as the price moves in waves, the bot extracts profit from the direction changes occurring on top and bottom of the waves.

    Let's look, for instance, at the worst drawdown, which is RB (newer strategy). We see that the bot, while keeping alive a minimal investment in the move, is still capable to <b>scalp while investing</b>.

    I have put circles around those scalps, which i call "scorpion-tail scalps" and they add up to several Ks.

    Tom

    <img src="http://www.elitetrader.com/vb/attachment.php?s=&postid=3230053" width="1200" />
     
    #25     Jul 7, 2011
  6. Hi

    Here the situation now of the last (difficult) run (the dd for RB has approached the maximum seen in simulations.)

    The bot is patiently working to turn the significant investment into profit (as it is programmed for).

    So far the newer version has shown a smaller dd (investment), as expected from Montecarlo simulations (the reward/risk ratio of the 2 strategies is instead nearly the same: just the newer strategy is sligthly more efficient).

    The realized has reached 14-15K in both, and the bot patiently "converging" towards profit, through scalping on retracements.

    Tom

    <img src="http://www.elitetrader.com/vb/attachment.php?s=&postid=3234168" width="1200" />
     
    #26     Jul 11, 2011
  7. We are still in dd (investing). The large investment allowed on RB is slowing down the recovery time and we need to be patient.
    With a real investment we would have probably traded "against the bot", by reversing on a manual clone, anyway we are interested here in exploring the worst and most unpleasant situations.

    The realized keeps increasing and "pulling". There is also an "hidden" component of actual "realized" which is actually incorporated in the PNL, because we compute the realized as the PNL up to the last flat situation. (The "irregularity" in the Realized curve is due to the temporary take profit for CL rollover. NG will also need to be rolled over soon)

    I have started a new folio (comparing old and new version), which will be shown in next post.

    Tom

    [chart below is the newer version]

    <img src="http://www.elitetrader.com/vb/attachment.php?s=&postid=3241827" width="1200" />
     
    #27     Jul 20, 2011
  8. Here is the new folio instance (started on thu). [The bottom chart is the newer strat version]

    [We can overlay up to 10 clients (folio instances) on the same account. This is an IB limit, the bot has no limits]

    The newer strat has a smaller PNL (this is as expected, as we know from sims that the reward/risk ratio is about the same, while the newer start has less dd).

    [In this folio i have avoided RB, for 2 reasons: we already have CL, and, in addition, we have open a folio where RB has a large investment.]

    <img src=http://www.elitetrader.com/vb/attachment.php?s=&postid=3241842 width="1200" />
     
    #28     Jul 20, 2011
  9. The new folio is proceeding ok.

    The old one, instead, is still stuck in the "investment" phase (but scalping) and probably we need to be patient for another week (RB is going to expire).

    I have rolled over several contracts which have expired (GC, HG, NG).

    [I have added also a "managed manual order manager", on request of a fund (which would probably be handy to run parallel proprietary strategies). ]

    I am doing massive changes to the app, removing the concept of "unrealized" and "realized" and replacing with something different (will explain this later).


    Tom

    <img src="http://www.elitetrader.com/vb/attachment.php?s=&postid=3244659" width="1200" />

    [chart below is the newer version]
     
    #29     Jul 22, 2011
  10. <b>New Concepts for the bot</b>
    <i>A more meaningful decomposition of PNL</i>
    ==============================

    Assume we have the following BUY / SELL orders (assume, for simplicity QTY = 1, zero comms and no multiplier, no closing costs). <b>
    Prices $</b> (ordered by magnitude):

    SELL
    15
    17
    9
    8
    7
    7
    6
    5
    5
    4
    2

    BUY
    30
    25
    10
    6
    5
    3
    2
    1

    Now, we can compute the <b>PNL</b> (Profit and Loss) relative to the above orders, and it is equal to 3 bucks.

    The problem is to decompose the PNL in an appropriate way such that we can really <b>understand</b> and have real insight on how the strategy is actually doing. For instance, how many positive scalps we have made (<b>money "pocketed"</b>), how many negative scalps we have made (for instance due to STOPs), which is money <b>"permanently lost"</b> and what is instead still "unrealized".

    Now we have already seen that the broker itself provides us with a decompositions of the type: <b>PNL = Realized + Unrealized</b>
    We also have been (approximately) following that so far. However, it's now time to <b>leave the herd and think out of the box </b> ;-))

    The above decomposition of the PNL turns out actually almost totally useless for the purposes of algorithmic trading and has a bureaucratic value, for tax purposes. [Infact you can review from here for instance: http://www.irs.gov/pub/irs-pdf/p550.pdf that the computation of the Realized is based on some assumptions, such as <b>FIFO or "Specific share identification"</b>, which are meaningless and arbitrary for the purpose of algorithmical trading.]

    Now, the motivation for this new insight arised from the simple observation that for instance the scalps made in deep drawdown were not accounted as "pocketed" (realized), while from a strategy perspective they are and should actually be shown to the trader as <b>"pocketed" money</b>. It is very important that the trader has a real and precise feeling about the <b>real "realized"</b> component and see it possibly grow, as this provides, as we have seen, a strong psychological support in the periods of "investment".

    So this lead to the necessity of some insight and different concepts, that i am introducing here.
    Thus, i proceeed defining the following decomposition (the components will be illustrated by different curves in the application charts):
    <b>PNL = Good Scalps + Bad Scalps + "Unrealized"</b>
    where:
    Good Scalps = amount due to non negative scalps, it's a <b>PERMANENT GAIN, money already pocketed</b>
    Bad Scalps = amount due to negative scalps, it's a <b>PERMANENT LOSS, money gone forever </b> (such as due to stop loss)
    Unrealized = it's the "real unrealized" part of the PNL

    Let's see a practical example, looking at the above orders. Let's identify first the GOOD scalps (we clearly want to give
    priority to their identification):

    Good Scalps:
    BUY - SELL
    10 - 15 $5
    6 - 17 $11
    5 - 9 $4
    3 - 8 $5
    2 - 7 $5
    1 - 7 $6
    ------------------ = $36

    So 6 "good" scalps. Amounting to a pocketed profit of 5 + 11 + 4 + 5 + 5 + 6 = 36.

    [ Note that changing the pairs in the scalps, doesnt change the value:
    10 - 17 $7
    6 - 15 $9
    5 - 7 $2
    3 - 7 $4
    2 - 8 $6
    1 - 9 $8
    ---------------- = $36 ]

    We are left with the orders, clearly amounting to a loss of 3 - 36 = -33 :

    SELL
    6
    5
    5
    4
    2

    BUY
    30
    25

    where there are necessarily 2 BAD scalps (stop loss or whatever). Now, this amount, that we could call "total loss", is made of 2 unrecoverable bad scalps and 3 open positions. So we can compute the total loss and partition it proportionally. So we have:
    total loss = Bad Scalps + Unrealized
    -33 = -33 (2/5) + -33 (3/5)
    that is:
    -33 = -13,2 + -19,8
    So of these 33 bucks, we can interpret 13,2 as <b>"permanently gone"</b>, and 19,8 as <b>"true unrealized component"</b>.

    In this case, the unrealized component, could be actually seen as the "ongoing investment in volatility": total loss = Bad Scalps + Ongoing Investment

    [Clearly, in my example here i have assumed qty=1 and not considered commissions or multipliers, to make the ideas more understandable. In actual implementation these have to be taken into account, which make these computations not really elementary to implement (especially the computation of the "permanent gain").]

    In summary, we have:
    <center>
    PNL = Good Scalps + Bad Scalps + Ongoing Investment
    </center>
    or if you prefer:
    <b><center>
    PNL = "Permanent Gain" + "Permanent Loss" + "Ongoing Investment"
    </b></center>
    Let me know your thoughts, or if you have further ideas to adjust these concepts or naming conventions.
    After the possible discussion, i will proceed by removing the current concepts of Realized/Unrealized and by substituting with the new concepts discussed here.
    (I will also make a web page with more detailed explanation and source code to compute these components.)

    Tom
     
    #30     Jul 24, 2011