ROBOT autotrading futures (through IB Gateway)

Discussion in 'Journals' started by fullautotrading, Jun 22, 2010.

  1. I am planning to begin forward testing here one of my (latest) strategy starting from now.

    It's an algorithmic strategy carried out through a .net autotrader coded by me.

    It is supposed to run completely unattended h24, sending orders to IB gateway.

    I will keep here a diary with results, also showing charts and
    screenshots of trades for possible discussion and strategy improvements.

    My general expectation about this strategy is that it should profit in the relatively long period, while it may be occasionally subject to the unavoidable drawdowns (eventually recovered).

    Strategy is symmetrical and has larger drawdown when there are sudden price moves or trends.

    Hope that from discussion and criticisms may stem ideas for possible improvements.



    [Just for simplicity, i will be using a initial packet size = 1 contract. If this value is increased, the results will vary proportionally. Strategy is applied to a folio of futures (emini, fx, commods), but could be applied to * any * other instrument.
    I am always developing more strategy variations. So, suggestions and discussion are always welcome!]
  2. Ok let's see what's the situation...

    I started a folio of 10 instruments:

    ES FUT 201009 GLOBEX 50 E-mini S&P 500
    YM FUT 201009 ECBOT 5 Mini Sized Dow Jones Industrial Average $5
    NQ FUT 201009 GLOBEX 20 E-mini NASDAQ 100 Futures

    AUD FUT 201009 GLOBEX 100000 AUD.USD (6A)
    GBP FUT 201009 GLOBEX 62500 GBP.USD (6B)
    CAD FUT 201009 GLOBEX 100000 CAD.USD (6C)
    EUR FUT 201009 GLOBEX 125000 EUR.USD (6E)
    CHF FUT 201009 GLOBEX 125000 CHF.USD (6S)

    GC FUT 201008 NYMEX 100 GOLD
    CL FUT 201008 NYMEX 1000 Light Sweet Crude Oil

    Market did not move much, so that the robot has little problems so far. AUD was the most active, with some entries and scalps. One scalp on gold and the rest pretty much inactive due to lack of price movement. GBP has drawdown.

    Strategy basic idea:

    The idea used here is actualy pretty simple. The robot is "marking" periodically the price curve (the yellow circles you can see on charts).
    Then, it tries always to "buy low and sell high" relative to those marks.

    Folio choice

    I have picked 10 instrument for this test. This is a not a particular "good"
    folio because of correlations. Infact, there are some instruments which are strongly correlated.
    Mainly i just picked up the most liquid, trying to put in there, for the test, emini, fx, and
    a couple commodoties.

    What is not good about "correlation" is that it may work as a drawdown "multiplicator" for strategies like this one. (And with 10 instruments like these, a drawdown of some hundred K is probably "normal".)

    [ -> An idea could, perhaps, be that of starting correlated instruments at different times]

    <a href=""> Trades so far (html) </a>

    (html report is generated automatically by the program itself)

    <img src="">
  3. I forgot to provide the trade chart legend.

    The chart symbols should be intuitive anyway:

    Blue: buy
    Maroon: sell

    circle: open (position = 0 before entry)
    square: close (position = 0 after)
    triangle: change size (position <> 0 before and after)

    The 2 price curves are bid/ask (maroon/blue)

    As "trade size" parameter, I set 260$ for each instrument. (A larger value would help better against large drawdowns: larger is the capital available, the smaller it can be.)

    Let me know in case is unclear, or any doubt.

    (in the post above i meant hundred thousands)
  4. kxvid


    Interesting system, up as of late. The real question is are you positive on a risk adjusted basis. You mention that the correlation between instruments isn't accounted for. I would caution that this will break the bank sooner or later. You have to ask the question, what benefit is realized by not accounting for exposure based off historical correlations?

    Another thing to consider, the system's bias or lack thereof. If the system is market neutral and trading highly correlated instruments, it will likely only gain in sideways markets. Just one heavily trending instrument can cause profit bleed with such a system. Ideally, one should adjust the long/short/neutral bias for each instrument based on future expectations. As such, a system does not become a profit making enterprise in itself, but a tool that a trader can use to profit from his/her market expectations in a way manual trading cannot.

    just my opinion..
  5. This is a very smart question, kxvid, and hits directly one important point, on which i would really gather some idea or contributions.

    I made a cursory remark on correlations and i am happy this point has been noted.
    Let me then focus on this.

    First of all what do i mean by "correlation"? We all know that in stat terms by correlation it is meant the degree
    of comply to a linear relation.
    In this context i would take the term in the sense that the instruments have price curves which "look like" very similar.

    I do measure "correlation" among instruments and i do it "dynamically": I take the latest M point equispaced on the price
    curves and compute a "correlation index" (can provide the formula if useful to discussion) which expresses if they
    are having similar behaviors on the intervals.

    That said, i would like to find meaningful ways to use this dynamic measure of "correlation" useful to improve
    "performances" (later will define what i mean by that).

    At this time, and in the algo running now, i have actually the following mechanism in place:

    DEVICE 1 - If an instrument is closed. Then find the highest correlated instrument which
    is open and has a position larger than a constant K.
    Then look at that correlated instrument and see if it's trending,
    Use the "degree" of such trend to project farther away the new entry,
    up or down, according to trend.

    In other words, the correlation info is currently used to suggest a "trend" or price move
    being experienced by *another* correlated instrument.

    As to "break the bank", that can happen to any system, depending on market. The real point is instead to calibrate the
    drawdown risk so that the strategy is reasonably playable with the given capital.
    Backtesting is a great tool to calibrate parameters and understanding it's magnitude.
    Most traders blow up their account even with a profitable strategy, because they underestimate potential drawdown (or lack capitals).

    The second part of your insightful comment would take some space to deal with, as it requires me to
    go more in depth with the strategy. I will, but in next posts, as this one is getting big.
    I anticipate that this strategy does not "only gain in sideways markets". It actually gains
    more in volatile markets. What is true, and i will explain why, is that it suffers larger drawdown in volatile markets.

    [ For this reason i am including in the test the fx instruments, which are among the wildest beasts. ;-) ]

  6. Here is an update of trades to "now":

    <a href=""> Chart update </a>

    Suffered some (relatively) little drawdown, but recovered.

    From the charts, i think that the strategy played also begins to be apparent.

  7. Now will begin saying something to respond to the second part of kxvid contribution.

    I think that a good way to describe this strategy
    is that: it tries, at any time, to "wrap" the price making "extreme" entries (buy low, sell high).

    Clearly, it does that by adjusting to "volatility".

    So, i would not use the word "neutral" to describe this approach, because it may imply a "directional" view of the market.
    On the contrary my (personal) view, for this strategy, is actually "static", the price range is seen as a battlefield and the flowing of time is not important. Only the price level matters.
    Trending or countertrending are concepts associated with time flowing. So i would not use none of those terms to describe this game.

    In my opinion, a strategy should always be "symmetrical", in the sense to avoid any skew which could lead to easy curve fitting.

    In fact it's always advisable to backtest strategies simultaneously on datasets which have a predominance of uptrend / downtrend / sideways to keep off the danger of overfitting. More than how much data, is important "what data". One can backtest tons of ticks and still be overfitting. Or use much less, but more wisely (and diversified).

  8. Trades

    <a href=""> Chart update </a>

    I think will stop here for the moment to resume the testing on sunday. (After all have averaged more than 1K per day.)

    I noticed that the trade size is probably a little too large and some oscillations may have been missed. After all, did not see excessive drawdown.

    For the session starting sunday will probably use a smaller "trade size" parameter. Will do some more backtesting in the weekend to check out drawdown.

    Any question welcome

  9. PNL view within application with legenda:

    <img src="">

    AbsPos = sum of abs positions
    P&L = "Net" P&L (liquidation value)
    Real = Realized
    Unr = Unrealized
    Comms = Commissions
    DD = current drawdown
    MDD = max drawdown ever seen
    AbsVal = sum of abs values
    MinP/Max P = min/max position
    Min/Max P&L = min/max P&L

    Blue Line = "Net" P&L (liquidation value)
    Dotted lines: are unrealized (pink), realized (light green)
  10. Restarted on sunday

    <a href=""> Chart update </a>

    <img src="">

    During the weekend have been carrying out some more backtesting.
    Actually backtesting and tuning results say that the value of "trade size" parameter I am currently using for this test is probably even too small. The most common best values found through tuning are 420$, 480$, 360$, 380$.

    To double check, i have also launched another test session with larger "trade size" on port 4001, to compare results.

    Clearly a larger "trade size" should be able to cope better with large sudden price moves and break out (up or down).

    #10     Jun 28, 2010