Advanced Usage
AsyncExchangeBroker
AsyncExchangeBroker
is the underlying model behind AsyncSingleWalletExchangeBroker
and AsyncMultipleWalletExchangeBroker
.
It provides more granular controls on multiple wallets in an object-oriented flavor. You can opt-in to use this model according to your requirements.
import asyncio
from term_structure.models.async_exchange_broker import AsyncExchangeBroker
async def main():
broker = AsyncExchangeBroker()
identity_1 = await broker.connect(
layer_1_wallet_address="0x9cd...9A3",
layer_1_wallet_private_key="0x78...89",
)
identity_2 = await broker.connect(
layer_1_wallet_address="0x6a5...0cF",
layer_1_wallet_private_key="0x16...G2",
)
order_1 = await broker.place_order(identity_1)
order_2 = await broker.place_order(identity_2)
asyncio.run(main())
AsyncExchangeClient
AsyncExchangeClient
is a pythonic mapper of Term Structure L2 HTTP API, with consistent naming, query parameters and request bodies to all the HTTP endpoints.
If you plan to use this model, you may have to generate signatures for private operations manually. The signature could be either handcrafted by yourself or generated via our official signing utility term-structure-python-signer-sdk.
import asyncio
from term_structure.models.async_exchange_client import AsyncExchangeClient
async def main():
client = AsyncExchangeClient()
exchange_info = await client.get_exchange_info()
asyncio.run(main())