{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://developer.tastytrade.com/schemas/backtesting/Leg",
  "title": "Leg",
  "type": "object",
  "required": [
    "type",
    "direction",
    "quantity",
    "strikeSelection",
    "daysUntilExpiration"
  ],
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "equity",
        "equity-option"
      ],
      "description": "The instrument type"
    },
    "direction": {
      "type": "string",
      "enum": [
        "long",
        "short"
      ],
      "description": "The position direction"
    },
    "side": {
      "type": "string",
      "enum": [
        "call",
        "put"
      ],
      "description": "The option side (only applicable for equity-option type)"
    },
    "quantity": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100,
      "description": "Number of contracts or shares (1-10 for options, 1-100 for stocks)"
    },
    "strikeSelection": {
      "type": "string",
      "enum": [
        "delta",
        "percentageOTM",
        "percentageOTMRelative",
        "currentPriceOffset",
        "currentPriceOffsetRelative",
        "currentPriceExactOffsetRelative",
        "premium"
      ],
      "description": "How to select the strike for this leg"
    },
    "strikeRelativeLeg": {
      "type": "integer",
      "description": "Index of the leg to use as reference when strike selection is relative to another leg"
    },
    "delta": {
      "type": "number",
      "minimum": 1,
      "maximum": 100,
      "description": "Delta value when strikeSelection is \"delta\" (expressed as integer from 1 to 100)"
    },
    "percentageOTM": {
      "type": "number",
      "description": "Percentage OTM when strikeSelection is \"percentageOTM\" or \"percentageOTMRelative\" (e.g. 0.1 for 10% OTM, -0.1 for 10% ITM)"
    },
    "currentPriceOffset": {
      "type": "number",
      "maximum": 50000,
      "description": "Offset from current price when strikeSelection is currentPriceOffset related (max 50000)"
    },
    "premium": {
      "type": "number",
      "maximum": 50000,
      "description": "Premium value when strikeSelection is \"premium\" (max 50000)"
    },
    "daysUntilExpiration": {
      "type": "integer",
      "description": "Days until expiration for this leg"
    }
  }
}
