> ## 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.

# Prompt Strategies

> Build trading strategies using natural language and LLMs

Prompt strategies let you define trading logic in natural language. At execution time, Hyperoru injects live market context into your template and sends it to an LLM, which returns a structured trading decision.

## How it works

```mermaid theme={null}
graph LR
    A[Prompt Template] --> B[Context Injection]
    B --> C[LLM Call]
    C --> D[Parse Decision]
    D --> E[Execute Order]
    F[Market Data] --> B
    G[Positions] --> B
    H[News] --> B
```

1. A trigger (signal or schedule) fires
2. The system loads the prompt template and replaces variables with live data
3. The enriched prompt is sent to the trader's configured LLM
4. The LLM response is parsed into a structured trading decision
5. The decision is validated, risk-checked, and executed

## Creating a prompt

```bash theme={null}
curl -X POST https://api.production.hyperoru.com/api/prompts \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "BTC Trend Follower",
    "content": "You are a cryptocurrency trader. Analyze the current market data and decide whether to open a position.\n\nCurrent prices:\n{market_prices}\n\nRecent market snapshots:\n{sampling_data}\n\nOpen positions:\n{open_positions}\n\nMarket regime: {market_regime}\n\nRespond with a JSON object containing: operation (long/short/hold), symbol, leverage, take_profit_pct, stop_loss_pct, and reasoning."
  }'
```

## Template variables

Use these placeholders in your prompt content. They are replaced with live data at execution time.

| Variable                 | Content                                                           |
| ------------------------ | ----------------------------------------------------------------- |
| `{market_prices}`        | Current bid/ask prices for all watchlist symbols                  |
| `{sampling_data}`        | Rolling window of market snapshots from the sampling pool         |
| `{trigger_context}`      | Metadata about the signal or schedule that triggered execution    |
| `{open_positions}`       | Active positions with entry price, size, unrealized PnL           |
| `{recent_trades}`        | Recent trade history for context on past decisions                |
| `{market_regime}`        | Current regime classification (trending, ranging, volatile, calm) |
| `{news_context}`         | Latest AI-classified news summaries                               |
| `{kline_data}`           | Recent candlestick data at the configured timeframe               |
| `{technical_indicators}` | RSI, MACD, Bollinger Bands, and other computed indicators         |

<Tip>
  You don't need to use every variable. Include only the context relevant to your strategy. Smaller prompts are faster and cheaper to execute.
</Tip>

## Binding prompts to traders

Connect a prompt to a trader via a binding. The binding specifies the trigger type:

<CodeGroup>
  ```bash Signal-triggered binding theme={null}
  curl -X POST https://api.production.hyperoru.com/api/bindings \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "trader_id": "trader-uuid",
      "prompt_id": "prompt-uuid",
      "trigger_type": "signal",
      "signal_pool_id": "pool-uuid",
      "symbols": ["BTC", "ETH"]
    }'
  ```

  ```bash Scheduled binding theme={null}
  curl -X POST https://api.production.hyperoru.com/api/bindings \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "trader_id": "trader-uuid",
      "prompt_id": "prompt-uuid",
      "trigger_type": "scheduled",
      "interval_minutes": 15,
      "symbols": ["BTC"]
    }'
  ```
</CodeGroup>

## AI-assisted prompt creation

Use the HyperAI agent to help write prompts by describing your strategy in plain language:

```bash theme={null}
curl -X POST https://api.production.hyperoru.com/api/hyper-ai/chat \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Create a prompt strategy that buys BTC when RSI is below 30 and the market regime is trending up, with 3x leverage and 5% take profit"
  }'
```

HyperAI generates a complete prompt template with the appropriate variables and response format.

## Prompt design tips

<CardGroup cols={2}>
  <Card title="Be specific about output format" icon="list-check">
    Always specify the exact JSON fields you expect in the response. LLMs produce more reliable structured output when the format is explicit.
  </Card>

  <Card title="Include reasoning" icon="brain">
    Ask the LLM to explain its reasoning. This creates an audit trail and helps you identify when the model misinterprets data.
  </Card>

  <Card title="Set clear boundaries" icon="shield">
    Define what the model should NOT do — e.g., "Never use leverage above 5x" or "Only trade BTC and ETH."
  </Card>

  <Card title="Test with backtesting" icon="clock-rotate-left">
    Use [prompt backtesting](/trading/backtesting) to evaluate how your prompt would have performed on historical data.
  </Card>
</CardGroup>
