Algorithmic trading for hedge funds: hedging techniques and application to a folio

Discussion in 'Journals' started by fullautotrading, Jul 21, 2014.

  1. Let's take now a look at both the 2 "extreme" instruments: the one with larger profit and the one with larger losses, to see what is going ok, and what perhaps needs some corrective action.

    They are currently TNA and UCO. TNA is now at about +4.3K, while UCO is about -2.5K.

    Let's first see TNA, as it obviously requires no much "care", at the moment. TNA is trading with the "Shield+" game, that is a game unbalanced towards the "long" side. It also has the "long position constraint" (layer settings). Remember that "long position constraint" does not mean "long players only": it merely means that the instrument will start long and generally "try" to keep a long position, even with sell scalpers opening and closing. Furthermore, "protective" sell players can violate the long position constraint (this is another option selectable in the "layer settings", which we will examine in detail in a future post).

    (I have been working on the "Bias-"/"Shield+" rules this week, and the enhancements will be contained in the next update).

    Clearly, the essential reason why TNA is doing ok, is because it went up and down in a limited range, thus giving the possibility to the players to scalp a good chunk of those fluctuations (in the bottom picture you can see the players which have scalped successfully and now are closed: the picture above contains only the "open" players).

    TNA_1.png

    Also remember that we have placed a few "protective option configurations" ("corridors"). They are:

    -1 CALL 75
    +100 shares (on a "manual" layer)
    free scalping
    +4 PUT 58

    and

    -1 CALL 69
    +100 shares (on a "manual" layer)
    free scalping
    +4 PUT 55

    So we are currently "protected" by 8 puts against possible movement downwards. If the instrument moves, I will be adding more of these configurations. The "manual" layer (the one containing the shares of the "protective option configurations") looks like:

    TNA_Manual.png

    It is clearly useful to keep the shares of the "protective configurations" on a separate layer, because it is easy to "see" when we can add more protection. We can just space adequately the manual orders on this layer, and we already have a pretty good guideline.

    In the next post, we will examine UCO. What is going "wrong" there, and what we can do to "protect" against a "runaway".
     
    Last edited: Aug 20, 2014
    #31     Aug 20, 2014
  2. Now let's take a look at UCO. This is one of the 2 instrument trading with a "symmetric" game (they are UCO and UNG) and no "position constraints". Playing the ("symmetric") game we call "Shield". [All the other instruments are trading with "biased" games and position constraints: "Bias-" with short position constraint for ERY, GDXJ, TBT, TZA, and "Shield+" with long position constraint for TNA].

    UCO has beeing going down all the time during our session (about 1 month). So while the short players have been closing (scalping the way down), we clearly remain with some buy players "stranded" and open (which wait to be possibly closed in the future).

    UCO_1.png

    You certainly remember we defined a long strangle (10 options, expiry January 2015) to provide some protection to UCO and create a scalping corridor.

    +10 CALL 44
    free scalping
    +10 PUT 28

    This structure, unlike all the other "option configurations" we created for the other biased games (which are theta neutral) has the obvious disadvantage to be be subject to theta decay and therefore add a loss if the price remains within the strangle or does not go much far. However, the idea was obviously to create a "scalping corridor", with the rationale that if the price remained within this corridor, the scalping activity until expiry would normally exceed the cost of the strangle.

    If, instead, the price runs away, the 10 long options would provide some protection (or even nice profit in case of extreme moves).

    Clearly, we could have elected to trade both UCO and UNG with a "biased" game anyway, and used protective structures similar to those we have seen for TZA or TNA (depending on the side we decide to "lean" on). However, it is still interesting to be able to cope with no obvious "drift", played with a "symmetric" s/h game.

    Now UCO appears to start running away, and we feel we may need some extra protection. So, at this point I don't wish to add more time decay, and therefore yesterday have added the following structure:

    -4 PUT 31
    -400 shares

    free scalping
    +8 PUT 28.5

    today, taking advantage of a small retreat, I reinforced it a bit with another smaller one:

    -1 PUT 31.5
    -100 shares

    free scalping
    +2 PUT 28.5

    Note that this offers an example of yet another type of "protective option configurations". This is "similar" to what we used to protect the long biased instruments (like TNA), with the difference that this time, to "finance" the time decay I am using PUTs instead of CALLs, and the shares to cover the puts are short. I preferred to do this because, in this case, I already had a pretty large long position, and wished to recover the margins. Note that the maximum long position reached over +2,500 shares, even if now it has been reduced by the 2 "protective" Sell players (red squares) you see at the bottom right of the top picture (bottom picture is the same, but showing also the closed players). The "protective" players are sized based on the losing buy side (and this is a form of use of past trading information).

    This suggests that probably we had to space a bit more (this is obviously a "rule" of the game that the manager can set) the loading buy players, so that the strangle position would would not be relatively too small. Anyway, I am "correcting" now this with these new additional structures.

    [ The application also provides the possibility to limit the "absolute number of players" (in addition to the ordinary limit to the global signed position, resulting by the difference of the buy and sell sides) to be used (this might be somehow useful to some fund manager when one is playing with options and what to create a more precise synergy between shares and options. In general, I am not a big fan of anything which can create "blocks" or "deadlocks", and I prefer somehow to proceed with "dynamical" adjustments).

    In essence, so far we have seen option configuration schemes of the types: +CALL/-PUT, +PUT/-CALL, +PUT/-PUT, +CALL/+CALL possibly accompanied by shares (long or short) on "manual" layers to "cover" the short options.

    In a next post, in case I will make a nice synthetic summary of all possible "canonical" and "basic" protective schemes you can start playing with, so that at least we cover all the "basic" cases happening in practice (and from there, with practice, you can easily stem with new ideas).
     
    Last edited: Aug 21, 2014
    #32     Aug 21, 2014
  3. End of the week. Here is an update on the folio situation:

    PNL33.png

    Margin usage is very low at the moment. We will be increasing it soon. (Clearly, options contribute a lot to reducing margin usage.) TNA is currently towering above all the other instruments. TZA, although is its inverse, paid a price for excessive size of "protective" buy players, so it could not make a profit yet on the reversal as TNA did. (Anyway, it will recover later, when these large protective buy players will be closed, on some surge up.)

    To conclude the previous discussion about UCO, let me add that all these option configurations we have been talking about are fully supported. In particular, in the case of the PUT/PUT configuration, one would proceed exactly as I previously explained in another post for the CALL/PUT or PUT/CALL, with the only difference that in the "Add / Execute option" dialog we select to pick options with same right. Ex:

    PutPut.png

    Of course, one can alternatively proceed manually: this facility, automatically searching the chain and selecting the strikes, just helps a lot to avoid errors, which when dealing with options can be costly to correct (due to significant spread).

    Finally, I momentarily switched UCO to "Bias-" game, in order to have more load on the (protective) sell side. In case, later I will switch it back to "Shield".
     
    Last edited: Aug 22, 2014
    #33     Aug 22, 2014
  4. In the previous post I made a cursory remark about TZA, excessive "protection" and why it did not make any money so far, while its inverse "twin" TNA did ok. Let's take a closer look at it, so we can also introduce the feature of the "player injector", we have mentioned in a previous post.

    If we look at the global PNL curve we can see there is a marked drop pf the Gain-Loss curve (see green arrow on top right). As I mentioned in a previous post, this is the effect of hedging orders, and an excessive plunge may sometimes signify (but not necessarily) that the "protective" orders are excessive. In any case, we may want to take a look at the instruments causing this and see whether they need some adjustment (and also, maybe, more "option configurations").

    Exploring the PNL curves of the individual instruments, we immediately find that the drop was also caused by TZA (bottom) picture, which shows clearly the plunge of G-L.

    ExcessProt.png

    Now that we have found an instrument responsible for that, let's take a look at the players that remained open (top picture shows the player open only, and bottom picture all orders):

    TZA_1.png

    You see there are those 3 "protective" buy players (blue squares) which definitely exercised an "excessive" protection, and therefore they raised our BUY average, thus causing TZA not making money so far, even though it scalped all the way up and down. (The other couple of buy players are "reversing" buy, which it's arguably a good ideas to disable completely, or strongly reduce, in the "Bias-" game.)

    Anyway, it's not a problem, we will possibly close those players (thus showing the now "hidden" result of the scalping) when (and if) the price surges again. If that happens, we have simply "delayed" our profits for the sake of (probably excessive) "protection".

    You see here one essential point of our procedure which is preserving the hedging information and be able to unwind its effects ("loss recycling"). In the "ordinary" approach with stop losses ("stop and forget"), you cannot do that and a losing strategy just reflects an unforgiving "loss of past trading information".

    Another important aspect, is that since the players preserve the trading information, the new sell players open are now sized keeping into account those buy player "open" (clearly, it's all "virtual"), and that is another form of use of past trading information. Again, in the ordinary stop loss approach you would not have that information available, and probably ending up with wrong sizing which will systematically lead to stack up losses.


    Player injection

    When, for instance, we wish to "correct" the effect of some "excessive" protective action (or, on the contrary, increase the hedging action when it seems to lack), in addition to possibly modify the game rules, we can also use the player injector ("balls" icon) which allows to "inject" new players which will be treated "as if" they where open by the algorithmic engine.

    (For instance, noticing that TZA has a pretty strong decay, I could have "reinforced" the reversal by "injecting" an additional sell player, when the price was still high. I am not suggesting that one should do that systematically of course, but merely indicating a possibility to exercise some discretionary intervention.)
     
    Last edited: Aug 25, 2014
    #34     Aug 25, 2014
  5. Today I have been just been occasionally watching the trading activity, while mostly working on the application and game concepts. Just added another "option configuration" to GDXJ, which moved down a bit.

    Here is a picture showing (top) while I was adding the options, and (bottom) the "manual layer" containing the shares to cover the short options.

    The "configuration" is the one you already should know well at this point (RN CALL/-N PUT and -N*100 shares) , with ratio R = 4:1.

    GDXJ_OPT.png
     
    Last edited: Aug 25, 2014
    #35     Aug 25, 2014
  6. ERY had also issues, similar to TZA, about excessive "protection" players. Looking at the scalping action, gave me the possibility to spot another possibility of improvement of the scalping engine about player distance.

    While it is obvious that players need to be spaced away from each other, the actual implementation of that may not be trivial at all. In fact, in the first implementation I just spaced away players of the same side (buy or sell). The problem with that initial approach was that for instance a "loading" sell player could prevent a "reversing" sell, and that did not look ok. So, currently, the application ensures the distance between player belonging to the same "phase" (loading-protecting-reversing-realizing).

    However, still does not look completely "satisfactory" to me, because even players belonging to the same "phase" may be be sized in a completely different way. For instance, one might have an old player with a smaller size momentarily blocking the opening of a new player for which it is requested a much larger size. So, this may cause some delays in trading action which may be "irritating" to the manager.

    In order to avoid this, I am planning to refine further the spacing algorithm to take into account also the size of the players, in order to avoid this kind of problems.

    About the ERY situation, for now, in the meantime that I code up the new feature, I forced to close the profitable sell players, and that immediately caused a new larger protective player to open up, and immediately "correct" the position (which was still long):

    ERY_1.png

    I also added another "protective option configuration" to ERY (same thing we did for TZA, but with "ratio" 2:1, because the available options did not allow an higher ratio.)

    ERY_OPT.png
     
    Last edited: Aug 26, 2014
    #36     Aug 26, 2014
  7. Here is a PNL update (we almost touched 8K today). We are proceeding prudentially, continuously protecting with option "configurations" and "corridors", to protect against possible "runaways", and let the unrelenting scalping action emerge. Friday August 29 is approaching, and we will have several options expiring that day, so we need to prepare for some "maintenance" and clean up. In the meantime, I am working on a refinement of the player spacing algorithm.

    PNL37.png
     
    Last edited: Aug 26, 2014
    #37     Aug 26, 2014
  8. Added another "protective option configuration" for TNA. Since next Friday the 2 "corridors" we have already created will expire, it seemed appropriate to start restoring the "protective" structures. The scheme is the one we already know well at this point (+RN PUT / -N CALL / +N 100 shares) with ratio R=4, N=1. [Note that the application does practically all by itself, both selecting the PUT strike (which by default is taken ATM) and then finding the "closest" OTM CALLs which satisfy the desired ratio (if they exist, clearly). This is quite comfortable.] Today I started testing (on simulated price curves) the new algo for player spacing and, if ok, I will go live next week with it. I also added a few more screen information for options, which can be useful for maintenance.

    TNA_OPT1.png

    (Top picture shows a screenshot of the utility to scan and add the options, bottom picture shows the "manual" layer with the shares we use for the protective structures.)
     
    Last edited: Aug 27, 2014
    #38     Aug 27, 2014
  9. Added another "protective option configuration" for TBT too (this is the "inverse type" respect to TNA, because we are trading it with a "short bias" ("Bias-" game with "short position constraint"): +RN CALLs / -N PUT / -N 100 shares) with ratio R=5, N=1. This time the availability of cheaper OTM strikes allowed more protection in this "corridor" (rate 5:1):

    TBT_OPT1.png
     
    #39     Aug 28, 2014
  10. While UCO, that was previously terrifying us :) seems momentarily stalled in a narrow range (and that is good because even the mere activity of scalping alone on a narrow range would easily make up for the plunge it suffered), UNG, which we also defended with a preliminary long "strangle" (of which I am not a great fan), instead remained fluctuating within a 8% range for all this time, so that was actually favorable to our scalping action (top picture is UNG, open players only; bottom picture, the same but all executed orders. Buys in cyan, sells in red, as usual).

    UNG_1.png


    Remember that our most "ideal" situation (clearly impossible in real life) would be an instrument forever fluctuating between 2 "barriers" (not too far away, in order for the capital to hold the max move), which would cause, in principle, an unbounded profit. Clearly, while that is obviously impossible in reality, the function of those option configurations, along with the (directional) "protective players" superposition, is intuitively to sort of creating scalping-safe "corridors": either the instrument remains within the "corridor", thus adding up scalps, or it breaks out and, in that case, all the "superposed option configurations" which we have been creating have to provide protection, until we reach another situation where it starts fluctuating again, or, even better, bounce back, thus closing the "stranded" players waiting to be closed. Clearly, in all this process is absolutely fundamental the "preservation and use of past trading information", which essentially provides the basis for "strategic dominance", as I mentioned in other posts.
     
    Last edited: Aug 28, 2014
    #40     Aug 28, 2014