> ## Documentation Index
> Fetch the complete documentation index at: https://developers.uqpay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 创建订单

> 提交报价以执行交易。发送请求前持久化幂等键，并持续跟踪返回的订单直至终态。 示例包含实际 Sandbox 标识。新操作应获取新报价并使用新幂等键。

<RequestExample>
  ```bash cURL
  curl --request POST \
    --url 'https://api-sandbox.uqpaytech.com/api/v1/stocks/order' \
    --header "Content-Type: application/json" \
    --header "x-auth-token: Bearer ${SANDBOX_TOKEN}" \
    --header "x-idempotency-key: ${UNIQUE_IDEMPOTENCY_KEY}" \
    --data '{
    "quote_id": "0576b03b-56dd-48b1-ba24-058ce90d0f53",
    "client_reference": "stocks-docs-20260921-buy-01"
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200
  {
    "transfer_quantity": null,
    "order_id": "53fe3d55-85ff-4804-b6f0-a25a32aa082f",
    "quote_id": "0576b03b-56dd-48b1-ba24-058ce90d0f53",
    "client_reference": "stocks-docs-20260921-buy-01",
    "asset_id": "7453f146-b267-11f1-b4f4-0abd773ba497",
    "symbol": "AAPLx",
    "side": "BUY",
    "status": "PENDING",
    "network": "Ethereum",
    "funding_currency": "USDC",
    "quoted_quantity": "0.00297066689243735",
    "executed_quantity": null,
    "executed_price": null,
    "cash_amount": null,
    "fees": null,
    "total_amount": null,
    "transaction_hash": "0x7e7b7f06c0a4adce2ec2bc01b455fd4e014b9f298e7e2598b02c93dffa86a96f",
    "failure_code": null,
    "failure_message": null,
    "created_at": "2026-09-21T01:33:08.629Z",
    "updated_at": "2026-09-21T01:33:13.84Z",
    "completed_at": null,
    "failed_at": null
  }
  ```
</ResponseExample>


## OpenAPI

````yaml /zh/stocks/stocks.yaml post /order
openapi: 3.0.3
info:
  title: UQPAY Stocks API
  version: 1.0.0
  description: 浏览资产、获取报价、创建订单并查询订单及持仓。金额和数量使用十进制字符串。
  x-source-en-commit: 586409f
  x-source-en-path: stocks/stocks.yaml
servers:
  - url: https://api-sandbox.uqpaytech.com/api/v1/stocks
    description: Sandbox
security:
  - AuthToken: []
paths:
  /order:
    post:
      tags:
        - Stocks
      summary: 创建订单
      description: >-
        提交报价以执行交易。发送请求前持久化幂等键，并持续跟踪返回的订单直至终态。 示例包含实际 Sandbox
        标识。新操作应获取新报价并使用新幂等键。
      operationId: createStocksOrder
      parameters:
        - name: x-idempotency-key
          in: header
          required: true
          schema:
            type: string
            format: uuid
            pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
          description: 用于维持操作幂等性的唯一标识符。同一操作重试时使用相同的键和请求内容；新的操作使用新的键。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrderRequest'
            examples:
              sandbox:
                summary: Sandbox request
                value:
                  quote_id: 0576b03b-56dd-48b1-ba24-058ce90d0f53
                  client_reference: stocks-docs-20260921-buy-01
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
              examples:
                sandbox:
                  summary: Sandbox response
                  value:
                    transfer_quantity: null
                    order_id: 53fe3d55-85ff-4804-b6f0-a25a32aa082f
                    quote_id: 0576b03b-56dd-48b1-ba24-058ce90d0f53
                    client_reference: stocks-docs-20260921-buy-01
                    asset_id: 7453f146-b267-11f1-b4f4-0abd773ba497
                    symbol: AAPLx
                    side: BUY
                    status: PENDING
                    network: Ethereum
                    funding_currency: USDC
                    quoted_quantity: '0.00297066689243735'
                    executed_quantity: null
                    executed_price: null
                    cash_amount: null
                    fees: null
                    total_amount: null
                    transaction_hash: >-
                      0x7e7b7f06c0a4adce2ec2bc01b455fd4e014b9f298e7e2598b02c93dffa86a96f
                    failure_code: null
                    failure_message: null
                    created_at: '2026-09-21T01:33:08.629Z'
                    updated_at: '2026-09-21T01:33:13.84Z'
                    completed_at: null
                    failed_at: null
        '400':
          description: 请求失败。读取错误响应中的 type、code 和 message。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: 请求失败。读取错误响应中的 type、code 和 message。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: 请求失败。读取错误响应中的 type、code 和 message。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: 请求失败。读取错误响应中的 type、code 和 message。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: 请求失败。读取错误响应中的 type、code 和 message。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: 请求失败。读取错误响应中的 type、code 和 message。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: 网关未能完成请求。写入操作应先核对结果，再使用同一幂等键重试。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 请求失败。读取错误响应中的 type、code 和 message。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-codeSamples:
        - lang: cURL
          source: |-
            curl --request POST \
              --url 'https://api-sandbox.uqpaytech.com/api/v1/stocks/order' \
              --header "Content-Type: application/json" \
              --header "x-auth-token: Bearer ${SANDBOX_TOKEN}" \
              --header "x-idempotency-key: ${UNIQUE_IDEMPOTENCY_KEY}" \
              --data '{
              "quote_id": "0576b03b-56dd-48b1-ba24-058ce90d0f53",
              "client_reference": "stocks-docs-20260921-buy-01"
            }'
components:
  schemas:
    OrderRequest:
      type: object
      additionalProperties: false
      properties:
        quote_id:
          type: string
          format: uuid
          description: 创建订单时提交的报价标识。
          example: 0576b03b-56dd-48b1-ba24-058ce90d0f53
        client_reference:
          type: string
          minLength: 1
          maxLength: 100
          nullable: true
          description: 用于查询订单的客户参考号，不能替代幂等键。
          example: stocks-docs-20260921-buy-01
      required:
        - quote_id
    Order:
      type: object
      additionalProperties: false
      properties:
        order_id:
          type: string
          format: uuid
          description: 用于查询订单详情的订单标识。
          example: 53fe3d55-85ff-4804-b6f0-a25a32aa082f
        quote_id:
          type: string
          format: uuid
          description: 交易订单使用的报价标识；充值和提现记录为 null。
          nullable: true
          example: 0576b03b-56dd-48b1-ba24-058ce90d0f53
        client_reference:
          type: string
          nullable: true
          description: 用于查询订单的客户参考号，不能替代幂等键。
          example: stocks-docs-20260921-buy-01
        asset_id:
          type: string
          format: uuid
          description: 平台资产 UUID，列表与所有交易接口共用
          example: 7453f146-b267-11f1-b4f4-0abd773ba497
        symbol:
          type: string
          description: 资产代码。
          example: AAPLx
        side:
          type: string
          enum:
            - BUY
            - SELL
            - DEPOSIT
            - WITHDRAWAL
          description: 订单业务类型。交易订单来源于报价；充值和提现记录表示资产转入或转出。
          example: BUY
        status:
          type: string
          enum:
            - PENDING
            - SUCCESS
            - FAILED
          description: 订单处理状态。完成后再按结算数值进行对账。
          example: SUCCESS
        network:
          type: string
          nullable: true
          description: 执行或资产转移所用的区块链网络；不可用时为 null。
          example: Ethereum
        funding_currency:
          type: string
          description: 交易使用的资金币种；资产转移记录为 null。
          nullable: true
          example: USDC
        quoted_quantity:
          type: string
          pattern: ^-?[0-9]+(\.[0-9]+)?$
          nullable: true
          description: 所接受报价中的数量；报价未确定数量或记录属于资产转移时为 null。
          example: '0.00297066689243735'
        executed_quantity:
          type: string
          pattern: ^-?[0-9]+(\.[0-9]+)?$
          nullable: true
          description: 已完成交易的结算数量；结算前为 null。
          example: '0.00297066689243735'
        executed_price:
          type: string
          pattern: ^-?[0-9]+(\.[0-9]+)?$
          nullable: true
          description: 以 funding_currency 计价的每单位结算价格，不表示资产转移的成本基础。
          example: '336.624750000000055741'
        cash_amount:
          type: string
          pattern: ^-?[0-9]+(\.[0-9]+)?$
          nullable: true
          description: 以 funding_currency 计价、不含手续费的结算金额；结算前及资产转移记录为 null。
          example: '1'
        fees:
          type: array
          items:
            $ref: '#/components/schemas/Fee'
          nullable: true
          description: 已完成订单记录的费用；null 表示尚无已结算费用信息。
          example:
            - type: TRADING
              amount: '0.0005'
              currency: USDC
        total_amount:
          type: string
          pattern: ^-?[0-9]+(\.[0-9]+)?$
          nullable: true
          description: >-
            以 funding_currency 计价，买入时为含手续费的结算总支出，卖出时为扣除手续费后的结算收入；结算前及资产转移记录为
            null。
          example: '1.0005'
        transaction_hash:
          type: string
          nullable: true
          description: 可用时返回公开交易哈希；null 本身不表示订单失败。
          example: '0x7e7b7f06c0a4adce2ec2bc01b455fd4e014b9f298e7e2598b02c93dffa86a96f'
        failure_code:
          type: string
          nullable: true
          description: 失败订单的业务失败标识，与 HTTP 错误码分别处理。
        failure_message:
          type: string
          nullable: true
          description: 订单失败原因的可读说明；未报告失败时为 null。
        created_at:
          type: string
          format: date-time
          description: 订单创建时间。
          example: '2026-09-21T01:33:08.629Z'
        updated_at:
          type: string
          format: date-time
          description: 订单最近更新时间。
          example: '2026-09-21T01:50:53.855Z'
        completed_at:
          type: string
          format: date-time
          nullable: true
          description: 结算完成时间；订单完成前为 null。
          example: '2026-09-21T01:50:53.561Z'
        failed_at:
          type: string
          format: date-time
          nullable: true
          description: 终态失败时间；订单未失败时为 null。
        transfer_quantity:
          type: string
          pattern: ^-?[0-9]+(\.[0-9]+)?$
          nullable: true
          description: 充值或提现的资产数量；买入和卖出订单为 null。
      required:
        - order_id
        - quote_id
        - client_reference
        - asset_id
        - symbol
        - side
        - status
        - network
        - funding_currency
        - quoted_quantity
        - executed_quantity
        - executed_price
        - cash_amount
        - fees
        - total_amount
        - transaction_hash
        - failure_code
        - failure_message
        - created_at
        - updated_at
        - completed_at
        - failed_at
        - transfer_quantity
    Error:
      type: object
      additionalProperties: false
      required:
        - type
        - code
        - message
      properties:
        type:
          type: string
          description: 用于分类处理失败的错误类别。
          pattern: ^[a-z][a-z0-9]*(_[a-z0-9]+)*$
        code:
          type: string
          description: 可供程序处理的业务错误码。结合 HTTP 状态处理，不要依赖 message 文本匹配。
          pattern: ^[a-z][a-z0-9]*(_[a-z0-9]+)*$
        message:
          type: string
          description: 错误原因的可读说明。
    Fee:
      type: object
      additionalProperties: false
      properties:
        type:
          type: string
          enum:
            - TRADING
            - DEPOSIT
            - WITHDRAWAL
          description: 费用类别。
          example: TRADING
        amount:
          type: string
          pattern: ^-?[0-9]+(\.[0-9]+)?$
          description: 费用金额
          example: '0.0005'
        currency:
          type: string
          description: 收取费用的币种。
          example: USDC
      required:
        - type
        - amount
        - currency
  securitySchemes:
    AuthToken:
      type: apiKey
      in: header
      name: x-auth-token
      description: 由 UQPAY 提供的登录 API Token。

````