Skip to main content

futu_backend/
trade_query.rs

1// 交易数据查询
2//
3// CMD 使用必须走 `TRADE_QUERY_COMMANDS` registry。不要在调用点现场写
4// `base_cmd + 10000` 或重复解释 real/sim cmd;历史上真实/模拟 cmd 混用
5// 已多次造成 backend business error。
6
7use futu_cache::trd_cache::{
8    CachedCashInfo, CachedFunds, CachedMarketInfo, CachedPosition, TrdCache,
9};
10use futu_core::error::Result;
11
12use crate::conn::BackendConn;
13// `odr_sys_cmn / order_sys_interface / sim_order_sys_interface` 透传给
14// sub-mod tests (account_info/tests.rs, crypto_account/tests.rs, orders/response_status_tests.rs)
15// 通过 `use super::*` 接入; trade_query.rs 顶层不直接用, cargo fix 会想剪.
16#[allow(unused_imports)]
17use crate::proto_internal::{
18    asset_pl, asset_query, config_base, crypto_risk, crypto_risk_comm, inbound_oe, inbound_read,
19    mobile_fund_asset, odr_sys_cmn, order_sys_interface, sim_order_sys_interface,
20};
21
22mod account_info;
23mod common;
24mod crypto_account;
25mod crypto_orders;
26mod orders;
27mod sim;
28
29pub use crate::trade_cmd::{
30    CMD_ACCOUNT_INFO, CMD_FUND_BOND_DETAIL_ASSET, CMD_QUERY_FUND,
31    CMD_QUERY_HISTORY_ORDER_FILL_LIST, CMD_QUERY_HISTORY_ORDER_LIST, CMD_QUERY_ORDER_FILL_INFO,
32    CMD_QUERY_ORDER_FILL_LIST, CMD_QUERY_ORDER_LIST, CMD_QUERY_POSITION, CMD_SIM_QUERY_FUND,
33    CMD_SIM_QUERY_HISTORY_ORDER_FILL_LIST, CMD_SIM_QUERY_HISTORY_ORDER_LIST,
34    CMD_SIM_QUERY_ORDER_FILL_INFO, CMD_SIM_QUERY_ORDER_FILL_LIST, CMD_SIM_QUERY_ORDER_LIST,
35    CMD_SIM_QUERY_POSITION, TRADE_QUERY_COMMANDS, TradeBackendChannel, TradeQueryBodyProto,
36    TradeQueryOperation, trade_query_command,
37};
38
39pub use account_info::{query_account_info, query_position_account_info};
40pub use common::{create_backend_req_id, hash_str_to_u64};
41pub use crypto_account::{query_crypto_account_info, query_crypto_position_account_info};
42pub use crypto_orders::{
43    CryptoCashLogInfo, CryptoMaxBuySellQtyInfo, CryptoOrderFeeInfo, CryptoOrderFeeItem,
44    query_crypto_cash_logs, query_crypto_history_order_fills, query_crypto_history_orders,
45    query_crypto_max_buy_sell_qty, query_crypto_order_fees, query_crypto_order_fills,
46    query_crypto_order_info, query_crypto_order_related_fills, query_crypto_orders,
47    query_crypto_trade_configs,
48};
49pub use orders::{
50    OrderFillInfo, backend_deal_status_to_ftapi, backend_order_fill_qty_price_for_ftapi,
51    backend_order_status_to_ftapi, backend_order_type_to_ftapi,
52    backend_real_market_to_trd_market_like_cpp, derive_backend_market_list,
53    history_order_fill_list_cmd_for_env, history_order_list_cmd_for_env, init_trade_data,
54    is_valid_real_trd_market_like_cpp, order_fill_info_cmd_for_env, order_fill_list_cmd_for_env,
55    query_order_fill_info_strict_for_push_refresh, query_order_fills,
56    query_order_fills_strict_for_push_refresh, query_orders, query_orders_strict,
57    query_orders_strict_for_push_refresh, try_order_fill_proto_to_info_like_cpp,
58};
59pub use sim::{query_funds_sim, query_positions_sim};