> ## 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.

# Stocks 订单

> 接收 Stocks 订单处理中、已完成和失败的状态通知。

## 事件类型

所有订单通知使用 `event_name: STOCKS_ORDER`，通过 `event_type` 区分订单阶段。

| 事件类型                      | 订单状态      | 含义                           |
| ------------------------- | --------- | ---------------------------- |
| `stocks.order.processing` | `PENDING` | 订单已受理，尚未确定的成交数据为空。           |
| `stocks.order.completed`  | `SUCCESS` | 订单已完成结算，使用实际成交数值核对结果。        |
| `stocks.order.failed`     | `FAILED`  | 订单已进入终态失败。未创建订单的报价拒绝不会触发此通知。 |

## 订单快照

三个事件共用下方的通知封装和订单字段定义。`data.order` 是事件发生时的订单快照。

* **处理中**：`completed_at`、`failed_at`、`failure_code` 和 `failure_message` 为空。
* **已完成**：`completed_at` 有值，失败相关字段为空。通知提供成交数量、本金、费用和总金额；没有可用结算价格时，成交价可以为空。
* **失败**：`failed_at`、`failure_code` 和 `failure_message` 有值，`completed_at` 为空。成交数量、金额和费用为空。失败码包括 `STOCKS_ORDER_FAILED`，以及订单创建后报价在执行前过期时的 `STOCKS_QUOTE_EXPIRED`。

## 处理通知

通知可能重复或乱序到达。处理中通知晚于终态通知到达时，不要回退订单状态。通知投递超时或缺少交易哈希本身不表示订单失败。

按照[接收订单 Webhook](/zh/stocks/guide/receive-webhooks)完成验签、持久化以及投递与业务事件去重。使用[查询订单](/zh/stocks/api-reference/retrieve-order)核对当前结果。


## OpenAPI

````yaml stocks/webhooks-stocks.yaml webhook stocksOrder
openapi: 3.1.0
info:
  title: Stocks order webhooks
  version: 1.6.0
  description: >-
    Order state notifications delivered as HTTP POST JSON to your subscribed
    endpoint.
servers: []
security: []
paths: {}

````