{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Auto Start (request)",
  "description": "Start an automated trading run following a predefined strategy",
  "type": "object",
  "auth_required": 1,
  "auth_scopes": ["trade"],
  "additionalProperties": false,
  "required": [
    "auto_start",
    "contract_template",
    "strategy_id",
    "strategy_parameters"
  ],
  "properties": {
    "auto_start": {
      "description": "Must be `1`",
      "type": "integer",
      "enum": [1]
    },
    "contract_template": {
      "description": "Template defining the contract parameters to be used for each purchase in this run",
      "type": "object",
      "additionalProperties": false,
      "required": ["contract_type", "currency", "underlying_symbol"],
      "properties": {
        "amount": {
          "description": "[Optional] Initial stake or payout value",
          "type": "number",
          "minimum": 0
        },
        "barrier": {
          "description": "[Optional] Barrier for the contract (or last digit prediction for digit contracts)",
          "type": "string",
          "pattern": "^(?=.{1,20}$)[+-]?[0-9]+\\.?[0-9]*$"
        },
        "barrier2": {
          "description": "[Optional] Low barrier for the contract (for contracts with two barriers)",
          "type": "string",
          "pattern": "^(?=.{1,20}$)[+-]?[0-9]+\\.?[0-9]*$"
        },
        "basis": {
          "description": "[Optional] Indicates whether amount is 'payout' or 'stake' for binary options",
          "type": "string",
          "enum": ["payout", "stake"]
        },
        "contract_type": {
          "description": "A valid contract type",
          "type": "string",
          "enum": [
            "HIGHER",
            "LOWER",
            "ACCU",
            "ASIAND",
            "ASIANU",
            "CALL",
            "CALLE",
            "DIGITDIFF",
            "DIGITEVEN",
            "DIGITMATCH",
            "DIGITODD",
            "DIGITOVER",
            "DIGITUNDER",
            "EXPIRYMISS",
            "EXPIRYMISSE",
            "EXPIRYRANGE",
            "EXPIRYRANGEE",
            "MULTDOWN",
            "MULTUP",
            "NOTOUCH",
            "ONETOUCH",
            "PUT",
            "PUTE",
            "RANGE",
            "RESETCALL",
            "RESETPUT",
            "RUNHIGH",
            "RUNLOW",
            "TICKHIGH",
            "TICKLOW",
            "TURBOSLONG",
            "TURBOSSHORT",
            "UPORDOWN",
            "VANILLALONGCALL",
            "VANILLALONGPUT"
          ]
        },
        "currency": {
          "description": "The account-holder's currency",
          "type": "string",
          "pattern": "^[a-zA-Z0-9]{2,20}$"
        },
        "duration": {
          "description": "[Optional] Duration quantity",
          "type": "integer",
          "maximum": 99999999,
          "minimum": 0
        },
        "duration_unit": {
          "description": "[Optional] Duration unit: `s` seconds, `m` minutes, `h` hours, `d` days, `t` ticks",
          "type": "string",
          "enum": ["d", "m", "s", "h", "t"]
        },
        "growth_rate": {
          "description": "[Optional] Growth rate of an accumulator contract",
          "type": "number"
        },
        "limit_order": {
          "description": "[Optional] Order to close the contract once the order condition is met (only for `MULTUP`, `MULTDOWN`, and `ACCU` contracts)",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "stop_loss": {
              "description": "Contract will be automatically closed when the value reaches a specific loss",
              "type": "number"
            },
            "take_profit": {
              "description": "Contract will be automatically closed when the value reaches a specific profit",
              "type": "number"
            }
          }
        },
        "multiplier": {
          "description": "[Optional] The multiplier for non-binary options",
          "type": "number",
          "minimum": 0
        },
        "selected_tick": {
          "description": "[Optional] The tick predicted to have the highest/lowest value - for tickhigh and ticklow contracts",
          "type": "integer"
        },
        "underlying_symbol": {
          "description": "Symbol code",
          "type": "string",
          "pattern": "^\\w{2,30}$"
        }
      }
    },
    "strategy_id": {
      "description": "Identifier of the strategy to run",
      "type": "string",
      "pattern": "^\\w{1,64}$"
    },
    "strategy_parameters": {
      "description": "Parameters specific to the selected strategy (e.g. martingale multiplier, max rounds)",
      "type": "object"
    },
    "subscribe": {
      "description": "[Optional] If set to `1`, will stream run updates (new contracts purchased, status changes) until the run ends or `forget` is called.",
      "type": "integer",
      "enum": [1]
    },
    "passthrough": {
      "description": "[Optional] Used to pass data through the websocket, which may be retrieved via the `echo_req` output field.",
      "type": "object"
    },
    "req_id": {
      "description": "[Optional] Used to map request to response.",
      "type": "integer"
    }
  }
}
