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

# Strategy JSON format

> Reference the portable Miramarket strategy JSON structure.

Strategy JSON is the portable external representation of a Miramarket strategy.

It is designed to be readable by humans and deterministic enough for AI agents to generate safely.

## Top-level object

```json theme={null}
{
  "version": "1.1.0",
  "strategy_id": "example_strategy",
  "initial_principal_usd": 100,
  "root_node_id": "condition_entry",
  "nodes": [],
  "edges": [],
  "decision_groups": []
}
```

| Field                   | Type    | Required | Meaning                                            |
| ----------------------- | ------- | -------- | -------------------------------------------------- |
| `version`               | string  | Yes      | Strategy JSON version.                             |
| `strategy_id`           | string  | Yes      | Stable strategy identifier.                        |
| `initial_principal_usd` | number  | Yes      | Starting capital in USD. Must be greater than `0`. |
| `root_node_id`          | string  | Yes      | `node_id` of the root node.                        |
| `nodes`                 | array   | Yes      | Condition and action nodes.                        |
| `edges`                 | array   | Yes      | Action-to-condition continuation edges.            |
| `decision_groups`       | array   | Yes      | Condition-to-action selection groups.              |
| `is_demo`               | boolean | No       | When `true`, skips the fee-aware principal check.  |

## Nodes

Each node is either a `CONDITION` or an `ACTION`.

```json theme={null}
{
  "node_id": "condition_entry",
  "type": "CONDITION",
  "level": 0,
  "condition": {}
}
```

```json theme={null}
{
  "node_id": "buy_yes",
  "type": "ACTION",
  "level": 0,
  "action": {}
}
```

| Field       | Type   | Required            | Meaning                                    |
| ----------- | ------ | ------------------- | ------------------------------------------ |
| `node_id`   | string | Yes                 | Unique node identifier.                    |
| `type`      | string | Yes                 | `CONDITION` or `ACTION`.                   |
| `level`     | number | Yes                 | Graph level. Must be `0` or greater.       |
| `condition` | object | For condition nodes | Decision logic.                            |
| `action`    | object | For action nodes    | Capital movement or execution instruction. |

## Condition object

```json theme={null}
{
  "watch": {
    "venue": "POLYMARKET",
    "market_id": "btc-above-100k-may-2026",
    "outcome_token": "YES",
    "token_id": "1234567890"
  },
  "signal": "IMPLIED_PROBABILITY",
  "trigger": "CROSS_ABOVE",
  "threshold": 0.6
}
```

| Field         | Type   | Required         | Meaning                                   |
| ------------- | ------ | ---------------- | ----------------------------------------- |
| `watch`       | object | Yes              | Market or selector to observe.            |
| `signal`      | string | Yes              | Signal type.                              |
| `trigger`     | string | Yes              | `CROSS_ABOVE` or `CROSS_BELOW`.           |
| `threshold`   | number | Yes              | Trigger threshold.                        |
| `timing`      | object | For time signals | Timing details.                           |
| `reference`   | object | No               | Reference mode for return or PnL signals. |
| `stabilizers` | object | No               | Hysteresis or cooldown settings.          |
| `conjuncts`   | array  | No               | Additional `AND` clauses.                 |

## Action object

```json theme={null}
{
  "action_type": "BUY_MARKET_OUTCOME",
  "allocation_pct": 100,
  "target": {
    "venue": "POLYMARKET",
    "market": {
      "market_id": "btc-above-100k-may-2026",
      "outcome_token": "YES",
      "token_id": "1234567890"
    }
  }
}
```

| Field            | Type   | Required                       | Meaning                          |
| ---------------- | ------ | ------------------------------ | -------------------------------- |
| `action_type`    | string | Yes                            | Action to perform.               |
| `allocation_pct` | number | Required in `SPLIT_100` groups | Percentage of selected capital.  |
| `target`         | object | Yes                            | Market, wallet, or vault target. |
| `risk_guards`    | object | No                             | Execution guardrails.            |

## Edges

Edges represent continuation after an action.

```json theme={null}
{
  "edge_id": "edge_1",
  "from_node_id": "buy_yes",
  "to_node_id": "condition_exit"
}
```

Edges must always be action-to-condition.

## Decision groups

Decision groups represent condition-to-action selection.

```json theme={null}
{
  "group_id": "entry_group",
  "condition_node_id": "condition_entry",
  "action_node_ids": ["buy_yes", "hold_cash"],
  "level": 0,
  "mode": "SPLIT_100"
}
```

| Field               | Type   | Required | Meaning                                           |
| ------------------- | ------ | -------- | ------------------------------------------------- |
| `group_id`          | string | Yes      | Unique decision group identifier.                 |
| `condition_node_id` | string | Yes      | Condition node that selects actions.              |
| `action_node_ids`   | array  | Yes      | Actions selected by the condition.                |
| `level`             | number | Yes      | Same level as the condition and selected actions. |
| `mode`              | string | Yes      | `SINGLE` or `SPLIT_100`.                          |
| `priority_order`    | array  | No       | Ordered action IDs for priority-aware selection.  |

## Relationship model

Use `decision_groups` for condition-to-action relationships.

Use `edges` only for action-to-condition continuation.

```text theme={null}
condition_entry --decision group--> buy_yes
buy_yes --edge--> condition_exit
condition_exit --decision group--> sell_yes
```

This separation makes the graph unambiguous for humans and AI agents.
