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.
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.
You can find available documentation on e.g. market data and placing orders here: http://interactivebrokers.github.io/tws-api/
I do all the decision making in tickPrice(...) and in orderStatus(...) I verifiy that there were no errors in execution
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.