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

# Autonomous Decision Loop

> The meta-loop: research, hypothesize, backtest, deploy, monitor, improve.

The Autonomous Decision Loop is the brain of the system - the continuous cycle where the LLM researches markets, forms hypotheses, tests them, deploys strategies, monitors results, and learns from outcomes.

## The Loop

<Steps>
  <Step title="Research">
    Scan markets, aggregate signals from LLM forecasts, oracles, wallet consensus, and technical indicators.
  </Step>

  <Step title="Hypothesize">
    Form a thesis: "Market X is mispriced because Y." Score confidence.
  </Step>

  <Step title="Backtest">
    Run automated backtest with robustness checks (permutation, walk-forward, CPCV).
  </Step>

  <Step title="Deploy">
    Start in staging (paper mode), then promote to live if performance holds.
  </Step>

  <Step title="Monitor">
    Track P\&L, health, edge decay, and execution quality in real time.
  </Step>

  <Step title="Improve">
    Adjust parameters, retire losers, scale winners. Loop back to Research.
  </Step>
</Steps>

Each iteration of this loop is logged with full reasoning for audit.

## Research Pipeline

The LLM periodically scans the market universe for opportunities.

```python theme={null}
# Scan for opportunities via MCP
opportunities = research.scan(
    universe=fund.market_universe,
    signals=["llm_forecast", "oracle", "wallet_consensus"],
    min_edge=0.05,
    min_liquidity=1000,
)
# Returns ranked opportunities with evidence
```

### Signal Aggregation

Multiple signal sources are combined:

| Signal           | Source                   | Weight     |
| ---------------- | ------------------------ | ---------- |
| LLM Forecast     | llm\_forecast()          | Primary    |
| Oracle Edge      | scan\_edges()            | Secondary  |
| Wallet Consensus | compute\_consensus()     | Confirming |
| Technical        | regime\_signal, momentum | Timing     |
| Sentiment        | llm\_scan() with news    | Confirming |

## Automated Backtest-to-Deploy

When the LLM identifies an opportunity, it constructs a strategy, backtests it, and deploys if it passes checks.

### Deploy Decision Criteria

| Criterion                | Threshold                  | Rationale                    |
| ------------------------ | -------------------------- | ---------------------------- |
| Sharpe ratio             | > 1.0                      | Minimum risk-adjusted return |
| Total trades             | > 30                       | Statistical significance     |
| Robustness p-value       | \< 0.05                    | Not due to luck              |
| Walk-forward consistency | > 60% OOS windows positive | Not overfit                  |
| Max drawdown             | \< 20%                     | Acceptable worst case        |

```python theme={null}
# Backtest-to-deploy flow
hypothesis = research.best_opportunity()
result = backtest(hypothesis.to_strategy(), data=historical_data)

if result.passes_criteria(min_sharpe=1.0, min_trades=30, max_drawdown=0.20):
    robustness = robustness_test(result)
    if robustness.combined_p_value < 0.05:
        controller.deploy(hypothesis.to_strategy(), mode="staging")
```

## Memory & Learning

The LLM has persistent memory across sessions to avoid repeating mistakes.

### What Gets Stored

| Memory Type              | Example                                                         |
| ------------------------ | --------------------------------------------------------------- |
| **Strategy performance** | "MM on crypto markets averaged Sharpe 1.8 in Q1"                |
| **Market-type models**   | "Political markets are mean-reverting before elections"         |
| **Regime mappings**      | "High-vol regime: widen spreads, reduce directional"            |
| **Edge decay**           | "Wallet copy-trading edge decayed from 15% to 3% over 60 days"  |
| **Failure reasons**      | "Directional on sports markets failed due to resolution timing" |

### Learning Feedback

After monitoring for N days, the system diagnoses and records outcomes:

<CardGroup cols={2}>
  <Card title="Profitable" icon="circle-check">
    Record the success pattern and scale up capital allocation.
  </Card>

  <Card title="Regime Changed" icon="cloud-sun">
    Record regime sensitivity. Adjust strategy for new conditions.
  </Card>

  <Card title="Liquidity Dried Up" icon="droplet-slash">
    Record minimum liquidity requirement for this market type.
  </Card>

  <Card title="Edge Was Spurious" icon="ghost">
    Record false positive. Tighten backtest criteria for similar markets.
  </Card>

  <Card title="Execution Was Poor" icon="gauge-low">
    Adjust execution parameters (spread, size, timing).
  </Card>
</CardGroup>

## Continuous Improvement

The loop isn't just deploy-and-forget. Active strategies are continuously monitored and adjusted.

| Action                     | Trigger                                         |
| -------------------------- | ----------------------------------------------- |
| **Re-optimize parameters** | Weekly, or when performance drops               |
| **Mutate strategy**        | Try small variations on successful strategies   |
| **Prune dead strategies**  | No edge detected for N consecutive days         |
| **Rebalance capital**      | Shift from fading strategies to growing ones    |
| **Update models**          | New market resolution provides calibration data |

## MCP Tools

| Tool                      | Description                                                 |
| ------------------------- | ----------------------------------------------------------- |
| `backtest_hypothesis`     | Backtest a strategy idea, return results + robustness       |
| `decision_log`            | View recent autonomous decisions with reasoning             |
| `learning_summary`        | What the system has learned (successful patterns, failures) |
| `improvement_suggestions` | Recommended parameter changes based on recent performance   |
