Skip to main content

futu_backend/trade_query/orders/
query_orders.rs

1//! trade_query/orders/query_orders — query_orders + query_orders_inner (real + sim 双路径)
2//! (v1.4.110 CC Batch J: 拆自 orders.rs L336-666)
3
4use futu_cache::trd_cache::TrdCache;
5use futu_core::error::Result;
6
7use crate::conn::BackendConn;
8
9use super::order_list::query_orders_inner;
10use super::types::{CurrentOrderQueryResult, QueryErrorMode};
11
12pub async fn query_orders(
13    backend: &BackendConn,
14    acc_id: u64,
15    trd_cache: &TrdCache,
16) -> Result<CurrentOrderQueryResult> {
17    query_orders_inner(backend, acc_id, trd_cache, QueryErrorMode::LenientCacheRead).await
18}
19
20/// v1.4.109: strict 版 query_orders for write/push safety paths.
21///
22/// 与 lenient 版区别: decode 失败 / `result != 0` → 返 `Err` (会被 retry 重试).
23/// 不再 silent 当 "Ok(empty)" → silent-success 反模式 D (CLAUDE.md #45) 的修复.
24///
25/// Callers that need a trustworthy order baseline before mutating order state
26/// must use this strict variant, not the read-path lenient cache-miss helper.
27pub async fn query_orders_strict(
28    backend: &BackendConn,
29    acc_id: u64,
30    trd_cache: &TrdCache,
31) -> Result<CurrentOrderQueryResult> {
32    query_orders_inner(
33        backend,
34        acc_id,
35        trd_cache,
36        QueryErrorMode::StrictPushRefresh,
37    )
38    .await
39}
40
41/// v1.4.106 codex 0932 F3 [P2]: strict 版 query_orders for push-refresh path.
42///
43/// **4 attempts 全失败**: caller (dispatcher) 应触发 F4 `record_f2_exhausted` +
44/// log warn. 不再 silent 当成功流转.
45pub async fn query_orders_strict_for_push_refresh(
46    backend: &BackendConn,
47    acc_id: u64,
48    trd_cache: &TrdCache,
49) -> Result<CurrentOrderQueryResult> {
50    query_orders_strict(backend, acc_id, trd_cache).await
51}