> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anchorage.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Trade and rebalance

> Submit single and block trade orders, manage pricing data, and understand the settlement lifecycle.

Before trading end-client funds, review:

* Asset support
* Trade precision and minimums
* Available balance to trade
* Order types and submission methods
* Single vs. block trades
* Pricing data
* Best practices
* Settlement lifecycle

<Note>
  Testing in sandbox differs from production. Settlement testing is limited due to a mismatch between tradeable and testnet assets.
</Note>

***

## Asset support

Asset support for the wealth management integration is a subset of Anchorage Digital's full custody asset list. Fetch supported assets from **`GET /v2/trading/pairs`**.

***

## Trade precision and minimums

Minimum order sizes and precision increments are returned by **`GET /v2/trading/pairs`** and enforced at order submission.

```json Example trading pair theme={null}
{
  "data": [
    {
      "description": "Buy AAVE with USD, or Sell AAVE for USD",
      "pair": "AAVE-USD",
      "referenceData": {
        "baseAssetType": "AAVE",
        "baseSizeIncrement": "0.00000001",
        "lastUpdateTime": "2024-07-09T15:57:55.249Z",
        "minimumOrderSize": "0.000000010000000000000002",
        "priceIncrement": "0.0000001",
        "quoteAssetType": "USD",
        "quoteSizeIncrement": "0.01"
      }
    }
  ]
}
```

| Field                | Description                                                                                              |
| :------------------- | :------------------------------------------------------------------------------------------------------- |
| `baseSizeIncrement`  | Minimum size increment when specifying order quantity in the base asset. Maximum decimal places allowed. |
| `quoteSizeIncrement` | Minimum size increment in the quote asset (e.g., USD to 2 decimal places = `0.01`).                      |
| `priceIncrement`     | Minimum price increment in the response from the liquidity provider.                                     |
| `minimumOrderSize`   | Minimum required base asset size to place an order.                                                      |

***

## Balance available to trade

Fetch `availableForTrading` per subaccount from **`GET /v2/subaccounts/customers/{customerId}/accounts`**. This balance includes unsettled assets, which are also tradeable.

```json theme={null}
"balances": [
  {
    "assetType": "BTC",
    "totalBalance": "1",
    "availableForWithdrawal": "0.5",
    "availableForTrading": "0.5"
  }
]
```

***

## Order types and methods

Supported order type: **Limit FoK** (more types coming soon).

Submission methods:

* REST API — **`POST /v2/trading/order`**
* [WebSocket](/knowledge-base/platform/developers/trading/websocket-getting-started)

***

## Single orders and block trades

### Single orders

Single subaccount orders are ideal for tailored portfolio management or direct client trade requests. Also used to on/off-ramp specific assets without rebalancing across subaccounts.

### Block trades

Block trading executes multiple subaccount allocations as a single institutional order — same execution price for all underlying trades. Routes to liquidity providers via smart order routing.

**Block trade requirements:**

* All allocations must sum to the total order quantity.
* All allocations must meet `availableToTrade` balance — if any allocation fails, the entire order fails.
* Allocations are capped at 1,000 per order.
* Allocation quantity must match the order's currency.
* All orders are Fill-or-Kill (FoK).
* Programmatic cancellations and short selling are not supported.

***

## Pricing data

Pull real-time asset price data from the [WebSocket market data stream](/knowledge-base/platform/developers/trading/websocket-getting-started).

<Steps>
  <Step title="Configure WebSocket connection" />

  <Step title="Subscribe to the asset pair" />

  <Step title="Use response data when submitting orders" />
</Steps>

<CodeGroup>
  ```python Subscribe to market data theme={null}
  def subscribe_marketdata(ws, symbol, receiver):
      msg = json.dumps({
          "messageType": "MarketDataSnapshotRequest",
          "timestamp": datetime.now().isoformat(),
          "payload": {
              "type": "subscribe",
              "symbol": symbol,
              "reqId": str(uuid.uuid4())
          }
      })
      ws.send(msg)
      while True:
          resp = json.loads(ws.recv())
          receiver(resp)
  ```

  ```json Market data snapshot response theme={null}
  {
    "messageType": "MarketDataSnapshot",
    "timestamp": "2023-02-08T14:19:44Z",
    "payload": {
      "asks": [
        { "price": "23083.25076763", "size": "1" },
        { "price": "23084.28705625", "size": "4" }
      ],
      "bids": [
        { "price": "23081.96", "size": "1" },
        { "price": "23080.96918517", "size": "4" }
      ],
      "reqId": "e07b9683-af27-481a-b4db-1c492114e930",
      "symbol": "BTC-USD"
    }
  }
  ```
</CodeGroup>

***

## Submit an order

### Key submission rules

1. Include a 1–5% buffer on `limitPrice` to reduce rejections during price volatility. Execution still fills at best market rate.
2. Submit in USD for buys; submit in-kind for sells.
3. `accountId` is not required for subaccount trades.
4. `baseSizeIncrement` — round allocation quantities to this precision before submission. The parent order uses this precision when routing to liquidity providers.

### Order status values

| Status     | Description                                                                             |
| :--------- | :-------------------------------------------------------------------------------------- |
| `FILLED`   | Order fully executed.                                                                   |
| `CANCELED` | Limit FoK order did not cross the book. Safe to resubmit.                               |
| `REJECTED` | Poorly formatted, liquidity provider issue, or internal error. Do not retry repeatedly. |

### Trade status values

| Status     | Description                                                                                        |
| :--------- | :------------------------------------------------------------------------------------------------- |
| `PENDING`  | Trade accepted; temporary status while Anchorage Digital receives fill details from market makers. |
| `EXECUTED` | Fill price and fees available; pre-settlement.                                                     |
| `SETTLING` | Netted balances sent to Anchorage Digital; settling with liquidity providers.                      |
| `SETTLED`  | All funds settled; subaccount balances updated.                                                    |
| `REJECTED` | Trade failed — asset volatility exceeded slippage or insufficient trading limit.                   |
| `CANCELED` | Trade canceled manually.                                                                           |

### REST API — block order

<CodeGroup>
  ```bash Request theme={null}
  curl --request POST \
       --url https://api.anchorage-staging.com/v2/trading/order \
       --header 'Api-Access-Key: [API Key]' \
       --header 'accept: application/json' \
       --header 'content-type: application/json' \
       --data '{
    "clOrderId": "6fb5fc79-0bb4-446d-82dd-d4687fb56a02",
    "symbol": "BTC-USD",
    "side": "BUY",
    "currency": "USD",
    "quantity": "100.00",
    "orderType": "LIMIT",
    "limitPrice": "100004.05",
    "timestamp": "2025-02-20T18:32:51.133Z",
    "allocation": [
      { "subaccountId": "ec761b5e-fd2c-497a-a9a0-f8738ac97bd", "quantity": "10" },
      { "subaccountId": "bc1234e-12v3-ab31-1234-gf8738ac597bd", "quantity": "90" }
    ]
  }'
  ```

  ```json Response (filled) theme={null}
  {
    "data": {
      "clOrderId": "6fb5fc79-0bb4-446d-82dd-d4687fb56a02",
      "orderId": "a94c8d75-6c9d-4903-95f3-5b0893e76cb7",
      "symbol": "BTC-USD",
      "side": "BUY",
      "currency": "USD",
      "orderType": "MARKET",
      "orderStatus": "FILLED",
      "avgPx": "21005.4",
      "orderQty": "10000.00",
      "cumQty": "10000.00",
      "counterQty": "0.4760680586896702",
      "fee": "0.00001359805",
      "feeCurrency": "BTC",
      "transactTime": "2022-11-20T20:32:16.423Z"
    }
  }
  ```
</CodeGroup>

### WebSocket — block order

<CodeGroup>
  ```json Submit order theme={null}
  {
    "messageType": "NewOrderSingle",
    "timestamp": "2023-03-12T22:22:09.925952Z",
    "payload": {
      "clOrderId": "47ce2580-5e57-45d8-b67f-71a5aa55d05f",
      "symbol": "BTC-USD",
      "side": "SELL",
      "currency": "USD",
      "quantity": "10000",
      "orderType": "LIMIT",
      "limitPrice": "21000",
      "timeInForce": "GTC",
      "accountId": "3fa8372d-b51d-44ab-a456-43e947e4be10"
    }
  }
  ```

  ```json Execution report (filled) theme={null}
  {
    "messageType": "ExecutionReport",
    "payload": {
      "clOrderId": "47ce2580-5e57-45d8-b67f-71a5aa55d05f",
      "symbol": "BTC-USD",
      "orderStatus": "FILLED",
      "avgPx": "21990.01",
      "cumQty": "10000",
      "fee": "0.00045521",
      "feeCurrency": "BTC",
      "transactTime": "2023-03-12T22:22:09.925050Z"
    }
  }
  ```

  ```json Execution report (rejected) theme={null}
  {
    "messageType": "ExecutionReport",
    "payload": {
      "clOrderId": "47ce2580-5e57-45d8-b67f-71a5aa55d05f",
      "symbol": "BTC-USD",
      "orderStatus": "REJECTED",
      "rejectReason": "Invalid request",
      "rejectReasonText": "invalid price: 21500.0001, must be multiplication of 0.01",
      "transactTime": "2023-03-12T22:22:09.925050Z"
    }
  }
  ```
</CodeGroup>

***

## Trading best practices

1. Confirm supported trade pairs and log precision requirements per asset.
2. Configure pricing market data feed.
3. Fetch `availableToTrade` balance before each trade.
4. Call the RFQ endpoint to verify quote precision and minimum trade size. Requires `tradingAccountId`.
5. Submit a single or block order over WebSocket or REST.
6. Monitor orders and trades endpoints to report execution price and quantity to end clients.
7. Monitor subaccount balances as trades settle.

<Tip>
  Implement retry logic for REST order submissions. Suggested approach:

  * Retry after 1s, 2s, then 4s on non-201 errors.
  * A 201 response with `REJECTED` status indicates a liquidity provider issue (insufficient liquidity, min order size) — retries will not help.
  * A 500 error typically indicates a subaccount balance issue.
</Tip>

***

## Settlement lifecycle

Settlement is fully automated by Anchorage Digital.

### Unsettled balances

Unsettled balances are available for trading immediately but not for withdrawal until settled.

### Network fees

Anchorage Digital funds network fees for settlement activity. Fees are tracked in the "FBO gas fees" subaccount and funded regularly by Anchorage Digital — no action required from the wealth manager.

### Settlement status values

| Status                                                   | Description                                                                                         |
| :------------------------------------------------------- | :-------------------------------------------------------------------------------------------------- |
| `PENDING`                                                | Settlement created; covers one or more trades.                                                      |
| `SETTLING`                                               | Funds transferred from wealth manager wallets; Anchorage Digital settling with liquidity providers. |
| `SETTLED`                                                | All funds settled; subaccount balances updated.                                                     |
| `CANCELED`                                               | Settlement canceled.                                                                                |
| `EXECUTED`, `REJECTED`, `PENDINGALLOCATION`, `ALLOCATED` | Internal statuses — not applicable to the wealth management use case.                               |

### Settlement types

`TRADE` | `FEE` (custody, advisory, model, management)

### Automated settlement status flow

| Event                     | Trade status | Settlement status |
| :------------------------ | :----------- | :---------------- |
| Trade executed            | `EXECUTED`   | —                 |
| Trade added to settlement | `EXECUTED`   | `PENDING`         |
| First leg settled         | `SETTLING`   | `SETTLING`        |
| Second leg settled        | `SETTLED`    | `SETTLED`         |

***

## Integration example

```python theme={null}
import requests
import uuid

request_headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "Api-Access-Key": "[API Key]"
}

customer_id = "[customerId]"

# Step 1: Get subaccount balances
response = requests.get(
    f"https://api.anchorage-staging.com/v2/subaccounts/customers/{customer_id}/accounts",
    headers=request_headers
)
data = response.json()["data"]
# check availableForTrading per subaccount

# Step 2: Submit block order
order_request = {
    "clOrderId": "fb45ac11-584a-4c31-93ae-6db3c0fb1547",
    "symbol": "ETH-USD",
    "side": "SELL",
    "currency": "ETH",
    "quantity": "0.226",
    "orderType": "LIMIT",
    "limitPrice": "2100",
    "timestamp": "2024-01-26T19:31:55Z",
    "allocation": [
        { "subaccountId": "e3523a44-0a16-4923-8c65-5bd3c0fe5513", "quantity": "0.128" },
        { "subaccountId": "82962476-6250-443e-bcda-1bf6f959ebcd", "quantity": "0.098" }
    ]
}

response = requests.post(
    "https://api.anchorage-staging.com/v2/trading/order",
    json=order_request,
    headers=request_headers
)
data = response.json()["data"]

# Step 3: Check order status
order_id = "1a69504c1-18ae-9fb4-a4ea-9f83699"
response = requests.get(
    f"https://api.anchorage-staging.com/v2/trading/orders/{order_id}",
    headers=request_headers
)
data = response.json()["data"]
# check orderStatus, avgPx, fee
```
