Strategy preview v1
Forge API 1
The request the Strategy Studio posts to the monitor and the reply it reads. request and reply are the two documents; every other definition is a part of one of them.
request
| Name | Type | Required |
|---|---|---|
| v | any | Required |
| strategy | strategy | Required |
| series | array | Required |
| visible_from | integer | Required |
condition
| Name | Type | Required |
|---|---|---|
| field | field | Required |
| path | string | Required |
| name | string | Required |
| values | bit_or_null_array | Required |
page
| Name | Type | Required |
|---|---|---|
| v | any | Required |
| preview_key | sha256 | Required |
| strategy_sha256 | sha256 | Required |
| series_key | sha256 | Required |
| t_open | array | Required |
| warmup | integer | Required |
| events | object | Required |
| levels | object | Required |
| plots | object | Required |
| conditions | array | Required |
| dropped | object | Required |
| engine | string | Required |
Schema
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Strategy preview v1",
"description": "The request the Strategy Studio posts to the monitor and the reply it reads. `request` and `reply` are the two documents; every other definition is a part of one of them.",
"$defs": {
"sha256": {
"type": "string",
"pattern": "^[0-9a-f]{64}$"
},
"ms_array": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
},
"maxItems": 10000
},
"num_array": {
"type": "array",
"items": {
"type": "number"
},
"maxItems": 10000
},
"num_or_null_array": {
"type": "array",
"items": {
"type": [
"number",
"null"
]
},
"maxItems": 5000
},
"bit_array": {
"type": "array",
"items": {
"enum": [
0,
1
]
},
"maxItems": 5000
},
"bit_or_null_array": {
"type": "array",
"items": {
"enum": [
0,
1,
null
]
},
"maxItems": 5000
},
"dropped_array": {
"type": "array",
"items": {
"enum": [
null,
"warmup",
"same_run"
]
},
"maxItems": 5000
},
"field": {
"enum": [
"long_entry",
"short_entry",
"long_exit",
"short_exit"
]
},
"strategy": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": [
"kind",
"spec"
],
"properties": {
"kind": {
"const": "spec"
},
"spec": {
"$ref": "strategy-spec.schema.json"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"kind",
"strategy_id",
"revision"
],
"properties": {
"kind": {
"const": "version"
},
"strategy_id": {
"type": "string",
"format": "uuid"
},
"revision": {
"type": "integer",
"minimum": 1
}
}
}
]
},
"series": {
"type": "object",
"additionalProperties": false,
"required": [
"role",
"meta",
"cols"
],
"properties": {
"role": {
"enum": [
"chart",
"other"
]
},
"meta": {
"type": "object",
"additionalProperties": false,
"required": [
"spec",
"series_key",
"volume_kind"
],
"properties": {
"spec": {
"$ref": "bar-spec.schema.json"
},
"series_key": {
"$ref": "#/$defs/sha256"
},
"volume_kind": {
"enum": [
"tick",
"traded"
]
},
"volume_absent": {
"const": true
}
}
},
"cols": {
"type": "object",
"additionalProperties": false,
"required": [
"t_open",
"t_close",
"o",
"h",
"l",
"c",
"vol",
"flags"
],
"properties": {
"t_open": {
"$ref": "#/$defs/ms_array"
},
"t_close": {
"$ref": "#/$defs/ms_array"
},
"o": {
"$ref": "#/$defs/num_array"
},
"h": {
"$ref": "#/$defs/num_array"
},
"l": {
"$ref": "#/$defs/num_array"
},
"c": {
"$ref": "#/$defs/num_array"
},
"vol": {
"$ref": "#/$defs/num_array"
},
"flags": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"maxItems": 10000
}
}
}
}
},
"request": {
"type": "object",
"additionalProperties": false,
"required": [
"v",
"strategy",
"series",
"visible_from"
],
"properties": {
"v": {
"const": 1
},
"strategy": {
"$ref": "#/$defs/strategy"
},
"series": {
"type": "array",
"minItems": 1,
"maxItems": 4,
"items": {
"$ref": "#/$defs/series"
}
},
"visible_from": {
"type": "integer",
"minimum": 0
}
}
},
"plot": {
"type": "object",
"additionalProperties": false,
"required": [
"label",
"pane",
"values"
],
"properties": {
"label": {
"type": "string"
},
"pane": {
"enum": [
"price",
"own"
]
},
"values": {
"$ref": "#/$defs/num_or_null_array"
}
}
},
"condition": {
"type": "object",
"additionalProperties": false,
"required": [
"field",
"path",
"name",
"values"
],
"properties": {
"field": {
"$ref": "#/$defs/field"
},
"path": {
"type": "string"
},
"name": {
"type": "string"
},
"values": {
"$ref": "#/$defs/bit_or_null_array"
}
}
},
"page": {
"type": "object",
"additionalProperties": false,
"required": [
"v",
"preview_key",
"strategy_sha256",
"series_key",
"t_open",
"warmup",
"events",
"levels",
"plots",
"conditions",
"dropped",
"engine"
],
"properties": {
"v": {
"const": 1
},
"preview_key": {
"$ref": "#/$defs/sha256"
},
"strategy_sha256": {
"$ref": "#/$defs/sha256"
},
"series_key": {
"$ref": "#/$defs/sha256"
},
"t_open": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
},
"maxItems": 5000
},
"warmup": {
"type": "integer",
"minimum": 0
},
"events": {
"type": "object",
"additionalProperties": false,
"required": [
"long_entry",
"short_entry",
"long_exit",
"short_exit"
],
"properties": {
"long_entry": {
"$ref": "#/$defs/bit_array"
},
"short_entry": {
"$ref": "#/$defs/bit_array"
},
"long_exit": {
"$ref": "#/$defs/bit_array"
},
"short_exit": {
"$ref": "#/$defs/bit_array"
}
}
},
"levels": {
"type": "object",
"additionalProperties": false,
"required": [
"stop",
"target"
],
"properties": {
"stop": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/$defs/num_or_null_array"
}
]
},
"target": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/$defs/num_or_null_array"
}
]
}
}
},
"plots": {
"type": "object",
"maxProperties": 64,
"additionalProperties": {
"$ref": "#/$defs/plot"
}
},
"conditions": {
"type": "array",
"maxItems": 256,
"items": {
"$ref": "#/$defs/condition"
}
},
"dropped": {
"type": "object",
"additionalProperties": false,
"required": [
"long_entry",
"short_entry"
],
"properties": {
"long_entry": {
"$ref": "#/$defs/dropped_array"
},
"short_entry": {
"$ref": "#/$defs/dropped_array"
}
}
},
"engine": {
"type": "string",
"minLength": 1
}
}
},
"finding": {
"type": "object",
"additionalProperties": false,
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "string",
"minLength": 1
},
"message": {
"type": "string",
"minLength": 1
},
"line": {
"type": [
"integer",
"null"
],
"minimum": 1
}
}
},
"reply": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": [
"v",
"status",
"id",
"page"
],
"properties": {
"v": {
"const": 1
},
"status": {
"const": "ready"
},
"id": {
"type": "string",
"minLength": 1,
"maxLength": 64
},
"page": {
"$ref": "#/$defs/page"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"v",
"status",
"id",
"retry_after_ms"
],
"properties": {
"v": {
"const": 1
},
"status": {
"const": "pending"
},
"id": {
"type": "string",
"minLength": 1,
"maxLength": 64
},
"retry_after_ms": {
"type": "integer",
"minimum": 100,
"maximum": 10000
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"v",
"status",
"id",
"code",
"message"
],
"properties": {
"v": {
"const": 1
},
"status": {
"const": "failed"
},
"id": {
"type": "string",
"minLength": 1,
"maxLength": 64
},
"code": {
"enum": [
"strategy_preview_refused",
"strategy_preview_needs_series",
"strategy_preview_too_slow",
"strategy_preview_unavailable"
]
},
"message": {
"type": "string",
"minLength": 1
},
"findings": {
"type": "array",
"maxItems": 100,
"items": {
"$ref": "#/$defs/finding"
}
},
"needs": {
"type": "array",
"minItems": 1,
"maxItems": 3,
"items": {
"$ref": "bar-spec.schema.json"
}
}
}
}
]
}
}
}