Using the Python-SDK
This example demonstrates the complete workflow for placing an order on the 21X platform. It involves initializing the REST client to discover trading pairs, retrieving the OrderBook
address for a specific pair, setting up the OrderBook
class, and submitting an order.
Steps to Place an Order
Initialize the REST API Client
Use the REST client to fetch trading pairs and locate the target trading pair.
Fetch Trading Pairs
Retrieve a list of available trading pairs and identify the pair of interest.
Retrieve Price Information
Use the getTradeInfo
endpoint to retrieve trade information for the selected trading pair.
Initialize the OrderBook
Class
OrderBook
ClassUse the retrieved orderbook_address
to interact with the smart contract.
Set Token Allowances
Before placing an order, ensure that the allowances for the base and quote tokens are set appropriately.
Place an Order
Use the create_buy_order
or create_sell_order
methods to submit your order.
Summary of Workflow
Use the REST API client to fetch trading pairs and locate the
OrderBook
address.Initialize the
OrderBook
class with the retrieved address.Ensure sufficient token allowances are set for the transaction.
Submit a buy or sell order using the
OrderBook
class.
Last updated