openapi: 3.1.0
info:
  title: CrossTrade API
  version: 1.0.0
  description: 'The CrossTrade API provides programmatic access to NinjaTrader 8 through the CrossTrade add-on.


    ## Architecture


    All API calls require an active NinjaTrader 8 instance with the CrossTrade add-on connected.

    Requests are forwarded via RPC to the add-on running on your machine.


    **Two access methods:**

    1. **REST API** (this spec) — Standard HTTP endpoints at `/v1/api/*`

    2. **WebSocket API** — Connect to `/ws/stream` for real-time data and RPC


    ## Authentication


    All endpoints require a Bearer token in the `Authorization` header.

    API access requires a **Pro subscription**.


    ## Rate Limits


    - **180 requests/minute** per user (shared across HTTP and WebSocket)

    - **20-request burst** allowance

    - Market data subscription changes: ~20/minute


    ## WebSocket API


    Connect to `/ws/stream` for real-time market data, PnL streaming, and RPC calls.


    ### Actions


    | Action | Description |

    |--------|-------------|

    | `rpc` | Call any RPC function: `{"action": "rpc", "id": "req-1", "api": "PlaceOrder", "args": {...}}` |

    | `subscribe` | Subscribe to market data: `{"action": "subscribe", "instruments": ["ES 03-26"]}` |

    | `unsubscribe` | Unsubscribe: `{"action": "unsubscribe", "instruments": ["ES 03-26"]}` |

    | `streamPnl` | Toggle PnL streaming: `{"action": "streamPnl", "enabled": true, "interval": 1000}` |

    | `ping` | Keepalive: `{"action": "ping"}` |


    ### Events Received


    | Type | Description |

    |------|-------------|

    | `marketData` | `{"type": "marketData", "quotes": [...]}` |

    | `pnlUpdate` | `{"type": "pnlUpdate", "epoch": ..., "accounts": [...]}` |

    | RPC response | `{"id": "req-1", "data": {...}}` |

    '
  contact:
    name: CrossTrade
    url: https://crosstrade.io
servers:
- url: https://app.crosstrade.io
  description: Production
- url: https://dev.crosstrade.io
  description: Development
security:
- bearerAuth: []
paths:
  /v1/api/accounts:
    get:
      tags:
      - Accounts
      x-rpc-api: ListAccounts
      summary: Get Accounts
      description: '**RPC Function:** `ListAccounts`'
      operationId: accts
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/snapshot:
    get:
      tags:
      - Accounts
      x-rpc-api: GetAccountSummary
      summary: Get Accounts Summary
      description: '**RPC Function:** `GetAccountSummary`'
      operationId: summary
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/positions/flatten:
    post:
      tags:
      - Positions
      x-rpc-api: Flatten
      summary: Flatten All Positions in All Accounts
      description: '**RPC Function:** `Flatten`


        **Optional fields (from add-on):** `account`, `instrument`, `cancelOrders`, `strategyTag`, `strategyTagMode`, `force`'
      operationId: flatten_everything
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                account:
                  type: string
                cancelOrders:
                  type: boolean
                force:
                  type: boolean
                instrument:
                  type: string
                strategyTag:
                  type: string
                strategyTagMode:
                  type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}:
    get:
      tags:
      - Accounts
      x-rpc-api: GetAccount
      summary: Get Account
      description: '**RPC Function:** `GetAccount`


        **Optional fields (from add-on):** `account`'
      operationId: acct
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/orders/cancelall:
    post:
      tags:
      - Orders
      x-rpc-api: CancelAllOrders
      summary: Cancel All Orders in All Accounts
      description: '**RPC Function:** `CancelAllOrders`'
      operationId: cancel_all_orders
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/positions:
    get:
      tags:
      - Positions
      x-rpc-api: ListPositions
      summary: List Active Positions in Account
      description: '**RPC Function:** `ListPositions`


        **Optional fields (from add-on):** `account`'
      operationId: list_positions
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/orders:
    get:
      tags:
      - Orders
      x-rpc-api: ListOrders
      summary: List Active/Orders in Account
      description: '**RPC Function:** `ListOrders`


        **Optional fields (from add-on):** `account`, `lookbackTime`, `activeOnly`'
      operationId: list_orders
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      - name: activeOnly
        in: query
        required: false
        schema:
          type: string
          default: 'true'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/strategies:
    get:
      tags:
      - Strategies
      x-rpc-api: ListStrategies
      summary: Get Active Strategies in Account
      description: '**RPC Function:** `ListStrategies`'
      operationId: list_strats
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/strategies/{id}:
    get:
      tags:
      - Strategies
      x-rpc-api: GetStrategy
      summary: Get Strategy by ID
      description: '**RPC Function:** `GetStrategy`


        **Optional fields (from add-on):** `strategyId`'
      operationId: get_strat
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      - name: id
        in: path
        required: true
        schema:
          type: string
        description: Resource ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/strategies/{id}/close:
    post:
      tags:
      - Strategies
      x-rpc-api: CloseStrategy
      summary: Close Strategy by ID
      description: '**RPC Function:** `CloseStrategy`


        **Optional fields (from add-on):** `strategyId`, `signalName`, `strategyTag`, `force`'
      operationId: close_strat
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      - name: id
        in: path
        required: true
        schema:
          type: string
        description: Resource ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/executions:
    get:
      tags:
      - Executions
      x-rpc-api: ListExecutions
      summary: Get Executions by Account
      description: '**RPC Function:** `ListExecutions`'
      operationId: list_executions
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      - name: lookbackTime
        in: query
        required: false
        schema:
          type: string
          default: '320'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/positions/close:
    post:
      tags:
      - Positions
      x-rpc-api: ClosePosition
      summary: Close Position (account, instrument)
      description: '**RPC Function:** `ClosePosition`


        **Optional fields (from add-on):** `strategyTag`, `force`, `quantity`, `percent`'
      operationId: close_position
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                force:
                  type: boolean
                instrument:
                  type: string
                percent:
                  type: number
                quantity:
                  type: integer
                strategyTag:
                  type: string
              required:
              - instrument
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/positions/reverse:
    post:
      tags:
      - Positions
      x-rpc-api: Reverse
      summary: Reverse
      description: '**RPC Function:** `Reverse`


        **Optional fields (from add-on):** `strategyTag`, `force`'
      operationId: reverse
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                force:
                  type: boolean
                instrument:
                  type: string
                strategyTag:
                  type: string
              required:
              - instrument
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/positions/reverseposition:
    post:
      tags:
      - Positions
      x-rpc-api: ReversePosition
      summary: Reverse Position (account, instrument, action, orderType, quantity, timeInForce, limitPrice, stopPrice, ocoId,
        strategy)
      description: '**RPC Function:** `ReversePosition`


        **Optional fields (from add-on):** `account`, `instrument`, `strategyTag`, `force`, `action`, `quantity`'
      operationId: reverse_position
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: string
                force:
                  type: boolean
                instrument:
                  type: string
                quantity:
                  type: integer
                strategyTag:
                  type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/positions/flatten:
    post:
      tags:
      - Positions
      x-rpc-api: Flatten
      summary: Flatten Positions in 1 account (account, instrument)
      description: '**RPC Function:** `Flatten`


        **Optional fields (from add-on):** `account`, `instrument`, `cancelOrders`, `strategyTag`, `strategyTagMode`, `force`'
      operationId: flatten_position
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                cancelOrders:
                  type: boolean
                force:
                  type: boolean
                instrument:
                  type: string
                strategyTag:
                  type: string
                strategyTagMode:
                  type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/position:
    get:
      tags:
      - Accounts
      x-rpc-api: GetPosition
      summary: Get Position by Account + Instrument (instrument URL-encoded)
      description: '**RPC Function:** `GetPosition`


        **Optional fields (from add-on):** `account`, `instrument`'
      operationId: get_position
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      - name: instrument
        in: query
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/market/quote:
    get:
      tags:
      - Market Data
      summary: Get Quote by Account + Instrument (uses wss.py IPC caching system)
      operationId: get_quote
      parameters:
      - name: root
        in: query
        required: true
        schema:
          type: string
      - name: instrument
        in: query
        required: true
        schema:
          type: string
      - name: showRollover
        in: query
        required: false
        schema:
          type: string
          default: 'false'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/quote:
    get:
      tags:
      - Accounts
      summary: Get Quote by Account + Instrument (uses wss.py IPC caching system)
      operationId: get_quote
      parameters:
      - name: root
        in: query
        required: true
        schema:
          type: string
      - name: instrument
        in: query
        required: true
        schema:
          type: string
      - name: showRollover
        in: query
        required: false
        schema:
          type: string
          default: 'false'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/orders/cancel:
    post:
      tags:
      - Orders
      x-rpc-api: CancelOrders
      summary: Cancel Orders by Account + Instrument
      description: '**RPC Function:** `CancelOrders`


        **Optional fields (from add-on):** `account`, `instrument`, `strategyTag`, `force`'
      operationId: cancel_orders
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                force:
                  type: boolean
                instrument:
                  type: string
                strategyTag:
                  type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/orders/place:
    post:
      tags:
      - Orders
      x-rpc-api: PlaceOrder
      summary: Place Order
      description: '**RPC Function:** `PlaceOrder`


        **Optional fields (from add-on):** `targetQuantity`, `stopPrice`, `limitPrice`, `ocoId`, `strategy`, `orderId`, `strategyTag`,
        `force`, `requireMarketPosition`, `maxPositions`, `smartOptions`'
      operationId: place_order
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: string
                force:
                  type: boolean
                instrument:
                  type: string
                limitPrice:
                  type: number
                maxPositions:
                  type: integer
                ocoId:
                  type: string
                orderId:
                  type: string
                orderType:
                  type: string
                quantity:
                  type: integer
                requireMarketPosition:
                  type: string
                smartOptions:
                  type: object
                stopPrice:
                  type: number
                strategy:
                  type: string
                strategyTag:
                  type: string
                targetQuantity:
                  type: integer
                timeInForce:
                  type: string
              required:
              - action
              - instrument
              - orderType
              - quantity
              - timeInForce
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/orders/flatplace:
    post:
      tags:
      - Orders
      x-rpc-api: FlatPlace
      summary: Flat Place Order
      description: '**RPC Function:** `FlatPlace`


        **Optional fields (from add-on):** `account`, `instrument`, `strategyTag`, `force`, `action`, `quantity`'
      operationId: flat_place_order
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: string
                force:
                  type: boolean
                instrument:
                  type: string
                quantity:
                  type: integer
                strategyTag:
                  type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/orders/{id}/status:
    get:
      tags:
      - Orders
      x-rpc-api: GetOrderStatus
      summary: Get Order Status by ID
      description: '**RPC Function:** `GetOrderStatus`'
      operationId: get_order_status
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      - name: id
        in: path
        required: true
        schema:
          type: string
        description: Resource ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/orders/{id}/change:
    put:
      tags:
      - Orders
      x-rpc-api: Change
      summary: Change Order
      description: '**RPC Function:** `Change`


        **Optional fields (from add-on):** `limitPrice`, `stopPrice`, `quantity`, `strategyId`, `account`, `strategyTag`,
        `force`'
      operationId: change_order
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      - name: id
        in: path
        required: true
        schema:
          type: string
        description: Resource ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                force:
                  type: boolean
                limitPrice:
                  type: number
                orderId:
                  type: string
                quantity:
                  type: integer
                stopPrice:
                  type: number
                strategyId:
                  type: string
                strategyTag:
                  type: string
              required:
              - orderId
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/orders/{id}/cancel:
    post:
      tags:
      - Orders
      x-rpc-api: Cancel
      summary: Cancel Order by ID
      description: '**RPC Function:** `Cancel`


        **Optional fields (from add-on):** `strategyId`, `account`, `strategyTag`, `force`'
      operationId: cancel_order
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      - name: id
        in: path
        required: true
        schema:
          type: string
        description: Resource ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/orders/{id}/replace:
    post:
      tags:
      - Orders
      x-rpc-api: CancelReplace
      summary: Cancel Replace Order
      description: '**RPC Function:** `CancelReplace`


        **Optional fields (from add-on):** `strategyTag`, `force`'
      operationId: cancel_replace_order
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      - name: id
        in: path
        required: true
        schema:
          type: string
        description: Resource ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: string
                force:
                  type: boolean
                instrument:
                  type: string
                orderId:
                  type: string
                orderType:
                  type: string
                quantity:
                  type: string
                strategyTag:
                  type: string
                timeInForce:
                  type: string
              required:
              - action
              - instrument
              - orderId
              - orderType
              - quantity
              - timeInForce
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/orders/{id}:
    get:
      tags:
      - Orders
      x-rpc-api: GetOrder
      summary: Get Order by ID
      description: '**RPC Function:** `GetOrder`


        **Optional fields (from add-on):** `orderId`'
      operationId: get_order
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      - name: id
        in: path
        required: true
        schema:
          type: string
        description: Resource ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /v1/api/accounts/{account}/executions/{id}:
    get:
      tags:
      - Executions
      x-rpc-api: GetExecution
      summary: Get Execution by ID
      description: '**RPC Function:** `GetExecution`'
      operationId: get_execution
      parameters:
      - name: account
        in: path
        required: true
        schema:
          type: string
        description: Account name (e.g., "Sim101")
        example: Sim101
      - name: id
        in: path
        required: true
        schema:
          type: string
        description: Resource ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Bad request or operation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: Client (NinjaTrader add-on) not connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded (180 req/min per user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
      - bearerAuth: []
  /ws/stream:
    get:
      tags:
      - WebSocket API
      summary: Streaming WebSocket endpoint
      description: "Real-time streaming WebSocket endpoint. Supports:\n\n- **RPC calls** to the NinjaTrader add-on (same functions\
        \ as REST API)\n- **Market data streaming** via instrument subscriptions\n- **PnL streaming** for real-time account\
        \ updates\n\n### Send: RPC Call\n```json\n{\n  \"action\": \"rpc\",\n  \"id\": \"my-request-1\",\n  \"api\": \"PlaceOrder\"\
        ,\n  \"args\": {\n    \"account\": \"Sim101\",\n    \"instrument\": \"ES 03-26\",\n    \"action\": \"Buy\",\n    \"\
        orderType\": \"Market\",\n    \"quantity\": 1,\n    \"timeInForce\": \"Gtc\"\n  }\n}\n```\n\n### Send: Subscribe to\
        \ Market Data\n```json\n{\"action\": \"subscribe\", \"instruments\": [\"ES 03-26\", \"NQ 03-26\"]}\n```\n\n### Send:\
        \ Stream PnL\n```json\n{\"action\": \"streamPnl\", \"enabled\": true, \"interval\": 1000}\n```\n\n### Receive: Market\
        \ Data\n```json\n{\"type\": \"marketData\", \"quotes\": [{\"instrument\": \"ES 03-26\", \"last\": 5425.50, ...}]}\n\
        ```\n\n### Receive: RPC Response\n```json\n{\"id\": \"my-request-1\", \"data\": {\"orderId\": \"abc123\", \"success\"\
        : true}}\n```\n\nSingle session enforced — connecting from a new client disconnects the previous one.\n"
      operationId: websocket_stream
      parameters:
      - name: Authorization
        in: header
        required: true
        schema:
          type: string
        description: Bearer token
      responses:
        '101':
          description: WebSocket upgrade successful
      security:
      - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API bearer token. Requires an active Pro subscription with API access.
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message
tags:
- name: Accounts
  description: Account management and queries
- name: Positions
  description: Position management — list, close, flatten, reverse
- name: Orders
  description: Order placement, modification, and cancellation
- name: Strategies
  description: Strategy management
- name: Executions
  description: Execution history and queries
- name: Market Data
  description: Quotes, bars, subscriptions, and streaming
- name: WebSocket API
  description: Real-time streaming WebSocket API
