![]() ![]() IB.sleep() is actually util.sleep(), which is actually run(asyncio.sleep()), which basically gives the event loop time to gather all the outstanding tasks and routines, update variables, do general housekeeping, etc. It does this asynchronously and various data is sent and returned to the event loop at different moments in time. When you instantiate an IB() object, that ib object begins running a loop in the background of your script as a separate thread, constantly listening for messages, sending messages, reacting to state changes, etc, all known as an "event loop". Regarding ib.sleep() and why it's needed, here is my understanding: Hope this is helpful to you.Īh yes, ib.sleep()! I always forget about that. I think if you try to place the orders manually like this you will be able to figure out quickly where your problem is. parentId number, you can manually create more exotic brackets (like a no-stoploss bracket, or ladder-fill-take-profit bracket, etc). If you implement your own bracket there is no restriction that it must be three orders as long as each child has the correct. orderId, with every order except the last one set to. ![]() ![]() To diagnose your problem, you can do the same thing manually like this: Īs you can see from IB's github link, brackets are just three individual orders with each child's. So when you do for ord in ticker_bracket_order: for example, all that you're doing is placing a few well-crafted orders in succession which TWS inteprets as a bracket order. And this BracketOrder object is simply a tuple of three individual orders. Regardless, if you're willing to take a more granular approach to diagnose the problem, might I suggest to write your own bracket order implementation to see where the problem is? It's quite easy:Īll we need to understand is that IB.bracketOrder is a function that returns a order.BracketOrder object. You attached a picture of the API window, may I ask what does the "Orders" window in TWS itself show? Another thought I had was that I seem to recall the orders on my API window are different than what I see on the TWS window whilst they are pending. It's the weekend, so I have no way of testing the code live, but just by looking at your code I myself can't see anything wrong. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |