Place Margin Order
Place a margin trade order using market, limit, stop, or TWAP order types. See the Guide.
-
Place a margin trade order. Margin orders are similar to trade orders, except assets withdraw from your Margin Trade Account instead of your Go Account. You can execute market, limit, stop, and TWAP order types. Set
"fundingType": "margin"to specify a margin order. For stop orders, include"type": "stop"and the requiredtriggerPricefield; optionally includelimitPricefor a stop limit order.BitGo initiates a Net Open Position (NOP) check before trades execute. Trades that exceed your NOP limit do not execute. If a trade causes your account to violate margin limits, you cannot place further trades until your account returns to a healthy state.
Note: Testnet confirms trade orders but does not settle them. Trade orders settle only in the production environment.
Prerequisites: Access token must have the
trade_tradescope. You must have the Trade role and a funded collateral account.
// 1. Place Trade Order
export BITGO_EXPRESS_HOST="<YOUR_LOCAL_HOST>"
export ACCOUNT_ID="<YOUR_ACCOUNT_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X POST \
http://$BITGO_EXPRESS_HOST/api/prime/trading/v1/accounts/$ACCOUNT_ID/orders \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"clientOrderId": "myorder1",
"type": "market",
"product": "TBTC-TUSD*",
"fundingType": "margin",
"side": "buy",
"quantity": "10000",
"quantityCurrency": "TUSD*"
}'
// 1. Place Trade Order
// Use the REST API for this step (see cURL tab)
// 1. Place Trade Order Response
{
"id": "67fd640c-cb6c-4218-80ae-49e79ec15646",
"accountId": "60e740e7898f7d00064d43769a73dc48",
"clientOrderId": "myorderid1",
"time": "2021-08-05T18:05:23.431Z",
"creationDate": "2021-08-05T18:05:22.286Z",
"scheduledDate": "2021-08-05T18:05:00.000Z",
"lastFillDate": "2021-08-05T18:05:23.302Z",
"completionDate": "2021-08-05T18:05:23.431Z",
"settleDate": "2021-08-05T20:00:00.000Z",
"fundingType": "margin",
"type": "market",
"status": "completed",
"product": "TBTC-TUSD*",
"side": "buy",
"quantity": "1000",
"quantityCurrency": "TUSD*",
"filledQuantity": "0.02457152",
"averagePrice": "40697.32"
}