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

# Analytics

> Trade performance analysis, AI attribution, and strategy evaluation

Hyperoru's analytics system provides comprehensive performance measurement across every dimension of your trading — by strategy, account, symbol, trigger type, and AI decision quality.

## Overview

Every trade is recorded with full context: the strategy that generated it, the signals that triggered it, the AI reasoning, entry/exit conditions, and resulting PnL. Analytics aggregate this data into actionable insights.

```bash theme={null}
curl "https://api.production.hyperoru.com/api/analytics/summary" \
  -H "Authorization: Bearer $TOKEN"
```

```json theme={null}
{
  "total_pnl": 4523.80,
  "total_trades": 312,
  "win_rate": 0.58,
  "sharpe_ratio": 1.42,
  "max_drawdown_pct": 12.3,
  "best_trade_pnl": 890.50,
  "worst_trade_pnl": -340.20,
  "avg_trade_duration_hours": 8.4
}
```

## Analytics dimensions

<Tabs>
  <Tab title="By Strategy">
    Compare the performance of different prompts and programs:

    ```bash theme={null}
    curl "https://api.production.hyperoru.com/api/analytics/by-strategy" \
      -H "Authorization: Bearer $TOKEN"
    ```

    | Metric    | BTC Momentum (Prompt) | RSI Reversion (Program) | Breakout Hunter (Prompt) |
    | --------- | --------------------- | ----------------------- | ------------------------ |
    | Trades    | 89                    | 145                     | 78                       |
    | Win Rate  | 62%                   | 55%                     | 68%                      |
    | Total PnL | \$2,100               | \$1,200                 | \$1,223                  |
    | Sharpe    | 1.8                   | 1.1                     | 2.1                      |
  </Tab>

  <Tab title="By Account">
    Evaluate performance across different trader accounts:

    ```bash theme={null}
    curl "https://api.production.hyperoru.com/api/analytics/by-account" \
      -H "Authorization: Bearer $TOKEN"
    ```

    Useful when running multiple traders with different risk profiles or exchange configurations.
  </Tab>

  <Tab title="By Symbol">
    Identify which symbols your strategies perform best on:

    ```bash theme={null}
    curl "https://api.production.hyperoru.com/api/analytics/by-symbol" \
      -H "Authorization: Bearer $TOKEN"
    ```

    | Symbol | Trades | Win Rate | Total PnL | Avg PnL/Trade |
    | ------ | ------ | -------- | --------- | ------------- |
    | BTC    | 134    | 61%      | \$2,800   | \$20.89       |
    | ETH    | 98     | 55%      | \$1,100   | \$11.22       |
    | SOL    | 80     | 58%      | \$623     | \$7.79        |
  </Tab>

  <Tab title="By Operation">
    Break down performance by trade direction:

    ```bash theme={null}
    curl "https://api.production.hyperoru.com/api/analytics/by-operation" \
      -H "Authorization: Bearer $TOKEN"
    ```

    | Direction | Trades | Win Rate | Avg PnL |
    | --------- | ------ | -------- | ------- |
    | Long      | 198    | 60%      | \$18.50 |
    | Short     | 114    | 54%      | \$8.20  |
  </Tab>

  <Tab title="By Trigger Type">
    Compare signal-triggered vs scheduled strategy performance:

    ```bash theme={null}
    curl "https://api.production.hyperoru.com/api/analytics/by-trigger" \
      -H "Authorization: Bearer $TOKEN"
    ```

    | Trigger   | Trades | Win Rate | Sharpe |
    | --------- | ------ | -------- | ------ |
    | Signal    | 187    | 62%      | 1.7    |
    | Scheduled | 125    | 52%      | 0.9    |
  </Tab>
</Tabs>

## AI attribution analysis

For prompt-based strategies, Hyperoru analyzes the quality of AI trading decisions:

```bash theme={null}
curl "https://api.production.hyperoru.com/api/analytics/ai-attribution?trader_id=trader-uuid" \
  -H "Authorization: Bearer $TOKEN"
```

| Metric                  | Description                                                   |
| ----------------------- | ------------------------------------------------------------- |
| **Decision accuracy**   | Percentage of AI decisions that resulted in profitable trades |
| **Reasoning quality**   | Correlation between stated confidence and actual outcomes     |
| **Context utilization** | Which template variables most influenced profitable decisions |
| **Model comparison**    | Side-by-side performance when using different LLM models      |
| **Regime performance**  | AI accuracy broken down by market regime                      |

<Tip>
  Use AI attribution to identify which market conditions your LLM excels at and where it struggles. This guides prompt refinement and model selection.
</Tip>

## Program analytics

For program strategies, analytics include execution metrics alongside performance:

| Metric                    | Description                                           |
| ------------------------- | ----------------------------------------------------- |
| **Execution time**        | Average and p99 Python execution duration             |
| **Decision distribution** | Breakdown of hold vs long vs short decisions          |
| **Factor correlation**    | Which factors most influenced profitable decisions    |
| **Backtest alignment**    | How closely live performance matches backtest results |

```bash theme={null}
curl "https://api.production.hyperoru.com/api/analytics/program?program_id=program-uuid" \
  -H "Authorization: Bearer $TOKEN"
```

## Trade replay

Replay individual trades to understand the decision context at the time of execution:

```bash theme={null}
curl "https://api.production.hyperoru.com/api/analytics/trades/{trade_id}/replay" \
  -H "Authorization: Bearer $TOKEN"
```

The replay includes:

<AccordionGroup>
  <Accordion title="Market snapshot">
    Price data, indicators, and regime classification at the time the decision was made.
  </Accordion>

  <Accordion title="Strategy input">
    The full prompt (with injected variables) sent to the LLM, or the program input data.
  </Accordion>

  <Accordion title="AI response / program output">
    The raw decision output including reasoning.
  </Accordion>

  <Accordion title="Execution details">
    Order placement timestamps, fill prices, slippage, and fees.
  </Accordion>

  <Accordion title="Outcome">
    Position lifecycle from entry to exit, including TP/SL triggers and final PnL.
  </Accordion>
</AccordionGroup>

<Note>
  Trade replay is invaluable for debugging underperforming strategies. Review the AI reasoning alongside the market context to identify patterns of errors.
</Note>

## Time range filtering

All analytics endpoints support time range filtering:

```bash theme={null}
curl "https://api.production.hyperoru.com/api/analytics/summary?from=2025-07-01&to=2025-07-15" \
  -H "Authorization: Bearer $TOKEN"
```

This lets you evaluate performance over specific periods, compare weeks or months, and isolate the impact of strategy changes.
