Back to Community
Fill notification

Is there a way my code can get notified when an order is placed, filled or partially filled? The calculations performed "behind the scenes" by order_percent, order_value, and order_target_* are valuable but make it difficult to track the actual orders placed.

I suppose I could monitor open orders and positions in handle_data and manually construct a history of orders and fills but this seems rather tedious.


4 responses

+1 up vote this excellent question.
For two years there has been no reply.
I searched the forums and cannot find an answer.

@Blue Seahawk, thank you for the link.

If I understand correctly, the technique employed is to poll for orders and detect fills.

oo = get_open_orders().values()  

This technique is computationally intensive, especially if get_open_orders is called from handle_data.

What I hoped for is that Quantopian would push notifications to our algorithms by invoking a user supplied function.

That is, when an order is submitted, there would be a 'callback' parameter to identify a user function.
Quantopian would call the user function when the order changes (fill, partial fill, cancel, etc.).

Quantopian already has an event driven mechanism for algo.schedule_function (for time based events).
It would be great to generalise this mechanism for other event types (not time based).

It would be too much work. A checkbox and field for which symbols to track, or context variables. Imagine even in a premium subscription for $100/yr or something could wind up as part of other extra features , too big.

By the way, one fine point, ordering should be done via a scheduled task of course, and you mentioned handle_data . If tracking were done from handle_data it would run in a different position in time vs scheduled tasks within the minute and wouldn't work as well, so you hit upon the reason track_orders is set to run each minute via scheduled task and importantly as mentioned there should always be listed after the scheduling of trade, rebalance or whatever function for ordering.