Back to Community
'get_open_orders()' function that can return date/time and price traded?

Does anyone know if there is a similar function to 'get_open_orders()' that can also return the date/time and the price securities were traded? Any insight would be helpful.

Thanks in advance!

6 responses

No there isn't, that I know of. I'd love to know the date/time that trade executions happened in the past, because it's necessary to correctly implement trailing stops.

Dig in the result of get_open_orders() deep enough, and you'll find the date and time of the last fill for each order.

The fill price is not provided. You have to keep the ID of each order you submit, then, every minute until filled, watch it to see if it's been filled in full or in part in the last minute; then calculate the fill price by applying the slippage model to the closing price of that minute bar.

The Position type also has a cost_basis field, the volume-weighted average price paid per share of the given asset, including commissions.

For more details, read the description of the Order type and of what get_open_orders returns. There is no substitute to reading the manual.

Andre - have you found any way to get the date/time of an execution from previous days? I think the orders data is wiped every night, so if you have a position from some time last week, there's know way to know exactly when it was (aside from storing it yourself in context, which is problematic).

No, I haven't. I believe you have to catch this information while it's hot. Correct me here if I'm wrong.

Another thing: Order object don't persist, but str order IDs do.


If security is None or not specified, returns all open orders. If security is specified, returns open orders for that security
sid: (optional) A security object. Can be also be None.
If sid is unspecified or None, returns a dictionary keyed by security id. The dictionary contains a list of orders for each sid, oldest first. If a sid is specified,
returns a list of open orders for that sid, oldest first

This is from the Quantopian help docs, and what I'm getting is that it does store the date/time of execution (to list them chronologically) - anyone have any idea how to access that?

Andre, where are you finding your information? Have you guys found more in-depth documentation?

My information comes from the Quantopian help page. When that's not enough, I write code to do things and see what I get.

As to the first question, you should know how to iterate over a dictionary, and how to access a field of an object.