What you will accomplish
- Define server-side trading limits
- Calculate USD order value with decimal arithmetic
- Disable leverage by default
- Reject orders when account state or quote freshness is uncertain
Before you begin
- A server-side limits configuration outside the model
- Production exchange information and price data
- A secure execution service
- Monitoring and revocation access
Prices and order values are shown in USD. The collateral currency, such as USDC or USDT, and its blockchain network are separate settings. Check the live account and market settings for allowed currencies, minimum size, and leverage.
Start with nothing allowed
Start with every account, symbol, side, order type, payment currency, and leverage setting blocked. Then allow only what the agent actually needs, with a maximum USD value per order and per day.
{
"policyVersion": "qt-agent-policy-v1",
"allowedSymbols": ["BTC", "ETH"],
"maxNotionalUsd": "1000.00",
"allowedPaymentCurrencies": ["USDC"],
"allowLeverage": false
}Validate live symbol state and quantity precision
Use exchange information or instruments only for fields they actually return, such as status and quantityScale. Do not infer minimum size or leverage availability from exchangeInfo.
Calculate USD order value with decimal arithmetic
Multiply the amount by the USD price using Decimal. Reject a missing, negative, invalid, or over-limit value.
from decimal import Decimal, InvalidOperation
def notional_usd(price: str, quantity: str) -> Decimal:
try:
p = Decimal(price)
q = Decimal(quantity)
value = p * q
except InvalidOperation as exc:
raise ValueError('invalid decimal input') from exc
if not p.is_finite() or not q.is_finite() or not value.is_finite():
raise ValueError('price and quantity must be finite')
if value <= 0:
raise ValueError('notional must be positive')
return valueValidate payment currency separately
Confirm that paymentCurrency is allowed for the account and current funding configuration. quoteAsset=USD is a price unit, not permission to send any stablecoin.
Apply MCP server limits
The MCP server should enforce the allowed symbols, maximum USD order value, leverage, credentials, and approval requirements. Client-side limits may be stricter but must never be looser.
Apply account and venue limits
Before a live order, confirm that trading is enabled and that the current balance, margin, risk status, and Quote.Trade account limits allow it. After submission, use Quote.Trade order and account data to confirm the result.
Common problems and fixes
A permitted symbol was delisted or halted
Live market status overrides the static allowlist. Reject until production metadata shows the market active.
Different services show different daily order totals
Use one shared order-total ledger and ignore duplicate events. Do not resume trading until every service shows the same total.
The model asks to change the limits
Require an authenticated operator to change the server-side limits. Do not allow a conversational tool call to change them.