Skip to main content

get_order_book

Function get_order_book 

Source
pub async fn get_order_book(
    __arg0: State<RestState>,
    rec: Option<Extension<Arc<KeyRecord>>>,
    __arg2: Json<Value>,
) -> Result<Json<Value>, (StatusCode, Json<Value>)>
Expand description

POST /api/orderbook — 获取摆盘

v1.4.90 P2-F fix: 未订阅 silent empty → 改 loud ret=-1 hint, 对齐 C++ OpenD “please subscribe first” 行为.

背景:get_order_book handler 从 global QotCache 读. 未订阅 → cache 空 → 返 ret_type=0 + 空 ask/bid lists. C++ OpenD 在 handler 入口检测 sub_info 为空 → 直接返 ret=-1. Rust gateway handler 走 silent-success(CLAUDE.md 坑 #45)— 这是 “ret_type:0 前必须有真实 downstream effect” 反模式的变种 (读路径上的 silent empty).

修法选择: gateway handler 改动会触碰 cross-channel forward (MCP / gRPC / WS 都共享同一 handler), v1.4.90 多 agent 并行约束本 agent 只改 REST. 在 REST 层 post-process: 检测 ask_list 和 bid_list 都空 → 重写 ret_type=-1 + loud hint. 对调用方等价于 C++ “please subscribe first” 体感.

判定边界: ask_list AND bid_list 都空 = 未订阅 (即使深度无价位时 C++/backend 也会返至少 1 条占位). 仅一边空 = 订阅了但单边无报价 (合法, 不改). 注意此 heuristic 在“订阅了但 push 还没到“时可能误报为“未订阅“ — hint 文本明示这两种情况, 用户区分.