> For the complete documentation index, see [llms.txt](https://docs.hipersnipe.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hipersnipe.com/features/analytics-pnl.md).

# Analytics and PnL

## Access

| Screen                          | How to open                                                                                                |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| **Trade Journal** (recommended) | Main menu → **📊 Trade Journal**                                                                           |
| **Analytics & PnL**             | `analytics_menu` callback — handler exists in `handlers/analytics_ui.py` but **no main-menu button** today |

Use **Trade Journal** for lifetime stats and recent closes. This page documents the underlying PnL math used across the bot.

## Analytics dashboard metrics

When `analytics_menu` is opened:

| Metric             | Description                              |
| ------------------ | ---------------------------------------- |
| Total realized PnL | Sum of closed trade profits/losses (SOL) |
| Win rate           | % of profitable closed cycles            |
| Last 5 trades      | Symbol, PnL %, quick history             |

## PnL calculation (`pnl_tracker.py`)

### Cycle model

Trades are grouped into **position cycles**. A new cycle starts when you buy after fully closing a position (balance → dust).

| Metric           | Formula                                                  |
| ---------------- | -------------------------------------------------------- |
| Total Invested   | Sum of SOL spent on buys in current cycle                |
| Total Realized   | Sum of SOL received from sells in current cycle          |
| Total Unrealized | Current holdings value in SOL minus remaining cost basis |
| Net Open PnL     | (Realized + Unrealized) − Invested                       |
| Net Open PnL %   | Net Open PnL / Invested × 100                            |

### Partial sells and DCA

Partial take-profits do **not** reset the cycle. Additional buys (DCA) add to the same cycle's invested total. The Trading UI **Chart** line reflects full-cycle realized and unrealized values.

## PnL share cards

See [PnL sharing and social cards](/features/pnl-sharing.md) for branded images, community broadcasts, and Twitter integration.

## Entry market cap

Average entry MC is derived from execution data:

```
entry_mc = (invested_sol / buy_tokens) × total_supply × sol_usd
```

Pump.fun tokens use 1B supply for MC display consistency.

## Related

* [Trade Journal](/features/trade-journal.md)
* [Trading UI](/features/trading-ui.md)
* [Leaderboard and tournament](/features/leaderboard-tournament.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.hipersnipe.com/features/analytics-pnl.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
