Skip to content
Tianyu edited this page Apr 23, 2020 · 2 revisions

Submitting an Order

Once an order object is created, its actually really easy to submit.

By default, submit_order will use preview mode, where it doesn't actually flag the order for execution with Ally. Instead, it will return quote information.

If you're sure you want to have the order submitted as is, use parameter preview=False and discard_quotes=False.

exec_status = a.submit_order(
    order=some_order,
    preview=True
)

Among the data returned by submit_order, one of the items is an order ID.

Cancelling an outstanding order

Given an order ID, cancel the outstanding order (if the existing order isn't already filled)

ally.order.Cancel( 15 )         # in this case with orderID 15
ally.order.Cancel( orderid=15 ) # equivalent

o = ally.order.Cancel( 15 )
a.submit_order(o)

Modifying an outstanding order

Given an order ID and a new order, Ally allows us to replace an existing outstanding order with new values (if the existing order isn't already filled)

o = ally.order.Modify(
    orderid=15,
    order=order_I_actually_want # enter a new order
)
a.submit_order(o)