TRADEHUBTESTNET

All tools

preview_perp_order

Preview a perpetual futures order · read-only · scopes: trade:propose

Check a perpetual futures order with its stop-loss (optional take-profit) against this agent's permissions, the person's limits and the price band, sending nothing. Use before every new position, also one that waits for a price (trigger_price). Not for closing (use close_perp_position_reduce_only). size_base (base coin): from size_position_by_risk; the stop: stop_loss (USD) or stop_pct. Returns preview_id (valid 30 s), notional, risk, margin, likely fill and every check; a rejection names the failing check and, when a fix is certain, suggested_args. Next: execute_previewed_order(preview_id).

Call it

MCP tools/call

{"name": "preview_perp_order", "arguments": {"symbol": "BTC", "side": "buy", "size_base": 0.01}}

REST

POST /v1/orders/preview
{"symbol": "BTC", "side": "buy", "size_base": 0.01}

Inputs

NameMeaning (* required)
symbol *Base coin, e.g. BTC
side *buy = open or add to a long, sell = open or add to a short
size_base *Size in the base coin (BTC, not USD); rounded down to the venue step. Get it from size_position_by_risk
stop_lossRequired stop-loss, USD per coin: below entry for buys, above for sells. Or give stop_pct
stop_pctOr the stop as a distance from the entry (trigger price, limit price or mark), 0.02 = 2%
venueVenue: sandbox, hyperliquid, okx, bybit or binance. Omitted: the agent's only venue, else hyperliquid, else your only connected venue, else sandbox; or "best": the cheapest all-in venue (price plus fee) you may use and have the margin for
order_type
priceLimit price, USD per coin (limit orders only)
leverageLeverage, e.g. 5
take_profitOptional take-profit, USD per coin
trigger_priceOptional: hold the order and open it at market only when the mark reaches this price (a breakout or a pullback), re-checked then; market orders only. Risk is computed from this price
trigger_valid_hoursWith trigger_price: hours it waits before lapsing, 1-168 (default 24)
reasonOptional: why, in your words (up to 500 characters). The person sees it on the approval card and in history; other agents never do
hold_hoursOptional: how long you expect to hold, in hours, to see funding and the round trip's cost (and, with venue "best", to choose by them)

Returns

FieldMeaning and unit
okTrue: every check passed
preview_idPass to execute_previewed_order within 30 seconds
expires_atISO 8601 UTC
venueVenue name
symbolBase coin
sidebuy or sell
sizeSize after rounding down to the venue step, in the base coin (e.g. BTC), not USD
mark_priceMark at preview time, USD per coin
notional_usdsize x entry, USD
risk_usdLoss if the stop fills, USD
margin_usdMargin needed, USD
est_fill_priceMarket orders: average fill if executed now against the book, USD per coin; null for limit orders or when the book is too thin to say
est_slippage_bpsest_fill_price against mark_price in basis points, positive = worse; a market order never fills beyond the price band
est_fee_usdTrading fee for this order, USD: taker rate for market orders, maker for limit; the exit pays a fee too
fee_rate_bpsThe rate used, basis points of notional
fee_sourceaccount (your own rate), published (the base rate) or none (sandbox)
venue_choiceWith venue "best": why this venue (all-in price and the alternatives)
est_funding_usdWith hold_hours: funding over that time at today's rate, USD; negative = received
est_round_trip_cost_usdWith hold_hours: entry fee, exit fee at the taker rate and that funding, USD
requires_approvalTrue: execute_previewed_order will wait for a person's approval
trigger_priceA trigger entry: opens at market only when the mark reaches this, USD per coin
trigger_valid_hoursA trigger entry: hours it waits before lapsing
checksEvery check that ran, all pass

Rejections: error codes, each with what to do.

TradeHub never asks for withdrawal permissions.