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

# getAvailableToTrade

> Per-market amount an account can still buy or sell

Returns the amount the account can still buy and sell on one market, in the market's margin asset.

<Info>
  The examples on this page use **Hyperliquid** (`provider: 'hyperliquid'`). Replace the `provider` value with any supported DEX from `getProviders()`.
</Info>

```typescript theme={null}
const figure = await perps.getAvailableToTrade({
  provider: 'hyperliquid',
  address: userAddress,
  marketId: 'BTC',
});

console.log(figure.buy, figure.sell); // decimal strings, in figure.asset units
```

## Parameters

| Parameter  | Type     | Required | Description                                |
| ---------- | -------- | -------- | ------------------------------------------ |
| `provider` | `string` | Yes      | DEX identifier                             |
| `address`  | `string` | Yes      | User's wallet address                      |
| `marketId` | `string` | Yes      | Canonical `Market.id` to size the order on |

## Returns

`AvailableToTrade`:

| Field        | Type           | Description                                                      |
| ------------ | -------------- | ---------------------------------------------------------------- |
| `providerId` | `string`       | Provider that owns the market                                    |
| `marketId`   | `string`       | The market this figure applies to, equal to `Market.id`          |
| `asset`      | `AssetDisplay` | The market's margin asset, which both amounts are denominated in |
| `buy`        | `string`       | Amount the account can still buy                                 |
| `sell`       | `string`       | Amount the account can still sell                                |

This is the per-market figure an order panel reads before it lets the user size an order. It differs from [`AccountSummary.availableMargin`](/sdk/account/get-account#perpsclientgetaccountsummary), which stays account-scoped and does not reflect one market's margin asset.

## Provider fallback

A provider that exposes no per-market figure falls back to an account-scoped read. The SDK fetches the account with [`getAccount()`](/sdk/account/get-account), derives [`getAccountSummary()`](/sdk/account/get-account#perpsclientgetaccountsummary), and returns the account's `availableMargin` as both `buy` and `sell`, in the market's quote asset.

Hyperliquid implements the per-market read directly, from the venue's `activeAssetData.availableToTrade` — see [Hyperliquid / Account figures](/providers/hyperliquid#account-figures).
