basePath: /
definitions:
  management.CreateOrderRequest:
    properties:
      amount:
        type: string
      engine_type:
        type: string
      filled_amount:
        type: string
      filled_value:
        type: string
      market_symbol:
        type: string
      market_type:
        type: string
      price:
        type: string
      side:
        enum:
        - buy
        - sell
        type: string
      status:
        enum:
        - pending
        - partial
        - filled
        - cancelled
        type: string
      type:
        type: string
      unfilled_amount:
        type: string
      user_id:
        type: integer
    required:
    - amount
    - engine_type
    - market_symbol
    - market_type
    - side
    - status
    - type
    - user_id
    type: object
  management.CreateStopOrderRequest:
    properties:
      amount:
        type: string
      engine_type:
        type: string
      market_symbol:
        type: string
      market_type:
        type: string
      price:
        type: string
      side:
        enum:
        - buy
        - sell
        type: string
      state:
        enum:
        - waiting
        - triggered
        - cancelled
        - failed
        type: string
      trigger_dir:
        enum:
        - up
        - down
        type: string
      trigger_price:
        type: string
      type:
        type: string
      user_id:
        type: integer
    required:
    - amount
    - engine_type
    - market_symbol
    - market_type
    - side
    - state
    - trigger_price
    - type
    - user_id
    type: object
  management.OrderResponse:
    properties:
      code:
        type: integer
      data:
        $ref: '#/definitions/models.SpotOrder'
      message:
        type: string
    type: object
  management.OrdersDataResponse:
    properties:
      count:
        type: integer
      orders:
        items:
          $ref: '#/definitions/models.SpotOrder'
        type: array
    type: object
  management.OrdersResponse:
    properties:
      code:
        type: integer
      data:
        $ref: '#/definitions/management.OrdersDataResponse'
      message:
        type: string
    type: object
  management.StatsData:
    properties:
      cancelled_orders:
        type: integer
      filled_orders:
        type: integer
      orders_by_market:
        additionalProperties:
          format: int64
          type: integer
        type: object
      pending_orders:
        type: integer
      total_orders:
        type: integer
      total_stop_orders:
        type: integer
      triggered_stop_orders:
        type: integer
      waiting_stop_orders:
        type: integer
    type: object
  management.StatsResponse:
    properties:
      code:
        type: integer
      data:
        $ref: '#/definitions/management.StatsData'
      message:
        type: string
    type: object
  management.StopOrderResponse:
    properties:
      code:
        type: integer
      data:
        $ref: '#/definitions/models.SpotStopOrder'
      message:
        type: string
    type: object
  management.StopOrdersDataResponse:
    properties:
      count:
        type: integer
      orders:
        items:
          $ref: '#/definitions/models.SpotStopOrder'
        type: array
    type: object
  management.StopOrdersResponse:
    properties:
      code:
        type: integer
      data:
        $ref: '#/definitions/management.StopOrdersDataResponse'
      message:
        type: string
    type: object
  management.UpdateOrderRequest:
    properties:
      filled_amount:
        type: string
      filled_value:
        type: string
      status:
        enum:
        - pending
        - partial
        - filled
        - cancelled
        type: string
      unfilled_amount:
        type: string
    type: object
  management.UpdateStopOrderRequest:
    properties:
      state:
        enum:
        - waiting
        - triggered
        - cancelled
        - failed
        type: string
    type: object
  models.Action:
    properties:
      created_at:
        type: string
      id:
        type: integer
      is_active:
        type: boolean
      key:
        type: string
      title_en:
        type: string
      title_fa:
        type: string
      updated_at:
        type: string
    type: object
  models.Admin:
    properties:
      admin_emails:
        $ref: '#/definitions/models.AdminEmail'
      admin_phones:
        $ref: '#/definitions/models.AdminPhone'
      created_at:
        type: string
      emails:
        items:
          $ref: '#/definitions/models.AdminEmail'
        type: array
      id:
        type: integer
      is_active:
        type: boolean
      last_login:
        type: string
      meta_data:
        type: string
      phones:
        items:
          $ref: '#/definitions/models.AdminPhone'
        type: array
      roles:
        items:
          $ref: '#/definitions/models.Role'
        type: array
      updated_at:
        type: string
      username:
        maxLength: 50
        minLength: 3
        type: string
    required:
    - id
    - username
    type: object
  models.AdminEmail:
    properties:
      admin_id:
        type: integer
      email:
        type: string
      id:
        type: integer
      is_active:
        type: boolean
      is_verified:
        type: boolean
      verified_at:
        type: string
    type: object
  models.AdminPhone:
    properties:
      admin_id:
        type: integer
      country_code:
        type: string
      id:
        type: integer
      is_active:
        type: boolean
      is_verified:
        type: boolean
      phone:
        type: string
      verified_at:
        type: string
    type: object
  models.EngineType:
    enum:
    - internal_match_engine
    - coinex
    type: string
    x-enum-varnames:
    - EngineTypeInternalMatch
    - EngineTypeCoinEx
  models.File:
    properties:
      admin_id:
        type: integer
      bucket:
        type: string
      created_at:
        type: string
      filename:
        type: string
      id:
        type: integer
      is_public:
        type: boolean
      meta_data:
        type: string
      mime_type:
        type: string
      original_name:
        type: string
      path:
        type: string
      size:
        type: integer
      updated_at:
        type: string
      url:
        type: string
      user_id:
        type: integer
    type: object
  models.MFAMethod:
    properties:
      description:
        type: string
      icon:
        type: string
      id:
        type: integer
      is_active:
        type: boolean
      is_default:
        type: boolean
      is_hidden:
        type: boolean
      is_optional:
        type: boolean
      is_required:
        type: boolean
      key:
        type: string
      name:
        type: string
    type: object
  models.MarketType:
    enum:
    - SPOT
    - MARGIN
    type: string
    x-enum-varnames:
    - MarketTypeSpot
    - MarketTypeMargin
  models.OrderSide:
    enum:
    - buy
    - sell
    type: string
    x-enum-varnames:
    - OrderSideBuy
    - OrderSideSell
  models.OrderStatus:
    enum:
    - pending
    - pending_routing
    - routed
    - routing_failed
    - partial
    - filled
    - cancelled
    - rejected
    type: string
    x-enum-varnames:
    - OrderStatusPending
    - OrderStatusPendingRouting
    - OrderStatusRouted
    - OrderStatusRoutingFailed
    - OrderStatusPartial
    - OrderStatusFilled
    - OrderStatusCancelled
    - OrderStatusRejected
  models.OrderType:
    enum:
    - limit
    - market
    - ioc
    - fok
    - maker
    type: string
    x-enum-varnames:
    - OrderTypeLimit
    - OrderTypeMarket
    - OrderTypeIOC
    - OrderTypeFOK
    - OrderTypeMaker
  models.Permission:
    properties:
      action:
        $ref: '#/definitions/models.Action'
      action_id:
        type: integer
      created_at:
        type: string
      description:
        type: string
      id:
        type: integer
      is_active:
        type: boolean
      key:
        type: string
      resource:
        $ref: '#/definitions/models.Resource'
      resource_id:
        type: integer
      roles:
        items:
          $ref: '#/definitions/models.Role'
        type: array
      title_en:
        type: string
      title_fa:
        type: string
      updated_at:
        type: string
    type: object
  models.Resource:
    properties:
      created_at:
        type: string
      id:
        type: integer
      is_active:
        type: boolean
      key:
        type: string
      scope:
        $ref: '#/definitions/models.Scope'
      scope_id:
        type: integer
      title_en:
        type: string
      title_fa:
        type: string
      updated_at:
        type: string
    type: object
  models.Role:
    properties:
      admins:
        items:
          $ref: '#/definitions/models.Admin'
        type: array
      created_at:
        type: string
      description:
        type: string
      id:
        type: integer
      name:
        type: string
      permissions:
        items:
          $ref: '#/definitions/models.Permission'
        type: array
      updated_at:
        type: string
      users:
        items:
          $ref: '#/definitions/models.User'
        type: array
    type: object
  models.Scope:
    properties:
      created_at:
        type: string
      id:
        type: integer
      is_active:
        type: boolean
      key:
        type: string
      title_en:
        type: string
      title_fa:
        type: string
      updated_at:
        type: string
    type: object
  models.SpotMarketRef:
    properties:
      base_asset_id:
        type: integer
      created_at:
        type: string
      id:
        type: integer
      is_active:
        type: boolean
      maker_fee_rate:
        type: string
      market:
        type: string
      max_order_size:
        type: number
      min_order_size:
        type: number
      price_step:
        type: number
      quantity_step:
        type: number
      quote_asset_id:
        type: integer
      taker_fee_rate:
        type: string
      updated_at:
        type: string
    type: object
  models.SpotOrder:
    properties:
      amount:
        type: number
      avg_price:
        type: number
      created_at:
        description: Timestamps
        type: string
      engine_type:
        allOf:
        - $ref: '#/definitions/models.EngineType'
        description: Engine type - determines which matching engine will process this
          order
      filled_amount:
        description: Execution state
        type: number
      filled_value:
        type: number
      id:
        type: integer
      market_symbol:
        description: Market symbol (e.g., BTCUSDT)
        type: string
      market_type:
        allOf:
        - $ref: '#/definitions/models.MarketType'
        description: Order details
      price:
        type: number
      side:
        $ref: '#/definitions/models.OrderSide'
      spot_market:
        allOf:
        - $ref: '#/definitions/models.SpotMarketRef'
        description: SpotMarket is loaded via LoadSpotMarket / FindWithRelations (not
          a DB column).
      status:
        allOf:
        - $ref: '#/definitions/models.OrderStatus'
        description: Status
      type:
        $ref: '#/definitions/models.OrderType'
      unfilled_amount:
        type: number
      updated_at:
        type: string
      user:
        $ref: '#/definitions/models.User'
      user_id:
        type: integer
    type: object
  models.SpotStopOrder:
    properties:
      amount:
        type: number
      created_at:
        description: Timestamps
        type: string
      engine_type:
        allOf:
        - $ref: '#/definitions/models.EngineType'
        description: Engine type - determines which matching engine will process this
          order
      id:
        type: integer
      market_symbol:
        description: Market symbol (e.g., BTCUSDT)
        type: string
      market_type:
        allOf:
        - $ref: '#/definitions/models.MarketType'
        description: Order details
      price:
        type: number
      result_order_id:
        description: Platform order ID when triggered
        type: integer
      side:
        $ref: '#/definitions/models.OrderSide'
      spot_market:
        allOf:
        - $ref: '#/definitions/models.SpotMarketRef'
        description: SpotMarket is loaded via LoadSpotMarket / FindWithRelations (not
          a DB column).
      state:
        allOf:
        - $ref: '#/definitions/models.StopOrderState'
        description: State
      trigger_dir:
        $ref: '#/definitions/models.TriggerDirection'
      trigger_price:
        type: number
      triggered_at:
        type: string
      type:
        $ref: '#/definitions/models.OrderType'
      updated_at:
        type: string
      user:
        $ref: '#/definitions/models.User'
      user_id:
        type: integer
    type: object
  models.StopOrderState:
    enum:
    - waiting
    - triggered
    - cancelled
    - failed
    type: string
    x-enum-varnames:
    - StopOrderStateWaiting
    - StopOrderStateTriggered
    - StopOrderStateCancelled
    - StopOrderStateFailed
  models.TriggerDirection:
    enum:
    - up
    - down
    type: string
    x-enum-varnames:
    - TriggerDirUp
    - TriggerDirDown
  models.User:
    properties:
      created_at:
        type: string
      email:
        $ref: '#/definitions/models.UserEmail'
      emails:
        items:
          $ref: '#/definitions/models.UserEmail'
        type: array
      id:
        type: integer
      is_active:
        type: boolean
      is_frozen:
        type: boolean
      kyc_status:
        type: string
      meta_data:
        type: string
      name:
        maxLength: 50
        minLength: 3
        type: string
      phone:
        $ref: '#/definitions/models.UserPhone'
      phones:
        items:
          $ref: '#/definitions/models.UserPhone'
        type: array
      profile_image:
        $ref: '#/definitions/models.File'
      roles:
        items:
          $ref: '#/definitions/models.Role'
        type: array
      updated_at:
        type: string
      upload_id:
        type: integer
      user_mfas:
        items:
          $ref: '#/definitions/models.UserMFA'
        type: array
      username:
        maxLength: 50
        minLength: 3
        type: string
    required:
    - username
    type: object
  models.UserEmail:
    properties:
      created_at:
        type: string
      email:
        type: string
      id:
        type: integer
      is_active:
        type: boolean
      is_verified:
        type: boolean
      updated_at:
        type: string
      user_id:
        type: integer
      verified_at:
        type: string
    type: object
  models.UserMFA:
    properties:
      created_at:
        type: string
      id:
        type: integer
      mfa_method:
        $ref: '#/definitions/models.MFAMethod'
      mfa_method_id:
        type: integer
      status:
        type: string
      updated_at:
        type: string
      user_id:
        type: integer
    type: object
  models.UserPhone:
    properties:
      country_code:
        type: string
      created_at:
        type: string
      id:
        type: integer
      is_active:
        type: boolean
      is_verified:
        type: boolean
      phone:
        type: string
      updated_at:
        type: string
      user_id:
        type: integer
      verified_at:
        type: string
    type: object
  response.ErrorResponse:
    properties:
      code:
        type: integer
      error: {}
      message:
        type: string
    type: object
  response.SuccessResponse:
    properties:
      code:
        type: integer
      message:
        type: string
    type: object
host: management-api.poolthewool.com
info:
  contact: {}
  description: Administrative API for spot orders and stop orders. Authenticate via
    POST /management/auth/login, then use the returned Bearer token.
  title: Rcoinx Spot Order Management API
  version: "1.0"
paths:
  /management/spot/orders:
    get:
      consumes:
      - application/json
      description: Get paginated list of spot orders with optional filters
      parameters:
      - default: 1
        description: Page number
        in: query
        name: page
        type: integer
      - default: 10
        description: Page size
        in: query
        name: page_size
        type: integer
      - description: Filter by user ID
        in: query
        name: user_id
        type: integer
      - description: Filter by symbol
        in: query
        name: market_symbol
        type: string
      - description: Filter by market type
        in: query
        name: market_type
        type: string
      - description: Filter by side
        in: query
        name: side
        type: string
      - description: Filter by status
        in: query
        name: status
        type: string
      - description: Filter by engine type
        in: query
        name: engine_type
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/management.OrdersResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/response.ErrorResponse'
      security:
      - Bearer: []
      summary: Get list of spot orders
      tags:
      - Spot Order Management
    post:
      consumes:
      - application/json
      description: Create a new spot order record manually (for corrections)
      parameters:
      - description: Order object
        in: body
        name: order
        required: true
        schema:
          $ref: '#/definitions/management.CreateOrderRequest'
      produces:
      - application/json
      responses:
        "201":
          description: Created
          schema:
            $ref: '#/definitions/management.OrderResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/response.ErrorResponse'
      security:
      - Bearer: []
      summary: Create spot order record
      tags:
      - Spot Order Management
  /management/spot/orders/{id}:
    delete:
      consumes:
      - application/json
      description: Soft delete a spot order record
      parameters:
      - description: Order ID
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.SuccessResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/response.ErrorResponse'
      security:
      - Bearer: []
      summary: Delete spot order record
      tags:
      - Spot Order Management
    get:
      consumes:
      - application/json
      description: Get spot order details by ID
      parameters:
      - description: Order ID
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/management.OrderResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/response.ErrorResponse'
      security:
      - Bearer: []
      summary: Get spot order by ID
      tags:
      - Spot Order Management
    put:
      consumes:
      - application/json
      description: Update an existing spot order record
      parameters:
      - description: Order ID
        in: path
        name: id
        required: true
        type: integer
      - description: Order update object
        in: body
        name: order
        required: true
        schema:
          $ref: '#/definitions/management.UpdateOrderRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/management.OrderResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/response.ErrorResponse'
      security:
      - Bearer: []
      summary: Update spot order record
      tags:
      - Spot Order Management
  /management/spot/orders/stats:
    get:
      consumes:
      - application/json
      description: Get statistics about orders and stop orders
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/management.StatsResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/response.ErrorResponse'
      security:
      - Bearer: []
      summary: Get order statistics
      tags:
      - Spot Order Management
  /management/spot/orders/user/{user_id}:
    get:
      consumes:
      - application/json
      description: Get all spot orders for a specific user
      parameters:
      - description: User ID
        in: path
        name: user_id
        required: true
        type: integer
      - default: 1
        description: Page number
        in: query
        name: page
        type: integer
      - default: 10
        description: Page size
        in: query
        name: page_size
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/management.OrdersResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/response.ErrorResponse'
      security:
      - Bearer: []
      summary: Get spot orders by user ID
      tags:
      - Spot Order Management
  /management/spot/stop-orders:
    get:
      consumes:
      - application/json
      description: Get paginated list of spot stop orders with optional filters
      parameters:
      - default: 1
        description: Page number
        in: query
        name: page
        type: integer
      - default: 10
        description: Page size
        in: query
        name: page_size
        type: integer
      - description: Filter by user ID
        in: query
        name: user_id
        type: integer
      - description: Filter by symbol
        in: query
        name: market_symbol
        type: string
      - description: Filter by market type
        in: query
        name: market_type
        type: string
      - description: Filter by side
        in: query
        name: side
        type: string
      - description: Filter by state
        in: query
        name: state
        type: string
      - description: Filter by engine type
        in: query
        name: engine_type
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/management.StopOrdersResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/response.ErrorResponse'
      security:
      - Bearer: []
      summary: Get list of spot stop orders
      tags:
      - Spot Stop Order Management
    post:
      consumes:
      - application/json
      description: Create a new spot stop order record manually (for corrections)
      parameters:
      - description: Stop Order object
        in: body
        name: order
        required: true
        schema:
          $ref: '#/definitions/management.CreateStopOrderRequest'
      produces:
      - application/json
      responses:
        "201":
          description: Created
          schema:
            $ref: '#/definitions/management.StopOrderResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/response.ErrorResponse'
      security:
      - Bearer: []
      summary: Create spot stop order record
      tags:
      - Spot Stop Order Management
  /management/spot/stop-orders/{id}:
    delete:
      consumes:
      - application/json
      description: Soft delete a spot stop order record
      parameters:
      - description: Stop Order ID
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.SuccessResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/response.ErrorResponse'
      security:
      - Bearer: []
      summary: Delete spot stop order record
      tags:
      - Spot Stop Order Management
    get:
      consumes:
      - application/json
      description: Get spot stop order details by ID
      parameters:
      - description: Stop Order ID
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/management.StopOrderResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/response.ErrorResponse'
      security:
      - Bearer: []
      summary: Get spot stop order by ID
      tags:
      - Spot Stop Order Management
    put:
      consumes:
      - application/json
      description: Update an existing spot stop order record
      parameters:
      - description: Stop Order ID
        in: path
        name: id
        required: true
        type: integer
      - description: Stop Order update object
        in: body
        name: order
        required: true
        schema:
          $ref: '#/definitions/management.UpdateStopOrderRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/management.StopOrderResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/response.ErrorResponse'
      security:
      - Bearer: []
      summary: Update spot stop order record
      tags:
      - Spot Stop Order Management
  /management/spot/stop-orders/user/{user_id}:
    get:
      consumes:
      - application/json
      description: Get all spot stop orders for a specific user
      parameters:
      - description: User ID
        in: path
        name: user_id
        required: true
        type: integer
      - default: 1
        description: Page number
        in: query
        name: page
        type: integer
      - default: 10
        description: Page size
        in: query
        name: page_size
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/management.StopOrdersResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/response.ErrorResponse'
      security:
      - Bearer: []
      summary: Get spot stop orders by user ID
      tags:
      - Spot Stop Order Management
securityDefinitions:
  Bearer:
    description: Type "Bearer" followed by a space and admin JWT token.
    in: header
    name: Authorization
    type: apiKey
swagger: "2.0"
