Shape check
Use the shape check when input may not be a strategy object yet. It verifies that the top-level value is an object and that required top-level fields have the expected primitive shape.Input
Any unknown value.Success
The value can be treated as strategy JSON for deeper validation.Failure
The shape check throws a domain error with a message that starts withStrategy shape:.
Common messages include:
| Message | Meaning |
|---|---|
Strategy shape: expected an object. | The input is not an object. |
Strategy shape: nodes must be an array. | nodes is missing or not an array. |
Strategy shape: edges must be an array. | edges is missing or not an array. |
Strategy shape: decision_groups must be an array. | decision_groups is missing or not an array. |
Strategy shape: initial_principal_usd must be a finite number. | initial_principal_usd is missing, non-numeric, or not finite. |
Semantic validation
Use semantic validation after shape checking. Semantic validation returns an array of error strings. An empty array means the strategy passed public validation.Input
A strategy JSON object.Options
| Option | Meaning |
|---|---|
skipFeeAwareCheck | When true, skip the fee-aware principal check. |
is_demo: true.
Output
Fee-aware sizing
Fee-aware sizing estimates the minimuminitial_principal_usd needed for every reachable leaf market action.
It accounts for:
- Allocation splits.
- Action depth.
- Conservative fee assumptions.
- Minimum dollar order size.
- Minimum share order size.
- Current price when provided.
- A fallback price when no current price is provided.
Result fields
| Field | Meaning |
|---|---|
requiredPrincipalUsd | Minimum required starting principal. |
worstLeafId | node_id of the limiting leaf action. |
worstLeafLabel | Label used in the validation message. |
worstLeafRawMinUsd | Raw minimum order size for that leaf before fee scaling. |
worstLeafPrice | Price used in the calculation. |
worstLeafPriceIsDefault | Whether the fallback price was used. |
null.
Public constants
| Name | Value | Meaning |
|---|---|---|
CLOB_MIN_USD | 1 | Minimum order size in USD. |
CLOB_MIN_SHARES | 5 | Minimum shares per order. |
DEFAULT_LEAF_PRICE | 0.50 | Fallback price used when current_price is absent. |
MAX_TRADING_FEE_RATE | 0.06 | Conservative fee rate used for design-time sizing. |
Recommended validation flow
- Parse JSON.
- Run the shape check.
- Run semantic validation.
- If errors are returned, show every error to the user or agent.
- Treat an empty error array as valid.
Agent guidance
When generating or repairing strategy JSON:- Do not suppress semantic errors.
- Preserve exact field names from the JSON format.
- If fee-aware sizing fails, increase
initial_principal_usdinstead of removing market actions. - Use
is_demo: trueonly when the strategy is explicitly a demo.