Research · TRUEFIX LABS
用 Rust 构建多券商交易系统
面向生产环境的 Provider 适配器、统一金融工具、订单生命周期、对账、风控和确定性执行指南。
简要回答。 多券商系统应把各 Provider API 隔离在适配器后面,并向系统其余部分提供统一的金融工具、行情、订单、持仓和能力模型。Rust 执行内核应保持确定性,显式建模未知结果,并把对账作为一等流程。
推荐架构
Use a layered design: provider clients at the edge, a normalization boundary for instruments and events, an order management system, a risk engine, an execution kernel, and durable audit storage. Provider selection belongs to a capability and entitlement layer, not to business logic that guesses from a broker name.
Provider API → Adapter → Canonical contracts → OMS → Risk → Execution → ReconciliationRust 设计选择
Use typed enums for order states, environments, sides, order types, and failure classes. Keep provider I/O asynchronous, but make the decision and risk path deterministic. Use cancellation-safe tasks, bounded channels, monotonic event sequence checks, and durable identifiers for every outbound request.
优先设计的失败模式
- Timeout after the provider accepted an order.
- WebSocket disconnect or sequence gaps.
- Symbol ambiguity across venues.
- Partial fills and fee currency differences.
- Position drift between local state and an account snapshot.
生产检查清单
Persist the original provider, client instance, account, environment, native symbol, client order ID, request revision, and evidence used for the decision. If an execution result is unknown, query the original identity and reconcile before considering any retry.
Sources
Last verified: 2026-09-28. Provider capabilities can change by region, account, product, environment, and entitlement; verify the linked official documentation before production use.
最后更新:2026-09-28