Simulating Limit Trades in IB TWS

Discussion in 'Automated Trading' started by sf631, Oct 27, 2012.

  1. sf631

    sf631

    I am building out an ATS stack to connect with IB (using the TradeLink framework to connect) and wanted to see if anyone has advice regarding how to best simulate order execution.

    I rely heavily on limit orders at or slightly inside the NBBO (so a buy limit equal to best bid or best bid + 0.01) rather than market orders. I think this will create a couple of issues with regard to accurately testing my executions.

    1) I assume when I use my papertrading account, which is based on live market data, my papertrading buy order doesn't appear on the NBBO since it's not real.
    2) Also, I'm not sure whether the IB paper trading account is smart enough to execute my limit order (which is not displayed on the real NBBO) when the quote crosses it, or only an executed trade. As an example, the market is at 1.00 x 1.02, I place a (paper) limit buy order at 1.01. If the market moves to 1.00 x 1.01 but no order has been executed at 1.01 or less, will my buy order simFill?

    If TWS paper trading doesn't handle these situations, does anyone know of a good solution? I've verified that TradeLink's simulator is not sophisticated to handle this scenario so that's not an option at present.

    I know one route is to build my own simulator from scratch but I'd prefer to avoid that if at all possible
     
  2. Yes, the papertrading account is at least that smart. It does not appear to take into account your simulated queue position though, not even if you route direct. It does appear to execute against a consolidated order book built off of a full feed, not IB's retail snapshot feed.

    All in all, though, it is a pretty accurate simulator. It's superior to most, if not all, of extant retail sims.

    If you roll your own sim, and you want it to be more accurate than IB's, you will not only have to subscribe to an all-message all-venue feed (expensive), but you will have build a realtime consolidated limit order book (harder than it sounds), and then you will have to build an emulator for the local server-side IB socket API so that your OMS can interface with your sim in the same way your OMS will interface with IB once you start trading.
     
  3. Hey why don't you try a real account with small money and a simulated account and see how big a percentage diff there is?
     
  4. Bowgett

    Bowgett

    Test on live account with small 100 share lots.
     
  5. Based on a year or so of my experience in this area, I have to disagree with this. Your paper buy limit orders will execute if there are any trades occuring at or below your price. This is unrealistic because it places you directly at the top of the queue so to speak, as if you are an HFT. This can create very significant differences between paper and real money executions, especially in low liquidity.

    The best approach is to consider your order filled (at the limit price) if a tick occurs below your buy limit price, because in reality, those two events will almost always coincide, unless your limit order has been sitting there from the previous day and you are among the first in the queue (and not even then in some cases). To do this, you need a feed that doesn't miss a single tick, and the IB feed will not be good enough for that.