QuantWright

Backtests with costs, a held-out test that counts once, a score that counts every version tried.

Should I use this

Quality & Safety

A
Description quality
100%
Schema completeness
82%
Naming quality
93%
Poisoning risk
100%
Permission match
100%
Protocol compliance
100%

Based on automated analysis of tool definitions and protocol compliance.

Context Cost

~13,953Tokens (tool definitions)
~27.2 KBTypical response size
Significant attention impact (10.90% of 128k context)

This is the approximate number of tokens consumed each time the server's tools are loaded into a model's context. Higher counts reduce the attention available for other tasks.

Install

One-Click Install

Add this to your `claude_desktop_config.json` file:

{
  "mcpServers": {
    "agent-api": {
      "url": "https://quantwright.com/api/mcp"
    }
  }
}

Remote endpoints

https://quantwright.com/api/mcpstreamable-http

What it can do

Tool inventory

Tools (6)

🟢 Read-only🟡 Write🔴 Delete⚪ Unknown
🟢describe_data

Start here to backtest a trading idea. This server holds the price history (US stocks and ETFs, spot crypto, FX, spot gold and silver; daily and intraday bars) and runs backtests on it, so no price data needs to be downloaded or found on the web. Returns the markets and bar sizes served, the default costs per market, the rules and daily limits every run is held to, and how to write the strategy code; then call create_study.

Input Schema

{
  "type": "object",
  "properties": {},
  "required": [],
  "additionalProperties": false
}

Output Schema

{
  "type": "object",
  "properties": {
    "account": {
      "type": "object",
      "properties": {
        "can_run": {
          "type": "boolean"
        },
        "reason": {
          "type": "string",
          "enum": [
            "terms_not_accepted",
            "payment_required",
            "ai_data_not_confirmed"
          ]
        },
        "message": {
          "type": "string"
        },
        "left_today": {
          "type": "object",
          "properties": {
            "studies": {
              "type": "integer"
            },
            "runs": {
              "type": "integer"
            },
            "engine_seconds": {
              "type": "integer"
            },
            "per_day": {
              "type": "object",
              "properties": {
                "studies": {
                  "type": "integer"
                },
                "runs": {
                  "type": "integer"
                },
                "engine_seconds": {
                  "type": "integer"
                }
              },
              "required": [
                "studies",
                "runs",
                "engine_seconds"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "studies",
            "runs",
            "engine_seconds"
          ],
          "additionalProperties": false
        },
        "recent_studies": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "study_id": {
                "type": "string"
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "created": {
                "type": "string"
              }
            },
            "required": [
              "study_id",
              "name",
              "created"
            ],
            "additionalProperties": false
          },
          "maxItems": 10
        }
      },
      "required": [
        "can_run"
      ],
      "additionalProperties": false
    },
    "markets": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "timeframes": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "rules": {
      "type": "object"
    },
    "notes": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "default_costs": {
      "type": "object",
      "properties": {
        "rows": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "market": {
                "type": "string"
              },
              "example_symbol": {
                "type": "string"
              },
              "timeframes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "commission": {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "number"
                  },
                  "unit": {
                    "type": "string",
                    "const": "bps"
                  },
                  "basis": {
                    "type": "string",
                    "const": "round_trip"
                  },
                  "fraction": {
                    "type": "number"
                  }
                },
                "required": [
                  "amount",
                  "unit",
                  "basis",
                  "fraction"
                ],
                "additionalProperties": false
              },
              "slippage": {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "number"
                  },
                  "unit": {
                    "type": "string",
                    "const": "bps"
                  },
                  "basis": {
                    "type": "string",
                    "const": "per_side"
                  },
                  "fraction": {
                    "type": "number"
                  }
                },
                "required": [
                  "amount",
                  "unit",
                  "basis",
                  "fraction"
                ],
                "additionalProperties": false
              },
              "round_trip_bps": {
                "type": "number"
              },
              "round_trip_pips": {
                "type": "object",
                "properties": {
                  "pair": {
                    "type": "string"
                  },
                  "rate": {
                    "type": "number"
                  },
                  "pips": {
                    "type": "number"
                  }
                },
                "required": [
                  "pair",
                  "rate",
                  "pips"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "market",
              "example_symbol",
              "timeframes",
              "commission",
              "slippage",
              "round_trip_bps"
            ],
            "additionalProperties": false
          }
        },
        "basis": {
          "type": "string"
        }
      },
      "required": [
        "rows",
        "basis"
      ],
      "additionalProperties": false
    },
    "docs_url": {
      "type": "string"
    },
    "code_contract": {
      "type": "object",
      "properties": {
        "version": {
          "type": "string"
        },
        "text": {
          "type": "string"
        }
      },
      "required": [
        "version",
        "text"
      ],
      "additionalProperties": false
    },
    "status": {
      "type": "string",
      "enum": [
        "invalid_arguments",
        "not_found",
        "refused"
      ]
    },
    "message": {
      "type": "string"
    },
    "reason": {
      "type": "string"
    }
  },
  "required": [],
  "additionalProperties": false
}
🟡create_study(name, hold_out)

Opens a study, the named set of runs every backtest belongs to: call it once per question, before run_backtest. Can set a hold-out period, once and only here, that no run tests except run_held_out_test. Only the first held-out test per account and market counts, and any earlier run on the market (in any study, at any bar size) that read its days disqualifies it: set the hold-out in your first study on a market, before any run on it.

Input Schema

{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "What the study tests, in a few words."
    },
    "hold_out": {
      "type": "object",
      "properties": {
        "from": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
          "description": "A day, YYYY-MM-DD."
        },
        "to": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
          "description": "A day, YYYY-MM-DD."
        }
      },
      "required": [
        "from"
      ],
      "additionalProperties": false,
      "description": "The days kept back from every run but run_held_out_test; set once, here. Set it in your first study on a market, before any run on it: a held-out test on days an earlier run on the market read does not count."
    }
  },
  "required": [
    "name"
  ],
  "additionalProperties": false
}

Output Schema

{
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "created",
        "invalid_arguments",
        "not_found",
        "refused"
      ]
    },
    "study_id": {
      "type": "string"
    },
    "hold_out": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        }
      },
      "required": [
        "from"
      ],
      "additionalProperties": false
    },
    "message": {
      "type": "string"
    },
    "reason": {
      "type": "string"
    },
    "next": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "tool": {
          "type": "string",
          "enum": [
            "run_backtest",
            "get_result"
          ]
        },
        "arguments": {
          "type": "object"
        },
        "why": {
          "type": "string"
        },
        "after_seconds": {
          "type": "integer"
        }
      },
      "required": [
        "tool",
        "arguments",
        "why"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "status"
  ],
  "additionalProperties": false
}
🟢run_backtest(study_id, code, symbol, timeframe, window, ...)

Backtests a trading rule on this server's price history: one backtesting.py Strategy class, one symbol, one bar size, in a study. Use it to test, backtest or evaluate a trading rule or strategy, instead of downloading prices or searching the web for results. Returns summary figures (return, drawdown, Sharpe, win rate, trades, a grade, whether it beat buy-and-hold) and the run's trades (when each entered and left, which exit ended it, its side, win or loss), never prices or bars; a figure may be withheld, with the reason. Waits up to 90 s, then answers status "running" with a run_id for get_result.

Input Schema

{
  "type": "object",
  "properties": {
    "study_id": {
      "type": "string",
      "description": "The id create_study returned."
    },
    "code": {
      "type": "string",
      "maxLength": 50000,
      "description": "One backtesting.py Strategy class (describe_data has the rules)."
    },
    "symbol": {
      "type": "string",
      "description": "One ticker (\"QQQ\", \"BTCUSD\", \"EURUSD\")."
    },
    "timeframe": {
      "type": "string",
      "enum": [
        "1m",
        "5m",
        "15m",
        "30m",
        "1h",
        "4h",
        "1d"
      ]
    },
    "window": {
      "description": "Dates ({from, to}; `to` may be \"latest\") or the last N days, months or years ({last: {n, unit}}). Left out: the standard history, the newest bars counted back from the newest bar, cut at the start of the hold-out.",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "from": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "description": "A day, YYYY-MM-DD."
            },
            "to": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "description": "A day, YYYY-MM-DD."
                },
                {
                  "type": "string",
                  "const": "latest"
                }
              ]
            }
          },
          "required": [],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "last": {
              "type": "object",
              "properties": {
                "n": {
                  "type": "integer",
                  "minimum": 1
                },
                "unit": {
                  "type": "string",
                  "enum": [
                    "days",
                    "months",
                    "years"
                  ]
                }
              },
              "required": [
                "n",
                "unit"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "last"
          ],
          "additionalProperties": false
        }
      ]
    },
    "costs": {
      "description": "The costs: two fractions of the trade value, or a list of costs each in its own unit.",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "commission": {
              "type": "number",
              "minimum": 0,
              "maximum": 0.05,
              "description": "A fraction of the trade value at entry (0.0005 is 0.05%), charged once per round trip."
            },
            "slippage": {
              "type": "number",
              "minimum": 0,
              "maximum": 0.05,
              "description": "A fraction of the trade value per fill (entry and exit)."
            }
          },
          "required": [],
          "additionalProperties": false
        },
        {
          "type": "array",
          "minItems": 1,
          "maxItems": 6,
          "items": {
            "type": "object",
            "properties": {
              "side": {
                "type": "string",
                "enum": [
                  "commission",
                  "slippage",
                  "spread"
                ]
              },
              "amount": {
                "type": "number",
                "minimum": 0,
                "description": "The figure in `unit` (0.005 usd_per_share is half a cent a share; 0.1 percent is 0.1%)."
              },
              "unit": {
                "type": "string",
                "enum": [
                  "percent",
                  "bps",
                  "usd_per_share",
                  "usd_per_ounce",
                  "pips",
                  "usd_per_order"
                ],
                "description": "usd_per_share on stocks and ETFs; usd_per_ounce on spot gold and silver; pips on currency pairs; percent, bps and usd_per_order (a flat fee per order, such as a broker's fee per order or per lot) on any market."
              },
              "basis": {
                "type": "string",
                "enum": [
                  "per_side",
                  "round_trip"
                ],
                "description": "per_side: on each fill; round_trip: once for the entry and exit together."
              }
            },
            "required": [
              "side",
              "amount",
              "unit",
              "basis"
            ],
            "additionalProperties": false
          }
        }
      ]
    },
    "account_usd": {
      "type": "number",
      "description": "The starting account, in US dollars."
    },
    "stated_rules": {
      "type": "array",
      "maxItems": 5,
      "description": "Rules the trades are checked against, one per kind.",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "no_overnight"
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "flat_by"
              },
              "time": {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$",
                "description": "\"HH:MM\", 24-hour."
              },
              "tz": {
                "type": "string",
                "description": "An IANA time zone (\"America/New_York\"); none is New York."
              }
            },
            "required": [
              "kind",
              "time"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "session"
              },
              "from": {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$",
                "description": "\"HH:MM\", 24-hour."
              },
              "to": {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$",
                "description": "\"HH:MM\", 24-hour."
              },
              "tz": {
                "type": "string",
                "description": "An IANA time zone (\"America/New_York\"); none is New York."
              }
            },
            "required": [
              "kind",
              "from",
              "to"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "max_trades_per_day"
              },
              "n": {
                "type": "integer",
                "minimum": 1,
                "maximum": 10
              }
            },
            "required": [
              "kind",
              "n"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "risk_per_trade_pct"
              },
              "pct": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 10,
                "description": "A percent as written: 0.5 is 0.5%."
              }
            },
            "required": [
              "kind",
              "pct"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "label": {
      "type": "string",
      "description": "A short text shown with the run."
    }
  },
  "required": [
    "study_id",
    "code",
    "symbol",
    "timeframe"
  ],
  "additionalProperties": false
}

Output Schema

{
  "type": "object",
  "properties": {
    "disclaimer": {
      "type": "string",
      "description": "The hypothetical-performance line, on a result (a run, or a study's runs): the same text the app shows with every result."
    },
    "status": {
      "type": "string",
      "enum": [
        "ran",
        "running",
        "refused",
        "rejected",
        "error",
        "held",
        "invalid_arguments",
        "not_found"
      ]
    },
    "run_id": {
      "type": "string"
    },
    "study_id": {
      "type": "string"
    },
    "message": {
      "type": "string"
    },
    "reason": {
      "type": "string"
    },
    "retryable": {
      "type": "boolean"
    },
    "replayed_from": {
      "type": "string"
    },
    "poll_after_seconds": {
      "type": "integer"
    },
    "version": {
      "type": "integer"
    },
    "headline": {
      "type": "string"
    },
    "grade": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "grade": {
          "type": [
            "string",
            "null"
          ]
        },
        "score": {
          "type": [
            "number",
            "null"
          ]
        },
        "trials": {
          "type": "number"
        },
        "deflated_sharpe": {
          "type": [
            "number",
            "null"
          ]
        },
        "search": {
          "type": "object",
          "properties": {
            "market": {
              "type": "string"
            },
            "runs": {
              "type": "object",
              "properties": {
                "in_study": {
                  "type": "integer"
                },
                "settings_30_days": {
                  "type": "integer"
                },
                "markets_in_study": {
                  "type": "integer"
                },
                "code_draws": {
                  "type": "integer"
                },
                "left_out_no_trades": {
                  "type": "integer"
                },
                "counted": {
                  "type": "integer"
                }
              },
              "required": [
                "in_study",
                "counted"
              ],
              "additionalProperties": false
            },
            "evaluations_without_a_run": {
              "type": "object",
              "properties": {
                "sweep_cells": {
                  "type": "integer"
                },
                "sensitivity_variants": {
                  "type": "integer"
                },
                "walk_forward_evaluations": {
                  "type": "integer"
                }
              },
              "required": [
                "sweep_cells",
                "sensitivity_variants",
                "walk_forward_evaluations"
              ],
              "additionalProperties": false
            },
            "discarded_candidates": {
              "type": "integer"
            },
            "independent_tries": {
              "type": "object",
              "properties": {
                "settings": {
                  "type": "number"
                },
                "evaluations": {
                  "type": "number"
                }
              },
              "required": [
                "settings",
                "evaluations"
              ],
              "additionalProperties": false
            },
            "distinct_setting": {
              "type": "string"
            }
          },
          "required": [
            "market",
            "runs",
            "evaluations_without_a_run",
            "discarded_candidates",
            "distinct_setting"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "grade",
        "score",
        "trials",
        "deflated_sharpe"
      ],
      "additionalProperties": false
    },
    "grade_withheld": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "trial_count_incomplete",
        "trade_floor",
        null
      ]
    },
    "lines": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "maxItems": 2
    },
    "metrics": {
      "type": "object",
      "properties": {
        "trades": {
          "type": [
            "integer",
            "null"
          ]
        },
        "net_return": {
          "type": [
            "number",
            "null"
          ]
        },
        "max_drawdown": {
          "type": [
            "number",
            "null"
          ]
        },
        "annualized_return": {
          "type": [
            "number",
            "null"
          ]
        },
        "win_rate": {
          "type": [
            "number",
            "null"
          ]
        },
        "sharpe": {
          "type": [
            "number",
            "null"
          ]
        },
        "profit_factor": {
          "type": [
            "number",
            "null"
          ]
        },
        "exposure": {
          "type": [
            "number",
            "null"
          ]
        },
        "trades_per_year": {
          "type": [
            "number",
            "null"
          ]
        },
        "trades_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "net_return_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "max_drawdown_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "annualized_return_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "win_rate_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "sharpe_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "profit_factor_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "exposure_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "trades_per_year_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        }
      },
      "required": [
        "trades",
        "net_return",
        "max_drawdown",
        "annualized_return",
        "win_rate",
        "sharpe",
        "profit_factor",
        "exposure",
        "trades_per_year"
      ],
      "additionalProperties": false
    },
    "basis": {
      "type": "object",
      "properties": {
        "net_return": {
          "type": "string"
        },
        "max_drawdown": {
          "type": "string"
        },
        "sharpe": {
          "type": "string"
        },
        "profit_factor": {
          "type": "string"
        },
        "exposure": {
          "type": "string"
        },
        "deflated_sharpe": {
          "type": "string"
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "buy_and_hold": {
      "type": "object",
      "properties": {
        "beat": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "beat_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "return": {
          "type": "null"
        },
        "return_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "not_on_api"
          ]
        }
      },
      "required": [
        "beat",
        "return",
        "return_withheld"
      ],
      "additionalProperties": false
    },
    "market": {
      "type": "object",
      "properties": {
        "symbol": {
          "type": "string"
        },
        "timeframe": {
          "type": "string"
        },
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        },
        "bars": {
          "type": "integer"
        },
        "source": {
          "type": "string"
        },
        "derived_only": {
          "type": "boolean",
          "description": "True when the market-data licence lets the account see only results derived from the prices (figures, never the prices or bars themselves). It says what may be shown, not how the quote is made."
        }
      },
      "required": [
        "symbol",
        "timeframe",
        "from",
        "to",
        "bars",
        "source",
        "derived_only"
      ],
      "additionalProperties": false
    },
    "window": {
      "type": "object",
      "properties": {
        "asked": {
          "type": [
            "object",
            "null"
          ]
        },
        "run": {
          "type": "object",
          "properties": {
            "from": {
              "type": "string"
            },
            "to": {
              "type": "string"
            }
          },
          "required": [
            "from",
            "to"
          ],
          "additionalProperties": false
        },
        "standard": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "bars": {
              "type": "integer"
            }
          },
          "required": [
            "bars"
          ],
          "additionalProperties": false
        },
        "longest": {
          "type": "object",
          "properties": {
            "all_daily_history": {
              "type": "boolean"
            },
            "from": {
              "type": "string"
            },
            "most_bars": {
              "type": "integer"
            },
            "note": {
              "type": "string"
            }
          },
          "required": [
            "all_daily_history"
          ],
          "additionalProperties": false
        },
        "start_later": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "reason": {
              "type": "string",
              "enum": [
                "history_starts",
                "bars_fetched"
              ]
            },
            "first_bar": {
              "type": "string"
            },
            "bars_fetched": {
              "type": "integer"
            }
          },
          "required": [
            "reason",
            "first_bar",
            "bars_fetched"
          ],
          "additionalProperties": false
        },
        "end_at_hold_out": {
          "type": [
            "string",
            "null"
          ]
        },
        "warmup": {
          "type": "object",
          "properties": {
            "bars": {
              "type": "integer"
            },
            "from": {
              "type": "string"
            },
            "to": {
              "type": "string"
            }
          },
          "required": [
            "bars"
          ],
          "additionalProperties": false
        },
        "gaps": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string"
              },
              "to": {
                "type": "string"
              }
            },
            "required": [
              "from",
              "to"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "asked",
        "run",
        "standard",
        "longest",
        "start_later",
        "end_at_hold_out"
      ],
      "additionalProperties": false
    },
    "settings": {
      "type": "object",
      "properties": {
        "commission": {
          "type": "object",
          "properties": {
            "value": {},
            "origin": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false
        },
        "slippage": {
          "type": "object",
          "properties": {
            "value": {},
            "origin": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false
        },
        "account_usd": {
          "type": "object",
          "properties": {
            "value": {},
            "origin": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false
        },
        "window": {
          "type": "object",
          "properties": {
            "value": {},
            "origin": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false
        },
        "costs_charged": {
          "type": "object",
          "properties": {
            "value": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "side": {
                    "type": "string",
                    "enum": [
                      "commission",
                      "slippage",
                      "spread"
                    ]
                  },
                  "amount": {
                    "type": "number"
                  },
                  "unit": {
                    "type": "string",
                    "enum": [
                      "percent",
                      "bps",
                      "usd_per_share",
                      "usd_per_ounce",
                      "pips",
                      "usd_per_order"
                    ]
                  },
                  "basis": {
                    "type": "string",
                    "enum": [
                      "per_side",
                      "round_trip"
                    ]
                  }
                },
                "required": [
                  "side",
                  "amount",
                  "unit",
                  "basis"
                ],
                "additionalProperties": false
              }
            },
            "origin": {
              "type": [
                "string",
                "null"
              ]
            },
            "note": {
              "type": "string"
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false,
          "description": "Every cost the run charged, in its own unit and basis. When `costs` was a list, this is the list; `commission` and `slippage` then appear only for a side the list left out (the market's default, as a fraction of the trade value). `note` says where a cost changed basis when charged."
        }
      },
      "required": [
        "account_usd",
        "window"
      ],
      "additionalProperties": false
    },
    "cost_table": {
      "type": "object",
      "properties": {
        "components": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "component": {
                "type": "string",
                "enum": [
                  "commission",
                  "slippage",
                  "spread"
                ]
              },
              "amount": {
                "type": "number"
              },
              "unit": {
                "type": "string",
                "enum": [
                  "percent",
                  "bps",
                  "usd_per_share",
                  "usd_per_ounce",
                  "pips",
                  "usd_per_order"
                ]
              },
              "basis": {
                "type": "string",
                "enum": [
                  "per_side",
                  "round_trip"
                ]
              },
              "per_round_trip": {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "number"
                  },
                  "unit": {
                    "type": "string",
                    "enum": [
                      "bps",
                      "pips",
                      "usd",
                      "usd_per_share",
                      "usd_per_ounce"
                    ]
                  }
                },
                "required": [
                  "amount",
                  "unit"
                ],
                "additionalProperties": false
              },
              "charged": {
                "type": "string",
                "description": "When and on what the engine takes it."
              },
              "origin": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "caller: your costs; default: the market's default."
              }
            },
            "required": [
              "component",
              "amount",
              "unit",
              "basis",
              "per_round_trip",
              "charged",
              "origin"
            ],
            "additionalProperties": false
          }
        },
        "defaults_replaced": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "commission",
              "slippage"
            ]
          },
          "description": "The market defaults your costs replaced: none of them was charged, and nothing was added to your costs."
        },
        "round_trip_total": {
          "type": "object",
          "properties": {
            "bps_of_value": {
              "type": "number"
            },
            "pips": {
              "type": "number"
            },
            "usd": {
              "type": "number"
            },
            "usd_per_share": {
              "type": "number"
            },
            "usd_per_ounce": {
              "type": "number"
            }
          },
          "required": [
            "bps_of_value"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "components",
        "defaults_replaced",
        "round_trip_total"
      ],
      "additionalProperties": false,
      "description": "Every cost the run charged: each component (commission, slippage, spread) with its amount, unit and basis, what it comes to per round trip, when it is taken, and whether it is yours (caller) or the market's default; the round trip summed by unit (pips on a currency pair, the costs stated in pips). Costs you send replace the market's defaults side by side: a commission replaces the default commission, a slippage or a spread replaces the default slippage, a side you leave out is charged at the market's default, and nothing is added on top."
    },
    "stated_rule_breaks": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "rule": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "of": {
            "type": "integer"
          }
        },
        "required": [
          "rule",
          "name",
          "count",
          "of"
        ],
        "additionalProperties": false
      }
    },
    "look_ahead": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "leak",
        "possible",
        "clean",
        null
      ]
    },
    "held_out": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "counts": {
          "type": "boolean"
        },
        "tested_run": {
          "type": "object",
          "properties": {
            "run_id": {
              "type": "string"
            },
            "version": {
              "type": "integer"
            }
          },
          "required": [
            "run_id"
          ],
          "additionalProperties": false
        },
        "covered_by": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "made_in": {
                "type": "string",
                "enum": [
                  "api",
                  "app"
                ]
              },
              "version": {
                "type": "integer"
              },
              "window": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string"
                  }
                },
                "required": [
                  "from",
                  "to"
                ],
                "additionalProperties": false
              },
              "run_id": {
                "type": "string"
              },
              "study_id": {
                "type": "string"
              }
            },
            "required": [
              "made_in",
              "version",
              "window"
            ],
            "additionalProperties": false
          }
        },
        "covered_by_total": {
          "type": "integer"
        }
      },
      "required": [
        "counts"
      ],
      "additionalProperties": false
    },
    "hold_out_estimate": {
      "type": "object",
      "properties": {
        "expected_trades": {
          "type": "integer"
        },
        "trade_floor": {
          "type": "integer"
        },
        "years": {
          "type": "number"
        }
      },
      "required": [
        "expected_trades",
        "trade_floor",
        "years"
      ],
      "additionalProperties": false
    },
    "notices": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "withheld",
              "cut"
            ]
          },
          "field": {
            "type": "string"
          },
          "reason": {
            "type": "string",
            "enum": [
              "market_data_licence",
              "trade_floor",
              "trial_count_incomplete",
              "not_on_api",
              "no_benchmark"
            ]
          },
          "returned": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "default_limit": {
            "type": "integer"
          },
          "text": {
            "type": "string"
          }
        },
        "required": [
          "kind",
          "field",
          "text"
        ],
        "additionalProperties": false
      }
    },
    "runs_left_today": {
      "type": "object",
      "properties": {
        "symbol": {
          "type": "string"
        },
        "left": {
          "type": "integer"
        },
        "per_day": {
          "type": "integer"
        }
      },
      "required": [
        "symbol",
        "left",
        "per_day"
      ],
      "additionalProperties": false
    },
    "next": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "tool": {
          "type": "string",
          "enum": [
            "run_backtest",
            "get_result"
          ]
        },
        "arguments": {
          "type": "object"
        },
        "why": {
          "type": "string"
        },
        "after_seconds": {
          "type": "integer"
        }
      },
      "required": [
        "tool",
        "arguments",
        "why"
      ],
      "additionalProperties": false
    },
    "trade_list": {
      "type": "object",
      "properties": {
        "total": {
          "type": "integer"
        },
        "page": {
          "type": "integer"
        },
        "pages": {
          "type": "integer"
        },
        "clock": {
          "type": "string",
          "enum": [
            "ET",
            "CT",
            "UTC"
          ],
          "description": "The clock the times are on; there when the bars are shorter than a day (a daily run gives days)."
        },
        "outcome_withheld": {
          "type": "string",
          "enum": [
            "trade_floor"
          ],
          "description": "There when every outcome is null: a run of fewer trades than the floor gives no win or loss, as it gives no win rate."
        },
        "message": {
          "type": "string"
        },
        "trades": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "entry": {
                "type": "string"
              },
              "exit": {
                "type": "string"
              },
              "side": {
                "type": "string",
                "enum": [
                  "long",
                  "short"
                ]
              },
              "outcome": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "win",
                  "loss",
                  "flat",
                  null
                ]
              },
              "exit_type": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "stop",
                  "target",
                  "trailing stop",
                  "time limit",
                  "exit rule",
                  "end of data",
                  null
                ],
                "description": "Which exit ended the trade (never a price or level). There on a list kept with exit types."
              }
            },
            "required": [
              "entry",
              "exit",
              "side",
              "outcome"
            ],
            "additionalProperties": false
          },
          "maxItems": 100
        },
        "next": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "tool": {
              "type": "string",
              "enum": [
                "run_backtest",
                "get_result"
              ]
            },
            "arguments": {
              "type": "object"
            },
            "why": {
              "type": "string"
            },
            "after_seconds": {
              "type": "integer"
            }
          },
          "required": [
            "tool",
            "arguments",
            "why"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "total",
        "trades"
      ],
      "additionalProperties": false,
      "description": "The run's trades in the order they were made, a page at a time: when each entered and left (a day on daily bars; a time on the `clock` on shorter ones; \"open at the end\" for a trade still open when the data ended), its side, whether it won or lost after costs, and which exit ended it (a word: stop, exit rule, target, time limit…). No prices, levels, sizes or returns."
    }
  },
  "required": [
    "status"
  ],
  "additionalProperties": false
}
🟢get_result(run_id, study_id, version, before_version, trades_page)

Reads a backtest result by its run_id (when run_backtest answered "running", call this until the run ends), or a study's runs by study_id (one of them with version). A run comes with its trades, a page at a time (trades_page).

Input Schema

{
  "type": "object",
  "properties": {
    "run_id": {
      "type": "string",
      "description": "A run_id run_backtest or run_held_out_test returned."
    },
    "study_id": {
      "type": "string",
      "description": "A study's id, for its runs (the newest 20 by default); with `version`, one of them."
    },
    "version": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 1
        },
        {
          "type": "string",
          "pattern": "^[vV]?\\d+$"
        }
      ]
    },
    "before_version": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 1
        },
        {
          "type": "string",
          "pattern": "^[vV]?\\d+$"
        }
      ],
      "description": "With study_id: the 20 runs before this version (a list's `next` gives it)."
    },
    "trades_page": {
      "type": "integer",
      "minimum": 1,
      "description": "With a run (run_id, or study_id with version): the page of its trade list, from 1; a page holds 100 trades. Left out: the first."
    }
  },
  "required": [],
  "additionalProperties": false
}

Output Schema

{
  "type": "object",
  "properties": {
    "disclaimer": {
      "type": "string",
      "description": "The hypothetical-performance line, on a result (a run, or a study's runs): the same text the app shows with every result."
    },
    "status": {
      "type": "string",
      "enum": [
        "ran",
        "running",
        "refused",
        "rejected",
        "error",
        "held",
        "invalid_arguments",
        "not_found",
        "study"
      ]
    },
    "run_id": {
      "type": "string"
    },
    "study_id": {
      "type": "string"
    },
    "message": {
      "type": "string"
    },
    "reason": {
      "type": "string"
    },
    "retryable": {
      "type": "boolean"
    },
    "replayed_from": {
      "type": "string"
    },
    "poll_after_seconds": {
      "type": "integer"
    },
    "version": {
      "type": "integer"
    },
    "headline": {
      "type": "string"
    },
    "grade": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "grade": {
          "type": [
            "string",
            "null"
          ]
        },
        "score": {
          "type": [
            "number",
            "null"
          ]
        },
        "trials": {
          "type": "number"
        },
        "deflated_sharpe": {
          "type": [
            "number",
            "null"
          ]
        },
        "search": {
          "type": "object",
          "properties": {
            "market": {
              "type": "string"
            },
            "runs": {
              "type": "object",
              "properties": {
                "in_study": {
                  "type": "integer"
                },
                "settings_30_days": {
                  "type": "integer"
                },
                "markets_in_study": {
                  "type": "integer"
                },
                "code_draws": {
                  "type": "integer"
                },
                "left_out_no_trades": {
                  "type": "integer"
                },
                "counted": {
                  "type": "integer"
                }
              },
              "required": [
                "in_study",
                "counted"
              ],
              "additionalProperties": false
            },
            "evaluations_without_a_run": {
              "type": "object",
              "properties": {
                "sweep_cells": {
                  "type": "integer"
                },
                "sensitivity_variants": {
                  "type": "integer"
                },
                "walk_forward_evaluations": {
                  "type": "integer"
                }
              },
              "required": [
                "sweep_cells",
                "sensitivity_variants",
                "walk_forward_evaluations"
              ],
              "additionalProperties": false
            },
            "discarded_candidates": {
              "type": "integer"
            },
            "independent_tries": {
              "type": "object",
              "properties": {
                "settings": {
                  "type": "number"
                },
                "evaluations": {
                  "type": "number"
                }
              },
              "required": [
                "settings",
                "evaluations"
              ],
              "additionalProperties": false
            },
            "distinct_setting": {
              "type": "string"
            }
          },
          "required": [
            "market",
            "runs",
            "evaluations_without_a_run",
            "discarded_candidates",
            "distinct_setting"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "grade",
        "score",
        "trials",
        "deflated_sharpe"
      ],
      "additionalProperties": false
    },
    "grade_withheld": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "trial_count_incomplete",
        "trade_floor",
        null
      ]
    },
    "lines": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "maxItems": 2
    },
    "metrics": {
      "type": "object",
      "properties": {
        "trades": {
          "type": [
            "integer",
            "null"
          ]
        },
        "net_return": {
          "type": [
            "number",
            "null"
          ]
        },
        "max_drawdown": {
          "type": [
            "number",
            "null"
          ]
        },
        "annualized_return": {
          "type": [
            "number",
            "null"
          ]
        },
        "win_rate": {
          "type": [
            "number",
            "null"
          ]
        },
        "sharpe": {
          "type": [
            "number",
            "null"
          ]
        },
        "profit_factor": {
          "type": [
            "number",
            "null"
          ]
        },
        "exposure": {
          "type": [
            "number",
            "null"
          ]
        },
        "trades_per_year": {
          "type": [
            "number",
            "null"
          ]
        },
        "trades_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "net_return_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "max_drawdown_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "annualized_return_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "win_rate_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "sharpe_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "profit_factor_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "exposure_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "trades_per_year_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        }
      },
      "required": [
        "trades",
        "net_return",
        "max_drawdown",
        "annualized_return",
        "win_rate",
        "sharpe",
        "profit_factor",
        "exposure",
        "trades_per_year"
      ],
      "additionalProperties": false
    },
    "basis": {
      "type": "object",
      "properties": {
        "net_return": {
          "type": "string"
        },
        "max_drawdown": {
          "type": "string"
        },
        "sharpe": {
          "type": "string"
        },
        "profit_factor": {
          "type": "string"
        },
        "exposure": {
          "type": "string"
        },
        "deflated_sharpe": {
          "type": "string"
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "buy_and_hold": {
      "type": "object",
      "properties": {
        "beat": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "beat_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "return": {
          "type": "null"
        },
        "return_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "not_on_api"
          ]
        }
      },
      "required": [
        "beat",
        "return",
        "return_withheld"
      ],
      "additionalProperties": false
    },
    "market": {
      "type": "object",
      "properties": {
        "symbol": {
          "type": "string"
        },
        "timeframe": {
          "type": "string"
        },
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        },
        "bars": {
          "type": "integer"
        },
        "source": {
          "type": "string"
        },
        "derived_only": {
          "type": "boolean",
          "description": "True when the market-data licence lets the account see only results derived from the prices (figures, never the prices or bars themselves). It says what may be shown, not how the quote is made."
        }
      },
      "required": [
        "symbol",
        "timeframe",
        "from",
        "to",
        "bars",
        "source",
        "derived_only"
      ],
      "additionalProperties": false
    },
    "window": {
      "type": "object",
      "properties": {
        "asked": {
          "type": [
            "object",
            "null"
          ]
        },
        "run": {
          "type": "object",
          "properties": {
            "from": {
              "type": "string"
            },
            "to": {
              "type": "string"
            }
          },
          "required": [
            "from",
            "to"
          ],
          "additionalProperties": false
        },
        "standard": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "bars": {
              "type": "integer"
            }
          },
          "required": [
            "bars"
          ],
          "additionalProperties": false
        },
        "longest": {
          "type": "object",
          "properties": {
            "all_daily_history": {
              "type": "boolean"
            },
            "from": {
              "type": "string"
            },
            "most_bars": {
              "type": "integer"
            },
            "note": {
              "type": "string"
            }
          },
          "required": [
            "all_daily_history"
          ],
          "additionalProperties": false
        },
        "start_later": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "reason": {
              "type": "string",
              "enum": [
                "history_starts",
                "bars_fetched"
              ]
            },
            "first_bar": {
              "type": "string"
            },
            "bars_fetched": {
              "type": "integer"
            }
          },
          "required": [
            "reason",
            "first_bar",
            "bars_fetched"
          ],
          "additionalProperties": false
        },
        "end_at_hold_out": {
          "type": [
            "string",
            "null"
          ]
        },
        "warmup": {
          "type": "object",
          "properties": {
            "bars": {
              "type": "integer"
            },
            "from": {
              "type": "string"
            },
            "to": {
              "type": "string"
            }
          },
          "required": [
            "bars"
          ],
          "additionalProperties": false
        },
        "gaps": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string"
              },
              "to": {
                "type": "string"
              }
            },
            "required": [
              "from",
              "to"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "asked",
        "run",
        "standard",
        "longest",
        "start_later",
        "end_at_hold_out"
      ],
      "additionalProperties": false
    },
    "settings": {
      "type": "object",
      "properties": {
        "commission": {
          "type": "object",
          "properties": {
            "value": {},
            "origin": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false
        },
        "slippage": {
          "type": "object",
          "properties": {
            "value": {},
            "origin": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false
        },
        "account_usd": {
          "type": "object",
          "properties": {
            "value": {},
            "origin": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false
        },
        "window": {
          "type": "object",
          "properties": {
            "value": {},
            "origin": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false
        },
        "costs_charged": {
          "type": "object",
          "properties": {
            "value": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "side": {
                    "type": "string",
                    "enum": [
                      "commission",
                      "slippage",
                      "spread"
                    ]
                  },
                  "amount": {
                    "type": "number"
                  },
                  "unit": {
                    "type": "string",
                    "enum": [
                      "percent",
                      "bps",
                      "usd_per_share",
                      "usd_per_ounce",
                      "pips",
                      "usd_per_order"
                    ]
                  },
                  "basis": {
                    "type": "string",
                    "enum": [
                      "per_side",
                      "round_trip"
                    ]
                  }
                },
                "required": [
                  "side",
                  "amount",
                  "unit",
                  "basis"
                ],
                "additionalProperties": false
              }
            },
            "origin": {
              "type": [
                "string",
                "null"
              ]
            },
            "note": {
              "type": "string"
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false,
          "description": "Every cost the run charged, in its own unit and basis. When `costs` was a list, this is the list; `commission` and `slippage` then appear only for a side the list left out (the market's default, as a fraction of the trade value). `note` says where a cost changed basis when charged."
        }
      },
      "required": [
        "account_usd",
        "window"
      ],
      "additionalProperties": false
    },
    "cost_table": {
      "type": "object",
      "properties": {
        "components": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "component": {
                "type": "string",
                "enum": [
                  "commission",
                  "slippage",
                  "spread"
                ]
              },
              "amount": {
                "type": "number"
              },
              "unit": {
                "type": "string",
                "enum": [
                  "percent",
                  "bps",
                  "usd_per_share",
                  "usd_per_ounce",
                  "pips",
                  "usd_per_order"
                ]
              },
              "basis": {
                "type": "string",
                "enum": [
                  "per_side",
                  "round_trip"
                ]
              },
              "per_round_trip": {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "number"
                  },
                  "unit": {
                    "type": "string",
                    "enum": [
                      "bps",
                      "pips",
                      "usd",
                      "usd_per_share",
                      "usd_per_ounce"
                    ]
                  }
                },
                "required": [
                  "amount",
                  "unit"
                ],
                "additionalProperties": false
              },
              "charged": {
                "type": "string",
                "description": "When and on what the engine takes it."
              },
              "origin": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "caller: your costs; default: the market's default."
              }
            },
            "required": [
              "component",
              "amount",
              "unit",
              "basis",
              "per_round_trip",
              "charged",
              "origin"
            ],
            "additionalProperties": false
          }
        },
        "defaults_replaced": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "commission",
              "slippage"
            ]
          },
          "description": "The market defaults your costs replaced: none of them was charged, and nothing was added to your costs."
        },
        "round_trip_total": {
          "type": "object",
          "properties": {
            "bps_of_value": {
              "type": "number"
            },
            "pips": {
              "type": "number"
            },
            "usd": {
              "type": "number"
            },
            "usd_per_share": {
              "type": "number"
            },
            "usd_per_ounce": {
              "type": "number"
            }
          },
          "required": [
            "bps_of_value"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "components",
        "defaults_replaced",
        "round_trip_total"
      ],
      "additionalProperties": false,
      "description": "Every cost the run charged: each component (commission, slippage, spread) with its amount, unit and basis, what it comes to per round trip, when it is taken, and whether it is yours (caller) or the market's default; the round trip summed by unit (pips on a currency pair, the costs stated in pips). Costs you send replace the market's defaults side by side: a commission replaces the default commission, a slippage or a spread replaces the default slippage, a side you leave out is charged at the market's default, and nothing is added on top."
    },
    "stated_rule_breaks": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "rule": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "of": {
            "type": "integer"
          }
        },
        "required": [
          "rule",
          "name",
          "count",
          "of"
        ],
        "additionalProperties": false
      }
    },
    "look_ahead": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "leak",
        "possible",
        "clean",
        null
      ]
    },
    "held_out": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "counts": {
          "type": "boolean"
        },
        "tested_run": {
          "type": "object",
          "properties": {
            "run_id": {
              "type": "string"
            },
            "version": {
              "type": "integer"
            }
          },
          "required": [
            "run_id"
          ],
          "additionalProperties": false
        },
        "covered_by": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "made_in": {
                "type": "string",
                "enum": [
                  "api",
                  "app"
                ]
              },
              "version": {
                "type": "integer"
              },
              "window": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string"
                  }
                },
                "required": [
                  "from",
                  "to"
                ],
                "additionalProperties": false
              },
              "run_id": {
                "type": "string"
              },
              "study_id": {
                "type": "string"
              }
            },
            "required": [
              "made_in",
              "version",
              "window"
            ],
            "additionalProperties": false
          }
        },
        "covered_by_total": {
          "type": "integer"
        }
      },
      "required": [
        "counts"
      ],
      "additionalProperties": false
    },
    "hold_out_estimate": {
      "type": "object",
      "properties": {
        "expected_trades": {
          "type": "integer"
        },
        "trade_floor": {
          "type": "integer"
        },
        "years": {
          "type": "number"
        }
      },
      "required": [
        "expected_trades",
        "trade_floor",
        "years"
      ],
      "additionalProperties": false
    },
    "notices": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "withheld",
              "cut"
            ]
          },
          "field": {
            "type": "string"
          },
          "reason": {
            "type": "string",
            "enum": [
              "market_data_licence",
              "trade_floor",
              "trial_count_incomplete",
              "not_on_api",
              "no_benchmark"
            ]
          },
          "returned": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "default_limit": {
            "type": "integer"
          },
          "text": {
            "type": "string"
          }
        },
        "required": [
          "kind",
          "field",
          "text"
        ],
        "additionalProperties": false
      }
    },
    "runs_left_today": {
      "type": "object",
      "properties": {
        "symbol": {
          "type": "string"
        },
        "left": {
          "type": "integer"
        },
        "per_day": {
          "type": "integer"
        }
      },
      "required": [
        "symbol",
        "left",
        "per_day"
      ],
      "additionalProperties": false
    },
    "next": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "tool": {
          "type": "string",
          "enum": [
            "run_backtest",
            "get_result"
          ]
        },
        "arguments": {
          "type": "object"
        },
        "why": {
          "type": "string"
        },
        "after_seconds": {
          "type": "integer"
        }
      },
      "required": [
        "tool",
        "arguments",
        "why"
      ],
      "additionalProperties": false
    },
    "hold_out": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        }
      },
      "required": [
        "from"
      ],
      "additionalProperties": false
    },
    "runs": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "version": {
            "type": "integer"
          },
          "run_id": {
            "type": "string"
          },
          "headline": {
            "type": "string"
          },
          "grade": {
            "type": [
              "string",
              "null"
            ]
          },
          "trials": {
            "type": [
              "number",
              "null"
            ]
          },
          "net_return": {
            "type": [
              "number",
              "null"
            ]
          },
          "net_return_withheld": {
            "type": "string",
            "enum": [
              "market_data_licence",
              "trade_floor",
              "trial_count_incomplete",
              "not_on_api",
              "no_benchmark"
            ]
          },
          "grade_withheld": {
            "type": "string",
            "enum": [
              "trial_count_incomplete",
              "trade_floor"
            ]
          }
        },
        "required": [
          "version",
          "run_id",
          "headline",
          "grade",
          "trials",
          "net_return"
        ],
        "additionalProperties": false
      }
    },
    "highest_simulated_value": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "version": {
          "type": "integer"
        },
        "run_id": {
          "type": "string"
        },
        "net_return": {
          "type": "number"
        },
        "compared_runs": {
          "type": "integer"
        },
        "withheld_runs": {
          "type": "integer"
        }
      },
      "required": [
        "version",
        "run_id",
        "net_return",
        "compared_runs",
        "withheld_runs"
      ],
      "additionalProperties": false
    },
    "trade_list": {
      "type": "object",
      "properties": {
        "total": {
          "type": "integer"
        },
        "page": {
          "type": "integer"
        },
        "pages": {
          "type": "integer"
        },
        "clock": {
          "type": "string",
          "enum": [
            "ET",
            "CT",
            "UTC"
          ],
          "description": "The clock the times are on; there when the bars are shorter than a day (a daily run gives days)."
        },
        "outcome_withheld": {
          "type": "string",
          "enum": [
            "trade_floor"
          ],
          "description": "There when every outcome is null: a run of fewer trades than the floor gives no win or loss, as it gives no win rate."
        },
        "message": {
          "type": "string"
        },
        "trades": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "entry": {
                "type": "string"
              },
              "exit": {
                "type": "string"
              },
              "side": {
                "type": "string",
                "enum": [
                  "long",
                  "short"
                ]
              },
              "outcome": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "win",
                  "loss",
                  "flat",
                  null
                ]
              },
              "exit_type": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "stop",
                  "target",
                  "trailing stop",
                  "time limit",
                  "exit rule",
                  "end of data",
                  null
                ],
                "description": "Which exit ended the trade (never a price or level). There on a list kept with exit types."
              }
            },
            "required": [
              "entry",
              "exit",
              "side",
              "outcome"
            ],
            "additionalProperties": false
          },
          "maxItems": 100
        },
        "next": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "tool": {
              "type": "string",
              "enum": [
                "run_backtest",
                "get_result"
              ]
            },
            "arguments": {
              "type": "object"
            },
            "why": {
              "type": "string"
            },
            "after_seconds": {
              "type": "integer"
            }
          },
          "required": [
            "tool",
            "arguments",
            "why"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "total",
        "trades"
      ],
      "additionalProperties": false,
      "description": "The run's trades in the order they were made, a page at a time: when each entered and left (a day on daily bars; a time on the `clock` on shorter ones; \"open at the end\" for a trade still open when the data ended), its side, whether it won or lost after costs, and which exit ended it (a word: stop, exit rule, target, time limit…). No prices, levels, sizes or returns."
    }
  },
  "required": [
    "status"
  ],
  "additionalProperties": false
}
⚪run_held_out_test(run_id)

The final out-of-sample check: runs a finished run's exact code once over its study's hold-out period. Call it at the end, on the run you would keep: the first held-out test per account and market is the one that counts, and a hold-out with too few trades for figures (a result needs 10) spends it all the same: each development run says how many trades the hold-out is expected to hold, in `hold_out_estimate`.

Input Schema

{
  "type": "object",
  "properties": {
    "run_id": {
      "type": "string",
      "description": "A run of a study with a hold-out, which ran."
    }
  },
  "required": [
    "run_id"
  ],
  "additionalProperties": false
}

Output Schema

{
  "type": "object",
  "properties": {
    "disclaimer": {
      "type": "string",
      "description": "The hypothetical-performance line, on a result (a run, or a study's runs): the same text the app shows with every result."
    },
    "status": {
      "type": "string",
      "enum": [
        "ran",
        "running",
        "refused",
        "rejected",
        "error",
        "held",
        "invalid_arguments",
        "not_found"
      ]
    },
    "run_id": {
      "type": "string"
    },
    "study_id": {
      "type": "string"
    },
    "message": {
      "type": "string"
    },
    "reason": {
      "type": "string"
    },
    "retryable": {
      "type": "boolean"
    },
    "replayed_from": {
      "type": "string"
    },
    "poll_after_seconds": {
      "type": "integer"
    },
    "version": {
      "type": "integer"
    },
    "headline": {
      "type": "string"
    },
    "grade": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "grade": {
          "type": [
            "string",
            "null"
          ]
        },
        "score": {
          "type": [
            "number",
            "null"
          ]
        },
        "trials": {
          "type": "number"
        },
        "deflated_sharpe": {
          "type": [
            "number",
            "null"
          ]
        },
        "search": {
          "type": "object",
          "properties": {
            "market": {
              "type": "string"
            },
            "runs": {
              "type": "object",
              "properties": {
                "in_study": {
                  "type": "integer"
                },
                "settings_30_days": {
                  "type": "integer"
                },
                "markets_in_study": {
                  "type": "integer"
                },
                "code_draws": {
                  "type": "integer"
                },
                "left_out_no_trades": {
                  "type": "integer"
                },
                "counted": {
                  "type": "integer"
                }
              },
              "required": [
                "in_study",
                "counted"
              ],
              "additionalProperties": false
            },
            "evaluations_without_a_run": {
              "type": "object",
              "properties": {
                "sweep_cells": {
                  "type": "integer"
                },
                "sensitivity_variants": {
                  "type": "integer"
                },
                "walk_forward_evaluations": {
                  "type": "integer"
                }
              },
              "required": [
                "sweep_cells",
                "sensitivity_variants",
                "walk_forward_evaluations"
              ],
              "additionalProperties": false
            },
            "discarded_candidates": {
              "type": "integer"
            },
            "independent_tries": {
              "type": "object",
              "properties": {
                "settings": {
                  "type": "number"
                },
                "evaluations": {
                  "type": "number"
                }
              },
              "required": [
                "settings",
                "evaluations"
              ],
              "additionalProperties": false
            },
            "distinct_setting": {
              "type": "string"
            }
          },
          "required": [
            "market",
            "runs",
            "evaluations_without_a_run",
            "discarded_candidates",
            "distinct_setting"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "grade",
        "score",
        "trials",
        "deflated_sharpe"
      ],
      "additionalProperties": false
    },
    "grade_withheld": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "trial_count_incomplete",
        "trade_floor",
        null
      ]
    },
    "lines": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "maxItems": 2
    },
    "metrics": {
      "type": "object",
      "properties": {
        "trades": {
          "type": [
            "integer",
            "null"
          ]
        },
        "net_return": {
          "type": [
            "number",
            "null"
          ]
        },
        "max_drawdown": {
          "type": [
            "number",
            "null"
          ]
        },
        "annualized_return": {
          "type": [
            "number",
            "null"
          ]
        },
        "win_rate": {
          "type": [
            "number",
            "null"
          ]
        },
        "sharpe": {
          "type": [
            "number",
            "null"
          ]
        },
        "profit_factor": {
          "type": [
            "number",
            "null"
          ]
        },
        "exposure": {
          "type": [
            "number",
            "null"
          ]
        },
        "trades_per_year": {
          "type": [
            "number",
            "null"
          ]
        },
        "trades_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "net_return_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "max_drawdown_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "annualized_return_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "win_rate_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "sharpe_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "profit_factor_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "exposure_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "trades_per_year_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        }
      },
      "required": [
        "trades",
        "net_return",
        "max_drawdown",
        "annualized_return",
        "win_rate",
        "sharpe",
        "profit_factor",
        "exposure",
        "trades_per_year"
      ],
      "additionalProperties": false
    },
    "basis": {
      "type": "object",
      "properties": {
        "net_return": {
          "type": "string"
        },
        "max_drawdown": {
          "type": "string"
        },
        "sharpe": {
          "type": "string"
        },
        "profit_factor": {
          "type": "string"
        },
        "exposure": {
          "type": "string"
        },
        "deflated_sharpe": {
          "type": "string"
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "buy_and_hold": {
      "type": "object",
      "properties": {
        "beat": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "beat_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "trade_floor",
            "trial_count_incomplete",
            "not_on_api",
            "no_benchmark"
          ]
        },
        "return": {
          "type": "null"
        },
        "return_withheld": {
          "type": "string",
          "enum": [
            "market_data_licence",
            "not_on_api"
          ]
        }
      },
      "required": [
        "beat",
        "return",
        "return_withheld"
      ],
      "additionalProperties": false
    },
    "market": {
      "type": "object",
      "properties": {
        "symbol": {
          "type": "string"
        },
        "timeframe": {
          "type": "string"
        },
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        },
        "bars": {
          "type": "integer"
        },
        "source": {
          "type": "string"
        },
        "derived_only": {
          "type": "boolean",
          "description": "True when the market-data licence lets the account see only results derived from the prices (figures, never the prices or bars themselves). It says what may be shown, not how the quote is made."
        }
      },
      "required": [
        "symbol",
        "timeframe",
        "from",
        "to",
        "bars",
        "source",
        "derived_only"
      ],
      "additionalProperties": false
    },
    "window": {
      "type": "object",
      "properties": {
        "asked": {
          "type": [
            "object",
            "null"
          ]
        },
        "run": {
          "type": "object",
          "properties": {
            "from": {
              "type": "string"
            },
            "to": {
              "type": "string"
            }
          },
          "required": [
            "from",
            "to"
          ],
          "additionalProperties": false
        },
        "standard": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "bars": {
              "type": "integer"
            }
          },
          "required": [
            "bars"
          ],
          "additionalProperties": false
        },
        "longest": {
          "type": "object",
          "properties": {
            "all_daily_history": {
              "type": "boolean"
            },
            "from": {
              "type": "string"
            },
            "most_bars": {
              "type": "integer"
            },
            "note": {
              "type": "string"
            }
          },
          "required": [
            "all_daily_history"
          ],
          "additionalProperties": false
        },
        "start_later": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "reason": {
              "type": "string",
              "enum": [
                "history_starts",
                "bars_fetched"
              ]
            },
            "first_bar": {
              "type": "string"
            },
            "bars_fetched": {
              "type": "integer"
            }
          },
          "required": [
            "reason",
            "first_bar",
            "bars_fetched"
          ],
          "additionalProperties": false
        },
        "end_at_hold_out": {
          "type": [
            "string",
            "null"
          ]
        },
        "warmup": {
          "type": "object",
          "properties": {
            "bars": {
              "type": "integer"
            },
            "from": {
              "type": "string"
            },
            "to": {
              "type": "string"
            }
          },
          "required": [
            "bars"
          ],
          "additionalProperties": false
        },
        "gaps": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string"
              },
              "to": {
                "type": "string"
              }
            },
            "required": [
              "from",
              "to"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "asked",
        "run",
        "standard",
        "longest",
        "start_later",
        "end_at_hold_out"
      ],
      "additionalProperties": false
    },
    "settings": {
      "type": "object",
      "properties": {
        "commission": {
          "type": "object",
          "properties": {
            "value": {},
            "origin": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false
        },
        "slippage": {
          "type": "object",
          "properties": {
            "value": {},
            "origin": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false
        },
        "account_usd": {
          "type": "object",
          "properties": {
            "value": {},
            "origin": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false
        },
        "window": {
          "type": "object",
          "properties": {
            "value": {},
            "origin": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false
        },
        "costs_charged": {
          "type": "object",
          "properties": {
            "value": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "side": {
                    "type": "string",
                    "enum": [
                      "commission",
                      "slippage",
                      "spread"
                    ]
                  },
                  "amount": {
                    "type": "number"
                  },
                  "unit": {
                    "type": "string",
                    "enum": [
                      "percent",
                      "bps",
                      "usd_per_share",
                      "usd_per_ounce",
                      "pips",
                      "usd_per_order"
                    ]
                  },
                  "basis": {
                    "type": "string",
                    "enum": [
                      "per_side",
                      "round_trip"
                    ]
                  }
                },
                "required": [
                  "side",
                  "amount",
                  "unit",
                  "basis"
                ],
                "additionalProperties": false
              }
            },
            "origin": {
              "type": [
                "string",
                "null"
              ]
            },
            "note": {
              "type": "string"
            }
          },
          "required": [
            "value",
            "origin"
          ],
          "additionalProperties": false,
          "description": "Every cost the run charged, in its own unit and basis. When `costs` was a list, this is the list; `commission` and `slippage` then appear only for a side the list left out (the market's default, as a fraction of the trade value). `note` says where a cost changed basis when charged."
        }
      },
      "required": [
        "account_usd",
        "window"
      ],
      "additionalProperties": false
    },
    "cost_table": {
      "type": "object",
      "properties": {
        "components": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "component": {
                "type": "string",
                "enum": [
                  "commission",
                  "slippage",
                  "spread"
                ]
              },
              "amount": {
                "type": "number"
              },
              "unit": {
                "type": "string",
                "enum": [
                  "percent",
                  "bps",
                  "usd_per_share",
                  "usd_per_ounce",
                  "pips",
                  "usd_per_order"
                ]
              },
              "basis": {
                "type": "string",
                "enum": [
                  "per_side",
                  "round_trip"
                ]
              },
              "per_round_trip": {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "number"
                  },
                  "unit": {
                    "type": "string",
                    "enum": [
                      "bps",
                      "pips",
                      "usd",
                      "usd_per_share",
                      "usd_per_ounce"
                    ]
                  }
                },
                "required": [
                  "amount",
                  "unit"
                ],
                "additionalProperties": false
              },
              "charged": {
                "type": "string",
                "description": "When and on what the engine takes it."
              },
              "origin": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "caller: your costs; default: the market's default."
              }
            },
            "required": [
              "component",
              "amount",
              "unit",
              "basis",
              "per_round_trip",
              "charged",
              "origin"
            ],
            "additionalProperties": false
          }
        },
        "defaults_replaced": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "commission",
              "slippage"
            ]
          },
          "description": "The market defaults your costs replaced: none of them was charged, and nothing was added to your costs."
        },
        "round_trip_total": {
          "type": "object",
          "properties": {
            "bps_of_value": {
              "type": "number"
            },
            "pips": {
              "type": "number"
            },
            "usd": {
              "type": "number"
            },
            "usd_per_share": {
              "type": "number"
            },
            "usd_per_ounce": {
              "type": "number"
            }
          },
          "required": [
            "bps_of_value"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "components",
        "defaults_replaced",
        "round_trip_total"
      ],
      "additionalProperties": false,
      "description": "Every cost the run charged: each component (commission, slippage, spread) with its amount, unit and basis, what it comes to per round trip, when it is taken, and whether it is yours (caller) or the market's default; the round trip summed by unit (pips on a currency pair, the costs stated in pips). Costs you send replace the market's defaults side by side: a commission replaces the default commission, a slippage or a spread replaces the default slippage, a side you leave out is charged at the market's default, and nothing is added on top."
    },
    "stated_rule_breaks": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "rule": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "of": {
            "type": "integer"
          }
        },
        "required": [
          "rule",
          "name",
          "count",
          "of"
        ],
        "additionalProperties": false
      }
    },
    "look_ahead": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "leak",
        "possible",
        "clean",
        null
      ]
    },
    "held_out": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "counts": {
          "type": "boolean"
        },
        "tested_run": {
          "type": "object",
          "properties": {
            "run_id": {
              "type": "string"
            },
            "version": {
              "type": "integer"
            }
          },
          "required": [
            "run_id"
          ],
          "additionalProperties": false
        },
        "covered_by": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "made_in": {
                "type": "string",
                "enum": [
                  "api",
                  "app"
                ]
              },
              "version": {
                "type": "integer"
              },
              "window": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string"
                  }
                },
                "required": [
                  "from",
                  "to"
                ],
                "additionalProperties": false
              },
              "run_id": {
                "type": "string"
              },
              "study_id": {
                "type": "string"
              }
            },
            "required": [
              "made_in",
              "version",
              "window"
            ],
            "additionalProperties": false
          }
        },
        "covered_by_total": {
          "type": "integer"
        }
      },
      "required": [
        "counts"
      ],
      "additionalProperties": false
    },
    "hold_out_estimate": {
      "type": "object",
      "properties": {
        "expected_trades": {
          "type": "integer"
        },
        "trade_floor": {
          "type": "integer"
        },
        "years": {
          "type": "number"
        }
      },
      "required": [
        "expected_trades",
        "trade_floor",
        "years"
      ],
      "additionalProperties": false
    },
    "notices": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "withheld",
              "cut"
            ]
          },
          "field": {
            "type": "string"
          },
          "reason": {
            "type": "string",
            "enum": [
              "market_data_licence",
              "trade_floor",
              "trial_count_incomplete",
              "not_on_api",
              "no_benchmark"
            ]
          },
          "returned": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "default_limit": {
            "type": "integer"
          },
          "text": {
            "type": "string"
          }
        },
        "required": [
          "kind",
          "field",
          "text"
        ],
        "additionalProperties": false
      }
    },
    "runs_left_today": {
      "type": "object",
      "properties": {
        "symbol": {
          "type": "string"
        },
        "left": {
          "type": "integer"
        },
        "per_day": {
          "type": "integer"
        }
      },
      "required": [
        "symbol",
        "left",
        "per_day"
      ],
      "additionalProperties": false
    },
    "next": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "tool": {
          "type": "string",
          "enum": [
            "run_backtest",
            "get_result"
          ]
        },
        "arguments": {
          "type": "object"
        },
        "why": {
          "type": "string"
        },
        "after_seconds": {
          "type": "integer"
        }
      },
      "required": [
        "tool",
        "arguments",
        "why"
      ],
      "additionalProperties": false
    },
    "trade_list": {
      "type": "object",
      "properties": {
        "total": {
          "type": "integer"
        },
        "page": {
          "type": "integer"
        },
        "pages": {
          "type": "integer"
        },
        "clock": {
          "type": "string",
          "enum": [
            "ET",
            "CT",
            "UTC"
          ],
          "description": "The clock the times are on; there when the bars are shorter than a day (a daily run gives days)."
        },
        "outcome_withheld": {
          "type": "string",
          "enum": [
            "trade_floor"
          ],
          "description": "There when every outcome is null: a run of fewer trades than the floor gives no win or loss, as it gives no win rate."
        },
        "message": {
          "type": "string"
        },
        "trades": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "entry": {
                "type": "string"
              },
              "exit": {
                "type": "string"
              },
              "side": {
                "type": "string",
                "enum": [
                  "long",
                  "short"
                ]
              },
              "outcome": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "win",
                  "loss",
                  "flat",
                  null
                ]
              },
              "exit_type": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "stop",
                  "target",
                  "trailing stop",
                  "time limit",
                  "exit rule",
                  "end of data",
                  null
                ],
                "description": "Which exit ended the trade (never a price or level). There on a list kept with exit types."
              }
            },
            "required": [
              "entry",
              "exit",
              "side",
              "outcome"
            ],
            "additionalProperties": false
          },
          "maxItems": 100
        },
        "next": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "tool": {
              "type": "string",
              "enum": [
                "run_backtest",
                "get_result"
              ]
            },
            "arguments": {
              "type": "object"
            },
            "why": {
              "type": "string"
            },
            "after_seconds": {
              "type": "integer"
            }
          },
          "required": [
            "tool",
            "arguments",
            "why"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "total",
        "trades"
      ],
      "additionalProperties": false,
      "description": "The run's trades in the order they were made, a page at a time: when each entered and left (a day on daily bars; a time on the `clock` on shorter ones; \"open at the end\" for a trade still open when the data ended), its side, whether it won or lost after costs, and which exit ended it (a word: stop, exit rule, target, time limit…). No prices, levels, sizes or returns."
    }
  },
  "required": [
    "status"
  ],
  "additionalProperties": false
}
⚪compare_trades(run_id, study_id, version, trades, time_zone)

Checks a trader's own trades against a run's rule, on the price history this server holds: for each trade, in their order, whether the rule would have taken it and, if not, why (already in a trade, no entry signal that day, no bar that day). Use it when the trader lists trades they made and asks which the rule took, instead of working it out by hand. Takes a run (run_id) and the trades, each {side, entry, exit?}; answers in words, never prices. It re-runs the run's code, so it counts as a run on the run's symbol.

Input Schema

{
  "type": "object",
  "properties": {
    "run_id": {
      "type": "string",
      "description": "A run_id run_backtest or run_held_out_test returned: the run whose code is checked against the trades."
    },
    "study_id": {
      "type": "string",
      "description": "A study's id; with `version`, one of its runs."
    },
    "version": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 1
        },
        {
          "type": "string",
          "pattern": "^[vV]?\\d+$"
        }
      ]
    },
    "trades": {
      "type": "array",
      "minItems": 1,
      "maxItems": 50,
      "description": "The trader's own trades, in their order, each stamp exactly as the trader wrote it.",
      "items": {
        "type": "object",
        "properties": {
          "side": {
            "type": "string",
            "enum": [
              "long",
              "short"
            ]
          },
          "entry": {
            "type": "string",
            "description": "When they entered: \"YYYY-MM-DD\", or \"YYYY-MM-DD HH:MM\" on the clock they wrote."
          },
          "exit": {
            "type": "string",
            "description": "When they exited, the same way. Left out when they gave none."
          }
        },
        "required": [
          "side",
          "entry"
        ],
        "additionalProperties": false
      }
    },
    "time_zone": {
      "type": "string",
      "description": "The clock the trader says their times are on (\"UTC+2\", \"New York\", \"Europe/Prague\"). Left out: the clock the run's trade list is on (ET for stocks and ETFs, UTC otherwise)."
    }
  },
  "required": [
    "trades"
  ],
  "additionalProperties": false
}

Output Schema

{
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "compared",
        "invalid_arguments",
        "not_found",
        "refused",
        "error"
      ]
    },
    "run_id": {
      "type": "string"
    },
    "study_id": {
      "type": "string"
    },
    "version": {
      "type": "integer"
    },
    "market": {
      "type": "object",
      "properties": {
        "symbol": {
          "type": "string"
        },
        "timeframe": {
          "type": "string"
        }
      },
      "required": [
        "symbol",
        "timeframe"
      ],
      "additionalProperties": false
    },
    "summary": {
      "type": "string"
    },
    "counts": {
      "type": "object",
      "properties": {
        "taken": {
          "type": "integer"
        },
        "not_taken": {
          "type": "integer"
        },
        "not_compared": {
          "type": "integer"
        }
      },
      "required": [
        "taken",
        "not_taken",
        "not_compared"
      ],
      "additionalProperties": false
    },
    "trades": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "n": {
            "type": "integer"
          },
          "trade": {
            "type": "string"
          },
          "rule": {
            "type": "string",
            "enum": [
              "taken",
              "not taken",
              "not compared"
            ]
          },
          "reason": {
            "type": "string",
            "description": "The code for why: taken, in_trade, exit_unknown, no_bar, side_never, flat, outside_bars, other_symbol or no_time."
          },
          "answer": {
            "type": "string"
          },
          "why": {
            "type": "string"
          }
        },
        "required": [
          "n",
          "trade",
          "rule",
          "reason",
          "answer",
          "why"
        ],
        "additionalProperties": false
      }
    },
    "note": {
      "type": "string"
    },
    "message": {
      "type": "string"
    },
    "reason": {
      "type": "string"
    },
    "clock": {
      "type": "string",
      "description": "On bars shorter than a day: the clock every time of the answer is on (your time_zone as you stated it, else ET for stocks and ETFs, UTC otherwise)."
    },
    "runs_left_today": {
      "type": "object",
      "properties": {
        "symbol": {
          "type": "string"
        },
        "left": {
          "type": "integer"
        },
        "per_day": {
          "type": "integer"
        }
      },
      "required": [
        "symbol",
        "left",
        "per_day"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "status"
  ],
  "additionalProperties": false
}

Community

Rate this Server

Evidence

Recent observations

verifiedversion not recorded6 tools