Skip to main content

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.

Validation checks whether strategy JSON is structurally safe and internally consistent. The builder validates before treating a strategy as ready. You should fix every validation error before running, sharing, or generating strategy JSON for another system.

Shape rules

The top-level strategy must be an object with these fields:
  • version
  • strategy_id
  • initial_principal_usd
  • root_node_id
  • nodes
  • edges
  • decision_groups
nodes, edges, and decision_groups must be arrays. initial_principal_usd must be a finite number greater than 0.

Node rules

Every node needs a unique node_id. Every node must have type: "CONDITION" or type: "ACTION". Every node must have level >= 0. root_node_id must reference an existing node. Market actions require target.market.token_id.

Edge rules

Edges only encode continuation from an action to a later condition. Valid edge direction:
ACTION -> CONDITION
Invalid edge directions:
ACTION -> ACTION
CONDITION -> CONDITION
CONDITION -> ACTION
Condition-to-action selection belongs in decision_groups, not edges.

Level rules

The root node is level 0. A condition and its selected actions must have the same level. When an action continues to a child condition, the child condition level must be the action level plus 1.

Decision group rules

Every condition must appear in exactly one decision group. Every decision group must reference one condition and at least one action. The decision group condition and actions must all be on the same level. If mode is SPLIT_100, the referenced actions must have allocation_pct values that sum to 100.

Timing rules

TIME_SINCE_GROUP_SECONDS requires a timing object. For BEFORE_CLOSE, seconds_before_close must be greater than 0. For ABSOLUTE_TIME, absolute_trigger_time_iso must be present. Non-time signals must not include timing.

Graph rules

The graph must be acyclic. A strategy cannot loop back to a prior node.

Fee-aware principal check

For market actions, validation can estimate the minimum initial_principal_usd needed to clear market order minimums after allocation splits and estimated fees. The estimate uses:
ValueMeaning
CLOB_MIN_USDMinimum order size in dollars.
CLOB_MIN_SHARESMinimum number of shares.
MAX_TRADING_FEE_RATEConservative fee estimate.
DEFAULT_LEAF_PRICEFallback price when no current price is supplied.
If validation reports that principal is too low, increase initial_principal_usd, reduce split depth, or provide accurate current_price values for market targets.

Common errors

Error patternFix
nodes must be an arraySet nodes to an array, even for generated JSON.
root_node_id does not reference an existing nodeMake root_node_id match a node_id.
must be ACTION -> CONDITIONMove condition-to-action relationships into decision_groups.
split allocation is ..., expected 100Adjust action allocation_pct values.
requires target.market.token_idAdd the outcome token ID to the market action.
Graph contains a cycleRemove the edge that loops back to an earlier node.

Agent checklist

Before returning generated strategy JSON, verify:
  • initial_principal_usd > 0.
  • root_node_id exists in nodes.
  • Every node_id is unique.
  • Every condition has exactly one decision group.
  • Every decision group action ID exists and references an action.
  • Every split group sums to 100.
  • Every edge is action-to-condition.
  • No cycle exists.
  • Every market action has token_id.