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

# 报价与下单

> 将资产标识传入报价，再使用报价标识创建订单。

[Stablecoin Account API Publisher Disclaimer](/zh/stablecoin-account/v1.6/guide/stablecoin-account-api-publisher-disclaimer)

先通过[选择资产](/zh/stocks/guide/integration)取得 `asset_id` 和支持的资金币种。卖出前，使用 `asset_id` 调用 [List positions](/zh/stocks/api-reference/list-positions)，检查 `available_quantity`。

## 1. 创建报价

调用 [Create quote](/zh/stocks/api-reference/create-quote)（`POST /quote`），请求体按交易方向填写：

| 字段                 | 买入                             | 卖出                                                 |
| ------------------ | ------------------------------ | -------------------------------------------------- |
| `asset_id`         | 所选资产标识                         | 所选资产标识                                             |
| `side`             | `BUY`                          | `SELL`                                             |
| `funding_currency` | 支持的资金币种                        | 支持的资金币种                                            |
| `cash_amount`      | 不含手续费的正数资金金额，使用十进制字符串，最多 6 位小数 | 不传                                                 |
| `quantity`         | 不传                             | 正数资产数量，使用十进制字符串，最多 8 位小数，且不超过 `available_quantity` |

请求头 `x-idempotency-key` 使用新的小写 UUID。保存返回的 `quote_id`，检查 `quantity`、`price`、`cash_amount`、`fees`、`total_amount` 和 `expires_at`。值为 null 的字段不能作为已确认成交结果。

## 2. 提交报价

在报价过期前调用 [Create order](/zh/stocks/api-reference/create-order)（`POST /order`），将上一步返回值填入 `quote_id`。如需后续用自己的业务编号查找订单，可填写 `client_reference`。

订单请求使用新的 `x-idempotency-key`，不要与报价请求共用。保存返回的 `order_id`。一份报价只能创建一笔订单。

请求超时时，沿用该次操作的原幂等键和原请求体重试。报价过期则重新获取报价，不再提交旧标识。API Reference 提供真实请求和响应示例，实际调用时使用你新获取的标识。

## 3. 跟踪订单

调用 [Retrieve order](/zh/stocks/api-reference/retrieve-order)（`GET /order/{order_id}`），或接收[订单通知](/zh/stocks/guide/receive-webhooks)。

| 状态        | 下一步                                                                                                                 |
| --------- | ------------------------------------------------------------------------------------------------------------------- |
| `PENDING` | 继续跟踪当前订单。                                                                                                           |
| `SUCCESS` | 读取 `executed_quantity`、可用的成交价、`cash_amount`、`fees` 和 `total_amount`，再[核对持仓](/zh/stocks/guide/orders-and-positions)。 |
| `FAILED`  | 读取 `failure_code` 和 `failure_message`，再决定是否重新获取报价。                                                                  |

买入时，`total_amount` 是含手续费的总支出；卖出时是扣除手续费后的收入，均以 `funding_currency` 计价。
