# JAFX Trading API — public specification (generated from the service's spec)
openapi: 3.1.0
info:
  title: JAFX Trading API
  version: 1.0.0
  summary: Programmatic access to your own JAFX trading account.
  description: |
    REST + WebSocket API for bots and AI agents. Every request is bound to the
    one account its key was created for, on that account's server (Live Server
    or Demo Server). Market data comes from JAFX's central reference quote board,
    the same for every key (`price_basis: raw`); orders are decided by the
    broker's routing at the account's own prices.

    * Money and volume are decimal strings (`"0.01"`, `"10985.05"`); prices are numbers.
    * Times are ISO-8601 UTC. The broker day is Europe/Athens.
    * Every write needs an `Idempotency-Key` header. Retrying with the same key never trades twice.
    * Errors are RFC 9457 problem documents with a stable `code`.
    * Keys exist for Demo Server accounts (demo keys) and Live Server accounts (live keys). Live keys start with tight limits and confirm mode on.
    * Orders go through the account's own trading session, the way JAFX Terminal places a manual trade, so they are the client's own requests. A key trades for 24 hours after the account's last sign-in to JAFX Terminal (or Renew on its Developers page), whether or not the terminal stays open; after that orders answer `409 sign_in_required` and nothing is sent. With **Keep my bots trading around the clock** switched on in Developers, JAFX signs the session in again by itself, so the keys keep trading. `GET /me` shows until when (`session`) and whether it renews by itself (`session.renews_automatically`).
    * Keeping your key safe: anyone who gets a key can use it as you within its limits, a key that can trade included. Lock each key to your bot's IP addresses (`ip_allowlist`; other addresses get `403 ip_not_allowed`), give AI assistants that run in the cloud a Proposals key (every order waits for your OK), and never paste a key into a chat, a website or code you share.

    Streaming: `wss://terminal.jafx.com/trading-api/v1/stream` (see the developer guide).
    AI agents: MCP endpoint `https://terminal.jafx.com/trading-api/mcp` with the same keys.
  contact:
    name: JAFX developer support
servers:
  - url: https://terminal.jafx.com/trading-api/v1
security:
  - apiKey: []
tags:
  - name: Key
    x-displayName: Status and key
    description: Service status and the calling key's scopes, limits and trading state.
  - name: Market data
    description: Instruments, quotes and candles from the central JAFX quote board.
  - name: Account
    description: The key's trading account — summary, positions, pending orders, history.
  - name: Trading
    description: Orders, changes and closes. Every write needs an Idempotency-Key header.
paths:
  /status:
    get:
      operationId: getStatus
      x-scopes: []
      tags:
        - Key
      summary: Service status (no key needed)
      security: []
      responses:
        "200":
          description: Status
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Status"
  /me:
    get:
      operationId: getMe
      x-scopes: []
      tags:
        - Key
      summary: The calling key, its limits and the trading state
      responses:
        "200":
          description: Key
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Me"
        default:
          $ref: "#/components/responses/Problem"
  /symbols:
    get:
      operationId: listSymbols
      x-scopes:
        - market:read
      tags:
        - Market data
      summary: Tradable instruments
      responses:
        "200":
          description: Instruments
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Symbol"
        default:
          $ref: "#/components/responses/Problem"
  /symbols/{symbol}:
    get:
      operationId: getSymbol
      x-scopes:
        - market:read
      tags:
        - Market data
      summary: One instrument
      parameters:
        - $ref: "#/components/parameters/Symbol"
      responses:
        "200":
          description: Instrument
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Symbol"
        default:
          $ref: "#/components/responses/Problem"
  /quotes:
    get:
      operationId: getQuotes
      x-scopes:
        - market:read
      tags:
        - Market data
      summary: Current quotes
      parameters:
        - name: symbols
          in: query
          description: Comma-separated, at most 50. All instruments when omitted.
          schema:
            type: string
            example: EURUSD,XAUUSD
      responses:
        "200":
          description: Quotes
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Quote"
                  missing:
                    type: array
                    items:
                      type: string
        default:
          $ref: "#/components/responses/Problem"
  /candles/{symbol}:
    get:
      operationId: getCandles
      x-scopes:
        - market:read
      tags:
        - Market data
      summary: OHLC candles (the last one may still be forming)
      parameters:
        - $ref: "#/components/parameters/Symbol"
        - name: timeframe
          in: query
          schema:
            type: string
            enum:
              - M1
              - M5
              - M15
              - M30
              - H1
              - H4
              - D1
              - W1
            default: M1
        - name: from
          in: query
          schema:
            type: string
            format: date-time
        - name: to
          in: query
          schema:
            type: string
            format: date-time
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 2000
            default: 500
      responses:
        "200":
          description: Candles, oldest first
          content:
            application/json:
              schema:
                type: object
                properties:
                  symbol:
                    type: string
                  timeframe:
                    type: string
                  price_basis:
                    type: string
                    enum:
                      - raw
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Candle"
        default:
          $ref: "#/components/responses/Problem"
  /accounts:
    get:
      operationId: listAccounts
      x-scopes:
        - account:read
      tags:
        - Account
      summary: The key's account (a list of one)
      responses:
        "200":
          description: Accounts
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Account"
        default:
          $ref: "#/components/responses/Problem"
  /accounts/{account}:
    get:
      operationId: getAccount
      x-scopes:
        - account:read
      tags:
        - Account
      summary: Account summary
      parameters:
        - $ref: "#/components/parameters/Account"
      responses:
        "200":
          description: Account
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Account"
        default:
          $ref: "#/components/responses/Problem"
  /accounts/{account}/positions:
    get:
      operationId: listPositions
      x-scopes:
        - account:read
      tags:
        - Account
      summary: Open positions
      parameters:
        - $ref: "#/components/parameters/Account"
        - $ref: "#/components/parameters/ClientTag"
      responses:
        "200":
          description: Positions
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Position"
        default:
          $ref: "#/components/responses/Problem"
  /accounts/{account}/positions/{ticket}:
    patch:
      operationId: modifyPosition
      x-scopes:
        - trade
        - trade:propose
      tags:
        - Trading
      summary: Change stop loss / take profit (null removes one; an omitted one is kept)
      parameters:
        - $ref: "#/components/parameters/Account"
        - $ref: "#/components/parameters/Ticket"
        - $ref: "#/components/parameters/IdempotencyKey"
        - $ref: "#/components/parameters/Wait"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                stop_loss:
                  type:
                    - number
                    - "null"
                  exclusiveMinimum: 0
                take_profit:
                  type:
                    - number
                    - "null"
                  exclusiveMinimum: 0
      responses:
        "200":
          $ref: "#/components/responses/OrderResult"
        "202":
          $ref: "#/components/responses/OrderResult"
        default:
          $ref: "#/components/responses/Problem"
  /accounts/{account}/positions/{ticket}/close:
    post:
      operationId: closePosition
      x-scopes:
        - trade
        - trade:propose
      tags:
        - Trading
      summary: Close a position, wholly or partly
      parameters:
        - $ref: "#/components/parameters/Account"
        - $ref: "#/components/parameters/Ticket"
        - $ref: "#/components/parameters/IdempotencyKey"
        - $ref: "#/components/parameters/Wait"
      requestBody:
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                volume:
                  $ref: "#/components/schemas/Decimal"
      responses:
        "200":
          $ref: "#/components/responses/OrderResult"
        "202":
          $ref: "#/components/responses/OrderResult"
        default:
          $ref: "#/components/responses/Problem"
  /accounts/{account}/orders:
    get:
      operationId: listOrders
      x-scopes:
        - account:read
      tags:
        - Account
      summary: Pending orders
      parameters:
        - $ref: "#/components/parameters/Account"
        - $ref: "#/components/parameters/ClientTag"
      responses:
        "200":
          description: Pending orders
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/PendingOrder"
        default:
          $ref: "#/components/responses/Problem"
    post:
      operationId: placeOrder
      x-scopes:
        - trade
        - trade:propose
      tags:
        - Trading
      summary: Place a market or pending order
      description: |
        `201` executed or placed · `202` pending (broker still deciding), awaiting_confirmation (confirm-mode key)
        or outcome_unknown (poll the request; never resend under a new key) · `4xx` problem.
      parameters:
        - $ref: "#/components/parameters/Account"
        - $ref: "#/components/parameters/IdempotencyKey"
        - $ref: "#/components/parameters/Wait"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OrderRequest"
      responses:
        "201":
          $ref: "#/components/responses/OrderResult"
        "202":
          $ref: "#/components/responses/OrderResult"
        "422":
          $ref: "#/components/responses/Problem"
        default:
          $ref: "#/components/responses/Problem"
  /accounts/{account}/orders/{ticket}:
    patch:
      operationId: modifyOrder
      x-scopes:
        - trade
        - trade:propose
      tags:
        - Trading
      summary: Change a pending order (omitted fields are kept; null removes a stop or the expiry)
      parameters:
        - $ref: "#/components/parameters/Account"
        - $ref: "#/components/parameters/Ticket"
        - $ref: "#/components/parameters/IdempotencyKey"
        - $ref: "#/components/parameters/Wait"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                price:
                  type: number
                  exclusiveMinimum: 0
                stop_loss:
                  type:
                    - number
                    - "null"
                  exclusiveMinimum: 0
                take_profit:
                  type:
                    - number
                    - "null"
                  exclusiveMinimum: 0
                expires_at:
                  type:
                    - string
                    - "null"
                  format: date-time
      responses:
        "200":
          $ref: "#/components/responses/OrderResult"
        "202":
          $ref: "#/components/responses/OrderResult"
        default:
          $ref: "#/components/responses/Problem"
    delete:
      operationId: cancelOrder
      x-scopes:
        - trade
        - trade:propose
      tags:
        - Trading
      summary: Cancel a pending order
      parameters:
        - $ref: "#/components/parameters/Account"
        - $ref: "#/components/parameters/Ticket"
        - $ref: "#/components/parameters/IdempotencyKey"
        - $ref: "#/components/parameters/Wait"
      responses:
        "200":
          $ref: "#/components/responses/OrderResult"
        default:
          $ref: "#/components/responses/Problem"
  /accounts/{account}/trades:
    get:
      operationId: listTrades
      x-scopes:
        - account:read
      tags:
        - Account
      summary: Trades closed in a window (by close time), newest first
      parameters:
        - $ref: "#/components/parameters/Account"
        - name: from
          in: query
          schema:
            type: string
            format: date-time
          description: "Default: 7 days before `to`"
        - name: to
          in: query
          schema:
            type: string
            format: date-time
          description: "Default: now. The window may span 90 days."
        - $ref: "#/components/parameters/ClientTag"
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/Limit"
      responses:
        "200":
          description: Closed trades
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ClosedTrade"
                  next_cursor:
                    type:
                      - string
                      - "null"
                  from:
                    type: string
                    format: date-time
                  to:
                    type: string
                    format: date-time
        default:
          $ref: "#/components/responses/Problem"
  /accounts/{account}/transactions:
    get:
      operationId: listTransactions
      x-scopes:
        - account:read
      tags:
        - Account
      summary: Balance and credit operations
      parameters:
        - $ref: "#/components/parameters/Account"
        - name: from
          in: query
          schema:
            type: string
            format: date-time
        - name: to
          in: query
          schema:
            type: string
            format: date-time
        - $ref: "#/components/parameters/Cursor"
        - $ref: "#/components/parameters/Limit"
      responses:
        "200":
          description: Transactions
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Transaction"
                  next_cursor:
                    type:
                      - string
                      - "null"
        default:
          $ref: "#/components/responses/Problem"
  /accounts/{account}/requests/{request_id}:
    get:
      operationId: getRequest
      x-scopes:
        - account:read
      tags:
        - Trading
      summary: Where an order request stands
      parameters:
        - $ref: "#/components/parameters/Account"
        - name: request_id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Request status
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RequestStatus"
        default:
          $ref: "#/components/responses/Problem"
  /accounts/{account}/proposals:
    get:
      operationId: listProposals
      x-scopes:
        - trade
        - trade:propose
      tags:
        - Trading
      summary: Proposals created by this key (confirm mode)
      parameters:
        - $ref: "#/components/parameters/Account"
      responses:
        "200":
          description: Proposals
        default:
          $ref: "#/components/responses/Problem"
components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: jafx_<demo|live>_<key id>_<secret>
  parameters:
    Account:
      name: account
      in: path
      required: true
      schema:
        type: integer
    Ticket:
      name: ticket
      in: path
      required: true
      schema:
        type: integer
        minimum: 1
    Symbol:
      name: symbol
      in: path
      required: true
      schema:
        type: string
        example: EURUSD
    ClientTag:
      name: client_tag
      in: query
      schema:
        type: string
        pattern: ^[A-Za-z0-9._:-]{1,32}$
    Cursor:
      name: cursor
      in: query
      schema:
        type: string
    Limit:
      name: limit
      in: query
      schema:
        type: integer
        minimum: 1
        maximum: 1000
        default: 100
    Wait:
      name: wait
      in: query
      description: Seconds to wait for a held broker decision before answering 202
      schema:
        type: number
        minimum: 0
        maximum: 10
        default: 5
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      schema:
        type: string
        pattern: ^[A-Za-z0-9._:-]{1,64}$
  responses:
    Problem:
      description: Error
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/Problem"
    OrderResult:
      description: Order result
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/OrderResult"
  schemas:
    Decimal:
      type: string
      pattern: ^-?[0-9]+(\.[0-9]+)?$
      example: "0.01"
    Status:
      type: object
      properties:
        status:
          type: string
          enum:
            - ok
            - degraded
        api_version:
          type: string
        time:
          type: string
          format: date-time
        market_data:
          type: object
        broker:
          type: object
          description: How account data and trading reach the broker, per server. `state` is the worst of them.
          properties:
            state:
              $ref: "#/components/schemas/BrokerState"
            servers:
              type: object
              properties:
                live:
                  $ref: "#/components/schemas/ServerStatus"
                demo:
                  $ref: "#/components/schemas/ServerStatus"
            note:
              type: string
              description: "Orders go through each account's own session: an account's keys trade for 24 hours after its owner signs in to JAFX Terminal, or around the clock when the owner switches that on in Developers."
        live_trading_enabled:
          type: boolean
    ServerStatus:
      type: object
      properties:
        state:
          $ref: "#/components/schemas/BrokerState"
        sign_in_needed_for:
          type: array
          items:
            type: string
            enum:
              - trading
              - account_data
          description: "What needs the account owner's sign-in in the last 24 hours on this server: always trading; account data too where nothing else serves it (`account_data`)."
    BrokerState:
      type: string
      description: "`ready`: up; each account's session opens when its keys are used. `connected`: up, with a standing connection. `disabled`: not available on that server right now (503 broker_unavailable)."
      enum:
        - ready
        - connected
        - connecting
        - reconnecting
        - standby
        - failed
        - disabled
        - stopped
    Session:
      type: object
      description: The account's trading session that its keys trade through. It lasts 24 hours from the owner's last sign-in to JAFX Terminal (or Renew on its Developers page), whether or not the terminal stays open. With around-the-clock trading on, JAFX signs it in again by itself before it ends, or at the next request after it ended.
      properties:
        active:
          type: boolean
        renews_automatically:
          type: boolean
          description: "The owner switched on Keep my bots trading around the clock in Developers: JAFX signs this session in again by itself, so the keys keep trading past expires_at."
        signed_in_at:
          type:
            - string
            - "null"
          format: date-time
        expires_at:
          type:
            - string
            - "null"
          format: date-time
          description: Until when this sign-in lasts (present while active). With renews_automatically, the next one follows by itself.
        ended_at:
          type:
            - string
            - "null"
          format: date-time
        ended_reason:
          type:
            - string
            - "null"
          enum:
            - stopped
            - expired
            - ended_by_broker
            - resume_refused
            - no_active_key
            - not_master
            - unreadable
            - password_refused
            - null
          description: "`stopped`: the owner pressed Stop API trading. `expired`: 24 hours passed. `ended_by_broker`, `resume_refused`: the session ended at the broker (a sign-out of it, a password change). `no_active_key`: the account's last key went. `password_refused`: around-the-clock trading stopped because the trading account refused the saved password (for example after a password change); the owner switches it on again in Developers."
        note:
          type: string
    Me:
      type: object
      properties:
        key_id:
          type: string
        name:
          type: string
        account:
          type: integer
        server:
          type: string
          enum:
            - live
            - demo
          description: "The server the account is on: Live Server or Demo Server. Account numbers are per server."
        mode:
          type: string
          enum:
            - demo
            - live
        profile:
          type: string
          enum:
            - client
            - strategy
        scopes:
          type: array
          items:
            type: string
            enum:
              - market:read
              - account:read
              - trade
              - trade:propose
        constraints:
          $ref: "#/components/schemas/Constraints"
        expires_at:
          type: string
          format: date-time
        trading:
          type: object
          properties:
            mode:
              type: string
              enum:
                - on
                - close_only
                - off
            level:
              type: string
            reason:
              type:
                - string
                - "null"
        session:
          $ref: "#/components/schemas/Session"
        live_trading_enabled:
          type: boolean
    Constraints:
      type: object
      properties:
        demo_only:
          type: boolean
        max_volume_per_order:
          $ref: "#/components/schemas/Decimal"
        max_open_positions:
          type: integer
        orders_per_minute:
          type: integer
        modifications_per_minute:
          type: integer
        daily_loss_limit:
          oneOf:
            - type: "null"
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - percent
                    - amount
                value:
                  $ref: "#/components/schemas/Decimal"
        symbols:
          type:
            - array
            - "null"
          items:
            type: string
        ip_allowlist:
          type:
            - array
            - "null"
          items:
            type: string
          description: "The key's IP lock: up to 20 IP addresses or CIDR ranges it may be used from (any other answers 403 ip_not_allowed); null when the owner left it open to any IP address."
        confirm_mode:
          type: boolean
        mcp_enabled:
          type: boolean
    Symbol:
      type: object
      properties:
        symbol:
          type: string
        description:
          type: string
        group:
          type: string
        digits:
          type: integer
        contract_size:
          type: number
        tick_size:
          type: number
        volume_min:
          $ref: "#/components/schemas/Decimal"
        volume_max:
          $ref: "#/components/schemas/Decimal"
        volume_step:
          $ref: "#/components/schemas/Decimal"
        trade_mode:
          type: string
          enum:
            - full
            - disabled
        long_only:
          type: boolean
    Quote:
      type: object
      properties:
        symbol:
          type: string
        bid:
          type: number
        ask:
          type: number
        time:
          type: string
          format: date-time
        price_basis:
          type: string
          enum:
            - raw
            - group
    Candle:
      type: object
      properties:
        time:
          type: string
          format: date-time
          description: Bar open time
        open:
          type: number
        high:
          type: number
        low:
          type: number
        close:
          type: number
        tick_volume:
          type: integer
        complete:
          type: boolean
    Account:
      type: object
      properties:
        account:
          type: integer
        group:
          type: string
        mode:
          type: string
          enum:
            - demo
            - live
        currency:
          type: string
        leverage:
          type: integer
        balance:
          $ref: "#/components/schemas/Decimal"
        credit:
          $ref: "#/components/schemas/Decimal"
        equity:
          $ref: "#/components/schemas/Decimal"
        margin:
          $ref: "#/components/schemas/Decimal"
        free_margin:
          $ref: "#/components/schemas/Decimal"
        floating_profit:
          $ref: "#/components/schemas/Decimal"
        margin_level:
          type:
            - number
            - "null"
        as_of:
          type: string
          format: date-time
    Position:
      type: object
      properties:
        ticket:
          type: integer
        symbol:
          type: string
        side:
          type: string
          enum:
            - buy
            - sell
        volume:
          $ref: "#/components/schemas/Decimal"
        open_price:
          type: number
        open_time:
          type: string
          format: date-time
        stop_loss:
          type:
            - number
            - "null"
        take_profit:
          type:
            - number
            - "null"
        swap:
          $ref: "#/components/schemas/Decimal"
        commission:
          $ref: "#/components/schemas/Decimal"
        taxes:
          $ref: "#/components/schemas/Decimal"
        profit:
          $ref: "#/components/schemas/Decimal"
        comment:
          type: string
        origin:
          type: string
          enum:
            - api
            - web
            - mobile
            - dealer
            - expert
            - signal
            - client
            - other
        client_tag:
          type:
            - string
            - "null"
        from_ticket:
          type:
            - integer
            - "null"
          description: Original ticket of a partial-close remainder
    PendingOrder:
      type: object
      properties:
        ticket:
          type: integer
        symbol:
          type: string
        type:
          type: string
          enum:
            - buy_limit
            - sell_limit
            - buy_stop
            - sell_stop
        volume:
          $ref: "#/components/schemas/Decimal"
        price:
          type: number
        stop_loss:
          type:
            - number
            - "null"
        take_profit:
          type:
            - number
            - "null"
        expires_at:
          type:
            - string
            - "null"
          format: date-time
        placed_at:
          type: string
          format: date-time
        comment:
          type: string
        origin:
          type: string
        client_tag:
          type:
            - string
            - "null"
    ClosedTrade:
      allOf:
        - $ref: "#/components/schemas/Position"
        - type: object
          properties:
            type:
              type: string
              enum:
                - market
                - buy_limit
                - sell_limit
                - buy_stop
                - sell_stop
            close_price:
              type:
                - number
                - "null"
            close_time:
              type: string
              format: date-time
            state:
              type: string
              enum:
                - closed
                - closed_partial
                - closed_by
                - cancelled
                - expired
    Transaction:
      type: object
      properties:
        ticket:
          type: integer
        type:
          type: string
          enum:
            - balance
            - credit
        amount:
          $ref: "#/components/schemas/Decimal"
        time:
          type: string
          format: date-time
        comment:
          type: string
    OrderRequest:
      type: object
      additionalProperties: false
      required:
        - symbol
        - side
        - volume
      properties:
        symbol:
          type: string
          example: EURUSD
        side:
          type: string
          enum:
            - buy
            - sell
        type:
          type: string
          enum:
            - market
            - limit
            - stop
          default: market
        volume:
          $ref: "#/components/schemas/Decimal"
        price:
          type: number
          exclusiveMinimum: 0
          description: Required for limit and stop
        stop_loss:
          type: number
          exclusiveMinimum: 0
        take_profit:
          type: number
          exclusiveMinimum: 0
        expires_at:
          type: string
          format: date-time
          description: Limit and stop only
        comment:
          type: string
          maxLength: 200
        client_tag:
          type: string
          pattern: ^[A-Za-z0-9._:-]{1,32}$
          description: Stored with the trade (e.g. an MT magic number as "magic:42")
    OrderResult:
      type: object
      properties:
        request_id:
          type: string
        kind:
          type: string
          enum:
            - market
            - pending
            - modify_position
            - modify_order
            - cancel
            - close
        status:
          type: string
          enum:
            - filled
            - placed
            - pending
            - rejected
            - outcome_unknown
            - awaiting_confirmation
        ticket:
          type:
            - integer
            - "null"
        broker_status:
          type:
            - string
            - "null"
        failure:
          type:
            - string
            - "null"
        client_tag:
          type:
            - string
            - "null"
        position:
          $ref: "#/components/schemas/Position"
        order:
          $ref: "#/components/schemas/PendingOrder"
        proposal_id:
          type: string
        expires_at:
          type: string
          format: date-time
        note:
          type: string
    RequestStatus:
      type: object
      properties:
        request_id:
          type: string
        kind:
          type: string
        status:
          type: string
          enum:
            - received
            - sent
            - filled
            - placed
            - pending
            - rejected
            - outcome_unknown
            - refused
            - refused_by_broker
            - not_sent
            - proposed
        ticket:
          type:
            - integer
            - "null"
        failure:
          type:
            - string
            - "null"
        client_tag:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        decided_at:
          type:
            - string
            - "null"
          format: date-time
    Problem:
      type: object
      required:
        - type
        - title
        - status
        - code
      properties:
        type:
          type: string
          format: uri
        title:
          type: string
        status:
          type: integer
        code:
          type: string
          description: Stable error code (see the developer guide's error table)
          example: volume_limit_exceeded
        detail:
          type: string
        request_id:
          type: string
        details: {}
