{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/quantifyme-ai/json-schema/quantifyme-ai-train-request-schema.json",
  "title": "TrainRequest",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/quantifyme-ai-openapi.json#/components/schemas/TrainRequest",
  "properties": {
    "aux_feeds": {
      "$ref": "#/$defs/AuxFeeds"
    },
    "capital": {
      "description": "Account balance in USD. Drives the $ P&L and return-on-equity (P&L % = $ P&L / balance).",
      "type": "number"
    },
    "claude_model": {
      "type": "string"
    },
    "code": {
      "description": "Full Python strategy code (typically from /api/v1/generate). At most 64,000 characters; a longer one is refused with 400 prompt_too_long.",
      "type": "string"
    },
    "commission": {
      "description": "Round-trip commission, USD per lot of the market. Omit for the market's own: 6.00 on forex, 0.26 on XAUUSD (1 oz), 0.004 on XAGUSD (1 oz), 56.72 on BTCUSD (1 coin).",
      "type": "number"
    },
    "confidence_threshold": {
      "description": "Signal strictness: the raw predict_proba cutoff a bar must clear to fire, as a percent (55 = a score of 0.55). NOT a calibrated probability — a 55 setting was measured delivering a 50.0% hit rate. Overrides the value in strategy_config(). Classification-only (#432) - a regression strategy (task='regression') refuses this with 400; use signal_rules instead (return/spread units).",
      "type": "number"
    },
    "end_date": {
      "format": "date",
      "type": "string"
    },
    "indicators": {
      "$ref": "#/$defs/Indicators"
    },
    "leverage": {
      "description": "Margin only — sets required margin (notional / leverage); does NOT multiply P&L. Stored for future margin/liquidation modeling.",
      "type": "number"
    },
    "lot_size": {
      "description": "Position size in standard lots (1.0 = 100,000 units). This is the P&L driver: $ P&L = units × (exit−entry) / FX_conv − commission/swap.",
      "type": "number"
    },
    "model_name": {
      "description": "Optional. Auto-named Model N+1 if omitted.",
      "type": "string"
    },
    "risk_unit": {
      "default": "pips",
      "description": "How stop_loss/take_profit are interpreted. 'pips' = pip distance; 'usd' = $ risk at this lot; 'pct' = legacy fraction of price. The engine back-solves the price level per pair (pip_size + FX conversion).",
      "enum": [
        "pips",
        "usd",
        "pct"
      ],
      "type": "string"
    },
    "start_date": {
      "format": "date",
      "type": "string"
    },
    "stop_loss": {
      "description": "Stop-loss magnitude in risk_unit (e.g. 25 pips, or $250 when risk_unit='usd'). Omit/null to disable. Overrides the value in strategy_config().",
      "type": "number"
    },
    "swap_long": {
      "description": "USD per lot per night held long. Omit for the market's own: -1.00 on forex, -0.58 on XAUUSD, -0.0087 on XAGUSD, -18.91 on BTCUSD.",
      "type": "number"
    },
    "swap_short": {
      "description": "USD per lot per night held short. Omit for the market's own: 0.30 on forex, -0.06 on XAUUSD, -0.0009 on XAGUSD, 0.00 on BTCUSD. A default swap outside forex is never a credit; a number you send is charged as sent.",
      "type": "number"
    },
    "symbol": {
      "default": "EURUSD",
      "description": "Must match the symbol the code was generated for.",
      "enum": [
        "EURUSD",
        "GBPUSD",
        "USDJPY",
        "USDCHF",
        "AUDUSD",
        "NZDUSD",
        "USDCAD",
        "BTCUSD"
      ],
      "type": "string"
    },
    "take_profit": {
      "description": "Take-profit magnitude in risk_unit (e.g. 50 pips). Omit/null to disable. Overrides the value in strategy_config().",
      "type": "number"
    },
    "timeframe": {
      "default": "15min",
      "enum": [
        "1min",
        "5min",
        "15min",
        "1h"
      ],
      "type": "string"
    },
    "train_split": {
      "type": "number"
    }
  },
  "required": [
    "code"
  ],
  "type": "object",
  "$defs": {
    "AuxFeeds": {
      "description": "Extra (symbol, timeframe) feeds merged into the strategy's features as aux_* columns. Max 3; must differ from the primary.",
      "items": {
        "properties": {
          "symbol": {
            "enum": [
              "EURUSD",
              "GBPUSD",
              "USDJPY",
              "USDCHF",
              "AUDUSD",
              "NZDUSD",
              "USDCAD",
              "BTCUSD"
            ],
            "type": "string"
          },
          "timeframe": {
            "enum": [
              "1min",
              "5min",
              "15min",
              "1h"
            ],
            "type": "string"
          }
        },
        "type": "object"
      },
      "maxItems": 3,
      "type": "array"
    },
    "Indicators": {
      "additionalProperties": true,
      "description": "Flat indicator config. See GET /api/v1/indicator-schema for full param list.",
      "properties": {},
      "type": "object"
    }
  }
}