# TypeScript SDK — Trading: History & Volume

Methods for querying active orders, historical orders, past trades, and trading-volume statistics. All methods are on `client.trading`.

Every method in this namespace is a **POST mutation** — the SDK will **not** automatically retry on failure.

See the [API Specifications](/api-specifications) for full request/response schemas.

### listActiveOrders

`POST /v1/orders` · Authenticated

Retrieve all currently active (live) orders on the account.

```ts
const orders = await client.trading.listActiveOrders({});

for (const order of orders) {
  console.log(order.order_id, order.symbol, order.side, order.price);
}
```

> **Tip:** For real-time order updates without polling, subscribe to `client.websocket.orders()` instead. See the [WebSocket Reference](/tools/typescript-sdk/reference/websocket).

### listPastOrders

`POST /v1/orders/history` · Authenticated

Retrieve historical orders. You can filter by timestamp to paginate through results.

```ts
const orders = await client.trading.listPastOrders({
  symbol: "BTCUSD",
  timestamp: 1625000000000n,  // only orders after this time
  limit_trades: 50,
});

for (const order of orders) {
  console.log(order.order_id, order.type, order.executed_amount);
}
```

> **Caveat:** The `timestamp` field is a millisecond epoch value and may be `bigint`. The SDK accepts both `bigint` and `number` for int64 input fields.

### listPastTrades

`POST /v1/mytrades` · Authenticated

Retrieve your executed trades (fills). Each entry represents one side of a matched trade.

```ts
const trades = await client.trading.listPastTrades({
  symbol: "BTCUSD",
  timestamp: 1625000000000n,
  limit_trades: 100,
});

for (const trade of trades) {
  console.log(trade.tid);           // trade ID (bigint)
  console.log(trade.price);         // execution price (decimal string)
  console.log(trade.amount);        // fill amount (decimal string)
  console.log(trade.fee_amount);    // fee charged (decimal string)
  console.log(trade.fee_currency);  // fee currency
}
```

> **Caveat:** The `tid` (trade ID) field in the response is a `bigint`. The `timestamp` input accepts both `bigint` and `number`.

> **Tip:** Prices, amounts, and fees are **decimal strings**. See [Data Types](/tools/typescript-sdk/deep-dives/data-types).

### getTradingVolume

`POST /v1/tradevolume` · Authenticated

Retrieve your 30-day trading volume, broken down by fee tier and trading pair.

```ts
const volume = await client.trading.getTradingVolume({});

for (const entry of volume) {
  console.log(entry.symbol);             // e.g. "btcusd"
  console.log(entry.base_currency);      // e.g. "BTC"
  console.log(entry.total_volume_base);  // total volume in base currency (decimal string)
  console.log(entry.buy_maker_notional); // buy maker notional volume (decimal string)
  console.log(entry.sell_maker_notional);// sell maker notional volume (decimal string)
  console.log(entry.buy_maker_count);    // number of buy maker trades
}
```

> **Tip:** Volume values are **decimal strings**. Count values (`buy_maker_count`, etc.) are **numbers**.

### getNotionalTradingVolume

`POST /v1/notionalvolume` · Authenticated

Retrieve your 30-day notional trading volume in USD. This is used to determine your fee tier.

```ts
const result = await client.trading.getNotionalTradingVolume({});

console.log(result.notional_30d_volume);  // 30-day USD volume (decimal string)
console.log(result.api_maker_fee_bps);    // current maker fee in basis points (number)
console.log(result.api_taker_fee_bps);    // current taker fee in basis points (number)
```

> **Tip:** The `notional_30d_volume` field is a **decimal string**, while `api_maker_fee_bps` and `api_taker_fee_bps` are **numbers** (basis points).

## What's next

- [Trading: Order Lifecycle](/tools/typescript-sdk/reference/trading/order-lifecycle) — place, cancel, and inspect orders
- [WebSocket Reference](/tools/typescript-sdk/reference/websocket) — real-time order and trade streams
- [Patterns](/tools/typescript-sdk/patterns) — pagination and common workflows
- [Data Types](/tools/typescript-sdk/deep-dives/data-types) — decimal strings and bigint handling
