How do you handle asynchronous nature of IB API?

Discussion in 'Automated Trading' started by Chronos.Phenomena, Oct 5, 2010.

  1. especially in the higher than traditional frequency...

    do you handle all the asynchronous logic in your application, or do you handle that in a API layer... i.e. for your application Interactive Brokers provides synchronous service?

    my current application handles all the asynchronous aspects in the "business logic"... however, I'm thinking of synchronizing their API... for example, submit cancel order and then wait until the order is canceled...


    thoughts!
     
    fullautotrading likes this.
  2. I think that synchronizing the API will have negative impact on your app since it is waiting instead of ‚doing‘ something useful. The other question is WHY do you want to wait????

    Daniel
     
  3. To remove complexity from application logic...

    Also, I'm thinking of building a layer on the top of their api which will remove some complexity (order queues, cancelation requests, etc.).

    maybe to implement it on 'per instrument' basis... I don;t need to do anything while I'm waiting 0.3sec for order cancelation (for particular instrument)...

    I don't know... just thinking aloud...
     
  4. well done maxdama....any experience in JAVA?
     
  5. What makes you think that it reduces complexity? I think that you add different complexity if you synchronize it. If you wait for a response you need to add a kind of timeout and some other functionality to handle unexpected messages (quotes or lost connections).
     
  6. Fair enough trailingStop... as I said, I already have asynchronous application, however, I'm exploring the view of others...

    another option which I'm thinking about (different from synchronization) is a higher level API which will enable me to forget about orders.... I say position.open(...) position.close(...) etc...

    for example closing of the position includes

    1. Cancel all outstanding orders
    2. sell/buy to go flat

    I'm thinking of mechanism to trigger application logic only once "dirty work" is done onClose(), onOpen(), onSomethingElse()...
     
  7. slickpick, do you use sync philosophy yourself?

    what language? what's your average trading frequency?

    what;s your experience? good/bad
     
  8. real time streaming data doesnt require sync.

    historical data, i dont use sync either, just have a standalone process with ticker, frequency etc.. as the input that loads it into a database as they come, then can be sorted by timestamp or whatever you want, to be used for whatever backtesting.

    note i havent done live order yet, so this is just using their sandbox. Since my order execution is simple and not high frequency, i manage it on my side by simply using a synchronized static class to keep track of pending orders, and next course of action.

    i like the ib java api, it's very flexible and easy to hook into your system. My biggest complaint is their sandbox does not provide real time market data, not even delayed market data but random made up crap. I ended up have to hook up to their production api to get maket data, then point my order execution module to the sandbox, which is messy and dangerous.
     
  9. Why would this be messy/dangerous? Why not just use a Paper Trader account?
     
    #10     Oct 5, 2010