Skip to main content
ClearingEngineClient is the authenticated client for the T+ clearing engine. Rather than exposing a flat list of methods, it organises functionality into focused sub-clients, each accessible as a property. You use client.deposits to move funds in, client.withdrawals to move funds out, client.settlements to process settlement flows, client.vaults and client.assets to inspect the on-chain registry, and client.decimals to look up asset precision.

Initialization

ClearingEngineClient requires a User (for signing requests) and the base URL of your clearing engine instance. Use it as an async context manager.
import asyncio
from tplus.client import ClearingEngineClient
from tplus.utils.user import load_user

CE_BASE_URL = "http://127.0.0.1:3032"

async def main():
    user = load_user("alice")

    async with ClearingEngineClient(CE_BASE_URL, default_user=user) as client:
        # use client.deposits, client.withdrawals, etc.
        pass

asyncio.run(main())
For local development against a default setup, you can use the from_local convenience constructor instead of specifying the URL:
async with ClearingEngineClient.from_local(user) as client:
    ...
This connects to http://127.0.0.1:3032.

Sub-Client Properties

ClearingEngineClient exposes functionality through the following cached properties. Each property returns a dedicated sub-client scoped to that domain.

client.deposits

Initiate and track asset deposits from on-chain wallets into the T+ system. See examples/deposit.py for a runnable end-to-end flow.

client.withdrawals

Request withdrawals from the T+ system back to on-chain addresses. See examples/ for examples.

client.settlements

Submit and manage settlement requests, typically used to finalise trades between counterparties. See examples/settlement.py.

client.vaults

Read vault addresses and configuration from the T+ registry. client.vaults.get() returns list[ChainAddress].

client.assets

Query registered assets. Use AssetAddress for tradable tokens and ChainAddress for vault/registry addresses.

client.decimals

Look up the decimal precision for any registered asset — essential before scaling quantities to or from integer form.

client.admin

Administrative operations. Only available to authorised users with the admin role.

Typical Workflow: Checking Asset Info and Decimals

A common task before any deposit or trade is confirming the registered asset details and its decimal precision, so you can correctly scale amounts.
import asyncio
from tplus.client import ClearingEngineClient
from tplus.model.asset_identifier import AssetIdentifier, AssetAddress
from tplus.model.types import ChainID
from tplus.utils.user import load_user

CE_BASE_URL = "http://127.0.0.1:3032"

async def check_asset(token_address: str, evm_chain_id: int):
    user = load_user("alice")

    async with ClearingEngineClient(CE_BASE_URL, default_user=user) as client:
        # Build the asset address using the helper — never hand-encode the 9-byte chain ID
        asset_addr = AssetAddress.from_evm_address(token_address, chain_id=evm_chain_id)

        # Look up decimal precision for quantity scaling
        decimals = await client.decimals.get(asset_addr)
        print(f"Asset:    {asset_addr}")
        print(f"Decimals: {decimals}")

        # List registered vaults
        vaults = await client.vaults.get()
        for vault in vaults:
            print(f"Vault: {vault}")

asyncio.run(check_asset("0x58372ab62269A52fA636aD7F200d93999595DCAF", evm_chain_id=11155111))
Use AssetAddress.from_evm_address(address, chain_id=...) to build identifiers for EVM tokens. The chain_id parameter takes the raw EVM chain ID (e.g. 11155111 for Sepolia) — the helper encodes the T+ 9-byte chain-ID format for you. Never hand-write the @<chain> suffix.

When to Use ClearingEngineClient vs. OrderBookClient

ClearingEngineClient and OrderBookClient connect to different backend services and serve distinct purposes.
TaskUse
Place, cancel, or replace ordersOrderBookClient
Stream live order/trade eventsOrderBookClient
Query user inventory, margin, positionsOrderBookClient
Deposit funds into T+ClearingEngineClient (.deposits)
Withdraw funds from T+ClearingEngineClient (.withdrawals)
Submit or query settlementsClearingEngineClient (.settlements)
Look up registered assets or vaultsClearingEngineClient (.assets, .vaults)
Get asset decimal precisionClearingEngineClient (.decimals)
Market data (snapshots, klines, tickers)MarketDataClient
Amounts passed to the clearing engine must be correctly scaled. Always look up client.decimals for the asset before constructing a deposit or withdrawal request, or you risk sending the wrong on-chain value.

Error Handling

ClearingEngineClient raises the same typed exceptions as the rest of the T+ SDK. Import them from tplus:
from tplus import AuthError, NotFoundError, ServerError

try:
    decimals = await client.decimals.get(asset_addr)
except NotFoundError:
    print("Asset not registered in the clearing engine")
except AuthError:
    print("User signature was rejected")
except ServerError as err:
    print(f"Unexpected server error: {err}")