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

# V0.8.16

# Monaco Protocol SDK v0.8.16

This release corrects **portfolio statistics**: `pnl` now reports true realized PnL (previously it was net trading cash-flow), account equity now includes perpetuals, and the stats response gains a spot/perps equity breakdown. Affects `GET /api/v1/accounts/me/portfolio` (`sdk.profile.getPortfolioStats`) and the `pnl` metric of the portfolio chart (`sdk.profile.getPortfolioChart(period, "pnl")`).

## Fixed

### Realized PnL

`getPortfolioStats().pnl` and `getPortfolioChart(period, "pnl")` now return **average-cost realized PnL** — gains and losses are booked only when a position is reduced or closed, net of fees, across spot and perps (including funding), and exclude unrealized PnL on open positions.

Previously `pnl` summed the quote-currency (USDC) leg of trade ledger entries — i.e. net trading cash-flow — so **buying and holding** an asset showed as a loss and **selling deposited inventory** showed as pure profit. The response shape is unchanged; only the values (and the field documentation) change.

### `winLossRatio` type

`PortfolioStats.winLossRatio` is now typed **`number | null`** (previously `string`), matching the value the API actually returns. It is `null` when the period has no closed trades.

## Added

### Spot / perps equity breakdown

`PortfolioStats` gains two additive fields alongside `totalEquity`:

* **`spotEquity`** — spot account equity (quote-normalized string).
* **`perpsEquity`** — perpetuals (margin) account equity: collateral + realized − funding + unrealized PnL (quote-normalized string). Previously this was effectively `0`.

## Changed

### `totalEquity` now includes perpetuals

`totalEquity` now reflects **spot balances plus perpetuals (margin) account equity**, not spot balances alone.

### `maxDrawdown` nullable

`PortfolioStats.maxDrawdown` is now **`string | null`** — `null` when the period has no closed trades.

## Upgrade

```bash theme={null}
npm install @0xmonaco/core@0.8.16 @0xmonaco/types@0.8.16 @0xmonaco/react@0.8.16
# or bun
bun add @0xmonaco/core@0.8.16 @0xmonaco/types@0.8.16 @0xmonaco/react@0.8.16
```

Aside from the additive `spotEquity` / `perpsEquity` fields and the `winLossRatio` / `maxDrawdown` type refinements, request and response shapes are unchanged — most callers only see corrected values and need no code changes.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.