{
  "openapi": "3.1.0",
  "info": {
    "title": "Regimen",
    "version": "1.0.0",
    "summary": "Is this trading track record distinguishable from luck, and where does the edge live?",
    "description": "Regimen takes an equity curve — from an OlaXBT Nexus strategy or supplied directly — and reports what the evidence actually supports: the Probabilistic Sharpe Ratio, the Deflated Sharpe Ratio, the Minimum Track Record Length, a bootstrap interval, and a regime-conditional breakdown with a permutation test on the spread. It frequently answers that the evidence is too thin. That is the intended output, not a failure.\n\nIt does not trade, hold funds, custody keys or sign anything, and it performs no security, audit or compliance analysis.",
    "license": {
      "name": "MIT",
      "identifier": "MIT"
    }
  },
  "servers": [
    {
      "url": "https://regimen-nu.vercel.app"
    }
  ],
  "components": {
    "securitySchemes": {
      "nexusKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-nexus-key",
        "description": "An OlaXBT Nexus API key, issued in Nexus Studio under Profile → API keys. Required only for `source: olaxbt-nexus`. When omitted, a deployment-configured demo key is used if present, under a shared rate limit. Never stored, never logged."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "retryable"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "invalid_input",
                  "missing_credentials",
                  "unsupported_source",
                  "not_found",
                  "rate_limited",
                  "insufficient_sample",
                  "coverage_gap",
                  "undefined_statistic",
                  "upstream_unauthorized",
                  "upstream_rejected",
                  "upstream_not_published",
                  "upstream_rate_limited",
                  "upstream_unavailable",
                  "upstream_timeout",
                  "upstream_malformed",
                  "internal"
                ],
                "description": "Stable, machine-readable failure code."
              },
              "message": {
                "type": "string"
              },
              "retryable": {
                "type": "boolean",
                "description": "Whether repeating the identical request can succeed."
              },
              "remedy": {
                "type": "string",
                "description": "What to do instead. Written to be actionable by an agent."
              },
              "details": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      }
    }
  },
  "paths": {
    "/api/health": {
      "get": {
        "summary": "Liveness and build binding",
        "description": "Reports `status` and the exact 40-character commit this deployment was built from. Deliberately free of dependencies: a third-party outage must never make a healthy service look dead.",
        "responses": {
          "200": {
            "description": "Alive."
          }
        }
      }
    },
    "/.well-known/xagent-verification.json": {
      "get": {
        "summary": "Deployment proof",
        "description": "Binds this origin to one submission slug and one commit.",
        "responses": {
          "200": {
            "description": "The proof document."
          }
        }
      }
    },
    "/api/v1/status": {
      "get": {
        "summary": "Dependency health",
        "description": "Upstream reachability, whether a demo key is configured, and point-in-time cache occupancy. Kept separate from liveness on purpose.",
        "responses": {
          "200": {
            "description": "Status report."
          }
        }
      }
    },
    "/api/v1/evaluate": {
      "post": {
        "summary": "Evaluate a track record",
        "description": "The core question. Returns the Probabilistic Sharpe Ratio — the probability the true Sharpe beats a benchmark, corrected for sample length, skew and fat tails — a stationary-bootstrap confidence interval, and the Minimum Track Record Length: how long the record would have to run before the claim could be made at all.",
        "security": [
          {
            "nexusKey": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "selector"
                ],
                "properties": {
                  "selector": {
                    "oneOf": [
                      {
                        "type": "object",
                        "required": [
                          "source"
                        ],
                        "properties": {
                          "source": {
                            "const": "olaxbt-nexus"
                          },
                          "symbol": {
                            "type": "string",
                            "default": "BTC/USDT",
                            "description": "Market the strategy trades."
                          }
                        },
                        "description": "Analyse the OlaXBT Nexus strategy bound to the supplied API key."
                      },
                      {
                        "type": "object",
                        "required": [
                          "source",
                          "trackRecord"
                        ],
                        "properties": {
                          "source": {
                            "const": "inline"
                          },
                          "trackRecord": {
                            "$schema": "https://json-schema.org/draft/2020-12/schema",
                            "type": "object",
                            "properties": {
                              "label": {
                                "default": "inline-track-record",
                                "description": "A name for this track record, echoed back in results. Do not put anything sensitive here.",
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "equity": {
                                "minItems": 2,
                                "maxItems": 10000,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "t": {
                                      "description": "Epoch milliseconds, epoch seconds, or an ISO 8601 timestamp. UTC is assumed.",
                                      "type": [
                                        "number",
                                        "string"
                                      ]
                                    },
                                    "equity": {
                                      "type": "number",
                                      "exclusiveMinimum": 0,
                                      "description": "Account equity at that instant, in any single consistent unit."
                                    }
                                  },
                                  "required": [
                                    "t",
                                    "equity"
                                  ]
                                },
                                "description": "The equity curve, one point per period. Order does not matter; it is sorted by timestamp."
                              },
                              "trades": {
                                "maxItems": 20000,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "symbol": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 64
                                    },
                                    "pnl": {
                                      "type": "number",
                                      "description": "Realised profit or loss for the closed trade, in the equity unit."
                                    },
                                    "exitedAt": {
                                      "type": [
                                        "number",
                                        "string"
                                      ]
                                    },
                                    "entryPrice": {
                                      "type": "number"
                                    },
                                    "exitPrice": {
                                      "type": "number"
                                    },
                                    "holdingBars": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 9007199254740991
                                    },
                                    "exitReason": {
                                      "type": "string",
                                      "maxLength": 120
                                    }
                                  },
                                  "required": [
                                    "pnl"
                                  ]
                                }
                              },
                              "reportedSharpe": {
                                "description": "Optional. The Sharpe ratio you believe this track record has, so Regimen can contrast it with its own.",
                                "type": "number"
                              }
                            },
                            "required": [
                              "equity"
                            ]
                          },
                          "regimes": {
                            "$schema": "https://json-schema.org/draft/2020-12/schema",
                            "type": "object",
                            "properties": {
                              "observations": {
                                "minItems": 1,
                                "maxItems": 10000,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "date": {
                                      "type": "string",
                                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                                    },
                                    "factors": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 40
                                      },
                                      "additionalProperties": {
                                        "type": [
                                          "number",
                                          "string",
                                          "null"
                                        ]
                                      }
                                    }
                                  },
                                  "required": [
                                    "date",
                                    "factors"
                                  ]
                                }
                              }
                            },
                            "required": [
                              "observations"
                            ]
                          }
                        },
                        "description": "Analyse an equity curve supplied directly, from any venue or backtest."
                      }
                    ]
                  },
                  "options": {
                    "type": "object",
                    "properties": {
                      "benchmarkSharpe": {
                        "type": "number",
                        "default": 0,
                        "description": "Per-period Sharpe the record must beat."
                      },
                      "confidence": {
                        "type": "number",
                        "default": 0.95,
                        "exclusiveMinimum": 0.5,
                        "exclusiveMaximum": 1
                      },
                      "bootstrapResamples": {
                        "type": "integer",
                        "default": 2000,
                        "minimum": 200,
                        "maximum": 20000
                      },
                      "seed": {
                        "type": "integer",
                        "description": "Fixed by default, so an interval reproduces exactly."
                      },
                      "trialSharpes": {
                        "type": "array",
                        "items": {
                          "type": "number"
                        },
                        "description": "Per-period Sharpe ratios of other configurations tried for this strategy. Supplying them enables the Deflated Sharpe Ratio, which discounts the headline for how many variants were tested before this one was reported."
                      }
                    },
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The analysis. Wrapped as `{ data, meta }`; `meta` carries the request id and build commit.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "No credentials supplied and no demo key configured.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Rejected `Origin`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The upstream strategy has published nothing yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Well-formed request, but the data cannot support an answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Demo rate limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "The upstream data service is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/regime-map": {
      "post": {
        "summary": "Map performance to market regimes",
        "description": "Performance sliced by the conditions that held on each date — volatility, funding, open interest, positioning, sentiment, trend state. Every factor is read point-in-time, and each carries a permutation test: the observed best-to-worst spread is compared against spreads from randomly reshuffled labels, so a flattering subset cannot pass itself off as a regime effect.",
        "security": [
          {
            "nexusKey": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "selector"
                ],
                "properties": {
                  "selector": {
                    "oneOf": [
                      {
                        "type": "object",
                        "required": [
                          "source"
                        ],
                        "properties": {
                          "source": {
                            "const": "olaxbt-nexus"
                          },
                          "symbol": {
                            "type": "string",
                            "default": "BTC/USDT",
                            "description": "Market the strategy trades."
                          }
                        },
                        "description": "Analyse the OlaXBT Nexus strategy bound to the supplied API key."
                      },
                      {
                        "type": "object",
                        "required": [
                          "source",
                          "trackRecord"
                        ],
                        "properties": {
                          "source": {
                            "const": "inline"
                          },
                          "trackRecord": {
                            "$schema": "https://json-schema.org/draft/2020-12/schema",
                            "type": "object",
                            "properties": {
                              "label": {
                                "default": "inline-track-record",
                                "description": "A name for this track record, echoed back in results. Do not put anything sensitive here.",
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "equity": {
                                "minItems": 2,
                                "maxItems": 10000,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "t": {
                                      "description": "Epoch milliseconds, epoch seconds, or an ISO 8601 timestamp. UTC is assumed.",
                                      "type": [
                                        "number",
                                        "string"
                                      ]
                                    },
                                    "equity": {
                                      "type": "number",
                                      "exclusiveMinimum": 0,
                                      "description": "Account equity at that instant, in any single consistent unit."
                                    }
                                  },
                                  "required": [
                                    "t",
                                    "equity"
                                  ]
                                },
                                "description": "The equity curve, one point per period. Order does not matter; it is sorted by timestamp."
                              },
                              "trades": {
                                "maxItems": 20000,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "symbol": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 64
                                    },
                                    "pnl": {
                                      "type": "number",
                                      "description": "Realised profit or loss for the closed trade, in the equity unit."
                                    },
                                    "exitedAt": {
                                      "type": [
                                        "number",
                                        "string"
                                      ]
                                    },
                                    "entryPrice": {
                                      "type": "number"
                                    },
                                    "exitPrice": {
                                      "type": "number"
                                    },
                                    "holdingBars": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 9007199254740991
                                    },
                                    "exitReason": {
                                      "type": "string",
                                      "maxLength": 120
                                    }
                                  },
                                  "required": [
                                    "pnl"
                                  ]
                                }
                              },
                              "reportedSharpe": {
                                "description": "Optional. The Sharpe ratio you believe this track record has, so Regimen can contrast it with its own.",
                                "type": "number"
                              }
                            },
                            "required": [
                              "equity"
                            ]
                          },
                          "regimes": {
                            "$schema": "https://json-schema.org/draft/2020-12/schema",
                            "type": "object",
                            "properties": {
                              "observations": {
                                "minItems": 1,
                                "maxItems": 10000,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "date": {
                                      "type": "string",
                                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                                    },
                                    "factors": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 40
                                      },
                                      "additionalProperties": {
                                        "type": [
                                          "number",
                                          "string",
                                          "null"
                                        ]
                                      }
                                    }
                                  },
                                  "required": [
                                    "date",
                                    "factors"
                                  ]
                                }
                              }
                            },
                            "required": [
                              "observations"
                            ]
                          }
                        },
                        "description": "Analyse an equity curve supplied directly, from any venue or backtest."
                      }
                    ]
                  },
                  "options": {
                    "type": "object",
                    "properties": {
                      "minSample": {
                        "type": "integer",
                        "default": 15,
                        "minimum": 5,
                        "maximum": 500
                      },
                      "permutationResamples": {
                        "type": "integer",
                        "default": 2000,
                        "minimum": 200,
                        "maximum": 20000
                      },
                      "maxDates": {
                        "type": "integer",
                        "default": 45,
                        "minimum": 5,
                        "maximum": 45,
                        "description": "Most recent dates to read conditions for, bounded by the upstream rate limit."
                      },
                      "factorKeys": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "seed": {
                        "type": "integer"
                      }
                    },
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The analysis. Wrapped as `{ data, meta }`; `meta` carries the request id and build commit.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "No credentials supplied and no demo key configured.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Rejected `Origin`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The upstream strategy has published nothing yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Well-formed request, but the data cannot support an answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Demo rate limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "The upstream data service is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/self-attack": {
      "post": {
        "summary": "Attack the verdict",
        "description": "Runs the analysis against controls whose answer is known in advance: the strategy’s own returns with the edge removed, and a simulated population of strategies with no edge at all. Published rather than hidden, because an evaluation tool that never fails a control is indistinguishable from one that always agrees with you.",
        "security": [
          {
            "nexusKey": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "selector"
                ],
                "properties": {
                  "selector": {
                    "oneOf": [
                      {
                        "type": "object",
                        "required": [
                          "source"
                        ],
                        "properties": {
                          "source": {
                            "const": "olaxbt-nexus"
                          },
                          "symbol": {
                            "type": "string",
                            "default": "BTC/USDT",
                            "description": "Market the strategy trades."
                          }
                        },
                        "description": "Analyse the OlaXBT Nexus strategy bound to the supplied API key."
                      },
                      {
                        "type": "object",
                        "required": [
                          "source",
                          "trackRecord"
                        ],
                        "properties": {
                          "source": {
                            "const": "inline"
                          },
                          "trackRecord": {
                            "$schema": "https://json-schema.org/draft/2020-12/schema",
                            "type": "object",
                            "properties": {
                              "label": {
                                "default": "inline-track-record",
                                "description": "A name for this track record, echoed back in results. Do not put anything sensitive here.",
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "equity": {
                                "minItems": 2,
                                "maxItems": 10000,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "t": {
                                      "description": "Epoch milliseconds, epoch seconds, or an ISO 8601 timestamp. UTC is assumed.",
                                      "type": [
                                        "number",
                                        "string"
                                      ]
                                    },
                                    "equity": {
                                      "type": "number",
                                      "exclusiveMinimum": 0,
                                      "description": "Account equity at that instant, in any single consistent unit."
                                    }
                                  },
                                  "required": [
                                    "t",
                                    "equity"
                                  ]
                                },
                                "description": "The equity curve, one point per period. Order does not matter; it is sorted by timestamp."
                              },
                              "trades": {
                                "maxItems": 20000,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "symbol": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 64
                                    },
                                    "pnl": {
                                      "type": "number",
                                      "description": "Realised profit or loss for the closed trade, in the equity unit."
                                    },
                                    "exitedAt": {
                                      "type": [
                                        "number",
                                        "string"
                                      ]
                                    },
                                    "entryPrice": {
                                      "type": "number"
                                    },
                                    "exitPrice": {
                                      "type": "number"
                                    },
                                    "holdingBars": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 9007199254740991
                                    },
                                    "exitReason": {
                                      "type": "string",
                                      "maxLength": 120
                                    }
                                  },
                                  "required": [
                                    "pnl"
                                  ]
                                }
                              },
                              "reportedSharpe": {
                                "description": "Optional. The Sharpe ratio you believe this track record has, so Regimen can contrast it with its own.",
                                "type": "number"
                              }
                            },
                            "required": [
                              "equity"
                            ]
                          },
                          "regimes": {
                            "$schema": "https://json-schema.org/draft/2020-12/schema",
                            "type": "object",
                            "properties": {
                              "observations": {
                                "minItems": 1,
                                "maxItems": 10000,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "date": {
                                      "type": "string",
                                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                                    },
                                    "factors": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 40
                                      },
                                      "additionalProperties": {
                                        "type": [
                                          "number",
                                          "string",
                                          "null"
                                        ]
                                      }
                                    }
                                  },
                                  "required": [
                                    "date",
                                    "factors"
                                  ]
                                }
                              }
                            },
                            "required": [
                              "observations"
                            ]
                          }
                        },
                        "description": "Analyse an equity curve supplied directly, from any venue or backtest."
                      }
                    ]
                  },
                  "options": {
                    "type": "object",
                    "properties": {
                      "simulations": {
                        "type": "integer",
                        "default": 1000,
                        "minimum": 100,
                        "maximum": 20000
                      },
                      "benchmarkSharpe": {
                        "type": "number",
                        "default": 0
                      },
                      "seed": {
                        "type": "integer"
                      }
                    },
                    "additionalProperties": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The analysis. Wrapped as `{ data, meta }`; `meta` carries the request id and build commit.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "No credentials supplied and no demo key configured.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Rejected `Origin`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The upstream strategy has published nothing yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Well-formed request, but the data cannot support an answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Demo rate limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "The upstream data service is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "required": [
                        "code",
                        "message",
                        "retryable"
                      ],
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_input",
                            "missing_credentials",
                            "unsupported_source",
                            "not_found",
                            "rate_limited",
                            "insufficient_sample",
                            "coverage_gap",
                            "undefined_statistic",
                            "upstream_unauthorized",
                            "upstream_rejected",
                            "upstream_not_published",
                            "upstream_rate_limited",
                            "upstream_unavailable",
                            "upstream_timeout",
                            "upstream_malformed",
                            "internal"
                          ],
                          "description": "Stable, machine-readable failure code."
                        },
                        "message": {
                          "type": "string"
                        },
                        "retryable": {
                          "type": "boolean",
                          "description": "Whether repeating the identical request can succeed."
                        },
                        "remedy": {
                          "type": "string",
                          "description": "What to do instead. Written to be actionable by an agent."
                        },
                        "details": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}