Where do I make orders from with the IBKR API?

Discussion in 'Interactive Brokers' started by Tobben237, Nov 28, 2019.

  1. Tobben237


    I am new to the IBKR API and I'm trying to figure out where to put my "if-condition" that checks whether a condition is true or not, and then proceed to make a trade (or not).

    I understand that there are a lot of callback-methods that is being called after the connection is established, and the "myApp.run()" is called. I think I need to put my "if-condition" in one of these callback-methods, for example in "reqMktData"(?)

    Does anyone have any tips or experiences with where (what method) is a good place to execute orders continuously (if a condition is true) from?

    I hope I made the question clear, and to clarify further, I know how to make and send a single order. I am wondering how to make a program wait until a certain "if-condition" is true, and then execute it.
  2. traider


    use ib insync it's quite user friendly
    nooby_mcnoob and Tobben237 like this.
  3. Tobben237


    Thanks, I will look into that, it sounds like exactly what I'm looking for :)
  4. gaussian


    You need a state system and a loop that runs forever.

    In the loop you place your conditions, upon sending the order change your state to something like "ORDER_SENT" and block everything else in the loop until you get a response. After that, change the state to something like "ORDER_RECEIVED" and continue the loop.
  5. 2rosy


    You probably want that logic in the callback for market data. I think it's tick () or similar
  6. DaveV


    What language are you programming in?
  7. zwangerz


    I do all the decision making in tickPrice(...) and in orderStatus(...) I verifiy that there were no errors in execution
  8. This can be an appropriate way of doing things. However, you have to make sure that your code in tickPrice() is completed before the next data point enters. Otherwise your code is slowing down the processing of data. If this happens your code starts to respond to outdated/stale data.