Order Cancelation
Steps to Cancel an Order
Initialize the REST API Client
from x21_sdk import Client
# Initialize the REST client with authentication
client = Client()Fetch Open Orders
from x21_sdk.client.api.order import get_wallet_orders
from x21_sdk.client.models import OrderStatusEnum, OrderKindEnum
wallet_address = "0xYourWalletAddress"
wallet_orders = get_wallet_orders.sync(
client=client,
wallet_address=wallet_address,
only_open=True, # Ensure only open orders are retrieved
)
# Display open orders
for order in wallet_orders.items:
print(order)
selected_order = next(
order
for order in wallet_orders.items
if order.status == OrderStatusEnum.OPEN and order.order_kind == OrderKindEnum.BUY
)
# Select an order ID to cancel
trading_pair_id = selected_order.trading_pair_id
order_id_to_cancel = selected_order.external_order_idRetrieve OrderBook Address
Initialize the OrderBook Class
OrderBook ClassCancel the Order
Summary of Workflow
Last updated

