# Metrics Explained

## Profit & Loss (PnL)

### Unrealized PnL

**Definition:** Profit or loss on open positions (not yet closed).

**Formula:**

```
Long: (Current Price - Entry Price) × Size
Short: (Entry Price - Current Price) × Size
```

**Characteristics:**

* Changes in real-time as prices move
* Not guaranteed until position closed
* Shown in position panel

### Realized PnL

**Definition:** Profit or loss from closed positions (locked in).

**Formula:**

```
Realized PnL = Exit Price - Entry Price (accounting for size and fees)
```

**Characteristics:**

* Finalized when position closes
* Added to account balance
* Used for performance tracking

### Net PnL

**Definition:** Total profit/loss including both realized and unrealized.

```
Net PnL = Realized PnL + Unrealized PnL
```

## Trading Performance

### Win Rate

**Definition:** Percentage of profitable trades.

**Formula:**

```
Win Rate = (Winning Trades / Total Trades) × 100%
```

**Example:**

```
Total Trades: 100
Winning Trades: 65
Win Rate: 65%
```

**Interpretation:**

* 50%+: Positive win rate
* 60%+: Good performance
* 70%+: Excellent performance

High win rate doesn't guarantee profitability. Large losses can offset many small wins.

### Profit Factor

**Definition:** Ratio of gross profit to gross loss.

**Formula:**

```
Profit Factor = Gross Profit / Gross Loss
```

**Example:**

```
Gross Profit: $10,000
Gross Loss: $5,000
Profit Factor: 2.0
```

**Interpretation:**

* 1.0: Break even
* > 1.0: Profitable
* > 2.0: Strong performance

### Average Win vs Average Loss

**Metrics:**

```
Average Win = Total Profit from Wins / Number of Wins
Average Loss = Total Loss from Losses / Number of Losses
```

**Risk/Reward Ratio:**

```
R/R = Average Win / Average Loss
```

**Example:**

```
Average Win: $200
Average Loss: $100
R/R: 2:1 (winning trades are 2x larger than losers)
```

## Drawdown Metrics

### Current Drawdown

**Definition:** Current percentage below peak balance.

**Formula:**

```
Current Drawdown = ((Peak Balance - Current Balance) / Peak Balance) × 100%
```

**Example:**

```
Peak: $11,000
Current: $9,500
Drawdown: 13.6%
```

### Max Drawdown

**Definition:** Largest peak-to-trough decline observed.

**Use:** Measures worst-case risk exposure.

**Example:**

```
Peak: $10,000
Trough: $8,000
Max Drawdown: 20%
```

### Daily Drawdown

**Definition:** Loss within current 24-hour period.

**Resets:** Midnight UTC

**Example:**

```
Start of Day: $10,000
Current: $9,600
Daily Drawdown: 4%
```

## Risk-Adjusted Returns

### Sharpe Ratio

**Definition:** Measures return relative to risk taken.

**Formula:**

```
Sharpe Ratio = (Average Return - Risk-Free Rate) / Standard Deviation of Returns
```

**Interpretation:**

* <1.0: Poor risk-adjusted return
* 1.0-2.0: Good
* 2.0-3.0: Very good
* > 3.0: Excellent

**Example:**

```
Average Monthly Return: 5%
Risk-Free Rate: 0.3%
Std Dev: 10%
Sharpe: (5% - 0.3%) / 10% = 0.47
```

Higher Sharpe ratio = better risk-adjusted returns.

### Sortino Ratio

**Definition:** Like Sharpe, but only penalizes downside volatility.

**Why:** Ignores upside volatility (which is desirable).

**Formula:**

```
Sortino = (Average Return - Risk-Free Rate) / Downside Deviation
```

## Vault-Specific Metrics

### Vault ROI

**Definition:** Return on initial capital for the vault.

**Formula:**

```
ROI = ((Current Balance - Initial Balance) / Initial Balance) × 100%
```

**Example:**

```
Initial: $10,000
Current: $12,500
ROI: 25%
```

### Time to Deadline

**Definition:** Days remaining until deal ends.

**Displayed as:**

* "15 days remaining"
* "2 hours remaining"
* "Expired" (if past deadline)

### Oracle Freshness

**Definition:** Time since last balance update.

**Status:**

* Fresh: <5 min
* Warning: 5-10 min
* Stale: >10 min (trading blocked)

## Position Metrics

### Leverage

**Definition:** Position size relative to account equity.

**Formula:**

```
Leverage = Position Value / Account Equity
```

**Example:**

```
Position: 1.0 BTC @ $50,000 = $50,000
Equity: $10,000
Leverage: 5x
```

### Liquidation Distance

**Definition:** How far price can move before liquidation.

**Percentage:**

```
Liquidation Distance = ((Current Price - Liquidation Price) / Current Price) × 100%
```

**Example:**

```
Current Price: $50,000
Liquidation Price: $42,000
Distance: 16%
```

**Warning Levels:**

* > 20%: Safe
* 10-20%: Monitor
* 5-10%: Warning
* <5%: Critical

## Time-Based Metrics

### Holding Time

**Average:**

```
Average Holding Time = Total Time in Positions / Number of Trades
```

**Use:** Identifies trading style (scalping vs swing trading).

### Trading Frequency

**Trades per Day:**

```
Frequency = Total Trades / Number of Days
```

**Example:**

```
Total Trades: 150
Days: 30
Frequency: 5 trades/day
```

## Fee Analysis

### Total Fees Paid

**Components:**

* Trading fees (maker/taker)
* Gas fees (withdrawals, closes)
* Funding fees (perpetual positions)

### Fee Impact on PnL

**Net Profit After Fees:**

```
Net = Gross Profit - Total Fees
```

**Fee Percentage:**

```
Fee % = (Total Fees / Total Volume) × 100%
```

## Related Pages

* [Dashboard Overview](/analytics/dashboard-overview.md) - Navigate the dashboard
* [Exporting Data](/analytics/exporting-data.md) - Download metrics
* [Risk Controls](/trading/risk-controls.md) - Understand risk limits


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.atract.app/analytics/metrics-explained.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
