> For the complete documentation index, see [llms.txt](https://hyperpnl.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hyperpnl.gitbook.io/docs/architecture/core-backend/fee-funding-and-pnl-calculation.md).

# Fee, Funding and PnL Calculation

All trading-related calculations in HYPERPNL are performed internally by the Core Offchain Engine.

Fees, funding, and PnL are calculated deterministically using execution results and market data sourced from Hyperliquid. No values are estimated or adjusted manually.

#### <mark style="color:$warning;">**Trading Fees**</mark>

Trading fees are applied at execution time based on the order type.

Maker and taker fees are calculated directly from the executed trade size and applied immediately to the account state.\
There are no hidden spreads or additional execution fees.

#### <mark style="color:$warning;">**Funding**</mark>

Funding reflects the cost of holding a position over time.

Funding rates are sourced from the market and applied periodically based on the trader’s open positions.\
Funding is accounted for separately from trading fees and PnL and directly affects account equity.

#### <mark style="color:$warning;">**PnL Calculation**</mark>

PnL is derived from executed trades and current market prices.

* **Unrealized PnL** is calculated using the mark price and the position’s entry price
* **Realized PnL** is applied when positions are reduced or closed

PnL values are computed continuously and reflected in account equity in real time.

#### <mark style="color:$warning;">**Equity and Balance Updates**</mark>

Account equity is updated as a combination of:

* Balance
* Unrealized PnL
* Funding effects

These updates are used for drawdown checks and rule enforcement throughout the trading lifecycle.
