Cancelling Orders
Sending an instruction to cancel an open/unmatched (or residual/partially unmatched) order requires identifying the order by it's outcome_id and the order_id.
Other methods exist to cancel orders en masse - for example, cancelling all orders related to a particular outcome or for the whole market.
Market makers or other traders with a large number of orders needing to refresh price frequently might find these functions both faster and cheaper to use.
Python
Typescript
if uma.user_market_state.number_of_orders > 0:
# As an example, get the first order in the UserMarket account
my_order = uma.user_market_state.orders[0]
# Send a cancel instruction for this order
txn_signature = await uma.cancel_order(
owner = owner_keypair,
order_id = my_order.order_id,
outcome_id = my_order.outcome_id,
active_pre_flight_check = True
)
# Wait to ensure transaction has been confirmed before moving on
await client.provider.connection.confirm_transaction(signature['result'], Confirmed)
if (uma.numberOfOrders > 0) {
const myOrder = uma.orders[0]
const signature = await uma.cancelOrder(
ownerKeypair,
myOrder.orderId,
myOrder.outcomeId,
undefined, //Default Send Options will be used
undefined, //Don't re-try this if it fails
true
)
//Wait to ensure transaction has been confirmed before moving on
await client.connection.confirmTransaction(signature, "confirmed")
}
Last modified 11mo ago