Orders ans updates sequence

vijoeyz
vijoeyz edited March 2019 in Python client
Is the following sequence always true?

def place_order(...):
print('+++ place order')
kite.place_order(...)
print('--- place order')


def on_order_update(ws, data):
print('+++ on_order_update')
...
print('--- on_order_update')

Output screen:

+++ place order
+++ on_order_update
--- on_order_update
--- place order
And, the dataargument of the on_order_update, is it always a dictionary of size one? Meaning, is it not a list of dictionaries?

So, from where should I collect the order id? The return value of kite.place_order() or data['order_id']?
  • rakeshr
    @vijoeyz
    It's always better to collect order_id from response of kite.place_order(),As, both method is async and there can be the discrepancy at your end in capturing order_id in case of multiple placed order in same period from on_order_update method.
  • vijoeyz
    Thank you, @rakeshr .

    Could you please also suggest on the sequence? You said it can be asynchronous, which I can assume if the filled_quantity is not equal to the ordered quantity, then it can happen.
    1. Does the first callback of order update happen before the place_order() can return?
    2. I find that the dataparameter of on_order_update is a dictionary (not a list of dictionaries). So, does it mean that every callback is for only one token at a time?
  • rakeshr
    @vijoeyz
    Async can only effect, if you are continuously placing orders and at the time checking for on_order_update().
    Does the first callback of order update happen before the place_order() can return?
    No,place_order() is always first.
    I find that the data parameter of on_order_update is a dictionary (not a list of dictionaries). So, does it mean that every callback is for only one token at a time?
    Yes, it's a dictionary but for every call back you will get dictionary response for all OPEN/COMPLETE orders.
Sign In or Register to comment.