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

使用 [Create order](/zh/stocks/api-reference/create-order) 后保存的 `order_id`。按资产查询时，使用交易前选定的 `asset_id`。

## 1. 查询或找回订单

已知 `order_id` 时，调用 [Retrieve order](/zh/stocks/api-reference/retrieve-order)（`GET /order/{order_id}`）。如果未收到创建订单的响应，使用当时提交的 `client_reference` 调用 [List orders](/zh/stocks/api-reference/list-orders)（`GET /order`）查找。

查询历史订单时，可按 `asset_id`、`symbol`、`order_status` 或 `from` / `to` 筛选。这里的时间范围针对订单创建时间，包含 `from`，不包含 `to`。先找回原订单结果，再决定是否再次下单。

## 2. 查询当前持仓

交易成功后，将 `asset_id` 传给 [List positions](/zh/stocks/api-reference/list-positions)（`GET /position`）。

| 字段                   | 用途              |
| -------------------- | --------------- |
| `quantity`           | 该资产当前的总持仓数量。    |
| `available_quantity` | 后续申请卖出报价时可用的数量。 |
| `frozen_quantity`    | 已被占用、暂不可用的数量。   |

## 3. 关联持仓变动

将 `order_id` 传给 [List position events](/zh/stocks/api-reference/list-position-events)（`GET /position/event`），查找该笔交易的持仓变动。结合订单的 `executed_quantity`，读取 `quantity_delta`、`quantity_after` 和 `created_at`。

查询某个资产的变动历史时，可按 `asset_id` 或 `symbol` 筛选，并按需传入 `from` / `to`。这里的时间范围针对事件发生时间，包含 `from`，不包含 `to`。

变动类型为 `ADJUSTMENT` 时，使用该资产的 `asset_id` 调用 [List corporate actions](/zh/stocks/api-reference/list-corporate-actions)（`GET /asset/{asset_id}/corporate-action`）。读取 `old_multiplier`、`new_multiplier`、`effective_at` 和 `applied_at` 了解已应用的调整；持仓变动不一定关联订单。

订单列表也可能包含 `DEPOSIT` 和 `WITHDRAWAL` 记录，这类记录通过 `transfer_quantity` 表示数量；前述报价与下单流程创建的是 `BUY` 或 `SELL` 交易。

## 读取全部分页

列表查询传入 `page_number` 和 `page_size`，读取 `data` 后逐页增加 `page_number`，直到读完 `total_pages`。默认每页 10 条，最多 100 条。
