Modelling order execution for futures exchanges

Discussion in 'Automated Trading' started by topsy_1, Sep 30, 2008.

  1. topsy_1


    I’m currently writing a back-testing engine in Java which uses data captured from Eurex (via IB)

    I have a couple of questions as to how I should model trades / executions,

    1) Should I use the historical bid and ask values and assume that if the mid touches my requested order price an execution would have occurred? OR

    2) Should I use historical trade / execution data and assume that if my requested order price touches the traded price my order would have been executed (assuming my order size is less than the historical trade size)?

    I’m aware that I can’t truly model the exact execution price since it depends where my order is in the queue at that price, but I’d like to know which (if any) is most accurate.
  2. Tums


    If your model can make money buying at offer and selling at bid, you have half the battle won.
  3. rosy2


    if it trades through your price then you got filled. you can always adjust the results with +/- bands
  4. topsy_1


    Thank you for the replies. I think the “trade through the price” approach is pretty good, since you can be certain that an order at that price would have been executed.

    However, this raises another question which is perplexing me (perhaps it’s due to my misunderstanding of how markets / exchanges work)

    Q - What *exactly* is an execution / trade?

    Consider I place a buy market order for 1 contract. The market order is filled at price 99.00 and I get a fill report of size=1 price=99.00.

    How does this show up in terms of a trade? I assume we would get a trade report of size=1 price=99.00 ?

    Why don’t we two trades of size=1 price=99.00 – one for the BUY (my trade) and one for the corresponding SELL (my counterparty) ??

  5. MTE


    Each trade has a buyer and a seller otherwise there would be no trade.
  6. topsy_1


    I see. So if I place an order to BUY 10, and one counterparty fills size=5 @ 99.00 and another fills size=5 @ 99.00 - We would see two trades each with size=5 ?
  7. MTE


  8. topsy_1


    Thank you for all your replies. I have a question related to the relationship between the current bid/ask and the execution price.

    To put it simply, if I placed a market order to buy would this get executed at the bid price at that time (visa versa for sell and ask)?


    Can I determine the direction of a historical trade by correlating it with the bid / ask price at the time of the trade?
  9. You need to use Level II DOM data and build a table for exactly how many contracts can be filled at a certain instant of time. You can use this table for real time forward testing and for back testing use hi low average per tick for market order fill calculations.

    Market buy orders fill at ask.. and further up the chain if the offered contracts are less than your order. There's your slipage.
    Sell orders fill at bid.

    A good method for testing is to dynamially build your own market feed based on a minimum number of contracts.

    ie for ES use 50... calculate your "executable" bid and ask to fill orders for quantity 50. You'll get many intra tick "executable" ticks off of a real feed. Also filters out pricing noise and garbage.

    Key if your using market orders is to calculate what your fills should be. Don't rely on last trade data... it is delayed data..

    Direction is irrelevant: Sellers and Buyers are matched and reflected in Last Trade Price.
  10. topsy_1


    PocketChange (and all) many thanks for your contribution. It all makes sense and is a real eye opener- this discussion has led me to another level.

    I've now written a quick n dirty (will fix up later) data engine which captures and stores real time Level II DOM data. This essentially gives me the executable size for each price level in market at a given time.

    Next stage is to synthesise a theoretical executable price feed by sampling every x, where x is 'number of contracts'. This will give me 'intra tick' ticks! Which can be directly used to model executions. Great stuff.

    Questions now arises in that how can I use this to model limit orders? My strategy is very real-time and utilises limit orders for entry and exit.

    I assume that a limit order remains as such until price hits that level and then it turns into a market order?

    Anyone have any insights into how a limit order is treated in the book in a futures exchange?
    #10     Oct 2, 2008