pnl
Calculate Profit & Loss by combining realized and unrealized gains into a single financial summary for trading analysis.
Instructions
Generate a Profit & Loss (P&L) summary.
Combines realized and unrealized gains into a single financial overview.
Returns: A dictionary with keys 'realized' and 'unrealized' representing the total gains.
Example: pnl() -> {"realized": 320.75, "unrealized": 145.60}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- trader_tools.py:185-200 (handler)The `pnl` tool is defined as an MCP tool using the `@mcp.tool()` decorator. It calculates the Profit & Loss summary by calling `realized_gains()` and summing the results of `unrealized_gains()`.
@mcp.tool() def pnl() -> dict[str, float]: """Generate a Profit & Loss (P&L) summary. Combines realized and unrealized gains into a single financial overview. Returns: A dictionary with keys 'realized' and 'unrealized' representing the total gains. Example: pnl() -> {"realized": 320.75, "unrealized": 145.60} """ return { 'realized': realized_gains(), 'unrealized': sum(unrealized_gains().values()) }