Margin
Place Margin Order
Overview
Margin orders are similar to trade orders, except the assets for margin orders withdraw from your Margin Trade Account instead of your Go Account.
You can execute all trade order types as margin trades, including market, limit, stop, TWAP, and steady pace orders. See Place Trade Orders for details on each order type, including stop market and stop limit variants.
BitGo initiates a Net Open Position (NOP) check before trades execute. Trades that exceed your NOP limit don't execute. Additionally, BitGo runs margin calculations after trades successfully execute. If the trade causes your account to violate the margin limits, then you can't place further trades until your account returns to a healthy state, such as by posting more collateral.
Note: Trade orders made in testnet confirm but do not settle. Trade orders only settle in the production environment.
Prerequisites
- Get Started
- Create Wallets
- Deposit Assets
- Fund Collateral Account
- Enterprise user with the Trade role
- Access token with the
trade_tradescope
Cookbook
Need just the steps? Expand the cookbook below to get started:
Place Margin OrderOpen CookbookPlace Trade Order
Endpoint: Place Order
export BITGO_EXPRESS_HOST="<YOUR_LOCALHOST>"
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*"
}'
export BITGO_EXPRESS_HOST="<YOUR_LOCALHOST>"
export ACCOUNT_ID="<YOUR_ACCOUNT_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X POST http://$BITGO_EXPRESS/prime/trading/v1/accounts/$ACCOUNT_ID/orders \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"clientOrderId": "myorder1",
"type": "limit",
"product": "TBTC-TUSD*",
"fundingType": "margin",
"side": "buy",
"quantity": "1",
"quantityCurrency": "TBTC",
"limitPrice": "10005",
"duration": 60
}'
export BITGO_EXPRESS_HOST="<YOUR_LOCALHOST>"
export ACCOUNT_ID="<YOUR_ACCOUNT_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X POST http://$BITGO_EXPRESS/prime/trading/v1/accounts/$ACCOUNT_ID/orders \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN"
-d '{
"clientOrderId": "myorder1",
"type": "twap",
"product": "TBTC-TUSD*",
"fundingType": "margin",
"side": "buy",
"quantity": "100000",
"quantityCurrency": "TUSD*",
"duration": 60,
"interval": 5
}'
Step Result
{
"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"
}