Butterfly, now that we've got an orderStatus response from IB, how can I cancel/replace an order only if its filled=0. I was hoping for an example of code for changing a price. You said in the first few posts that what we did with the IB responses is what makes the difference in an effective ATS. I hope you haven't given up on this thread as its the most helpful in explaining and providing simple examples I've seen anywhere. GnM
If not filled, you simply place again the order using the same order ID. Price (and entire order) will be updated accordingly.
Thanks, appreciate all responses. But I am asking how my algorithm can get the "filled=0" field from the IB message into the code (as a variable or object....) so it can deal with it. Remember this is about developing an ATS and some of us really are beginners in programming.
For each placed order the "filled so far" quantity is received periodically by the "AxTws1.orderStatus" event; signature: Tws_orderStatus(ByVal Sender As Object, ByVal e As AxTWSLib._DTwsEvents_orderStatusEvent) along with other crucial realtime info, such as: e.id e.status e.filled e.remaining e.clientId e.permId e.avgFillPrice e.lastFillPrice ... etc.
I figured it out and because I'm not a total douche here is what I did: Code: def print_orderstatus(msg): global fillStatus if msg.filled == 0 and msg.orderId==NextOrderId: fillStatus = 'NextOrderId=',msg.orderId,'filled=',msg.filled print 'FillStatus =', fillStatus if __name__ == '__main__': con = ibConnection(port=7496,clientId=1234) con.registerAll(watcher) con.register(NextValidIdHandler, 'NextValidId') con.register(ContractDetailsHandler, 'ContractDetails') con.register(error_handler, 'Error') con.register(print_orderstatus, 'OrderStatus') Of course, this will only work once an order has been placed.
Actually, this works only once but doesn't update the fillStatus variable every time an OrderStatus message is sent from IB. I looked at it's type and saw it was a tuple (immuttable) so I tried to define as a list and a dict but it still would not update on each new message (and you know IB sends lots of those). If anyone has a technique for this I'd be interested in learning.
This approach will send order status through the orderStatus() method whenever it changes. No registering callbacks just simple subclassing
Thanks for the link. It certainly looks possible, however, for a beginner in programming what you sent is like trying to take a sip of water from a firehose. Other, more specific help on how to implement this into my code is welcome, thanks. Until then I'll keep studying methods, modules and classes and see if it all comes together. GnM
Here's a bare bones order status execution reporter you can run from commandline. You can run it, hit 'm' key and enter, place orders, see those orders in command prompt. maybe your problem was that you need to use reqAutoOpenOrders() and have clientID=0