info:
  description: 'Human-facing REST API for QuantDinger. Agent integrations use `/api/agent/v1`
    — see `docs/agent/agent-openapi.json`. Conventions: `docs/architecture/API_CONVENTIONS.md`.'
  contact:
    name: QuantDinger
    url: https://github.com/brokermr810/quantdinger
  license:
    name: See repository LICENSE
  title: QuantDinger Web API
  version: 1.0.0
components:
  securitySchemes:
    HumanJWT:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'User session JWT from `POST /api/auth/login`. Send as `Authorization:
        Bearer <token>`.'
    AgentToken:
      type: http
      scheme: bearer
      bearerFormat: qd_agent_xxx
      description: Agent Gateway token for `/api/agent/v1/*` only. See docs/agent/AGENT_QUICKSTART.md.
  schemas:
    Error:
      type: object
      properties:
        code:
          type: integer
          description: Error code
        status:
          type: string
          description: Error name
        message:
          type: string
          description: Error message
        errors:
          type: object
          description: Errors
          additionalProperties: {}
      additionalProperties: false
    PaginationMetadata:
      type: object
      properties:
        total:
          type: integer
          description: Total number of items.
        total_pages:
          type: integer
          description: Total number of pages.
        first_page:
          type: integer
          description: First available page number.
        last_page:
          type: integer
          description: Last available page number.
        page:
          type: integer
          description: Current page number.
        previous_page:
          type: integer
          description: Previous page number.
        next_page:
          type: integer
          description: Next page number.
      additionalProperties: false
    HumanSuccessEnvelope:
      type: object
      properties:
        code:
          type: integer
          description: 1 on success
          example: 1
        msg:
          type: string
          example: success
        data:
          nullable: true
      additionalProperties: false
    HumanErrorEnvelope:
      type: object
      properties:
        code:
          type: integer
          description: 0 on error
          example: 0
        msg:
          type: string
        data:
          nullable: true
      additionalProperties: false
    AgentSuccessEnvelope:
      type: object
      properties:
        code:
          type: integer
          description: 0 on success
          example: 0
        message:
          type: string
        data:
          nullable: true
      additionalProperties: false
    AgentError:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
        details:
          nullable: true
        retriable:
          type: boolean
      additionalProperties: false
    PaginationMeta:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        total:
          type: integer
      additionalProperties: false
    ApiInfo:
      type: object
      properties:
        name:
          type: string
          example: QuantDinger Python API
        version:
          type: string
          example: 5.0.1
        status:
          type: string
          example: running
        timestamp:
          type: string
          format: date-time
      additionalProperties: false
    HealthStatus:
      type: object
      properties:
        status:
          type: string
          example: healthy
        timestamp:
          type: string
          format: date-time
        role:
          type: string
          example: api
      additionalProperties: false
    ReadinessStatus:
      type: object
      properties:
        status:
          type: string
          example: healthy
        timestamp:
          type: string
          format: date-time
        role:
          type: string
          example: api
        checks:
          type: object
          additionalProperties:
            type: boolean
      additionalProperties: false
    WorkerHealth:
      type: object
      properties:
        status:
          type: string
          example: healthy
        timestamp:
          type: string
          format: date-time
        role:
          type: string
          example: api
        workers:
          type: array
          items:
            type: object
            additionalProperties: {}
      additionalProperties: false
    LoginRequest:
      type: object
      properties:
        username:
          type: string
          minLength: 1
          maxLength: 254
        account:
          type: string
          minLength: 1
          maxLength: 254
        password:
          type: string
          minLength: 1
          maxLength: 1024
        turnstile_token:
          type: string
          maxLength: 4096
          nullable: true
        turnstile_clearance:
          type: string
          maxLength: 4096
          nullable: true
      required:
      - password
      additionalProperties: false
    UserInfo:
      type: object
      properties:
        id:
          type: integer
        username:
          type: string
        nickname:
          type: string
          nullable: true
        email:
          type: string
          format: email
          nullable: true
        avatar:
          type: string
          nullable: true
        timezone:
          type: string
          nullable: true
        role:
          nullable: true
      additionalProperties: false
    LoginData:
      type: object
      properties:
        token:
          type: string
        userinfo:
          $ref: '#/components/schemas/UserInfo'
      required:
      - token
      - userinfo
      additionalProperties: false
    LoginResponse:
      type: object
      properties:
        code:
          type: integer
        msg:
          type: string
        data:
          anyOf:
          - type: object
            nullable: true
          - $ref: '#/components/schemas/LoginData'
      required:
      - code
      - msg
      additionalProperties: false
    RegisterRequest:
      type: object
      properties:
        email:
          type: string
          format: email
          maxLength: 254
        code:
          type: string
          minLength: 1
          maxLength: 32
        username:
          type: string
          minLength: 3
          maxLength: 30
        password:
          type: string
          minLength: 1
          maxLength: 1024
        referral_code:
          type: string
          default: ''
          maxLength: 64
      required:
      - code
      - email
      - password
      - username
      additionalProperties: false
    ResetPasswordRequest:
      type: object
      properties:
        email:
          type: string
          format: email
          maxLength: 254
        code:
          type: string
          minLength: 1
          maxLength: 32
        new_password:
          type: string
          minLength: 1
          maxLength: 1024
      required:
      - code
      - email
      - new_password
      additionalProperties: false
    ChangePasswordRequest:
      type: object
      properties:
        code:
          type: string
          minLength: 1
          maxLength: 32
        new_password:
          type: string
          minLength: 1
          maxLength: 1024
      required:
      - code
      - new_password
      additionalProperties: false
    CredentialCreateRequest:
      type: object
      properties:
        name:
          type: string
          default: ''
          maxLength: 128
        exchange_id:
          type: string
          minLength: 1
          maxLength: 32
        api_key:
          type: string
          default: ''
          maxLength: 4096
        apiKey:
          type: string
          default: ''
          maxLength: 4096
        secret_key:
          type: string
          default: ''
          maxLength: 4096
        secretKey:
          type: string
          default: ''
          maxLength: 4096
        passphrase:
          type: string
          default: ''
          maxLength: 4096
        base_url:
          type: string
          default: ''
          maxLength: 2048
          nullable: true
        baseUrl:
          type: string
          default: ''
          maxLength: 2048
          nullable: true
        enable_demo_trading:
          type: boolean
          default: false
        demo:
          type: boolean
          default: false
        sandbox:
          type: boolean
          default: false
        testnet:
          type: boolean
          default: false
        environment:
          type: string
          default: ''
          maxLength: 32
        network:
          type: string
          default: ''
          maxLength: 32
        market_scope:
          type: string
          default: ''
          enum:
          - ''
          - spot
          - swap
          - both
        marketScope:
          type: string
          default: ''
          maxLength: 32
        ibkr_host:
          type: string
          default: 127.0.0.1
          maxLength: 255
        ibkr_port:
          type: integer
          default: 7497
          minimum: 1
          maximum: 65535
        ibkr_client_id:
          type: integer
          default: 7
          minimum: 0
          maximum: 2147483647
        ibkr_account:
          type: string
          default: ''
          maxLength: 128
      required:
      - exchange_id
      additionalProperties: false
    CredentialCreatedData:
      type: object
      properties:
        id:
          type: integer
      required:
      - id
      additionalProperties: false
    CredentialCreatedResponse:
      type: object
      properties:
        code:
          type: integer
        msg:
          type: string
        data:
          anyOf:
          - type: object
            nullable: true
          - $ref: '#/components/schemas/CredentialCreatedData'
      required:
      - code
      - msg
      additionalProperties: false
    BillingOrderRequest:
      type: object
      properties:
        plan:
          type: string
          enum:
          - monthly
          - yearly
          - lifetime
        chain:
          type: string
          default: null
          enum:
          - TRC20
          - BEP20
          - ERC20
          - SOL
          - null
          nullable: true
      required:
      - plan
      additionalProperties: false
    QuickTradeOrderRequest:
      type: object
      properties:
        credential_id:
          type: integer
          minimum: 1
        symbol:
          type: string
          minLength: 1
          maxLength: 64
        side:
          type: string
          enum:
          - buy
          - sell
        order_type:
          type: string
          default: market
          enum:
          - market
          - limit
        amount:
          type: number
          minimum: 0.0
        price:
          type: number
          default: 0.0
          minimum: 0.0
        leverage:
          type: integer
          default: 1
          minimum: 1
          maximum: 125
        market_type:
          type: string
          default: ''
          enum:
          - ''
          - spot
          - swap
          - futures
          - future
          - perp
          - perpetual
        tp_price:
          type: number
          default: 0.0
          minimum: 0.0
        sl_price:
          type: number
          default: 0.0
          minimum: 0.0
        source:
          type: string
          default: manual
          maxLength: 64
        margin_mode:
          type: string
          default: ''
          maxLength: 16
        marginMode:
          type: string
          default: ''
          maxLength: 16
      required:
      - amount
      - credential_id
      - side
      - symbol
      additionalProperties: false
    QuickTradeCloseRequest:
      type: object
      properties:
        credential_id:
          type: integer
          minimum: 1
        symbol:
          type: string
          minLength: 1
          maxLength: 64
        market_type:
          type: string
          default: swap
          enum:
          - spot
          - swap
          - futures
          - future
          - perp
          - perpetual
        size:
          type: number
          default: 0.0
          minimum: 0.0
        close_scope:
          type: string
          default: full
          maxLength: 32
        closeScope:
          type: string
          default: ''
          maxLength: 32
        position_side:
          type: string
          default: ''
          enum:
          - ''
          - long
          - short
        close_side:
          type: string
          default: ''
          enum:
          - ''
          - long
          - short
        source:
          type: string
          default: manual
          maxLength: 64
      required:
      - credential_id
      - symbol
      additionalProperties: false
  responses:
    DEFAULT_ERROR:
      description: Default error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UNPROCESSABLE_ENTITY:
      description: Unprocessable Entity
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
tags:
- name: Health
  description: Liveness and API metadata (Public)
- name: Policy
  description: Capability and broker policy discovery (Public)
- name: Auth
  description: Authentication and OAuth (Public)
- name: Users
  description: User profile and administration (Mixed)
- name: Market
  description: Market data and watchlists (Public)
- name: Universe
  description: Point-in-time strategy universes (Internal)
- name: Factor
  description: Versioned factor catalog and research diagnostics (Internal)
- name: Indicator
  description: Indicator IDE workspace (Public)
- name: Backtest
  description: Unified V2 backtesting (Public)
- name: Strategy
  description: Strategy runtime and bots (Internal)
- name: Account
  description: Trading account snapshots and positions (Internal)
- name: Community
  description: Indicator marketplace (Public)
- name: Credentials
  description: Exchange credential vault (Internal)
- name: Dashboard
  description: Dashboard aggregates (Internal)
- name: Portfolio
  description: Manual portfolio tracking (Internal)
- name: Settings
  description: System and brand settings (Mixed)
- name: Billing
  description: Membership and USDT billing (Internal)
- name: FastAnalysis
  description: Fast AI analysis (Public)
- name: GlobalMarket
  description: Global market overview (Public)
- name: AIChat
  description: Legacy AI chat compatibility (Internal)
- name: QuickTrade
  description: Manual quick trade (Internal)
- name: IBKR
  description: Interactive Brokers adapter (Internal)
- name: Alpaca
  description: Alpaca adapter (Internal)
servers:
- url: http://localhost:5000
  description: Backend direct (python run.py)
- url: http://localhost:8888
  description: Docker Compose (via reverse proxy)
paths:
  /:
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiInfo'
      summary: API root
      tags:
      - Health
      operationId: getApiRoot
      x-visibility: public
  /health:
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthStatus'
      summary: Health check
      tags:
      - Health
      operationId: getHealth
      x-visibility: public
  /api/health:
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthStatus'
      summary: Health check (compat path)
      tags:
      - Health
      description: Used by Docker health checks and reverse-proxy probes.
      operationId: getApiHealthCompat
      x-visibility: public
  /api/health/ready:
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReadinessStatus'
      tags:
      - Health
      summary: Readiness check
      operationId: getReadiness
      x-visibility: internal
  /api/health/workers:
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkerHealth'
      tags:
      - Health
      summary: Worker health
      operationId: getWorkerHealth
      x-visibility: internal
  /metrics:
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Health
      summary: Prometheus metrics
      operationId: getPrometheusMetrics
      x_visibility: internal
      x-visibility: internal
  /api/policy/broker-market:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return the full broker x market x market_type compatibility matrix.
      description: "Response shape (kept stable for the frontend):\n{\n  \"code\"\
        : 1,\n  \"data\": {\n    \"broker_markets\": {\n        \"ibkr\":   {\"USStock\"\
        : [\"spot\"]},\n        \"alpaca\": {\"USStock\": [\"spot\"], \"Crypto\":\
        \ [\"spot\"]},\n        \"binance\": {\"Crypto\":  [\"spot\", \"swap\"]},\n\
        \        ...\n    },\n    \"long_only_brokers\": [\"alpaca\", \"ibkr\"],\n\
        \    \"bot_type_markets\": {\n        \"grid\":       [\"Crypto\"],\n    \
        \    \"martingale\": [\"Crypto\"],\n        \"dca\":        [\"Crypto\", \"\
        USStock\"],\n        \"trend\":      [\"Crypto\", \"USStock\"]\n    },\n \
        \   \"live_market_categories\": [\"Crypto\", \"USStock\"]\n  }\n}"
      tags:
      - Policy
      operationId: getApiPolicyBrokerMarket
      x-visibility: public
  /api/auth/security-config:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get public security configuration for frontend.
      description: 'Returns:

        turnstile_enabled: bool

        turnstile_site_key: str

        registration_enabled: bool

        oauth_google_enabled: bool

        oauth_github_enabled: bool'
      tags:
      - Auth
      operationId: getApiAuthSecurityConfig
      x-visibility: public
  /api/auth/turnstile-clearance:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Exchange a fresh Turnstile token for a short-lived local clearance.
      tags:
      - Auth
      operationId: postApiAuthTurnstileClearance
      x-visibility: public
  /api/auth/login:
    post:
      responses:
        '422':
          $ref: '#/components/responses/UNPROCESSABLE_ENTITY'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LoginResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoginRequest'
      summary: User login endpoint.
      description: "Request body:\n    username: str\n    password: str\n    turnstile_token:\
        \ str (optional, required if Turnstile is enabled)\n\nReturns:\n    token:\
        \ JWT token\n    userinfo: User information"
      tags:
      - Auth
      operationId: postApiAuthLogin
      x-visibility: public
  /api/auth/mfa/verify-login:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Complete a password login that was paused for TOTP verification.
      tags:
      - Auth
      operationId: postApiAuthMfaVerifyLogin
      x-visibility: public
  /api/auth/login-code:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Login with email verification code (quick login / register).
      description: 'Request body:

        email: str

        code: str (verification code)

        referral_code: str (optional, referrer''s user ID - only for new users)


        Login with email verification code (quick login / register).

        If user doesn''t exist, create a new account automatically.'
      tags:
      - Auth
      operationId: postApiAuthLoginCode
      x-visibility: public
  /api/auth/send-code:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Send verification code to email.
      description: 'Request body:

        email: str

        type: str (register, reset_password, change_password, change_email)

        turnstile_token: str (optional)'
      tags:
      - Auth
      operationId: postApiAuthSendCode
      x-visibility: public
  /api/auth/register:
    post:
      responses:
        '422':
          $ref: '#/components/responses/UNPROCESSABLE_ENTITY'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LoginResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RegisterRequest'
      summary: Register new user with email verification.
      description: 'Request body:

        email: str

        code: str (verification code)

        username: str

        password: str

        referral_code: str (optional, referrer''s user ID)'
      tags:
      - Auth
      operationId: postApiAuthRegister
      x-visibility: public
  /api/auth/reset-password:
    post:
      responses:
        '422':
          $ref: '#/components/responses/UNPROCESSABLE_ENTITY'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResetPasswordRequest'
      summary: Reset password with email verification.
      description: 'Request body:

        email: str

        code: str (verification code)

        new_password: str'
      tags:
      - Auth
      operationId: postApiAuthResetPassword
      x-visibility: public
  /api/auth/change-password:
    post:
      responses:
        '422':
          $ref: '#/components/responses/UNPROCESSABLE_ENTITY'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChangePasswordRequest'
      summary: Change password with email verification (for logged-in users).
      description: 'Request body:

        code: str (verification code sent to user''s email)

        new_password: str'
      tags:
      - Auth
      operationId: postApiAuthChangePassword
      x-visibility: public
  /api/auth/oauth/google:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Redirect to Google OAuth authorization page.
      description: "Query params:\nredirect: optional front-end URL (must be allow-listed).\
        \ When provided,\n          after successful login the user is redirected\
        \ there instead of\n          the default FRONTEND_URL. Supports multi-frontend\
        \ (PC + mobile)."
      tags:
      - Auth
      operationId: getApiAuthOauthGoogle
      x-visibility: public
  /api/auth/oauth/google/callback:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Handle Google OAuth callback
      tags:
      - Auth
      operationId: getApiAuthOauthGoogleCallback
      x-visibility: public
  /api/auth/oauth/github:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Redirect to GitHub OAuth authorization page.
      description: 'Query params:

        redirect: optional front-end URL (must be allow-listed), see oauth_google.'
      tags:
      - Auth
      operationId: getApiAuthOauthGithub
      x-visibility: public
  /api/auth/oauth/github/callback:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Handle GitHub OAuth callback
      tags:
      - Auth
      operationId: getApiAuthOauthGithubCallback
      x-visibility: public
  /api/auth/logout:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Logout (client removes token; server is stateless).
      tags:
      - Auth
      operationId: postApiAuthLogout
      x-visibility: public
  /api/auth/info:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get current user info.
      tags:
      - Auth
      operationId: getApiAuthInfo
      x-visibility: public
  /api/users/list:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: List all users (admin only).
      description: 'Query params:

        page: int (default 1)

        page_size: int (default 20, max 100)

        search: str (optional, search by username/email/nickname/id)

        user_id: int (optional, exact user id filter)'
      tags:
      - Users
      operationId: getApiUsersList
      x-visibility: internal
  /api/users/export:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Export all users as an Excel-friendly CSV file (admin only).
      tags:
      - Users
      operationId: getApiUsersExport
      x-visibility: internal
  /api/users/detail:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get user detail by ID (admin only)
      tags:
      - Users
      operationId: getApiUsersDetail
      x-visibility: internal
  /api/users/create:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Create a new user (admin only).
      description: 'Request body:

        username: str (required)

        password: str (required)

        email: str (optional)

        nickname: str (optional)

        role: str (optional, default ''user'')'
      tags:
      - Users
      operationId: postApiUsersCreate
      x-visibility: internal
  /api/users/update:
    put:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Update user information (admin only).
      description: "Query params:\n    id: int (required)\n\nRequest body:\n    email:\
        \ str (optional)\n    nickname: str (optional)\n    role: str (optional)\n\
        \    status: str (optional)"
      tags:
      - Users
      operationId: putApiUsersUpdate
      x-visibility: internal
  /api/users/delete:
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete a user (admin only)
      tags:
      - Users
      operationId: deleteApiUsersDelete
      x-visibility: internal
  /api/users/reset-password:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Reset a user's password (admin only).
      description: 'Request body:

        user_id: int (required)

        new_password: str (required)'
      tags:
      - Users
      operationId: postApiUsersResetPassword
      x-visibility: internal
  /api/users/roles:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get available roles and their permissions
      tags:
      - Users
      operationId: getApiUsersRoles
      x-visibility: internal
  /api/users/set-credits:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Set user credits (admin only).
      description: 'Request body:

        user_id: int (required)

        credits: int (required)

        remark: str (optional)'
      tags:
      - Users
      operationId: postApiUsersSetCredits
      x-visibility: internal
  /api/users/set-vip:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Set user VIP status (admin only).
      description: 'Request body:

        user_id: int (required)

        vip_days: int (optional, 0 to cancel VIP, positive number to grant VIP for
        days)

        vip_expires_at: str (optional, ISO format datetime, overrides vip_days if
        provided)

        remark: str (optional)'
      tags:
      - Users
      operationId: postApiUsersSetVip
      x-visibility: internal
  /api/users/credits-log:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get user credits log (admin only).
      description: 'Query params:

        user_id: int (required)

        page: int (default 1)

        page_size: int (default 20)'
      tags:
      - Users
      operationId: getApiUsersCreditsLog
      x-visibility: internal
  /api/users/login-logs:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Paginated account login history (password / email code / OAuth).
      tags:
      - Users
      operationId: getApiUsersLoginLogs
      x-visibility: internal
  /api/users/profile:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get current user's profile with billing info and notification settings
      tags:
      - Users
      operationId: getApiUsersProfile
      x-visibility: internal
  /api/users/profile/update:
    put:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Update current user's profile (limited fields).
      description: "Request body:\n    nickname: str (optional)\n    avatar: str (optional)\n\
        \    timezone: str (optional, IANA id; empty = follow client)\n\nNote: Email\
        \ cannot be changed after registration (for security).\n      Only admin can\
        \ change user email via User Management."
      tags:
      - Users
      operationId: putApiUsersProfileUpdate
      x-visibility: internal
  /api/users/mfa/status:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get current user's authenticator-app MFA status.
      tags:
      - Users
      operationId: getApiUsersMfaStatus
      x-visibility: internal
  /api/users/mfa/setup/start:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Start authenticator-app binding and return QR code data.
      tags:
      - Users
      operationId: postApiUsersMfaSetupStart
      x-visibility: internal
  /api/users/mfa/setup/confirm:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Confirm authenticator-app binding with a 6-digit TOTP code.
      tags:
      - Users
      operationId: postApiUsersMfaSetupConfirm
      x-visibility: internal
  /api/users/mfa/disable:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Disable current user's authenticator-app MFA after code verification.
      tags:
      - Users
      operationId: postApiUsersMfaDisable
      x-visibility: internal
  /api/users/my-credits-log:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get current user's credits log.
      description: 'Query params:

        page: int (default 1)

        page_size: int (default 20)'
      tags:
      - Users
      operationId: getApiUsersMyCreditsLog
      x-visibility: internal
  /api/users/my-referrals:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get list of users referred by current user.
      description: "Query params:\n    page: int (default 1)\n    page_size: int (default\
        \ 20)\n\nReturns:\n    list: Users referred by current user (id, username,\
        \ nickname, avatar, created_at)\n    total: Total count of referrals\n   \
        \ referral_code: Current user's referral code (user ID)\n    referral_bonus:\
        \ Credits earned per referral\n    register_bonus: Credits new users get on\
        \ registration"
      tags:
      - Users
      operationId: getApiUsersMyReferrals
      x-visibility: internal
  /api/users/notification-settings:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get current user's notification settings.
      tags:
      - Users
      operationId: getApiUsersNotificationSettings
      x-visibility: internal
    put:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Update current user's notification settings.
      tags:
      - Users
      operationId: putApiUsersNotificationSettings
      x-visibility: internal
  /api/users/chart-templates:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get current user's indicator chart templates.
      tags:
      - Users
      operationId: getApiUsersChartTemplates
      x-visibility: internal
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Create or update a user's indicator chart template.
      tags:
      - Users
      operationId: postApiUsersChartTemplates
      x-visibility: internal
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete a user's chart template by id.
      tags:
      - Users
      operationId: deleteApiUsersChartTemplates
      x-visibility: internal
  /api/users/notification-settings/test:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Send a test notification using saved notification settings.
      tags:
      - Users
      operationId: postApiUsersNotificationSettingsTest
      x-visibility: internal
  /api/users/change-password:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Change current user's password.
      tags:
      - Users
      operationId: postApiUsersChangePassword
      x-visibility: internal
  /api/users/system-strategies:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get all strategies across the entire system (admin only).
      description: 'Query params:

        page: int (default 1)

        page_size: int (default 20, max 100)

        status: str (optional, filter by status: running/stopped/all)

        execution_mode: str (optional, live/signal; omit or all for any)

        strategy_class: str (optional, cta/portfolio/robot; omit or all for any)

        search: str (optional, search by strategy name/symbol/username/id)

        strategy_id: int (optional, exact strategy id)

        user_id: int (optional, exact owner user id)

        sort_by: str (optional, whitelist; default status+updated_at)

        sort_order: str (optional, asc or desc; default desc when sort_by set)


        Get all strategies across the entire system (admin only).

        Returns strategy details with user info, positions, PnL, indicators, etc.'
      tags:
      - Users
      operationId: getApiUsersSystemStrategies
      x-visibility: internal
  /api/users/system-strategies/toggle:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Start or stop any strategy (admin only).
      description: 'Query/body:

        id / strategy_id: strategy primary key

        action: optional ``start`` | ``stop``; omit to toggle current status'
      tags:
      - Users
      operationId: postApiUsersSystemStrategiesToggle
      x-visibility: internal
  /api/users/system-strategies/delete:
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete any strategy from the system overview (admin only).
      tags:
      - Users
      operationId: deleteApiUsersSystemStrategiesDelete
      x-visibility: internal
  /api/users/admin-orders:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get all orders across the system (admin only).
      description: 'Query params:

        page: int (default 1)

        page_size: int (default 20, max 100)

        status: str (optional, filter by status: paid/pending/confirmed/expired/all)

        search: str (optional, search by username/email)


        Get all orders across the system (admin only).

        Lists USDT on-chain membership orders only (qd_usdt_orders).'
      tags:
      - Users
      operationId: getApiUsersAdminOrders
      x-visibility: internal
  /api/users/admin-orders/{order_id}/manual-confirm:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Admin-only "rescue" lever for USDT orders.
      description: "Use case: the buyer paid the correct amount to the correct receiving\n\
        address, but the on-chain reconciler missed the transaction (RPC\noutage,\
        \ exotic wallet, chain-specific edge case, off-chain mistake\nwhere the customer\
        \ used a slightly different amount than the order\nsuffix demanded, etc.).\
        \ Without this endpoint the admin's only option\nis to ``UPDATE qd_usdt_orders\
        \ ...`` by hand and then somehow trigger\n``purchase_membership``; this surface\
        \ does both atomically and leaves\nan audit trail.\n\nBody:\n    {\n     \
        \   \"tx_hash\": \"<on-chain tx hash>\",     # required\n        \"note\"\
        :    \"<free-form audit note>\"  # optional\n    }\n\nBehavior:\n    - Flips\
        \ the order to 'confirmed'.\n    - Stamps tx_hash + paid_at (if empty) + confirmed_at\
        \ + admin_note\n      + manual_confirmed_by + matched_via='manual_admin'.\n\
        \    - Calls ``purchase_membership`` exactly once per order (idempotent\n\
        \      on re-submit; already-confirmed orders only refresh the audit\n   \
        \   fields, no double-grant).\n    - Refuses ``status='cancelled'`` orders\
        \ so the admin doesn't\n      accidentally resurrect a deliberately-cancelled\
        \ refund."
      tags:
      - Users
      operationId: postApiUsersAdminOrdersOrderIdManualConfirm
      parameters:
      - name: order_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: order_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/users/admin-ai-stats:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get AI analysis usage statistics across the system (admin only).
      description: 'Query params:

        page: int (default 1)

        page_size: int (default 20, max 100)

        search: str (optional, search by username)


        Get AI analysis usage statistics across the system (admin only).

        Does NOT expose analysis results, only aggregated counts/stats.'
      tags:
      - Users
      operationId: getApiUsersAdminAiStats
      x-visibility: internal
  /api/users/admin/stats:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: KPI dashboard data for the User Management tab (admin only).
      description: 'Returns a single envelope with `summary`, `growth`, `activity`.

        See `app.services.user_stats_service` for the schema of each section.'
      tags:
      - Users
      operationId: getApiUsersAdminStats
      x-visibility: internal
  /api/indicator/kline:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Fetch OHLCV k-line bars.
      description: 'Query params:

        market: Market type (Crypto, USStock, Forex, Futures)

        symbol: Symbol or ticker

        timeframe: Bar size (1m, 5m, 15m, 30m, 1H, 4H, 1D, 1W)

        limit: Number of bars (default 300)

        before_time: Return bars before this Unix timestamp (optional)'
      tags:
      - Indicator
      operationId: getApiIndicatorKline
      x-visibility: public
  /api/backtest/run:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiBacktestRun
      summary: Post Api Backtest Run
      x-visibility: internal
  /api/backtest/factor-research:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiBacktestFactorResearch
      summary: Post Api Backtest Factor Research
      x-visibility: internal
  /api/backtest/factor-research/history:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: getApiBacktestFactorResearchHistory
      summary: Get Api Backtest Factor Research History
      x-visibility: internal
  /api/backtest/factor-research/get:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: getApiBacktestFactorResearchGet
      summary: Get Api Backtest Factor Research Get
      x-visibility: internal
  /api/backtest/tune:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiBacktestTune
      summary: Post Api Backtest Tune
      x-visibility: internal
  /api/backtest/history:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: getApiBacktestHistory
      summary: Get Api Backtest History
      x-visibility: internal
  /api/backtest/get:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: getApiBacktestGet
      summary: Get Api Backtest Get
      x-visibility: internal
  /api/market/config:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Public config for frontend (local mode).
      tags:
      - Market
      operationId: getApiMarketConfig
      description: 'Public config for frontend (local mode).

        Mirrors the old PHP `/addons/quantdinger/index/getConfig` shape.'
      x-visibility: public
  /api/market/types:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return supported market types for the add-watchlist modal.
      description: 'Visibility is controlled by the centralised :mod:`app.utils.market_visibility`

        rules, primarily the ``ENABLED_MARKETS`` whitelist, with

        ``SHOW_CN_STOCK`` / ``SHOW_HK_STOCK`` kept for back-compat. The radar

        (``/api/global-market/opportunities``) and the Agent API

        (``/api/agent/v1/markets``) read from the same helper so all three

        user-facing market lists stay in lock-step.'
      tags:
      - Market
      operationId: getApiMarketTypes
      x-visibility: public
  /api/market/menuFooterConfig:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Compatibility stub for old PHP `getMenuFooterConfig`.
      tags:
      - Market
      operationId: getApiMarketMenuFooterConfig
      description: 'Compatibility stub for old PHP `getMenuFooterConfig`.

        Frontend can also hardcode this locally; this endpoint remains for completeness.'
      x-visibility: public
  /api/market/symbols/search:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Lightweight symbol search.
      tags:
      - Market
      operationId: getApiMarketSymbolsSearch
      description: 'Lightweight symbol search.

        Crypto search is local-only; exchange catalogs are refreshed by the background
        sync task.'
      x-visibility: public
  /api/market/symbols/hot:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return a small curated hot list per market (local-only).
      tags:
      - Market
      operationId: getApiMarketSymbolsHot
      x-visibility: public
  /api/market/watchlist/get:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get watchlist for the current user.
      tags:
      - Market
      operationId: getApiMarketWatchlistGet
      x-visibility: public
  /api/market/watchlist/add:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Add a symbol to watchlist for the current user.
      tags:
      - Market
      operationId: postApiMarketWatchlistAdd
      x-visibility: public
  /api/market/watchlist/remove:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Remove a symbol from watchlist for the current user.
      tags:
      - Market
      operationId: postApiMarketWatchlistRemove
      x-visibility: public
  /api/market/watchlist/prices:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get realtime prices for the current user's watchlist.
      tags:
      - Market
      operationId: getApiMarketWatchlistPrices
      x-visibility: public
  /api/market/price:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get realtime price for a single symbol.
      description: 'Query params:

        market: Market type

        symbol: Symbol or ticker'
      tags:
      - Market
      operationId: getApiMarketPrice
      x-visibility: public
  /api/universes:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Universe
      operationId: getApiUniverses
      summary: Get Api Universes
      x-visibility: internal
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Universe
      operationId: postApiUniverses
      summary: Post Api Universes
      x-visibility: internal
  /api/universes/{universe_id}/clone:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Universe
      operationId: postApiUniversesUniverseIdClone
      summary: Post Api Universes Universe Id Clone
      parameters:
      - name: universe_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: universe_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/universes/admin/overview:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Universe
      operationId: getApiUniversesAdminOverview
      summary: Get Api Universes Admin Overview
      x-visibility: internal
  /api/universes/admin/sync:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Universe
      operationId: postApiUniversesAdminSync
      summary: Post Api Universes Admin Sync
      x-visibility: internal
  /api/universes/{universe_id}:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Universe
      operationId: getApiUniversesUniverseId
      summary: Get Api Universes Universe Id
      parameters:
      - name: universe_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: universe_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/universes/{universe_id}/members:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Universe
      operationId: getApiUniversesUniverseIdMembers
      summary: Get Api Universes Universe Id Members
      parameters:
      - name: universe_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: universe_id
      required: true
      schema:
        type: integer
        minimum: 0
    put:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Universe
      operationId: putApiUniversesUniverseIdMembers
      summary: Put Api Universes Universe Id Members
      parameters:
      - name: universe_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
  /api/universes/{universe_id}/snapshots:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Universe
      operationId: postApiUniversesUniverseIdSnapshots
      summary: Post Api Universes Universe Id Snapshots
      parameters:
      - name: universe_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: universe_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/factors:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Factor
      operationId: getApiFactors
      summary: Get Api Factors
      x-visibility: internal
  /api/factors/{factor_id}:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Factor
      operationId: getApiFactorsFactorId
      summary: Get Api Factors Factor Id
      parameters:
      - name: factor_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: factor_id
      required: true
      schema:
        type: string
        minLength: 1
  /api/factors/research:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Factor
      operationId: postApiFactorsResearch
      summary: Post Api Factors Research
      x-visibility: internal
  /api/factors/fundamentals/coverage:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Factor
      operationId: getApiFactorsFundamentalsCoverage
      summary: Get Api Factors Fundamentals Coverage
      x-visibility: internal
  /api/factors/fundamentals/sync:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Factor
      operationId: postApiFactorsFundamentalsSync
      summary: Post Api Factors Fundamentals Sync
      x-visibility: internal
  /api/market-modules/:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return canonical market module status for the current deployment.
      tags:
      - Market
      operationId: getApiMarketModules
      x-visibility: public
  /api/ai/skills:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return the public Copilot skill registry.
      tags:
      - AIChat
      operationId: getApiAiSkills
      x-visibility: internal
  /api/ai/tools:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return the public Copilot tool registry.
      tags:
      - AIChat
      operationId: getApiAiTools
      x-visibility: internal
  /api/ai/skills/install:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Install a prompt-only skill manifest.
      tags:
      - AIChat
      operationId: postApiAiSkillsInstall
      x-visibility: internal
  /api/ai/skills/{skill_id}:
    patch:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Enable or disable an installed prompt skill.
      tags:
      - AIChat
      operationId: patchApiAiSkillsSkillId
      parameters:
      - name: skill_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: skill_id
      required: true
      schema:
        type: string
        minLength: 1
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete an installed prompt skill.
      tags:
      - AIChat
      operationId: deleteApiAiSkillsSkillId
      parameters:
      - name: skill_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
  /api/ai/skills/{skill_id}/prompt:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Render a skill prompt for the current UI context.
      tags:
      - AIChat
      operationId: postApiAiSkillsSkillIdPrompt
      parameters:
      - name: skill_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: skill_id
      required: true
      schema:
        type: string
        minLength: 1
  /api/ai/agent/preflight:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return Copilot readiness checks for user guidance.
      tags:
      - AIChat
      operationId: getApiAiAgentPreflight
      x-visibility: internal
  /api/ai/agent/intent:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Classify a Copilot message into a structured agent workflow plan.
      tags:
      - AIChat
      operationId: postApiAiAgentIntent
      x-visibility: internal
  /api/ai/memory:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: List active user memories used by Copilot.
      tags:
      - AIChat
      operationId: getApiAiMemory
      x-visibility: internal
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Save a user-approved memory for future Copilot context.
      tags:
      - AIChat
      operationId: postApiAiMemory
      x-visibility: internal
  /api/ai/memory/{memory_id}:
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Deactivate a user memory.
      tags:
      - AIChat
      operationId: deleteApiAiMemoryMemoryId
      parameters:
      - name: memory_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: memory_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/ai/chat/message:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Send a Copilot message and get an LLM response.
      tags:
      - AIChat
      operationId: postApiAiChatMessage
      x-visibility: internal
  /api/ai/chat/message/stream:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Send a Copilot message and stream a Markdown response.
      tags:
      - AIChat
      operationId: postApiAiChatMessageStream
      x-visibility: internal
  /api/ai/chat/sessions:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - AIChat
      operationId: getApiAiChatSessions
      summary: Get Api Ai Chat Sessions
      x-visibility: internal
  /api/ai/chat/sessions/{session_id}:
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete one Copilot session and all related rows for the current user.
      tags:
      - AIChat
      operationId: deleteApiAiChatSessionsSessionId
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: session_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/ai/chat/history:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - AIChat
      operationId: getApiAiChatHistory
      summary: Get Api Ai Chat History
      x-visibility: internal
  /api/ai/chat/message/local:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Persist a local Copilot message, including frontend-generated actions.
      tags:
      - AIChat
      operationId: postApiAiChatMessageLocal
      x-visibility: internal
  /api/ai/chat/report/pdf:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - AIChat
      operationId: postApiAiChatReportPdf
      summary: Post Api Ai Chat Report Pdf
      x-visibility: internal
  /api/ai/chat/history/save:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Compatibility endpoint; chat/message persists automatically.
      tags:
      - AIChat
      operationId: postApiAiChatHistorySave
      x-visibility: internal
  /api/indicator/getIndicators:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get indicator list for the current user.
      description: 'Response:

        { code: 1, data: [ ... ] }'
      tags:
      - Indicator
      operationId: getApiIndicatorGetIndicators
      x-visibility: public
  /api/indicator/saveIndicator:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Create or update an indicator for the current user.
      description: "Request (frontend sends many extra fields; we store only the essentials):\n\
        {\n  id: number (0 for create),\n  name: string,\n  code: string,\n  description?:\
        \ string,\n  ...\n}"
      tags:
      - Indicator
      operationId: postApiIndicatorSaveIndicator
      x-visibility: public
  /api/indicator/versions:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: List saved code versions for one indicator owned by the current user.
      tags:
      - Indicator
      operationId: getApiIndicatorVersions
      x-visibility: public
  /api/indicator/versions/{version_id}:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get one saved code version.
      tags:
      - Indicator
      operationId: getApiIndicatorVersionsVersionId
      parameters:
      - name: version_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: version_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/indicator/versions/restore:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Post Api Indicator Versions Restore
      tags:
      - Indicator
      operationId: postApiIndicatorVersionsRestore
      description: Restore one code version to the current indicator and keep the
        restore as a new version.
      x-visibility: public
  /api/indicator/deleteIndicator:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete an indicator by id for the current user.
      tags:
      - Indicator
      operationId: postApiIndicatorDeleteIndicator
      x-visibility: public
  /api/indicator/getIndicatorParams:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return declared `# @param` fields for an indicator.
      description: "Used by the strategy builder to render a parameter form.\n\nQuery\
        \ params:\n    indicator_id: Indicator ID\n\nReturns:\n    params: [\n   \
        \     {\n            \"name\": \"ma_fast\",\n            \"type\": \"int\"\
        ,\n            \"default\": 5,\n            \"description\": \"Fast MA period\"\
        \n        },\n        ...\n    ]"
      tags:
      - Indicator
      operationId: getApiIndicatorGetIndicatorParams
      x-visibility: public
  /api/indicator/aiGenerate:
    post:
      responses:
        '200':
          description: Server-Sent Events stream
          content:
            text/event-stream:
              schema:
                type: string
      summary: SSE endpoint to generate indicator code.
      description: "Frontend expects 'text/event-stream' with chunks:\n  data: {\"\
        content\":\"...\"}\n\n\nthen:\n  data: [DONE]\n\n\n\nLocal-first: if OpenRouter\
        \ key is not configured, we return a reasonable template."
      tags:
      - Indicator
      operationId: postApiIndicatorAiGenerate
      x-visibility: public
  /api/indicator/codeQualityHints:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Heuristic hints + runtime smoke-execution for indicator code.
      description: "Request body:\n    code (required): Indicator source code\n\n\
        Returns hints with severity, code, and params. Static analysis catches\nstructural\
        \ issues; a sandboxed dry-run surfaces runtime errors before backtest."
      tags:
      - Indicator
      operationId: postApiIndicatorCodeQualityHints
      x-visibility: public
  /api/indicator/signal-alerts:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: List current user's indicator signal alert tasks.
      tags:
      - Indicator
      operationId: getApiIndicatorSignalAlerts
      x-visibility: public
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Create an indicator signal alert task.
      tags:
      - Indicator
      operationId: postApiIndicatorSignalAlerts
      x-visibility: public
  /api/indicator/signal-alerts/{task_id}:
    put:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Update an indicator signal alert task.
      tags:
      - Indicator
      operationId: putApiIndicatorSignalAlertsTaskId
      parameters:
      - name: task_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: task_id
      required: true
      schema:
        type: integer
        minimum: 0
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete an indicator signal alert task.
      tags:
      - Indicator
      operationId: deleteApiIndicatorSignalAlertsTaskId
      parameters:
      - name: task_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
  /api/indicator/signal-alerts/{task_id}/pause:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Pause an indicator signal alert task.
      tags:
      - Indicator
      operationId: postApiIndicatorSignalAlertsTaskIdPause
      parameters:
      - name: task_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: task_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/indicator/signal-alerts/{task_id}/resume:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Resume an indicator signal alert task.
      tags:
      - Indicator
      operationId: postApiIndicatorSignalAlertsTaskIdResume
      parameters:
      - name: task_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: task_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/indicator/signal-alerts/{task_id}/test:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Evaluate a task immediately for diagnostics.
      tags:
      - Indicator
      operationId: postApiIndicatorSignalAlertsTaskIdTest
      parameters:
      - name: task_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: task_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/strategies/script-templates:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: getApiStrategiesScriptTemplates
      summary: Get Api Strategies Script Templates
      x-visibility: internal
  /api/strategies/script-sources:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: getApiStrategiesScriptSources
      summary: Get Api Strategies Script Sources
      x-visibility: internal
  /api/strategies/script-sources/detail:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: getApiStrategiesScriptSourcesDetail
      summary: Get Api Strategies Script Sources Detail
      x-visibility: internal
  /api/strategies/script-sources/create:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesScriptSourcesCreate
      summary: Post Api Strategies Script Sources Create
      x-visibility: internal
  /api/strategies/script-sources/update:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesScriptSourcesUpdate
      summary: Post Api Strategies Script Sources Update
      x-visibility: internal
    put:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: putApiStrategiesScriptSourcesUpdate
      summary: Put Api Strategies Script Sources Update
      x-visibility: internal
  /api/strategies/script-sources/compile:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesScriptSourcesCompile
      summary: Post Api Strategies Script Sources Compile
      x-visibility: internal
  /api/strategies/script-sources/delete:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesScriptSourcesDelete
      summary: Post Api Strategies Script Sources Delete
      x-visibility: internal
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: deleteApiStrategiesScriptSourcesDelete
      summary: Delete Api Strategies Script Sources Delete
      x-visibility: internal
  /api/strategies/script-sources/versions:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: getApiStrategiesScriptSourcesVersions
      summary: Get Api Strategies Script Sources Versions
      x-visibility: internal
  /api/strategies/script-sources/versions/{version_id}:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: getApiStrategiesScriptSourcesVersionsVersionId
      summary: Get Api Strategies Script Sources Versions Version Id
      parameters:
      - name: version_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: version_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/strategies/script-sources/versions/restore:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesScriptSourcesVersionsRestore
      summary: Post Api Strategies Script Sources Versions Restore
      x-visibility: internal
  /api/strategies/script-sources/publish:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesScriptSourcesPublish
      summary: Post Api Strategies Script Sources Publish
      x-visibility: internal
  /api/account/snapshot:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Live swap/spot positions + open orders for a saved credential.
      tags:
      - Account
      operationId: getApiAccountSnapshot
      x-visibility: internal
  /api/account/positions:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: L1 account position mirror for Quick Trade / asset views.
      tags:
      - Account
      operationId: getApiAccountPositions
      x-visibility: internal
  /api/strategy-assets:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return executable script strategy assets.
      tags:
      - strategy
      operationId: getApiStrategyAssets
      x-visibility: internal
  /api/strategies/dry-run-deviation:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Quantify how far live fills drifted from backtest signal closes.
      tags:
      - Strategy
      operationId: getApiStrategiesDryRunDeviation
      x-visibility: internal
  /api/strategies/executors/templates:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: getApiStrategiesExecutorsTemplates
      summary: Get Api Strategies Executors Templates
      x-visibility: internal
  /api/strategies/executors/preview:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesExecutorsPreview
      summary: Post Api Strategies Executors Preview
      x-visibility: internal
  /api/strategies/executors/generate:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesExecutorsGenerate
      summary: Post Api Strategies Executors Generate
      x-visibility: internal
  /api/strategies/executors/create:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesExecutorsCreate
      summary: Post Api Strategies Executors Create
      x-visibility: internal
  /api/strategies/grid-resting-orders:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: List resting grid limit orders tracked for a live grid bot.
      tags:
      - Strategy
      operationId: getApiStrategiesGridRestingOrders
      x-visibility: internal
  /api/strategies/trades:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get trade records for the current user's strategy.
      tags:
      - Strategy
      operationId: getApiStrategiesTrades
      x-visibility: internal
  /api/strategies/equityCurve:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get equity curve for the current user's strategy.
      tags:
      - Strategy
      operationId: getApiStrategiesEquityCurve
      x-visibility: internal
  /api/strategies/performance:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get strategy performance metrics.
      tags:
      - Strategy
      operationId: getApiStrategiesPerformance
      x-visibility: internal
  /api/strategies/logs:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get strategy running logs.
      tags:
      - Strategy
      operationId: getApiStrategiesLogs
      x-visibility: internal
  /api/strategies/notifications:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Strategy signal notifications for the current user.
      tags:
      - Strategy
      operationId: getApiStrategiesNotifications
      x-visibility: internal
  /api/strategies/notifications/unread-count:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get unread notification count for the current user.
      tags:
      - Strategy
      operationId: getApiStrategiesNotificationsUnreadCount
      x-visibility: internal
  /api/strategies/notifications/read:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Mark a single notification as read for the current user.
      tags:
      - Strategy
      operationId: postApiStrategiesNotificationsRead
      x-visibility: internal
  /api/strategies/notifications/read-all:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Mark all notifications as read for the current user.
      tags:
      - Strategy
      operationId: postApiStrategiesNotificationsReadAll
      x-visibility: internal
  /api/strategies/notifications/clear:
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Clear all notifications for the current user.
      tags:
      - Strategy
      operationId: deleteApiStrategiesNotificationsClear
      x-visibility: internal
  /api/strategies/positions:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get position records for the current user's strategy.
      tags:
      - Strategy
      operationId: getApiStrategiesPositions
      x-visibility: internal
  /api/strategies/review-report:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Build an AI-assisted strategy review report from factual trade records.
      tags:
      - Strategy
      operationId: postApiStrategiesReviewReport
      x-visibility: internal
  /api/strategies/review-report/history:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: List or load saved AI strategy review reports.
      tags:
      - Strategy
      operationId: getApiStrategiesReviewReportHistory
      x-visibility: internal
  /api/strategies:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: getApiStrategies
      summary: Get Api Strategies
      x-visibility: internal
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategies
      summary: Post Api Strategies
      x-visibility: internal
  /api/strategies/{strategy_id}:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: getApiStrategiesStrategyId
      summary: Get Api Strategies Strategy Id
      parameters:
      - name: strategy_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: strategy_id
      required: true
      schema:
        type: integer
        minimum: 0
    put:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: putApiStrategiesStrategyId
      summary: Put Api Strategies Strategy Id
      parameters:
      - name: strategy_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: deleteApiStrategiesStrategyId
      summary: Delete Api Strategies Strategy Id
      parameters:
      - name: strategy_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
  /api/strategies/{strategy_id}/start:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesStrategyIdStart
      summary: Post Api Strategies Strategy Id Start
      parameters:
      - name: strategy_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: strategy_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/strategies/{strategy_id}/stop:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesStrategyIdStop
      summary: Post Api Strategies Strategy Id Stop
      parameters:
      - name: strategy_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: strategy_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/strategies/exchange/test:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesExchangeTest
      summary: Post Api Strategies Exchange Test
      x-visibility: internal
  /api/strategies/verify:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesVerify
      summary: Post Api Strategies Verify
      x-visibility: internal
  /api/strategies/generate:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      tags:
      - Strategy
      operationId: postApiStrategiesGenerate
      summary: Post Api Strategies Generate
      x-visibility: internal
  /api/credentials/desktop-brokers-policy:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Whether IBKR (local TWS or IB Gateway) may be configured on this deployment.
      tags:
      - Credentials
      operationId: getApiCredentialsDesktopBrokersPolicy
      description: 'Whether IBKR (local TWS or IB Gateway) may be configured on this
        deployment.

        Frontend uses this to disable options and show guidance before save/test.'
      x-visibility: private
  /api/credentials/list:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: List all credentials for the current user.
      tags:
      - Credentials
      operationId: getApiCredentialsList
      x-visibility: private
  /api/credentials/egress-ip:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Public egress IPv4/IPv6 of this API server (for exchange API key IP
        whitelist).
      tags:
      - Credentials
      operationId: getApiCredentialsEgressIp
      description: 'Public egress IPv4/IPv6 of this API server (for exchange API key
        IP whitelist).

        Uses ipify''s v4-only / v6-only endpoints so each family is detected independently.'
      x-visibility: private
  /api/credentials/test:
    post:
      responses:
        '422':
          $ref: '#/components/responses/UNPROCESSABLE_ENTITY'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CredentialCreateRequest'
      summary: Validate credentials against the selected private trading environment.
      tags:
      - Credentials
      operationId: postApiCredentialsTest
      x-visibility: private
  /api/credentials/create:
    post:
      responses:
        '422':
          $ref: '#/components/responses/UNPROCESSABLE_ENTITY'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CredentialCreatedResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CredentialCreateRequest'
      summary: Create a new credential for the current user.
      description: Supports crypto exchanges, IBKR (US stocks), and Alpaca.
      tags:
      - Credentials
      operationId: postApiCredentialsCreate
      x-visibility: private
  /api/credentials/update-name:
    put:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Update display name (alias) only — API keys in encrypted_config are
        untouched.
      tags:
      - Credentials
      operationId: putApiCredentialsUpdateName
      x-visibility: private
    patch:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Update display name (alias) only — API keys in encrypted_config are
        untouched.
      tags:
      - Credentials
      operationId: patchApiCredentialsUpdateName
      x-visibility: private
  /api/credentials/delete:
    delete:
      parameters:
      - in: query
        name: id
        schema:
          type: integer
          minimum: 1
        required: true
      responses:
        '422':
          $ref: '#/components/responses/UNPROCESSABLE_ENTITY'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete a credential for the current user.
      tags:
      - Credentials
      operationId: deleteApiCredentialsDelete
      x-visibility: private
  /api/dashboard/summary:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return dashboard summary used by the frontend dashboard view (private
        Vue repo).
      tags:
      - Dashboard
      operationId: getApiDashboardSummary
      x-visibility: internal
  /api/dashboard/pendingOrders:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return pending orders list for dashboard page.
      tags:
      - Dashboard
      operationId: getApiDashboardPendingOrders
      x-visibility: internal
  /api/dashboard/pendingOrders/{order_id}:
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete a pending order record (dashboard operation).
      tags:
      - Dashboard
      operationId: deleteApiDashboardPendingOrdersOrderId
      parameters:
      - name: order_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: order_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/settings/schema:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return settings schema definition (admin only).
      tags:
      - Settings
      operationId: getApiSettingsSchema
      x-visibility: internal
  /api/settings/public-config:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return non-sensitive config values needed by frontend widgets.
      tags:
      - Settings
      operationId: getApiSettingsPublicConfig
      x-visibility: internal
  /api/settings/brand-config:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Public, no-auth endpoint exposing branding / legal / contact info.
      description: 'Drives the frontend''s logo, footer, social links, legal modals
        and version

        label entirely from backend ENV vars so operators can rebrand a deployment

        by editing ``.env`` (or the Settings page) — no frontend rebuild required.


        Empty ENV values fall back to the bundled QuantDinger defaults so a fresh

        install still ships with working links instead of blanks.'
      tags:
      - Settings
      operationId: getApiSettingsBrandConfig
      x-visibility: internal
  /api/settings/values:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return current settings values without exposing stored secrets.
      tags:
      - Settings
      operationId: getApiSettingsValues
      x-visibility: internal
  /api/settings/market-catalog:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Return market catalog coverage and the latest synchronization state.
      tags:
      - Settings
      operationId: getApiSettingsMarketCatalog
      x-visibility: internal
  /api/settings/market-catalog/sync:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Start a non-blocking full sync for the supported crypto venues.
      tags:
      - Settings
      operationId: postApiSettingsMarketCatalogSync
      x-visibility: internal
  /api/settings/save:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Save settings to .env (admin only).
      tags:
      - Settings
      operationId: postApiSettingsSave
      x-visibility: internal
  /api/settings/openrouter-balance:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Query OpenRouter account balance (admin only).
      tags:
      - Settings
      operationId: getApiSettingsOpenrouterBalance
      x-visibility: internal
  /api/settings/test-connection:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Test third-party API connectivity (admin only).
      tags:
      - Settings
      operationId: postApiSettingsTestConnection
      x-visibility: internal
  /api/portfolio/positions:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get all manual positions with current prices for the current user.
      tags:
      - Portfolio
      operationId: getApiPortfolioPositions
      x-visibility: internal
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Add a new manual position for the current user.
      tags:
      - Portfolio
      operationId: postApiPortfolioPositions
      x-visibility: internal
  /api/portfolio/positions/{position_id}:
    put:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Update an existing position for the current user.
      tags:
      - Portfolio
      operationId: putApiPortfolioPositionsPositionId
      parameters:
      - name: position_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: position_id
      required: true
      schema:
        type: integer
        minimum: 0
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete a position for the current user.
      tags:
      - Portfolio
      operationId: deleteApiPortfolioPositionsPositionId
      parameters:
      - name: position_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
  /api/portfolio/summary:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get Api Portfolio Summary
      tags:
      - Portfolio
      operationId: getApiPortfolioSummary
      description: Get portfolio summary with total value, PnL, and market distribution
        for the current user.
      x-visibility: internal
  /api/portfolio/monitors:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get all position monitors for the current user.
      tags:
      - Portfolio
      operationId: getApiPortfolioMonitors
      x-visibility: internal
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Add a new position monitor for the current user.
      tags:
      - Portfolio
      operationId: postApiPortfolioMonitors
      x-visibility: internal
  /api/portfolio/monitors/{monitor_id}:
    put:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Update an existing monitor for the current user.
      tags:
      - Portfolio
      operationId: putApiPortfolioMonitorsMonitorId
      parameters:
      - name: monitor_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: monitor_id
      required: true
      schema:
        type: integer
        minimum: 0
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete a monitor for the current user.
      tags:
      - Portfolio
      operationId: deleteApiPortfolioMonitorsMonitorId
      parameters:
      - name: monitor_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
  /api/portfolio/monitors/{monitor_id}/run:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Manually trigger a monitor to run immediately.
      description: 'Supports two modes:

        - async=true (default): Returns immediately, runs in background, notifies
        via notification system

        - async=false: Waits for completion and returns result (may timeout for large
        portfolios)'
      tags:
      - Portfolio
      operationId: postApiPortfolioMonitorsMonitorIdRun
      parameters:
      - name: monitor_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: monitor_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/portfolio/alerts:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get all position alerts for the current user.
      tags:
      - Portfolio
      operationId: getApiPortfolioAlerts
      x-visibility: internal
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Add a new position alert for the current user.
      tags:
      - Portfolio
      operationId: postApiPortfolioAlerts
      x-visibility: internal
  /api/portfolio/alerts/{alert_id}:
    put:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Update an existing alert for the current user.
      tags:
      - Portfolio
      operationId: putApiPortfolioAlertsAlertId
      parameters:
      - name: alert_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: alert_id
      required: true
      schema:
        type: integer
        minimum: 0
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete an alert for the current user.
      tags:
      - Portfolio
      operationId: deleteApiPortfolioAlertsAlertId
      parameters:
      - name: alert_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
  /api/portfolio/groups:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get list of all groups with position counts for the current user.
      tags:
      - Portfolio
      operationId: getApiPortfolioGroups
      x-visibility: internal
  /api/portfolio/groups/rename:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Rename a group for the current user.
      tags:
      - Portfolio
      operationId: postApiPortfolioGroupsRename
      x-visibility: internal
  /api/ibkr/status:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get IBKR connection status.
      tags:
      - IBKR
      operationId: getApiIbkrStatus
      x-visibility: internal
  /api/ibkr/connect:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Connect to TWS / IB Gateway.
      description: 'Request body:

        host (optional, default 127.0.0.1): TWS/Gateway host

        port (optional, default 7497): TWS Live 7496, TWS Paper 7497, Gateway Live
        4001, Gateway Paper 4002

        clientId (optional, default 1): Client ID

        account (optional): Account for multi-account setups

        readonly (optional, default false): Read-only mode'
      tags:
      - IBKR
      operationId: postApiIbkrConnect
      x-visibility: internal
  /api/ibkr/disconnect:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Disconnect from IBKR.
      tags:
      - IBKR
      operationId: postApiIbkrDisconnect
      x-visibility: internal
  /api/ibkr/account:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get IBKR account information.
      tags:
      - IBKR
      operationId: getApiIbkrAccount
      x-visibility: internal
  /api/ibkr/positions:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get IBKR positions.
      tags:
      - IBKR
      operationId: getApiIbkrPositions
      x-visibility: internal
  /api/ibkr/orders:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get open IBKR orders.
      tags:
      - IBKR
      operationId: getApiIbkrOrders
      x-visibility: internal
  /api/ibkr/order:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Place an IBKR order.
      description: 'Request body:

        symbol (required): Ticker, e.g. AAPL

        side (required): buy or sell

        quantity (required): Number of shares

        marketType (optional, default USStock): Market type

        orderType (optional, default market): market or limit

        price (required for limit orders): Limit price'
      tags:
      - IBKR
      operationId: postApiIbkrOrder
      x-visibility: internal
  /api/ibkr/order/{order_id}:
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Cancel an IBKR order by ID.
      tags:
      - IBKR
      operationId: deleteApiIbkrOrderOrderId
      parameters:
      - name: order_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: order_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/ibkr/quote:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: 'Get real-time IBKR quote (query: symbol, marketType).'
      tags:
      - IBKR
      operationId: getApiIbkrQuote
      x-visibility: internal
  /api/alpaca/status:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get Alpaca connection status.
      tags:
      - Alpaca
      operationId: getApiAlpacaStatus
      x-visibility: internal
  /api/alpaca/connect:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Connect to Alpaca.
      description: 'Request body:

        apiKey (required): API key (PK prefix = paper, AK = live)

        secretKey (required): Secret key

        paper (optional, default true): Use paper trading

        baseUrl (optional): Override API base URL'
      tags:
      - Alpaca
      operationId: postApiAlpacaConnect
      x-visibility: internal
  /api/alpaca/disconnect:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Disconnect from Alpaca.
      tags:
      - Alpaca
      operationId: postApiAlpacaDisconnect
      x-visibility: internal
  /api/alpaca/account:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get Alpaca account information.
      tags:
      - Alpaca
      operationId: getApiAlpacaAccount
      x-visibility: internal
  /api/alpaca/positions:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get Alpaca open positions.
      tags:
      - Alpaca
      operationId: getApiAlpacaPositions
      x-visibility: internal
  /api/alpaca/orders:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get Alpaca recent orders or only open orders.
      tags:
      - Alpaca
      operationId: getApiAlpacaOrders
      x-visibility: internal
  /api/alpaca/order:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Place an Alpaca order.
      description: 'Request body:

        symbol (required): Ticker, e.g. AAPL

        side (required): buy or sell

        quantity (required): Share quantity

        marketType (optional): USStock or crypto (default USStock)

        orderType (optional): market or limit (default market)

        price (required for limit): Limit price

        extendedHours (optional): Allow extended-hours limit orders'
      tags:
      - Alpaca
      operationId: postApiAlpacaOrder
      x-visibility: internal
  /api/alpaca/order/{order_id}:
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Cancel an Alpaca order by ID.
      tags:
      - Alpaca
      operationId: deleteApiAlpacaOrderOrderId
      parameters:
      - name: order_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: internal
    parameters:
    - in: path
      name: order_id
      required: true
      schema:
        type: string
        minLength: 1
  /api/alpaca/quote/{symbol}:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get a real-time Alpaca quote.
      description: 'Query params:

        marketType (optional): USStock or crypto (default USStock)'
      tags:
      - Alpaca
      operationId: getApiAlpacaQuoteSymbol
      parameters:
      - name: symbol
        in: path
        required: true
        schema:
          type: string
      x-visibility: internal
    parameters:
    - in: path
      name: symbol
      required: true
      schema:
        type: string
        minLength: 1
  /api/global-market/overview:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get global market overview including indices, forex, crypto, and commodities.
      tags:
      - GlobalMarket
      operationId: getApiGlobalMarketOverview
      x-visibility: public
  /api/global-market/heatmap:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get market heatmap data for crypto, stock sectors, forex, and indices.
      tags:
      - GlobalMarket
      operationId: getApiGlobalMarketHeatmap
      x-visibility: public
  /api/global-market/news:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: 'Get financial news from various sources.  Query params: lang (''cn''|''en''|''all'').'
      tags:
      - GlobalMarket
      operationId: getApiGlobalMarketNews
      x-visibility: public
  /api/global-market/calendar:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get economic calendar events with impact indicators.
      tags:
      - GlobalMarket
      operationId: getApiGlobalMarketCalendar
      x-visibility: public
  /api/global-market/sentiment:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get comprehensive market sentiment indicators.
      tags:
      - GlobalMarket
      operationId: getApiGlobalMarketSentiment
      x-visibility: public
  /api/global-market/adanos-sentiment:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get optional Adanos Market Sentiment for selected US stock tickers.
      tags:
      - GlobalMarket
      operationId: getApiGlobalMarketAdanosSentiment
      x-visibility: public
  /api/global-market/opportunities:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Scan for trading opportunities across Crypto, US/CN/HK Stocks, and
        Forex.
      tags:
      - GlobalMarket
      operationId: getApiGlobalMarketOpportunities
      x-visibility: public
  /api/global-market/refresh:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Force refresh all market data (clears cache).
      tags:
      - GlobalMarket
      operationId: postApiGlobalMarketRefresh
      x-visibility: public
  /api/community/indicators:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: List published marketplace indicators.
      description: "Query params:\npage: Page number (default 1)\npage_size: Page\
        \ size (default 12)\nkeyword: Search keyword\npricing_type: 'free' / 'paid'\
        \ / empty (all)\nvip_free: 1/true to show VIP-free paid assets only\ncode_visibility:\
        \ 'visible' / 'hidden' / empty (all)\nmin_price, max_price: Numeric price\
        \ bounds\nsort_by: 'score' (default) / 'newest' / 'hot' / 'price_asc' /\n\
        \         'price_desc' / 'rating'.\n         'score' sorts by the composite\
        \ Strategy API V2 backtest score\n         (see services/community_kpis.py)\
        \ and is now the\n         default — putting genuinely well-performing indicators\n\
        \         at the top of the marketplace, not just the newest ones."
      tags:
      - Community
      operationId: getApiCommunityIndicators
      x-visibility: public
  /api/community/indicators/{indicator_id}:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get marketplace indicator detail.
      tags:
      - Community
      operationId: getApiCommunityIndicatorsIndicatorId
      parameters:
      - name: indicator_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: indicator_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/community/indicators/{indicator_id}/purchase:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Purchase a marketplace indicator.
      description: 'Side effects:

        1. Verify buyer has enough credits

        2. Debit buyer credits and credit seller

        3. Create purchase record

        4. Copy indicator into buyer account'
      tags:
      - Community
      operationId: postApiCommunityIndicatorsIndicatorIdPurchase
      parameters:
      - name: indicator_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: indicator_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/community/indicators/{indicator_id}/sync:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Sync latest code for a purchased indicator.
      description: "Use when the publisher updated code after the buyer purchased;\
        \ the buyer\npulls the newest version into their local copy.\n\nPreconditions:\n\
        \    - Caller must have purchased the indicator\n    - Published listings\
        \ sync from the latest marketplace code\n    - Unpublished/deleted listings\
        \ can still restore from the purchase snapshot"
      tags:
      - Community
      operationId: postApiCommunityIndicatorsIndicatorIdSync
      parameters:
      - name: indicator_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: indicator_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/community/my-purchases:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: List indicators purchased by the current user.
      tags:
      - Community
      operationId: getApiCommunityMyPurchases
      x-visibility: public
  /api/community/author/summary:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: 'Author overview: published / approved / pending / sales / revenue
        / avg rating.'
      tags:
      - Community
      operationId: getApiCommunityAuthorSummary
      x-visibility: public
  /api/community/author/published:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get Api Community Author Published
      tags:
      - Community
      operationId: getApiCommunityAuthorPublished
      description: List indicators published by the author with per-item sales, revenue,
        and rating.
      x-visibility: public
  /api/community/author/sales:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Paginated author sales ledger; optional indicator_id filter.
      tags:
      - Community
      operationId: getApiCommunityAuthorSales
      x-visibility: public
  /api/community/author/indicators/{indicator_id}/unpublish:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Let an author unpublish their own marketplace asset.
      tags:
      - Community
      operationId: postApiCommunityAuthorIndicatorsIndicatorIdUnpublish
      parameters:
      - name: indicator_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: indicator_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/community/indicators/{indicator_id}/comments:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: List comments for an indicator.
      tags:
      - Community
      operationId: getApiCommunityIndicatorsIndicatorIdComments
      parameters:
      - name: indicator_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: indicator_id
      required: true
      schema:
        type: integer
        minimum: 0
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Add a comment.
      description: "Request body:\n    rating: 1-5 star rating\n    content: Optional\
        \ comment text (max 500 chars)\n\nOnly purchasers may comment, and only once\
        \ per indicator."
      tags:
      - Community
      operationId: postApiCommunityIndicatorsIndicatorIdComments
      parameters:
      - name: indicator_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
  /api/community/indicators/{indicator_id}/comments/{comment_id}:
    put:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Update own comment.
      description: 'Request body:

        rating: 1-5 star rating

        content: Comment text (max 500 chars)'
      tags:
      - Community
      operationId: putApiCommunityIndicatorsIndicatorIdCommentsCommentId
      parameters:
      - name: indicator_id
        in: path
        required: true
        schema:
          type: integer
      - name: comment_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: indicator_id
      required: true
      schema:
        type: integer
        minimum: 0
    - in: path
      name: comment_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/community/indicators/{indicator_id}/my-comment:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get current user's comment on an indicator (for edit form).
      tags:
      - Community
      operationId: getApiCommunityIndicatorsIndicatorIdMyComment
      parameters:
      - name: indicator_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: indicator_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/community/indicators/{indicator_id}/performance:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get marketplace performance statistics for an asset.
      tags:
      - Community
      operationId: getApiCommunityIndicatorsIndicatorIdPerformance
      parameters:
      - name: indicator_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: indicator_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/community/admin/pending-indicators:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: List indicators pending review (admin only).
      description: 'Query params:

        page: Page number (default 1)

        page_size: Page size (default 20)

        review_status: ''pending'' / ''approved'' / ''rejected'' / ''all''

        keyword: Search name, description or author

        asset_type: ''indicator'' / ''script_template'' / empty

        pricing_type: ''free'' / ''paid'' / ''vip_free'' / empty

        sort_by: ''newest'' / ''oldest'' / ''price_asc'' / ''price_desc'''
      tags:
      - Community
      operationId: getApiCommunityAdminPendingIndicators
      x-visibility: public
  /api/community/admin/review-stats:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Review queue statistics (admin only).
      tags:
      - Community
      operationId: getApiCommunityAdminReviewStats
      x-visibility: public
  /api/community/admin/indicators/{indicator_id}/review:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Approve or reject an indicator (admin only).
      description: 'Request body:

        action: ''approve'' / ''reject''

        note: Optional review note'
      tags:
      - Community
      operationId: postApiCommunityAdminIndicatorsIndicatorIdReview
      parameters:
      - name: indicator_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: indicator_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/community/admin/indicators/{indicator_id}/unpublish:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Unpublish an indicator (admin only).
      description: 'Request body:

        note: Optional unpublish reason'
      tags:
      - Community
      operationId: postApiCommunityAdminIndicatorsIndicatorIdUnpublish
      parameters:
      - name: indicator_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: indicator_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/community/admin/indicators/{indicator_id}:
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete an indicator (admin only).
      tags:
      - Community
      operationId: deleteApiCommunityAdminIndicatorsIndicatorId
      parameters:
      - name: indicator_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: indicator_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/fast-analysis/analyze:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Fast AI analysis for any symbol.
      description: 'Request body:

        market (required): Crypto, USStock, Forex, etc.

        symbol (required): e.g. BTC/USDT, AAPL

        language (optional, default en-US): Response language

        model (optional): LLM model id, e.g. openai/gpt-5.4

        timeframe (optional, default 1D): Analysis timeframe

        async_submit (optional): Submit as background task'
      tags:
      - FastAnalysis
      operationId: postApiFastAnalysisAnalyze
      x-visibility: public
  /api/fast-analysis/history:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get analysis history for a symbol.
      description: GET /api/fast-analysis/history?market=Crypto&symbol=BTC/USDT&days=7&limit=10
      tags:
      - FastAnalysis
      operationId: getApiFastAnalysisHistory
      x-visibility: public
  /api/fast-analysis/history/all:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get all analysis history with pagination.
      description: GET /api/fast-analysis/history/all?page=1&pagesize=20
      tags:
      - FastAnalysis
      operationId: getApiFastAnalysisHistoryAll
      x-visibility: public
  /api/fast-analysis/history/{memory_id}:
    delete:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Delete a history record.
      description: DELETE /api/fast-analysis/history/123
      tags:
      - FastAnalysis
      operationId: deleteApiFastAnalysisHistoryMemoryId
      parameters:
      - name: memory_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: public
    parameters:
    - in: path
      name: memory_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/fast-analysis/feedback:
    post:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Submit user feedback on an analysis.
      description: 'Request body:

        memory_id (required): Analysis history ID

        feedback (required): helpful, not_helpful, accurate, or inaccurate'
      tags:
      - FastAnalysis
      operationId: postApiFastAnalysisFeedback
      x-visibility: public
  /api/fast-analysis/performance:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get AI analysis performance statistics.
      description: GET /api/fast-analysis/performance?market=Crypto&symbol=BTC/USDT&days=30
      tags:
      - FastAnalysis
      operationId: getApiFastAnalysisPerformance
      x-visibility: public
  /api/fast-analysis/similar-patterns:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get similar historical patterns for current market conditions.
      description: GET /api/fast-analysis/similar-patterns?market=Crypto&symbol=BTC/USDT
      tags:
      - FastAnalysis
      operationId: getApiFastAnalysisSimilarPatterns
      x-visibility: public
  /api/billing/plans:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get membership plan configuration + current user's billing snapshot.
      tags:
      - Billing
      operationId: getApiBillingPlans
      x-visibility: private
  /api/billing/usdt/chains:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: List USDT chains that are enabled AND have a receiving address
      tags:
      - Billing
      operationId: getApiBillingUsdtChains
      description: 'List USDT chains that are enabled AND have a receiving address

        configured. Chains without an address are auto-hidden by the backend

        so the frontend chain picker can render the response verbatim.'
      x-visibility: private
  /api/billing/usdt/create:
    post:
      responses:
        '422':
          $ref: '#/components/responses/UNPROCESSABLE_ENTITY'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BillingOrderRequest'
      summary: Create a USDT membership order.
      description: "Body:\n{\n  plan:  \"monthly\" | \"yearly\" | \"lifetime\",\n\
        \  chain: \"TRC20\" | \"BEP20\" | \"ERC20\" | \"SOL\"   # optional; defaults\
        \ to\n                                               # the first enabled chain\n\
        }"
      tags:
      - Billing
      operationId: postApiBillingUsdtCreate
      x-visibility: private
  /api/billing/usdt/order/{order_id}:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get my USDT order; refresh chain status by default.
      tags:
      - Billing
      operationId: getApiBillingUsdtOrderOrderId
      parameters:
      - name: order_id
        in: path
        required: true
        schema:
          type: integer
      x-visibility: private
    parameters:
    - in: path
      name: order_id
      required: true
      schema:
        type: integer
        minimum: 0
  /api/quick-trade/place-order:
    post:
      responses:
        '422':
          $ref: '#/components/responses/UNPROCESSABLE_ENTITY'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QuickTradeOrderRequest'
      summary: Place a quick market or limit order.
      description: "Body JSON:\ncredential_id  (int)    - saved exchange credential\
        \ ID\nsymbol         (str)    - e.g. \"BTC/USDT\"\nside           (str)  \
        \  - \"buy\" or \"sell\"\norder_type     (str)    - \"market\" or \"limit\"\
        \  (default: market)\namount         (float)  - spot quote amount or swap\
        \ margin amount in USDT\nprice          (float)  - limit price (required for\
        \ limit orders)\nleverage       (int)    - leverage multiplier (default: 1)\n\
        \                          - leverage = 1: spot market\n                 \
        \         - leverage > 1: swap (perpetual futures) market\nmarket_type   \
        \ (str)    - \"swap\" / \"spot\" (optional, auto-determined by leverage if\
        \ not provided)\ntp_price       (float)  - take-profit price (optional, for\
        \ record only)\nsl_price       (float)  - stop-loss price (optional, for record\
        \ only)\nsource         (str)    - \"ai_radar\" / \"ai_analysis\" / \"indicator\"\
        \ / \"manual\""
      tags:
      - QuickTrade
      operationId: postApiQuickTradePlaceOrder
      x-visibility: private
  /api/quick-trade/balance:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get available balance from exchange.
      description: 'Query: credential_id (int), market_type (str, default "swap")
        - active leg for ``available``/``total``.


        Response also includes ``swap`` and ``spot`` so the UI can show both account
        types.'
      tags:
      - QuickTrade
      operationId: getApiQuickTradeBalance
      x-visibility: private
  /api/quick-trade/position:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get current position for a symbol from exchange.
      description: 'Query: credential_id (int), symbol (str), market_type (str)'
      tags:
      - QuickTrade
      operationId: getApiQuickTradePosition
      x-visibility: private
  /api/quick-trade/close-position:
    post:
      responses:
        '422':
          $ref: '#/components/responses/UNPROCESSABLE_ENTITY'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QuickTradeCloseRequest'
      summary: Close an existing position.
      description: 'Body JSON:

        credential_id  (int)    - saved exchange credential ID

        symbol         (str)    - e.g. "BTC/USDT"

        market_type    (str)    - "swap" / "spot" (default: swap)

        size           (float)  - position size to close (optional, defaults to full
        position)

        close_scope    (str)    - "full" (default) or "system_tracked" (swap only:
        min(position, net from qd_quick_trades))

        position_side  (str)    - optional "long" / "short"; required when both directions
        exist for the same symbol

        source         (str)    - "ai_radar" / "ai_analysis" / "indicator" / "manual"'
      tags:
      - QuickTrade
      operationId: postApiQuickTradeClosePosition
      x-visibility: private
  /api/quick-trade/history:
    get:
      responses:
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanErrorEnvelope'
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HumanSuccessEnvelope'
      summary: Get quick trade history for the current user.
      description: 'Query: limit (int, default 50), offset (int, default 0)'
      tags:
      - QuickTrade
      operationId: getApiQuickTradeHistory
      x-visibility: private
openapi: 3.0.3
