{
 "components": {
  "responses": {
   "E400": {
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    },
    "description": "VALIDATION_ERROR: a parameter, a header or the body is not as described."
   },
   "E401": {
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    },
    "description": "API_KEY_INVALID: the key is missing, malformed, unknown or revoked (detail.reason CONTRACT_WALLET_REVOKED: the contract wallet that made it no longer accepts its sign-in; the key is revoked)."
   },
   "E403": {
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    },
    "description": "API_KEY_READ_ONLY: a key of the read scope called an order route."
   },
   "E404": {
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    },
    "description": "NOT_FOUND: an account that is not yours (exactly like an unknown one), an order, a market."
   },
   "E409": {
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    },
    "description": "A conflict of state (the position or the order moved since you read it, an order no longer open)."
   },
   "E422": {
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    },
    "description": "A refusal of the rules or of the execution (detail.reason), or IDEMPOTENCY_KEY_REUSED."
   },
   "E429": {
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    },
    "description": "RATE_LIMITED: wait Retry-After seconds (per key, and per trader for the order routes)."
   },
   "E503": {
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    },
    "description": "API_DISABLED, API_TRADING_DISABLED, ORDERS_BLOCKED, STORAGE_UNAVAILABLE or SIWE_RPC_UNAVAILABLE (the node of the contract wallet that made the key cannot answer): nothing was done, try later."
   }
  },
  "schemas": {
   "Error": {
    "properties": {
     "error": {
      "properties": {
       "code": {
        "type": "string"
       },
       "detail": {
        "type": "object"
       },
       "message": {
        "type": "string"
       },
       "source": {
        "enum": [
         "api",
         "engine",
         "exec"
        ],
        "type": "string"
       },
       "trace_id": {
        "type": "string"
       }
      },
      "required": [
       "code",
       "source",
       "message",
       "detail",
       "trace_id"
      ],
      "type": "object"
     }
    },
    "required": [
     "error"
    ],
    "type": "object"
   }
  },
  "securitySchemes": {
   "key": {
    "bearerFormat": "ppk_",
    "description": "ppk_ followed by 40 letters and digits",
    "scheme": "bearer",
    "type": "http"
   }
  }
 },
 "info": {
  "description": "Your accounts, from your own software or AI agent: read them with any key; trade with a key made with\n« Allow trading » (scope trade), under the same rules and limits as the terminal. Beta: breaking changes are possible.\n\nAuthentication: `Authorization: Bearer ppk_...` (a key of your trader space, shown once). Every answer is\n`Cache-Control: no-store`; errors are `{\"error\": {\"code\", \"source\", \"message\", \"detail\", \"trace_id\"}}`.\n\nNumbers are integers: a quantity in units of the market (one unit is `unit_e8` / 1e8 coin, `unit_e8` from\n`/markets`), an order price in micro-USD per unit, a quote (`bid_e8`, `ask_e8`) in USD x 1e8 per coin.\n\nAccount stream (WebSocket, not an OpenAPI operation): `GET /v1/api/accounts/{account_id}/stream` with the same\n`Authorization` header on the upgrade. Messages `{\"ch\", \"account_id\", \"seq\", \"ts\", \"data\"}` on the channels orders,\nexecutions, positions, account (risk) and equity, the current state first; `?since_seq=N` replays the executions\nafter N; `?batch=1` sends JSON arrays. Close codes: 4401 key, 4404 account, 4429 limit, 4503 API off, 1013 try later.",
  "title": "ProofPerps Trader API",
  "version": "1.0.0-beta"
 },
 "openapi": "3.1.0",
 "paths": {
  "/v1/api/accounts": {
   "get": {
    "operationId": "list_accounts",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Your accounts",
    "tags": [
     "read"
    ]
   }
  },
  "/v1/api/accounts/{account_id}": {
   "get": {
    "operationId": "get_account",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "One account",
    "tags": [
     "read"
    ]
   }
  },
  "/v1/api/accounts/{account_id}/executions": {
   "get": {
    "operationId": "list_executions",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     },
     {
      "in": "query",
      "name": "symbol",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Symbol"
      }
     },
     {
      "description": "Only what came after this journal sequence (next_after_seq of the previous page).",
      "in": "query",
      "name": "after_seq",
      "required": false,
      "schema": {
       "minimum": 0,
       "type": "integer"
      }
     },
     {
      "description": "At most this many rows.",
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "minimum": 1,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Executions (fills) with price, fee and realized PnL",
    "tags": [
     "read"
    ]
   }
  },
  "/v1/api/accounts/{account_id}/leverage/{symbol}": {
   "put": {
    "operationId": "set_leverage",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     },
     {
      "in": "path",
      "name": "symbol",
      "required": true,
      "schema": {
       "title": "Symbol",
       "type": "string"
      }
     },
     {
      "description": "1 to 64 printable ASCII characters. The same key and body give the stored answer again (replayed: true) and do nothing; another body under the same key is a 422 IDEMPOTENCY_KEY_REUSED. For a new order it is its client_order_id (letters, digits and . _ : - only).",
      "in": "header",
      "name": "Idempotency-Key",
      "required": true,
      "schema": {
       "maxLength": 64,
       "minLength": 1,
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": false,
        "properties": {
         "leverage_x": {
          "format": "int64",
          "minimum": 1,
          "type": "integer"
         }
        },
        "required": [
         "leverage_x"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "403": {
      "$ref": "#/components/responses/E403"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "409": {
      "$ref": "#/components/responses/E409"
     },
     "422": {
      "$ref": "#/components/responses/E422"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Set your leverage on one market",
    "tags": [
     "trade"
    ]
   }
  },
  "/v1/api/accounts/{account_id}/orders": {
   "get": {
    "operationId": "list_orders",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     },
     {
      "in": "query",
      "name": "status",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Status"
      }
     },
     {
      "in": "query",
      "name": "client_order_id",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Client Order Id"
      }
     },
     {
      "description": "Only what came after this journal sequence (next_after_seq of the previous page).",
      "in": "query",
      "name": "after_seq",
      "required": false,
      "schema": {
       "minimum": 0,
       "type": "integer"
      }
     },
     {
      "description": "At most this many rows.",
      "in": "query",
      "name": "limit",
      "required": false,
      "schema": {
       "minimum": 1,
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Orders (status=working|final; client_order_id finds one again after a lost answer)",
    "tags": [
     "read"
    ]
   },
   "post": {
    "operationId": "place_order",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     },
     {
      "description": "1 to 64 printable ASCII characters. The same key and body give the stored answer again (replayed: true) and do nothing; another body under the same key is a 422 IDEMPOTENCY_KEY_REUSED. For a new order it is its client_order_id (letters, digits and . _ : - only).",
      "in": "header",
      "name": "Idempotency-Key",
      "required": true,
      "schema": {
       "maxLength": 64,
       "minLength": 1,
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": false,
        "properties": {
         "client_order_id": {
          "description": "Optional: the Idempotency-Key when absent; must be it when given.",
          "maxLength": 64,
          "type": "string"
         },
         "limit_price": {
          "format": "int64",
          "type": "integer"
         },
         "order_type": {
          "default": "market",
          "enum": [
           "market",
           "limit",
           "stop",
           "stop_limit"
          ],
          "type": "string"
         },
         "qty": {
          "format": "int64",
          "minimum": 1,
          "type": "integer"
         },
         "reduce_only": {
          "default": false,
          "type": "boolean"
         },
         "side": {
          "enum": [
           "buy",
           "sell"
          ],
          "type": "string"
         },
         "stop_loss": {
          "format": "int64",
          "type": [
           "integer",
           "null"
          ]
         },
         "stop_loss_trail": {
          "format": "int64",
          "type": [
           "integer",
           "null"
          ]
         },
         "symbol": {
          "type": "string"
         },
         "take_profit": {
          "format": "int64",
          "type": [
           "integer",
           "null"
          ]
         },
         "take_profits": {
          "description": "Take-profit targets in place of take_profit: each {price, share}, the shares whole percents of at least 1 summing to 100 (for a position's brackets, no share moves the targets).",
          "items": {
           "additionalProperties": false,
           "properties": {
            "price": {
             "format": "int64",
             "minimum": 1,
             "type": "integer"
            },
            "share": {
             "type": [
              "integer",
              "null"
             ]
            }
           },
           "required": [
            "price"
           ],
           "type": "object"
          },
          "minItems": 1,
          "type": [
           "array",
           "null"
          ]
         },
         "trigger_price": {
          "format": "int64",
          "type": "integer"
         }
        },
        "required": [
         "symbol",
         "side",
         "qty"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "403": {
      "$ref": "#/components/responses/E403"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "409": {
      "$ref": "#/components/responses/E409"
     },
     "422": {
      "$ref": "#/components/responses/E422"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Place an order (market, limit, stop, stop_limit), with its stop loss and take profit",
    "tags": [
     "trade"
    ]
   }
  },
  "/v1/api/accounts/{account_id}/orders/{order_id}": {
   "delete": {
    "operationId": "cancel_order",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     },
     {
      "in": "path",
      "name": "order_id",
      "required": true,
      "schema": {
       "title": "Order Id",
       "type": "string"
      }
     },
     {
      "description": "1 to 64 printable ASCII characters. The same key and body give the stored answer again (replayed: true) and do nothing; another body under the same key is a 422 IDEMPOTENCY_KEY_REUSED. For a new order it is its client_order_id (letters, digits and . _ : - only).",
      "in": "header",
      "name": "Idempotency-Key",
      "required": true,
      "schema": {
       "maxLength": 64,
       "minLength": 1,
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "403": {
      "$ref": "#/components/responses/E403"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "409": {
      "$ref": "#/components/responses/E409"
     },
     "422": {
      "$ref": "#/components/responses/E422"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Cancel a working order",
    "tags": [
     "trade"
    ]
   },
   "patch": {
    "operationId": "modify_order",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     },
     {
      "in": "path",
      "name": "order_id",
      "required": true,
      "schema": {
       "title": "Order Id",
       "type": "string"
      }
     },
     {
      "description": "1 to 64 printable ASCII characters. The same key and body give the stored answer again (replayed: true) and do nothing; another body under the same key is a 422 IDEMPOTENCY_KEY_REUSED. For a new order it is its client_order_id (letters, digits and . _ : - only).",
      "in": "header",
      "name": "Idempotency-Key",
      "required": true,
      "schema": {
       "maxLength": 64,
       "minLength": 1,
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": false,
        "description": "expected_rev: the order's rev as you read it (orders list); at least one change.",
        "properties": {
         "expected_rev": {
          "format": "int64",
          "minimum": 0,
          "type": "integer"
         },
         "limit_price": {
          "format": "int64",
          "type": "integer"
         },
         "qty": {
          "format": "int64",
          "type": "integer"
         },
         "stop_loss": {
          "format": "int64",
          "type": [
           "integer",
           "null"
          ]
         },
         "take_profit": {
          "format": "int64",
          "type": [
           "integer",
           "null"
          ]
         },
         "trigger_price": {
          "format": "int64",
          "type": "integer"
         }
        },
        "required": [
         "expected_rev"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "403": {
      "$ref": "#/components/responses/E403"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "409": {
      "$ref": "#/components/responses/E409"
     },
     "422": {
      "$ref": "#/components/responses/E422"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Modify a working order (price, trigger, size, stop loss, take profit)",
    "tags": [
     "trade"
    ]
   }
  },
  "/v1/api/accounts/{account_id}/payout-requests": {
   "get": {
    "operationId": "list_payout_requests",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Payout requests and where they stand (read only)",
    "tags": [
     "read"
    ]
   }
  },
  "/v1/api/accounts/{account_id}/positions": {
   "get": {
    "operationId": "list_positions",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Open positions",
    "tags": [
     "read"
    ]
   }
  },
  "/v1/api/accounts/{account_id}/positions/{symbol}/brackets": {
   "put": {
    "operationId": "set_brackets",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     },
     {
      "in": "path",
      "name": "symbol",
      "required": true,
      "schema": {
       "title": "Symbol",
       "type": "string"
      }
     },
     {
      "description": "1 to 64 printable ASCII characters. The same key and body give the stored answer again (replayed: true) and do nothing; another body under the same key is a 422 IDEMPOTENCY_KEY_REUSED. For a new order it is its client_order_id (letters, digits and . _ : - only).",
      "in": "header",
      "name": "Idempotency-Key",
      "required": true,
      "schema": {
       "maxLength": 64,
       "minLength": 1,
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": false,
        "properties": {
         "expected_position_qty": {
          "format": "int64",
          "type": "integer"
         },
         "expected_stop_loss": {
          "format": "int64",
          "type": [
           "integer",
           "null"
          ]
         },
         "stop_loss": {
          "format": "int64",
          "type": [
           "integer",
           "null"
          ]
         },
         "stop_loss_trail": {
          "format": "int64",
          "type": [
           "integer",
           "null"
          ]
         },
         "take_profit": {
          "format": "int64",
          "type": [
           "integer",
           "null"
          ]
         },
         "take_profits": {
          "description": "Take-profit targets in place of take_profit: each {price, share}, the shares whole percents of at least 1 summing to 100 (for a position's brackets, no share moves the targets).",
          "items": {
           "additionalProperties": false,
           "properties": {
            "price": {
             "format": "int64",
             "minimum": 1,
             "type": "integer"
            },
            "share": {
             "type": [
              "integer",
              "null"
             ]
            }
           },
           "required": [
            "price"
           ],
           "type": "object"
          },
          "minItems": 1,
          "type": [
           "array",
           "null"
          ]
         }
        },
        "required": [
         "stop_loss",
         "take_profit",
         "expected_position_qty"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "403": {
      "$ref": "#/components/responses/E403"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "409": {
      "$ref": "#/components/responses/E409"
     },
     "422": {
      "$ref": "#/components/responses/E422"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Set, replace or remove the stop loss and take profit of a position",
    "tags": [
     "trade"
    ]
   }
  },
  "/v1/api/accounts/{account_id}/positions/{symbol}/close": {
   "post": {
    "operationId": "close_position",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     },
     {
      "in": "path",
      "name": "symbol",
      "required": true,
      "schema": {
       "title": "Symbol",
       "type": "string"
      }
     },
     {
      "description": "1 to 64 printable ASCII characters. The same key and body give the stored answer again (replayed: true) and do nothing; another body under the same key is a 422 IDEMPOTENCY_KEY_REUSED. For a new order it is its client_order_id (letters, digits and . _ : - only).",
      "in": "header",
      "name": "Idempotency-Key",
      "required": true,
      "schema": {
       "maxLength": 64,
       "minLength": 1,
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": false,
        "properties": {
         "expected_position_qty": {
          "description": "Signed; refused 409 when the position is no longer this.",
          "format": "int64",
          "type": "integer"
         }
        },
        "type": "object"
       }
      }
     },
     "required": false
    },
    "responses": {
     "201": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "403": {
      "$ref": "#/components/responses/E403"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "409": {
      "$ref": "#/components/responses/E409"
     },
     "422": {
      "$ref": "#/components/responses/E422"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Close a whole position at market (reduce-only)",
    "tags": [
     "trade"
    ]
   }
  },
  "/v1/api/accounts/{account_id}/positions/{symbol}/reverse": {
   "post": {
    "operationId": "reverse_position",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     },
     {
      "in": "path",
      "name": "symbol",
      "required": true,
      "schema": {
       "title": "Symbol",
       "type": "string"
      }
     },
     {
      "description": "1 to 64 printable ASCII characters. The same key and body give the stored answer again (replayed: true) and do nothing; another body under the same key is a 422 IDEMPOTENCY_KEY_REUSED. For a new order it is its client_order_id (letters, digits and . _ : - only).",
      "in": "header",
      "name": "Idempotency-Key",
      "required": true,
      "schema": {
       "maxLength": 64,
       "minLength": 1,
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "additionalProperties": false,
        "properties": {
         "expected_position_qty": {
          "format": "int64",
          "type": "integer"
         },
         "stop_loss": {
          "format": "int64",
          "type": [
           "integer",
           "null"
          ]
         },
         "stop_loss_trail": {
          "format": "int64",
          "type": [
           "integer",
           "null"
          ]
         },
         "take_profit": {
          "format": "int64",
          "type": [
           "integer",
           "null"
          ]
         }
        },
        "required": [
         "expected_position_qty"
        ],
        "type": "object"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "403": {
      "$ref": "#/components/responses/E403"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "409": {
      "$ref": "#/components/responses/E409"
     },
     "422": {
      "$ref": "#/components/responses/E422"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Close a position and open the same size the other way, both or neither",
    "tags": [
     "trade"
    ]
   }
  },
  "/v1/api/accounts/{account_id}/risk": {
   "get": {
    "operationId": "get_risk",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Risk left: room to the Daily Loss Limit and to the Max Drawdown, the day's reset",
    "tags": [
     "read"
    ]
   }
  },
  "/v1/api/accounts/{account_id}/trading-terms": {
   "get": {
    "operationId": "get_trading_terms",
    "parameters": [
     {
      "in": "path",
      "name": "account_id",
      "required": true,
      "schema": {
       "title": "Account Id",
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "The order types of the account and the leverage of each market",
    "tags": [
     "read"
    ]
   }
  },
  "/v1/api/markets": {
   "get": {
    "description": "The terminal's public list (``GET /v1/markets``), computed at most every ``markets_cache_ms`` for everybody;\nthe switch of the API first (one turn of the writer, like every read of a key).",
    "operationId": "list_markets",
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "Markets: class, unit, leverage ceiling, freeze state, last quote and statistics",
    "tags": [
     "read"
    ]
   }
  },
  "/v1/api/markets/{symbol}/quote": {
   "get": {
    "description": "The market's last quote (``bid_e8``, ``ask_e8``, ``ts_ms``...; null before the first one) and whether a new\norder may be placed on it now (``frozen``, ``manual_freeze``, ``reconnecting``).",
    "operationId": "get_quote",
    "parameters": [
     {
      "in": "path",
      "name": "symbol",
      "required": true,
      "schema": {
       "title": "Symbol",
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      },
      "description": "The same JSON the terminal gets from its route of the same name."
     },
     "400": {
      "$ref": "#/components/responses/E400"
     },
     "401": {
      "$ref": "#/components/responses/E401"
     },
     "404": {
      "$ref": "#/components/responses/E404"
     },
     "429": {
      "$ref": "#/components/responses/E429"
     },
     "503": {
      "$ref": "#/components/responses/E503"
     }
    },
    "summary": "The last quote of a market and whether a new order may be placed on it now",
    "tags": [
     "read"
    ]
   }
  }
 },
 "security": [
  {
   "key": []
  }
 ],
 "servers": [
  {
   "url": "https://app.proofperps.com"
  }
 ]
}
