pub struct Limits {
pub allowed_markets: Option<HashSet<String>>,
pub allowed_symbols: Option<HashSet<String>>,
pub max_order_value: Option<f64>,
pub max_daily_value: Option<f64>,
pub hours_window: Option<String>,
pub max_orders_per_minute: Option<u32>,
pub allowed_trd_sides: Option<HashSet<String>>,
pub allowed_acc_ids: Option<HashSet<u64>>,
pub allowed_card_nums: Option<Vec<String>>,
}Expand description
限额配置(与 KeyRecord 字段平级,独立出来便于传递)
Fields§
§allowed_markets: Option<HashSet<String>>§allowed_symbols: Option<HashSet<String>>§max_order_value: Option<f64>§max_daily_value: Option<f64>§hours_window: Option<String>§max_orders_per_minute: Option<u32>每分钟下单次数上限(滑动窗口,None 表示不限)。挡 spray-and-pray 类攻击:即使每单小于 max_order_value、日累计也够,也限制速率。
allowed_trd_sides: Option<HashSet<String>>允许的交易方向白名单:例如 ["SELL"] = 只让平仓 bot 卖;
None / 空集 → 不限。大小写敏感,用 "BUY" / "SELL" / "SELL_SHORT" / "BUY_BACK"。
allowed_acc_ids: Option<HashSet<u64>>v1.4.35 加(eli 回归报告建议 1):per-key acc_id 白名单
语义:该 key 只能对这些 acc_id 发 trade / unlock / query 操作;超出 列表的 acc_id 直接被 auth 层拒(403)。None / 空集 → 不限(向后兼容老 key)。
定位:operational safety(防 agent bug / LLM 幻觉 / key 泄露后爆炸半径)。 不等同 financial isolation —— 后者需要多 union card(L4,见 CLAUDE.md 隔离层级)。 对纯现金策略用户,L2 实质上等同财务隔离(没借钱就没传导)。
典型用法:
futucli gen-key --id bot-A --scopes trade:real,acc:read --allowed-acc-ids 10001,10002
futucli gen-key --id bot-B --scopes trade:real,acc:read --allowed-acc-ids 10003bot-A 只能动 10001/10002,bot-B 只能动 10003,互不影响。
allowed_card_nums: Option<Vec<String>>v1.4.103 (B10): per-key card_num 白名单 (string format).
daemon 启动后通过 GetAccList resolve → 合并进 allowed_acc_ids. 详见
[KeyRecord::allowed_card_nums].
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Limits
impl<'de> Deserialize<'de> for Limits
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Limits
impl RefUnwindSafe for Limits
impl Send for Limits
impl Sync for Limits
impl Unpin for Limits
impl UnsafeUnpin for Limits
impl UnwindSafe for Limits
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more