How To Trade Automated by Overcoming the Major Hurdles

Discussion in 'Automated Trading' started by tickzoom, Jun 3, 2009.

  1. By far the most daunting hurdle to automated trading that experts and
    novices alike mention is the handling of orders.

    That includes when to cancel and replace orders, OCO (one cancels the
    other), contingencies, handling rejects and of course the dreaded "partial fill".

    This thread discusses several approaches to solving this problem and
    will continue with how to handle other hurdles depending on the
    interest level.

    The first approach to solving this is: "Signal order handling"
    That will be covered the next post.

    Another approach involves using a "Logical Order"

    Then we can move on to the benefits of combining those together.

    Slow Response

    Please be patient with slow response because my ET account has PMs and email
    notifications disabled to avoid distracting me from coding and working
    on tickets for members except during builds.

    I will endeavor to check the thread and respond at least within 24 hours.

  2. Before diving into "signal order handling" it seems important
    to mention another directly related hurdle to trading automated.

    That hurdle involve the process of adapting models to market themes
    or phases. It seems most of us, at some point, try to build a single
    strategy or set of rules that adapts to the different phases of a
    market like trend, chop, or channel.

    If you ever tried that then you are aware of how painfully complex
    and confusing that becomes.

    The approach expounded here on ET by others far wiser than myself is
    to use multiple, simple models that trade the exact same symbol along
    with, perhaps, some logic to manage which of them is active.

    So you may have a moving average model, reversion to mean model, and some other
    volatility or chop model. Plus you may want multiple of each working
    in different fractals at the same time.

    It's rather impressive what happens when you combine together like this while
    trading a single instrument as long as the models have nearly zero
    correlation between each other.

    But if you write all these separate strategies. How do you make them work
    in a united--combined--operation on the same symbol?

    Or more specifically how would you ever process that heaping morass of
    orders from all of them and avoid strange bugs in the code for handling
    cancels, rejects, and partials?

    One good answer is Signal Order Handling to be discussed

    The point of this post is that signal order processing solves several distinct
    hurdles in one swift blow. Another hurdle that it solves is how to trade nested
    portfolios of models on a single instrument.

    Tremendous sophistication can arise relatively easily from these simple
    combined models based on symbol order handling.

  3. Signal order processing fundamentally means that the platform you use to run
    your models uses a least common denominator for controlling orders. That least
    common denominator is simply a value of 0, greater than 0 or less than 0.

    For example, signal 5 means long 5 contracts. Signal -5 means short 5 contracts.
    And, of course, signal 0 means flat.

    This thread can go into greater detail about how you handle buy/sell stop/limit,
    stop loss, emergency stop as well as combining models on a symbol and portfolio
    trading based on signal order processing. That is, if anyone posts an interest
    to get more detail.

    I will share as long as there is encouragement and/or questions.

  4. The fundamental concept with signal order handling
    is the ability to combine the signals of models
    and even portfolios of models.

    For example, let's say your trend following
    strategy is long 1 contract but your channel
    strategy is short one contract.

    Well to get the aggregate position desired, you
    simply take the sum of the signals. So 1 + -1 = 0.

    So in this situation your overall positions would
    be flat.

    If both were long 1 contract then 1 + 1 = 2. (Not
    rocket science here).

    When you simply sum the signals of all models or
    portfolios of models for a single symbol your
    handling of orders become child's play.

    You take the latest strategy signal and compare it
    to the total of your current position and open

    Let's say your signal indicates to be long 4
    contracts and your current positions are 2
    contracts plus 1 contract ordered but not yet

    That mean 4 - 3 = 1 which indicates for the
    execution components to submit an order to add
    another long contract.

    Of course this applies to shares of stock or
    forex, that's irrelevant.

    The sum results of all this is that if you have
    2 models which each generate a set of sharpe
    ratios and equity curves, the sharpe scores
    increase because the equity curve smooths to
    fit closer to a diagonal line.

    By equity curves summing, it means that where
    both models are up $5,000 then the overall total
    is up $10,000. But if one strategy is in a draw
    down period with $1,500 down from the recent
    equity high but the other strategy is up $4,500
    for the same period then you have a total of
    $3,000 gain.

    Obviously, you can do some interesting analysis
    on how to manage the aggregate risk involved and
    avoid or at least control period with both strategies
    might be in draw down periods at the same time.

    A variety of techniques exist for enabling/disabling
    strategies based on the current market themes.

    That way you reduce the draw down and maximize
    the profits. After you add several non-correlating
    strategies, as different time fractals, you can
    truly move on to ...

    capital extraction.

    Of course, developing the software to do all of
    that can be very time consuming if you have the
    skills. So it may be better to find a platform
    that already offers signal order handling.

    Still you may wonder about writing strategies
    that only use "market" orders. Or you may ask
    a related question, "how to use limit, and stop
    orders in this situation?"

    How to handle low liquidity markets using signal
    order handling?

    More later.

  5. smitty220


    This is interesting stuff, I'll be following your posts.....
  6. That's very kind of you. Whenever I check back and find an encouragement or
    question, I'll add another post.

    Even though there's much more to the matter of signal order handling. Let's
    break away for this post to the concept of Logical Orders and return to signal
    order handling so we can see how those can fit together.

    Unfortunately, the details of Logical Orders will be limited since the specific
    implementation within tickzoom is trade secret. But it's possible to discuss
    the general idea.

    For those of you that are technical, as in professional programmers, you'll
    understand the idea of creating an "abstraction layer" between your strategy
    trading rules and the raw broker orders.

    In layman terms that simply means that your trading rules never refer directly
    to simply a Buy Stop. But instead deal with a higher level API which handles
    much of the "ugliness" of real orders (or signal order handling) behind the

    Why do this? Well the raw broker orders of Buy/Sell Limit/Stop for example can
    have many different "logical" meanings which are far easier to manage when
    thought of and organized by those "logical" concepts.

    A specific example: A Buy Stop can be either an order to enter the market from a
    flat position or an order to exit the market from a short position
    or even to reverse from short. Additionally, it could be a stop loss that can
    "logically" be thought of as a different order type altogether.

    Add to that the break even stop and other money management stops like max daily
    loss and others. That gives a variety of possible uses of a simple "raw"
    Buy Stop order. In fact, it's possible that you have several Buy Stops active
    for a variety of those logical order types simultaneously.

    You see, if your trading rules deal directly with all those different Buy Stops
    which can be active at the same time, it can become confusing and complex as
    to which BuyStop does what.

    Instead, when you use a Logical Order, it becomes more clear. In addition to that,
    Logical Orders can more easily have "rules" associated with them to create
    OCO (One Cancels the Other) and Contingency orders.

    Furthermore, they can have verification rules that help you catch logic
    errors in your code. Programmers also refer to "strong typing" so that one
    type of programming object never can get confused with another. You can apply that to Logical Orders as well.

    As far as Logical Orders go, some say that tickzoom has a game changing API for handling orders
    that makes it like slicing butter to handle OCO, Contingency, and other rules for many orders of
    different or the same types all active at once.

    Now, unless someone has questions, We can leave the subject of Logical Orders.

    In the next thread, if there's still interest, we can discuss the advantages of
    combining Logical Orders with Signal Order Handling.

    If anyone wishes to ask about another specific hurdle to automated trading, please
    feel free to mention it. If I can't answer it perhaps someone else can.