Test a plain-words trading rule on historical prices and compare the trades with SPY. Not advice.
Maintain this server? Claim it
Call this server's tools from your browser. Nothing to install.
Requests go through mcptry because browsers can't call most MCP servers directly. Header values are sent to the server for that request only and are never stored or logged.
Tool list from our last check. Connect live to refresh it.
Build named time series from a run form. Needs version, data, and series.
Pick your client. Values in capitals, like YOUR_TOKEN, are yours to fill in.
Run in a terminal
claude mcp add --transport http backtester https://backtester.daenadigital.com/mcp
Build named time series from a run form. Needs version, data, and series.
| Argument | Type | Description |
|---|---|---|
| run* | object |
{
"type": "object",
"required": [
"run"
],
"properties": {
"run": {
"type": "object",
"$schema": "http://json-schema.org/draft-07/schema#",
"required": [
"version",
"data"
],
"properties": {
"data": {
"type": "object",
"required": [
"tickers",
"start",
"end",
"source"
],
"properties": {
"end": {
"type": "string"
},
"start": {
"type": "string"
},
"source": {
"enum": [
"price-api",
"intraday-api"
],
"type": "string"
},
"tickers": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"minItems": 1
},
"interval": {
"enum": [
"1min",
"5min",
"15min",
"30min",
"1hour"
],
"type": "string"
}
},
"additionalProperties": false
},
"money": {
"type": "object",
"required": [
"capital"
],
"properties": {
"capital": {
"type": "number",
"exclusiveMinimum": 0
},
"benchmark": {
"type": "string",
"const": "SPY",
"default": "SPY"
}
},
"additionalProperties": false
},
"series": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"required": [
"id",
"op",
"ticker",
"field",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "price"
},
"lag": {
"type": "integer",
"minimum": 0
},
"field": {
"enum": [
"open",
"high",
"low",
"close",
"volume"
],
"type": "string"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"points",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "observations"
},
"lag": {
"type": "integer",
"minimum": 0
},
"points": {
"type": "array",
"items": {
"type": "object",
"required": [
"observedAt",
"knownAt",
"value"
],
"properties": {
"value": {
"type": "number"
},
"knownAt": {
"anyOf": [
{
"type": "string"
},
{
"type": "string"
}
]
},
"observedAt": {
"anyOf": [
{
"type": "string"
},
{
"type": "string"
}
]
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"agg",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "session"
},
"agg": {
"enum": [
"sum",
"high",
"low",
"first"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"bars": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"description": "Running sum, high, low, or first value since the session start. With bars, only the first bars of each session count; the value is null until they finish, then held for the rest of the session.",
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "lag"
},
"lag": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"window",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"average",
"high",
"low",
"sum",
"change",
"stddev"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"window": {
"type": "integer",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"window",
"alpha",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "smooth"
},
"lag": {
"type": "integer",
"minimum": 0
},
"alpha": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"window": {
"type": "integer",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"left",
"right",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"add",
"subtract",
"multiply",
"ratio",
"min",
"max"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"left": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"right": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"peers",
"order",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "rank"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"order": {
"enum": [
"ascending",
"descending"
],
"type": "string"
},
"peers": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"minItems": 2
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"price",
"direction",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "ratchet"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"price": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"direction": {
"enum": [
"up",
"down"
],
"type": "string"
}
},
"description": "A level that moves only one way. Up: the larger of input and its own prior value, and it restarts at input after the prior price closes below it. Down is the reverse. Use it for Supertrend style bands.",
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"kind",
"span",
"back",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "pivot"
},
"lag": {
"type": "integer",
"minimum": 0
},
"back": {
"type": "integer",
"minimum": 0
},
"kind": {
"enum": [
"high",
"low"
],
"type": "string"
},
"read": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"span": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"description": "Swing high or low of input: a value beyond the span values before it and not passed by the span values after it. Known only span bars later. back 0 is the latest swing, 1 the one before. read returns another series at that swing bar.",
"additionalProperties": false
}
]
},
"default": []
},
"signals": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"required": [
"id",
"op",
"left",
"right"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"above",
"below",
"crossAbove",
"crossBelow"
],
"type": "string"
},
"left": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"right": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"inputs"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"and",
"or"
],
"type": "string"
},
"inputs": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"minItems": 2
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "not"
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"field",
"values"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "calendar"
},
"field": {
"enum": [
"month",
"day",
"firstSessionOfMonth",
"utcMinute"
],
"type": "string"
},
"values": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
},
"minItems": 1
}
},
"additionalProperties": false
}
]
},
"default": []
},
"version": {
"type": "number",
"const": 2
},
"simulation": {
"type": "object",
"required": [
"fillTiming"
],
"properties": {
"feeBps": {
"type": "number",
"default": 0,
"maximum": 10000,
"minimum": 0
},
"sleeves": {
"type": "array",
"items": {
"type": "object",
"required": [
"weight"
],
"properties": {
"weight": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"positions": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"direction",
"enter",
"size"
],
"properties": {
"add": {
"type": "object",
"required": [
"distance",
"maxUnits"
],
"properties": {
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxUnits": {
"type": "integer",
"minimum": 2,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"exit": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"size": {
"anyOf": [
{
"type": "object",
"required": [
"kind",
"fraction"
],
"properties": {
"kind": {
"type": "string",
"const": "fraction"
},
"fraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"kind",
"riskFraction",
"maxFraction",
"distance"
],
"properties": {
"kind": {
"type": "string",
"const": "risk"
},
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"riskFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
}
]
},
"enter": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"option": {
"type": "object",
"required": [
"right",
"strike",
"premium",
"expiry"
],
"properties": {
"right": {
"enum": [
"call",
"put"
],
"type": "string"
},
"expiry": {
"type": "string"
},
"strike": {
"type": "number",
"exclusiveMinimum": 0
},
"premium": {
"type": "number",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"direction": {
"enum": [
"long",
"short"
],
"type": "string"
},
"closeStopPct": {
"type": "number",
"maximum": 100,
"exclusiveMinimum": 0
},
"stopDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"trailDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
],
"description": "Trailing stop: distance below the highest high since entry for a long, or above the lowest low for a short. It moves only in the trade's favor and applies from the next bar."
},
"closeTargetPct": {
"type": "number",
"exclusiveMinimum": 0
},
"targetDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
"default": []
},
"allocation": {
"type": "object",
"required": [
"when",
"targets"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"targets": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"when",
"weight"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"weight": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
],
"description": "A number, or a series read on the rebalance date. A series weight must be 0 to 1."
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
"minItems": 1
},
"positions": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"direction",
"enter",
"size"
],
"properties": {
"add": {
"type": "object",
"required": [
"distance",
"maxUnits"
],
"properties": {
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxUnits": {
"type": "integer",
"minimum": 2,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"exit": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"size": {
"anyOf": [
{
"type": "object",
"required": [
"kind",
"fraction"
],
"properties": {
"kind": {
"type": "string",
"const": "fraction"
},
"fraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"kind",
"riskFraction",
"maxFraction",
"distance"
],
"properties": {
"kind": {
"type": "string",
"const": "risk"
},
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"riskFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
}
]
},
"enter": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"option": {
"type": "object",
"required": [
"right",
"strike",
"premium",
"expiry"
],
"properties": {
"right": {
"enum": [
"call",
"put"
],
"type": "string"
},
"expiry": {
"type": "string"
},
"strike": {
"type": "number",
"exclusiveMinimum": 0
},
"premium": {
"type": "number",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"direction": {
"enum": [
"long",
"short"
],
"type": "string"
},
"closeStopPct": {
"type": "number",
"maximum": 100,
"exclusiveMinimum": 0
},
"stopDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"trailDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
],
"description": "Trailing stop: distance below the highest high since entry for a long, or above the lowest low for a short. It moves only in the trade's favor and applies from the next bar."
},
"closeTargetPct": {
"type": "number",
"exclusiveMinimum": 0
},
"targetDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
"default": []
},
"allocation": {
"type": "object",
"required": [
"when",
"targets"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"targets": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"when",
"weight"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"weight": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
],
"description": "A number, or a series read on the rebalance date. A series weight must be 0 to 1."
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
},
"fillTiming": {
"enum": [
"nextOpen",
"nextClose"
],
"type": "string"
},
"slippageBps": {
"type": "number",
"default": 0,
"minimum": 0,
"exclusiveMaximum": 10000
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}Build named trading signals from a run form. Needs version, data, series, and signals.
| Argument | Type | Description |
|---|---|---|
| run* | object |
{
"type": "object",
"required": [
"run"
],
"properties": {
"run": {
"type": "object",
"$schema": "http://json-schema.org/draft-07/schema#",
"required": [
"version",
"data"
],
"properties": {
"data": {
"type": "object",
"required": [
"tickers",
"start",
"end",
"source"
],
"properties": {
"end": {
"type": "string"
},
"start": {
"type": "string"
},
"source": {
"enum": [
"price-api",
"intraday-api"
],
"type": "string"
},
"tickers": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"minItems": 1
},
"interval": {
"enum": [
"1min",
"5min",
"15min",
"30min",
"1hour"
],
"type": "string"
}
},
"additionalProperties": false
},
"money": {
"type": "object",
"required": [
"capital"
],
"properties": {
"capital": {
"type": "number",
"exclusiveMinimum": 0
},
"benchmark": {
"type": "string",
"const": "SPY",
"default": "SPY"
}
},
"additionalProperties": false
},
"series": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"required": [
"id",
"op",
"ticker",
"field",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "price"
},
"lag": {
"type": "integer",
"minimum": 0
},
"field": {
"enum": [
"open",
"high",
"low",
"close",
"volume"
],
"type": "string"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"points",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "observations"
},
"lag": {
"type": "integer",
"minimum": 0
},
"points": {
"type": "array",
"items": {
"type": "object",
"required": [
"observedAt",
"knownAt",
"value"
],
"properties": {
"value": {
"type": "number"
},
"knownAt": {
"anyOf": [
{
"type": "string"
},
{
"type": "string"
}
]
},
"observedAt": {
"anyOf": [
{
"type": "string"
},
{
"type": "string"
}
]
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"agg",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "session"
},
"agg": {
"enum": [
"sum",
"high",
"low",
"first"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"bars": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"description": "Running sum, high, low, or first value since the session start. With bars, only the first bars of each session count; the value is null until they finish, then held for the rest of the session.",
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "lag"
},
"lag": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"window",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"average",
"high",
"low",
"sum",
"change",
"stddev"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"window": {
"type": "integer",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"window",
"alpha",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "smooth"
},
"lag": {
"type": "integer",
"minimum": 0
},
"alpha": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"window": {
"type": "integer",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"left",
"right",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"add",
"subtract",
"multiply",
"ratio",
"min",
"max"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"left": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"right": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"peers",
"order",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "rank"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"order": {
"enum": [
"ascending",
"descending"
],
"type": "string"
},
"peers": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"minItems": 2
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"price",
"direction",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "ratchet"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"price": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"direction": {
"enum": [
"up",
"down"
],
"type": "string"
}
},
"description": "A level that moves only one way. Up: the larger of input and its own prior value, and it restarts at input after the prior price closes below it. Down is the reverse. Use it for Supertrend style bands.",
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"kind",
"span",
"back",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "pivot"
},
"lag": {
"type": "integer",
"minimum": 0
},
"back": {
"type": "integer",
"minimum": 0
},
"kind": {
"enum": [
"high",
"low"
],
"type": "string"
},
"read": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"span": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"description": "Swing high or low of input: a value beyond the span values before it and not passed by the span values after it. Known only span bars later. back 0 is the latest swing, 1 the one before. read returns another series at that swing bar.",
"additionalProperties": false
}
]
},
"default": []
},
"signals": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"required": [
"id",
"op",
"left",
"right"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"above",
"below",
"crossAbove",
"crossBelow"
],
"type": "string"
},
"left": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"right": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"inputs"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"and",
"or"
],
"type": "string"
},
"inputs": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"minItems": 2
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "not"
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"field",
"values"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "calendar"
},
"field": {
"enum": [
"month",
"day",
"firstSessionOfMonth",
"utcMinute"
],
"type": "string"
},
"values": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
},
"minItems": 1
}
},
"additionalProperties": false
}
]
},
"default": []
},
"version": {
"type": "number",
"const": 2
},
"simulation": {
"type": "object",
"required": [
"fillTiming"
],
"properties": {
"feeBps": {
"type": "number",
"default": 0,
"maximum": 10000,
"minimum": 0
},
"sleeves": {
"type": "array",
"items": {
"type": "object",
"required": [
"weight"
],
"properties": {
"weight": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"positions": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"direction",
"enter",
"size"
],
"properties": {
"add": {
"type": "object",
"required": [
"distance",
"maxUnits"
],
"properties": {
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxUnits": {
"type": "integer",
"minimum": 2,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"exit": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"size": {
"anyOf": [
{
"type": "object",
"required": [
"kind",
"fraction"
],
"properties": {
"kind": {
"type": "string",
"const": "fraction"
},
"fraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"kind",
"riskFraction",
"maxFraction",
"distance"
],
"properties": {
"kind": {
"type": "string",
"const": "risk"
},
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"riskFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
}
]
},
"enter": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"option": {
"type": "object",
"required": [
"right",
"strike",
"premium",
"expiry"
],
"properties": {
"right": {
"enum": [
"call",
"put"
],
"type": "string"
},
"expiry": {
"type": "string"
},
"strike": {
"type": "number",
"exclusiveMinimum": 0
},
"premium": {
"type": "number",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"direction": {
"enum": [
"long",
"short"
],
"type": "string"
},
"closeStopPct": {
"type": "number",
"maximum": 100,
"exclusiveMinimum": 0
},
"stopDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"trailDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
],
"description": "Trailing stop: distance below the highest high since entry for a long, or above the lowest low for a short. It moves only in the trade's favor and applies from the next bar."
},
"closeTargetPct": {
"type": "number",
"exclusiveMinimum": 0
},
"targetDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
"default": []
},
"allocation": {
"type": "object",
"required": [
"when",
"targets"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"targets": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"when",
"weight"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"weight": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
],
"description": "A number, or a series read on the rebalance date. A series weight must be 0 to 1."
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
"minItems": 1
},
"positions": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"direction",
"enter",
"size"
],
"properties": {
"add": {
"type": "object",
"required": [
"distance",
"maxUnits"
],
"properties": {
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxUnits": {
"type": "integer",
"minimum": 2,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"exit": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"size": {
"anyOf": [
{
"type": "object",
"required": [
"kind",
"fraction"
],
"properties": {
"kind": {
"type": "string",
"const": "fraction"
},
"fraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"kind",
"riskFraction",
"maxFraction",
"distance"
],
"properties": {
"kind": {
"type": "string",
"const": "risk"
},
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"riskFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
}
]
},
"enter": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"option": {
"type": "object",
"required": [
"right",
"strike",
"premium",
"expiry"
],
"properties": {
"right": {
"enum": [
"call",
"put"
],
"type": "string"
},
"expiry": {
"type": "string"
},
"strike": {
"type": "number",
"exclusiveMinimum": 0
},
"premium": {
"type": "number",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"direction": {
"enum": [
"long",
"short"
],
"type": "string"
},
"closeStopPct": {
"type": "number",
"maximum": 100,
"exclusiveMinimum": 0
},
"stopDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"trailDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
],
"description": "Trailing stop: distance below the highest high since entry for a long, or above the lowest low for a short. It moves only in the trade's favor and applies from the next bar."
},
"closeTargetPct": {
"type": "number",
"exclusiveMinimum": 0
},
"targetDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
"default": []
},
"allocation": {
"type": "object",
"required": [
"when",
"targets"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"targets": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"when",
"weight"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"weight": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
],
"description": "A number, or a series read on the rebalance date. A series weight must be 0 to 1."
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
},
"fillTiming": {
"enum": [
"nextOpen",
"nextClose"
],
"type": "string"
},
"slippageBps": {
"type": "number",
"default": 0,
"minimum": 0,
"exclusiveMaximum": 10000
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}Read historical prices for a run form. Needs only version and data.
| Argument | Type | Description |
|---|---|---|
| run* | object |
{
"type": "object",
"required": [
"run"
],
"properties": {
"run": {
"type": "object",
"$schema": "http://json-schema.org/draft-07/schema#",
"required": [
"version",
"data"
],
"properties": {
"data": {
"type": "object",
"required": [
"tickers",
"start",
"end",
"source"
],
"properties": {
"end": {
"type": "string"
},
"start": {
"type": "string"
},
"source": {
"enum": [
"price-api",
"intraday-api"
],
"type": "string"
},
"tickers": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"minItems": 1
},
"interval": {
"enum": [
"1min",
"5min",
"15min",
"30min",
"1hour"
],
"type": "string"
}
},
"additionalProperties": false
},
"money": {
"type": "object",
"required": [
"capital"
],
"properties": {
"capital": {
"type": "number",
"exclusiveMinimum": 0
},
"benchmark": {
"type": "string",
"const": "SPY",
"default": "SPY"
}
},
"additionalProperties": false
},
"series": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"required": [
"id",
"op",
"ticker",
"field",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "price"
},
"lag": {
"type": "integer",
"minimum": 0
},
"field": {
"enum": [
"open",
"high",
"low",
"close",
"volume"
],
"type": "string"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"points",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "observations"
},
"lag": {
"type": "integer",
"minimum": 0
},
"points": {
"type": "array",
"items": {
"type": "object",
"required": [
"observedAt",
"knownAt",
"value"
],
"properties": {
"value": {
"type": "number"
},
"knownAt": {
"anyOf": [
{
"type": "string"
},
{
"type": "string"
}
]
},
"observedAt": {
"anyOf": [
{
"type": "string"
},
{
"type": "string"
}
]
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"agg",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "session"
},
"agg": {
"enum": [
"sum",
"high",
"low",
"first"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"bars": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"description": "Running sum, high, low, or first value since the session start. With bars, only the first bars of each session count; the value is null until they finish, then held for the rest of the session.",
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "lag"
},
"lag": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"window",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"average",
"high",
"low",
"sum",
"change",
"stddev"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"window": {
"type": "integer",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"window",
"alpha",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "smooth"
},
"lag": {
"type": "integer",
"minimum": 0
},
"alpha": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"window": {
"type": "integer",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"left",
"right",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"add",
"subtract",
"multiply",
"ratio",
"min",
"max"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"left": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"right": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"peers",
"order",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "rank"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"order": {
"enum": [
"ascending",
"descending"
],
"type": "string"
},
"peers": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"minItems": 2
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"price",
"direction",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "ratchet"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"price": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"direction": {
"enum": [
"up",
"down"
],
"type": "string"
}
},
"description": "A level that moves only one way. Up: the larger of input and its own prior value, and it restarts at input after the prior price closes below it. Down is the reverse. Use it for Supertrend style bands.",
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"kind",
"span",
"back",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "pivot"
},
"lag": {
"type": "integer",
"minimum": 0
},
"back": {
"type": "integer",
"minimum": 0
},
"kind": {
"enum": [
"high",
"low"
],
"type": "string"
},
"read": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"span": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"description": "Swing high or low of input: a value beyond the span values before it and not passed by the span values after it. Known only span bars later. back 0 is the latest swing, 1 the one before. read returns another series at that swing bar.",
"additionalProperties": false
}
]
},
"default": []
},
"signals": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"required": [
"id",
"op",
"left",
"right"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"above",
"below",
"crossAbove",
"crossBelow"
],
"type": "string"
},
"left": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"right": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"inputs"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"and",
"or"
],
"type": "string"
},
"inputs": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"minItems": 2
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "not"
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"field",
"values"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "calendar"
},
"field": {
"enum": [
"month",
"day",
"firstSessionOfMonth",
"utcMinute"
],
"type": "string"
},
"values": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
},
"minItems": 1
}
},
"additionalProperties": false
}
]
},
"default": []
},
"version": {
"type": "number",
"const": 2
},
"simulation": {
"type": "object",
"required": [
"fillTiming"
],
"properties": {
"feeBps": {
"type": "number",
"default": 0,
"maximum": 10000,
"minimum": 0
},
"sleeves": {
"type": "array",
"items": {
"type": "object",
"required": [
"weight"
],
"properties": {
"weight": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"positions": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"direction",
"enter",
"size"
],
"properties": {
"add": {
"type": "object",
"required": [
"distance",
"maxUnits"
],
"properties": {
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxUnits": {
"type": "integer",
"minimum": 2,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"exit": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"size": {
"anyOf": [
{
"type": "object",
"required": [
"kind",
"fraction"
],
"properties": {
"kind": {
"type": "string",
"const": "fraction"
},
"fraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"kind",
"riskFraction",
"maxFraction",
"distance"
],
"properties": {
"kind": {
"type": "string",
"const": "risk"
},
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"riskFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
}
]
},
"enter": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"option": {
"type": "object",
"required": [
"right",
"strike",
"premium",
"expiry"
],
"properties": {
"right": {
"enum": [
"call",
"put"
],
"type": "string"
},
"expiry": {
"type": "string"
},
"strike": {
"type": "number",
"exclusiveMinimum": 0
},
"premium": {
"type": "number",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"direction": {
"enum": [
"long",
"short"
],
"type": "string"
},
"closeStopPct": {
"type": "number",
"maximum": 100,
"exclusiveMinimum": 0
},
"stopDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"trailDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
],
"description": "Trailing stop: distance below the highest high since entry for a long, or above the lowest low for a short. It moves only in the trade's favor and applies from the next bar."
},
"closeTargetPct": {
"type": "number",
"exclusiveMinimum": 0
},
"targetDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
"default": []
},
"allocation": {
"type": "object",
"required": [
"when",
"targets"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"targets": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"when",
"weight"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"weight": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
],
"description": "A number, or a series read on the rebalance date. A series weight must be 0 to 1."
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
"minItems": 1
},
"positions": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"direction",
"enter",
"size"
],
"properties": {
"add": {
"type": "object",
"required": [
"distance",
"maxUnits"
],
"properties": {
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxUnits": {
"type": "integer",
"minimum": 2,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"exit": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"size": {
"anyOf": [
{
"type": "object",
"required": [
"kind",
"fraction"
],
"properties": {
"kind": {
"type": "string",
"const": "fraction"
},
"fraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"kind",
"riskFraction",
"maxFraction",
"distance"
],
"properties": {
"kind": {
"type": "string",
"const": "risk"
},
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"riskFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
}
]
},
"enter": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"option": {
"type": "object",
"required": [
"right",
"strike",
"premium",
"expiry"
],
"properties": {
"right": {
"enum": [
"call",
"put"
],
"type": "string"
},
"expiry": {
"type": "string"
},
"strike": {
"type": "number",
"exclusiveMinimum": 0
},
"premium": {
"type": "number",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"direction": {
"enum": [
"long",
"short"
],
"type": "string"
},
"closeStopPct": {
"type": "number",
"maximum": 100,
"exclusiveMinimum": 0
},
"stopDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"trailDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
],
"description": "Trailing stop: distance below the highest high since entry for a long, or above the lowest low for a short. It moves only in the trade's favor and applies from the next bar."
},
"closeTargetPct": {
"type": "number",
"exclusiveMinimum": 0
},
"targetDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
"default": []
},
"allocation": {
"type": "object",
"required": [
"when",
"targets"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"targets": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"when",
"weight"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"weight": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
],
"description": "A number, or a series read on the rebalance date. A series weight must be 0 to 1."
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
},
"fillTiming": {
"enum": [
"nextOpen",
"nextClose"
],
"type": "string"
},
"slippageBps": {
"type": "number",
"default": 0,
"minimum": 0,
"exclusiveMaximum": 10000
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}List available price data, fields, dates, limits, and whether reports can be retained for publishing.
No arguments.
{
"type": "object",
"properties": {},
"additionalProperties": false
}List published website strategies, their URLs, and their current keys. Use a current key as expectedKey only when the user asks to replace that saved strategy.
No arguments.
{
"type": "object",
"properties": {},
"additionalProperties": false
}Run a backtest and show its results. Supply strategyExplanation in plain terms for the widget. In your reply, explain the rule, always show Return vs. SPY (summary.returnVsSpyPct in percentage points, or Unavailable), and give one takeaway or limit supported by the report. Choose any additional cards using stats. Use scoreSeries for a separate score panel. Use chartSeries to select named report series and set their legend labels, line or bar types, colors, and line patterns. Keep the interpretation about this historical test. To publish this exact result later, pass its reportId to save_strategy after the user asks to save it to the website.
| Argument | Type | Description |
|---|---|---|
| run* | object | |
| stats | array | |
| chartSeries | array | Additional price-panel plots. Reference named engine report series. Set a legend label, line or bar type, line pattern, and optional hex color. |
| scoreSeries | string | Named report series to draw in the separate score panel. |
| strategyExplanation | string | In 1 to 3 plain sentences, explain what the strategy trades, what triggers buys and sells or rebalancing, and one key assumption when relevant. Use the run rules. Leave historical results for the report. |
{
"type": "object",
"required": [
"run"
],
"properties": {
"run": {
"type": "object",
"$schema": "http://json-schema.org/draft-07/schema#",
"required": [
"version",
"data"
],
"properties": {
"data": {
"type": "object",
"required": [
"tickers",
"start",
"end",
"source"
],
"properties": {
"end": {
"type": "string"
},
"start": {
"type": "string"
},
"source": {
"enum": [
"price-api",
"intraday-api"
],
"type": "string"
},
"tickers": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"minItems": 1
},
"interval": {
"enum": [
"1min",
"5min",
"15min",
"30min",
"1hour"
],
"type": "string"
}
},
"additionalProperties": false
},
"money": {
"type": "object",
"required": [
"capital"
],
"properties": {
"capital": {
"type": "number",
"exclusiveMinimum": 0
},
"benchmark": {
"type": "string",
"const": "SPY",
"default": "SPY"
}
},
"additionalProperties": false
},
"series": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"required": [
"id",
"op",
"ticker",
"field",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "price"
},
"lag": {
"type": "integer",
"minimum": 0
},
"field": {
"enum": [
"open",
"high",
"low",
"close",
"volume"
],
"type": "string"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"points",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "observations"
},
"lag": {
"type": "integer",
"minimum": 0
},
"points": {
"type": "array",
"items": {
"type": "object",
"required": [
"observedAt",
"knownAt",
"value"
],
"properties": {
"value": {
"type": "number"
},
"knownAt": {
"anyOf": [
{
"type": "string"
},
{
"type": "string"
}
]
},
"observedAt": {
"anyOf": [
{
"type": "string"
},
{
"type": "string"
}
]
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"agg",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "session"
},
"agg": {
"enum": [
"sum",
"high",
"low",
"first"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"bars": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"description": "Running sum, high, low, or first value since the session start. With bars, only the first bars of each session count; the value is null until they finish, then held for the rest of the session.",
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "lag"
},
"lag": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"window",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"average",
"high",
"low",
"sum",
"change",
"stddev"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"window": {
"type": "integer",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"window",
"alpha",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "smooth"
},
"lag": {
"type": "integer",
"minimum": 0
},
"alpha": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"window": {
"type": "integer",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"left",
"right",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"add",
"subtract",
"multiply",
"ratio",
"min",
"max"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"left": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"right": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"peers",
"order",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "rank"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"order": {
"enum": [
"ascending",
"descending"
],
"type": "string"
},
"peers": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"minItems": 2
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"price",
"direction",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "ratchet"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"price": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"direction": {
"enum": [
"up",
"down"
],
"type": "string"
}
},
"description": "A level that moves only one way. Up: the larger of input and its own prior value, and it restarts at input after the prior price closes below it. Down is the reverse. Use it for Supertrend style bands.",
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"kind",
"span",
"back",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "pivot"
},
"lag": {
"type": "integer",
"minimum": 0
},
"back": {
"type": "integer",
"minimum": 0
},
"kind": {
"enum": [
"high",
"low"
],
"type": "string"
},
"read": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"span": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"description": "Swing high or low of input: a value beyond the span values before it and not passed by the span values after it. Known only span bars later. back 0 is the latest swing, 1 the one before. read returns another series at that swing bar.",
"additionalProperties": false
}
]
},
"default": []
},
"signals": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"required": [
"id",
"op",
"left",
"right"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"above",
"below",
"crossAbove",
"crossBelow"
],
"type": "string"
},
"left": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"right": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"inputs"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"and",
"or"
],
"type": "string"
},
"inputs": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"minItems": 2
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "not"
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"field",
"values"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "calendar"
},
"field": {
"enum": [
"month",
"day",
"firstSessionOfMonth",
"utcMinute"
],
"type": "string"
},
"values": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
},
"minItems": 1
}
},
"additionalProperties": false
}
]
},
"default": []
},
"version": {
"type": "number",
"const": 2
},
"simulation": {
"type": "object",
"required": [
"fillTiming"
],
"properties": {
"feeBps": {
"type": "number",
"default": 0,
"maximum": 10000,
"minimum": 0
},
"sleeves": {
"type": "array",
"items": {
"type": "object",
"required": [
"weight"
],
"properties": {
"weight": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"positions": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"direction",
"enter",
"size"
],
"properties": {
"add": {
"type": "object",
"required": [
"distance",
"maxUnits"
],
"properties": {
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxUnits": {
"type": "integer",
"minimum": 2,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"exit": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"size": {
"anyOf": [
{
"type": "object",
"required": [
"kind",
"fraction"
],
"properties": {
"kind": {
"type": "string",
"const": "fraction"
},
"fraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"kind",
"riskFraction",
"maxFraction",
"distance"
],
"properties": {
"kind": {
"type": "string",
"const": "risk"
},
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"riskFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
}
]
},
"enter": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"option": {
"type": "object",
"required": [
"right",
"strike",
"premium",
"expiry"
],
"properties": {
"right": {
"enum": [
"call",
"put"
],
"type": "string"
},
"expiry": {
"type": "string"
},
"strike": {
"type": "number",
"exclusiveMinimum": 0
},
"premium": {
"type": "number",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"direction": {
"enum": [
"long",
"short"
],
"type": "string"
},
"closeStopPct": {
"type": "number",
"maximum": 100,
"exclusiveMinimum": 0
},
"stopDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"trailDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
],
"description": "Trailing stop: distance below the highest high since entry for a long, or above the lowest low for a short. It moves only in the trade's favor and applies from the next bar."
},
"closeTargetPct": {
"type": "number",
"exclusiveMinimum": 0
},
"targetDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
"default": []
},
"allocation": {
"type": "object",
"required": [
"when",
"targets"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"targets": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"when",
"weight"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"weight": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
],
"description": "A number, or a series read on the rebalance date. A series weight must be 0 to 1."
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
"minItems": 1
},
"positions": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"direction",
"enter",
"size"
],
"properties": {
"add": {
"type": "object",
"required": [
"distance",
"maxUnits"
],
"properties": {
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxUnits": {
"type": "integer",
"minimum": 2,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"exit": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"size": {
"anyOf": [
{
"type": "object",
"required": [
"kind",
"fraction"
],
"properties": {
"kind": {
"type": "string",
"const": "fraction"
},
"fraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"kind",
"riskFraction",
"maxFraction",
"distance"
],
"properties": {
"kind": {
"type": "string",
"const": "risk"
},
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"riskFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
}
]
},
"enter": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"option": {
"type": "object",
"required": [
"right",
"strike",
"premium",
"expiry"
],
"properties": {
"right": {
"enum": [
"call",
"put"
],
"type": "string"
},
"expiry": {
"type": "string"
},
"strike": {
"type": "number",
"exclusiveMinimum": 0
},
"premium": {
"type": "number",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"direction": {
"enum": [
"long",
"short"
],
"type": "string"
},
"closeStopPct": {
"type": "number",
"maximum": 100,
"exclusiveMinimum": 0
},
"stopDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"trailDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
],
"description": "Trailing stop: distance below the highest high since entry for a long, or above the lowest low for a short. It moves only in the trade's favor and applies from the next bar."
},
"closeTargetPct": {
"type": "number",
"exclusiveMinimum": 0
},
"targetDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
"default": []
},
"allocation": {
"type": "object",
"required": [
"when",
"targets"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"targets": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"when",
"weight"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"weight": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
],
"description": "A number, or a series read on the rebalance date. A series weight must be 0 to 1."
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
},
"fillTiming": {
"enum": [
"nextOpen",
"nextClose"
],
"type": "string"
},
"slippageBps": {
"type": "number",
"default": 0,
"minimum": 0,
"exclusiveMaximum": 10000
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
"stats": {
"type": "array",
"items": {
"enum": [
"period",
"tradeCount",
"fillCount",
"finalValue",
"returnPct",
"maxDrawdownPct",
"benchmarkFinalValue",
"returnVsSpyPct",
"winRatePct"
],
"type": "string"
},
"$schema": "http://json-schema.org/draft-07/schema#",
"maxItems": 9
},
"chartSeries": {
"type": "array",
"items": {
"type": "object",
"required": [
"seriesId"
],
"properties": {
"type": {
"enum": [
"line",
"bar"
],
"type": "string",
"default": "line"
},
"color": {
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
},
"label": {
"type": "string",
"maxLength": 80,
"minLength": 1
},
"style": {
"enum": [
"solid",
"dashed",
"dotted"
],
"type": "string",
"default": "solid"
},
"seriesId": {
"type": "string",
"maxLength": 100,
"minLength": 1
}
},
"additionalProperties": false
},
"$schema": "http://json-schema.org/draft-07/schema#",
"maxItems": 12,
"description": "Additional price-panel plots. Reference named engine report series. Set a legend label, line or bar type, line pattern, and optional hex color."
},
"scoreSeries": {
"type": "string",
"maxLength": 100,
"minLength": 1,
"description": "Named report series to draw in the separate score panel."
},
"strategyExplanation": {
"type": "string",
"$schema": "http://json-schema.org/draft-07/schema#",
"maxLength": 600,
"minLength": 1,
"description": "In 1 to 3 plain sentences, explain what the strategy trades, what triggers buys and sells or rebalancing, and one key assumption when relevant. Use the run rules. Leave historical results for the report."
}
},
"additionalProperties": false
}Publish a completed report to the public website after the user asks to save it. Use the reportId returned by report, a public slug, and client-authored page and presentation choices. Never submit or invent result numbers. Adds it to the strategy directory without rerunning the strategy. Existing slugs require expectedKey to replace a different result. setAsHome changes the home page only when explicitly requested.
| Argument | Type | Description |
|---|---|---|
| id* | string | Public page slug. New slugs add a page; existing slugs require expectedKey to replace. |
| page* | object | |
| reportId* | string | The reportId returned by report. Do not submit prices, trades, or statistics. |
| setAsHome | boolean | Also select this strategy for the home page. Otherwise preserve the current home strategy. |
| expectedKey | string | Current published key, required only when replacing a different saved result at this slug. |
| presentation* | object |
{
"type": "object",
"$schema": "http://json-schema.org/draft-07/schema#",
"required": [
"reportId",
"id",
"presentation",
"page"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]{0,63}$",
"description": "Public page slug. New slugs add a page; existing slugs require expectedKey to replace."
},
"page": {
"type": "object",
"required": [
"title",
"description",
"category"
],
"properties": {
"exit": {
"type": "string",
"minLength": 1
},
"title": {
"type": "string",
"minLength": 1
},
"signal": {
"type": "string",
"minLength": 1
},
"category": {
"type": "string",
"minLength": 1
},
"headline": {
"type": "string",
"minLength": 1
},
"description": {
"type": "string",
"minLength": 1
}
},
"additionalProperties": false
},
"reportId": {
"type": "string",
"pattern": "^[a-f0-9]{64}$",
"description": "The reportId returned by report. Do not submit prices, trades, or statistics."
},
"setAsHome": {
"type": "boolean",
"default": false,
"description": "Also select this strategy for the home page. Otherwise preserve the current home strategy."
},
"expectedKey": {
"type": "string",
"pattern": "^reports\\/[a-f0-9]{64}\\.json$",
"description": "Current published key, required only when replacing a different saved result at this slug."
},
"presentation": {
"type": "object",
"required": [
"mainTicker",
"company",
"stats",
"strategyExplanation",
"sections"
],
"properties": {
"stats": {
"type": "array",
"items": {
"enum": [
"period",
"tradeCount",
"fillCount",
"finalValue",
"returnPct",
"maxDrawdownPct",
"benchmarkFinalValue",
"returnVsSpyPct",
"winRatePct"
],
"type": "string"
},
"maxItems": 9
},
"company": {
"type": "string",
"minLength": 1
},
"sections": {
"type": "array",
"items": {
"enum": [
"rule",
"performance",
"equity",
"widget"
],
"type": "string"
},
"maxItems": 4
},
"mainTicker": {
"type": "string",
"minLength": 1
},
"chartSeries": {
"type": "array",
"items": {
"type": "object",
"required": [
"seriesId"
],
"properties": {
"type": {
"enum": [
"line",
"bar"
],
"type": "string",
"default": "line"
},
"color": {
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
},
"label": {
"type": "string",
"maxLength": 80,
"minLength": 1
},
"style": {
"enum": [
"solid",
"dashed",
"dotted"
],
"type": "string",
"default": "solid"
},
"seriesId": {
"type": "string",
"maxLength": 100,
"minLength": 1
}
},
"additionalProperties": false
},
"maxItems": 12,
"description": "Additional price-panel plots. Reference named engine report series. Set a legend label, line or bar type, line pattern, and optional hex color."
},
"scoreSeries": {
"anyOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "null"
}
]
},
"strategyExplanation": {
"type": "string",
"maxLength": 600,
"minLength": 1,
"description": "In 1 to 3 plain sentences, explain what the strategy trades, what triggers buys and sells or rebalancing, and one key assumption when relevant. Use the run rules. Leave historical results for the report."
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}Make a report public so it can be shared, and return its page URL. Needs only the reportId returned by report. The page text comes from the report itself. Sharing the same report again returns the same URL. The report widget calls this when the visitor presses its share icon.
| Argument | Type | Description |
|---|---|---|
| reportId* | string | The reportId returned by report. |
{
"type": "object",
"$schema": "http://json-schema.org/draft-07/schema#",
"required": [
"reportId"
],
"properties": {
"reportId": {
"type": "string",
"pattern": "^[a-f0-9]{64}$",
"description": "The reportId returned by report."
}
},
"additionalProperties": false
}Simulate historical fills and account balances. Needs the full run form.
| Argument | Type | Description |
|---|---|---|
| run* | object |
{
"type": "object",
"required": [
"run"
],
"properties": {
"run": {
"type": "object",
"$schema": "http://json-schema.org/draft-07/schema#",
"required": [
"version",
"data"
],
"properties": {
"data": {
"type": "object",
"required": [
"tickers",
"start",
"end",
"source"
],
"properties": {
"end": {
"type": "string"
},
"start": {
"type": "string"
},
"source": {
"enum": [
"price-api",
"intraday-api"
],
"type": "string"
},
"tickers": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"minItems": 1
},
"interval": {
"enum": [
"1min",
"5min",
"15min",
"30min",
"1hour"
],
"type": "string"
}
},
"additionalProperties": false
},
"money": {
"type": "object",
"required": [
"capital"
],
"properties": {
"capital": {
"type": "number",
"exclusiveMinimum": 0
},
"benchmark": {
"type": "string",
"const": "SPY",
"default": "SPY"
}
},
"additionalProperties": false
},
"series": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"required": [
"id",
"op",
"ticker",
"field",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "price"
},
"lag": {
"type": "integer",
"minimum": 0
},
"field": {
"enum": [
"open",
"high",
"low",
"close",
"volume"
],
"type": "string"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"points",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "observations"
},
"lag": {
"type": "integer",
"minimum": 0
},
"points": {
"type": "array",
"items": {
"type": "object",
"required": [
"observedAt",
"knownAt",
"value"
],
"properties": {
"value": {
"type": "number"
},
"knownAt": {
"anyOf": [
{
"type": "string"
},
{
"type": "string"
}
]
},
"observedAt": {
"anyOf": [
{
"type": "string"
},
{
"type": "string"
}
]
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"agg",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "session"
},
"agg": {
"enum": [
"sum",
"high",
"low",
"first"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"bars": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"description": "Running sum, high, low, or first value since the session start. With bars, only the first bars of each session count; the value is null until they finish, then held for the rest of the session.",
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "lag"
},
"lag": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"window",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"average",
"high",
"low",
"sum",
"change",
"stddev"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"window": {
"type": "integer",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"window",
"alpha",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "smooth"
},
"lag": {
"type": "integer",
"minimum": 0
},
"alpha": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"window": {
"type": "integer",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"left",
"right",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"add",
"subtract",
"multiply",
"ratio",
"min",
"max"
],
"type": "string"
},
"lag": {
"type": "integer",
"minimum": 0
},
"left": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"right": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"peers",
"order",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "rank"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"order": {
"enum": [
"ascending",
"descending"
],
"type": "string"
},
"peers": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"minItems": 2
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"price",
"direction",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "ratchet"
},
"lag": {
"type": "integer",
"minimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"price": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"direction": {
"enum": [
"up",
"down"
],
"type": "string"
}
},
"description": "A level that moves only one way. Up: the larger of input and its own prior value, and it restarts at input after the prior price closes below it. Down is the reverse. Use it for Supertrend style bands.",
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input",
"kind",
"span",
"back",
"lag"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "pivot"
},
"lag": {
"type": "integer",
"minimum": 0
},
"back": {
"type": "integer",
"minimum": 0
},
"kind": {
"enum": [
"high",
"low"
],
"type": "string"
},
"read": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"span": {
"type": "integer",
"exclusiveMinimum": 0
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"description": "Swing high or low of input: a value beyond the span values before it and not passed by the span values after it. Known only span bars later. back 0 is the latest swing, 1 the one before. read returns another series at that swing bar.",
"additionalProperties": false
}
]
},
"default": []
},
"signals": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"required": [
"id",
"op",
"left",
"right"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"above",
"below",
"crossAbove",
"crossBelow"
],
"type": "string"
},
"left": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"right": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"inputs"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"enum": [
"and",
"or"
],
"type": "string"
},
"inputs": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"minItems": 2
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"input"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "not"
},
"input": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"id",
"op",
"field",
"values"
],
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"op": {
"type": "string",
"const": "calendar"
},
"field": {
"enum": [
"month",
"day",
"firstSessionOfMonth",
"utcMinute"
],
"type": "string"
},
"values": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
},
"minItems": 1
}
},
"additionalProperties": false
}
]
},
"default": []
},
"version": {
"type": "number",
"const": 2
},
"simulation": {
"type": "object",
"required": [
"fillTiming"
],
"properties": {
"feeBps": {
"type": "number",
"default": 0,
"maximum": 10000,
"minimum": 0
},
"sleeves": {
"type": "array",
"items": {
"type": "object",
"required": [
"weight"
],
"properties": {
"weight": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"positions": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"direction",
"enter",
"size"
],
"properties": {
"add": {
"type": "object",
"required": [
"distance",
"maxUnits"
],
"properties": {
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxUnits": {
"type": "integer",
"minimum": 2,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"exit": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"size": {
"anyOf": [
{
"type": "object",
"required": [
"kind",
"fraction"
],
"properties": {
"kind": {
"type": "string",
"const": "fraction"
},
"fraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"kind",
"riskFraction",
"maxFraction",
"distance"
],
"properties": {
"kind": {
"type": "string",
"const": "risk"
},
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"riskFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
}
]
},
"enter": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"option": {
"type": "object",
"required": [
"right",
"strike",
"premium",
"expiry"
],
"properties": {
"right": {
"enum": [
"call",
"put"
],
"type": "string"
},
"expiry": {
"type": "string"
},
"strike": {
"type": "number",
"exclusiveMinimum": 0
},
"premium": {
"type": "number",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"direction": {
"enum": [
"long",
"short"
],
"type": "string"
},
"closeStopPct": {
"type": "number",
"maximum": 100,
"exclusiveMinimum": 0
},
"stopDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"trailDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
],
"description": "Trailing stop: distance below the highest high since entry for a long, or above the lowest low for a short. It moves only in the trade's favor and applies from the next bar."
},
"closeTargetPct": {
"type": "number",
"exclusiveMinimum": 0
},
"targetDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
"default": []
},
"allocation": {
"type": "object",
"required": [
"when",
"targets"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"targets": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"when",
"weight"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"weight": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
],
"description": "A number, or a series read on the rebalance date. A series weight must be 0 to 1."
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
"minItems": 1
},
"positions": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"direction",
"enter",
"size"
],
"properties": {
"add": {
"type": "object",
"required": [
"distance",
"maxUnits"
],
"properties": {
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxUnits": {
"type": "integer",
"minimum": 2,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"exit": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"size": {
"anyOf": [
{
"type": "object",
"required": [
"kind",
"fraction"
],
"properties": {
"kind": {
"type": "string",
"const": "fraction"
},
"fraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"kind",
"riskFraction",
"maxFraction",
"distance"
],
"properties": {
"kind": {
"type": "string",
"const": "risk"
},
"distance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"maxFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
},
"riskFraction": {
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
},
"additionalProperties": false
}
]
},
"enter": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"option": {
"type": "object",
"required": [
"right",
"strike",
"premium",
"expiry"
],
"properties": {
"right": {
"enum": [
"call",
"put"
],
"type": "string"
},
"expiry": {
"type": "string"
},
"strike": {
"type": "number",
"exclusiveMinimum": 0
},
"premium": {
"type": "number",
"exclusiveMinimum": 0
}
},
"additionalProperties": false
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"direction": {
"enum": [
"long",
"short"
],
"type": "string"
},
"closeStopPct": {
"type": "number",
"maximum": 100,
"exclusiveMinimum": 0
},
"stopDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
},
"trailDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
],
"description": "Trailing stop: distance below the highest high since entry for a long, or above the lowest low for a short. It moves only in the trade's favor and applies from the next bar."
},
"closeTargetPct": {
"type": "number",
"exclusiveMinimum": 0
},
"targetDistance": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number"
}
]
}
},
"additionalProperties": false
},
"default": []
},
"allocation": {
"type": "object",
"required": [
"when",
"targets"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"targets": {
"type": "array",
"items": {
"type": "object",
"required": [
"ticker",
"when",
"weight"
],
"properties": {
"when": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
"ticker": {
"type": "string",
"pattern": "^[A-Z0-9][A-Z0-9.-]{0,11}$"
},
"weight": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_]*$"
},
{
"type": "number",
"maximum": 1,
"exclusiveMinimum": 0
}
],
"description": "A number, or a series read on the rebalance date. A series weight must be 0 to 1."
}
},
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
},
"fillTiming": {
"enum": [
"nextOpen",
"nextClose"
],
"type": "string"
},
"slippageBps": {
"type": "number",
"default": 0,
"minimum": 0,
"exclusiveMaximum": 10000
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}We read every tool's name, description and inputs the way the model will, looking for instructions hidden from you. A clean result means no warning signs, not a guarantee. Scanned Nov 8, 2026.