Executing Trade
Open pair and basket trades across venues, and choose how they execute.
A trade on Pear is a basket: one or more long legs and one or more short legs. You open the whole basket in a single call, scoped to a connected trade account.
Open a trade
POST /trade/open opens a basket at market:
curl -X POST "https://pro-gateway.pearprotocol.io/trade/open" \
-H "x-api-key: $PEAR_API_KEY" \
-H "x-trade-account-id: $TRADE_ACCOUNT_ID" \
-H "Content-Type: application/json" \
-d '{
"type": "MARKET",
"legs": [
{ "symbol": "0", "side": "BUY", "mode": "USD", "amount": "500" },
{ "symbol": "1", "side": "SELL", "mode": "USD", "amount": "500" }
]
}'That is long BTC / short ETH on Hyperliquid, 500 USD a side. symbol is the instrument ID, not the ticker, see Instrument ID.
Opening the same basket again adjusts the existing position rather than creating a second one. The response then comes back with intent: "ADJUST" and an extra position object, see Basket Trade.
Execution is asynchronous
/trade/open returns 202 Accepted with an execution whose status starts at IDLE. The fill and the resulting position arrive over the WebSocket as execution.completed, then position.created or position.updated. They are not in the HTTP response.
/trade/open is the only endpoint in this section that returns 202. The three resting-order endpoints return 200 OK with the object they created.
Never read an ambiguous HTTP response as "no order was placed". Reconcile with GET /executions/{id} first. See Error Handling.
Execution styles
Choose how the basket fills:
| Style | Endpoint | Behaviour | Success |
|---|---|---|---|
| Market | POST /trade/open | Fill now, at market. | 202 Accepted, an execution. |
| Trigger | POST /triggers/open | Open when a market condition is met. Six condition types, see Trigger Order. | 200 OK, the created trigger. |
| TWAP | POST /schedules | Split the order into timed slices. | 200 OK, the created schedule. |
| Ladder | POST /ladders | Stagger entries across a range. | 200 OK, the created ladder. |
Before you open
- Set leverage per instrument with
PUT /leverage. Leverage is an account setting, not a field on the trade. See Set leverage below. - Quote your fee with
GET /fee. - Add your
clientIdto the body to attribute the trade to your integration. Every order-placing endpoint on the pages below accepts it.PUT /leveragedoes not.
Set leverage
PUT /leverage sets leverage for one instrument on the trade account:
curl -X PUT "https://pro-gateway.pearprotocol.io/leverage" \
-H "x-api-key: $PEAR_API_KEY" \
-H "x-trade-account-id: $TRADE_ACCOUNT_ID" \
-H "Content-Type: application/json" \
-d '{ "symbol": "0", "leverage": 5, "marginMode": "cross" }'| Field | Rule |
|---|---|
symbol | Instrument ID, not the ticker. |
leverage | Integer greater than 0. |
marginMode | cross or isolated. Required on every connector except Bybit. Bybit rejects it. |
Omitting marginMode on Hyperliquid, Binance, OKX, or Lighter is a 400. Sending it on Bybit is also a 400.
The call returns 200 OK with an empty object. Call it once per instrument before you open.
The SDK method is sdk.core.trade.setLeverage, under trade. There is no leverage namespace:
await sdk.core.trade.setLeverage({ symbol: '0', leverage: 5, marginMode: 'cross' });Once open, see Managing Open Position and Managing Open Order.