Skip to main content

GenKeyArgs

Struct GenKeyArgs 

Source
pub struct GenKeyArgs {
Show 16 fields pub(crate) id: String, pub(crate) scopes: String, pub(crate) keys_file: Option<PathBuf>, pub(crate) expires: Option<String>, pub(crate) note: Option<String>, pub(crate) allowed_markets: Option<String>, pub(crate) allowed_symbols: Option<String>, pub(crate) max_order_value: Option<f64>, pub(crate) max_daily_value: Option<f64>, pub(crate) hours_window: Option<String>, pub(crate) max_orders_per_minute: Option<u32>, pub(crate) allowed_trd_sides: Option<String>, pub(crate) allowed_acc_ids: Option<String>, pub(crate) allowed_card_nums: Option<String>, pub(crate) bind_this_machine: bool, pub(crate) bind_machines: Option<String>,
}

Fields§

§id: String

人读 ID(审计日志用,必须唯一)

§scopes: String

授予的 scope,逗号分隔(v1.4.34+ 补齐 admin;详见 –help 的 scopes 长说明)

§keys_file: Option<PathBuf>

keys.json 路径。默认(按 OS):macOS ~/Library/Application Support/futu/keys.json / Linux ~/.config/futu/keys.json / Windows %APPDATA%/futu/keys.json

§expires: Option<String>

过期时间: Nd / Nh / Nm 或 RFC3339(如 2026-12-31T23:59:59Z)

§note: Option<String>

备注

§allowed_markets: Option<String>

允许的市场,逗号分隔(如 HK,US)

§allowed_symbols: Option<String>

允许的品种白名单,逗号分隔(MARKET.CODE 格式,如 HK.00700,HK.09988)

§max_order_value: Option<f64>

单笔订单金额上限

§max_daily_value: Option<f64>

单日累计金额上限

§hours_window: Option<String>

允许交易的时间窗口(服务器本地时区)HH:MM-HH:MM,跨午夜如 22:00-04:00

§max_orders_per_minute: Option<u32>

每 60s 最多下单次数(滑动窗口速率限制)

单笔金额 / 日累计之外再加一层防 spray-and-pray: 假设攻击者拿到一把 max_order_value = 50 的 key,没速率限制的话 一分钟能刷 N 千单;加了这个就被钳制在 max_orders_per_minute 内。

§allowed_trd_sides: Option<String>

允许的交易方向白名单,逗号分隔

典型用法:--allowed-trd-sides SELL → 只允许平仓 bot 卖; 值:BUY / SELL / SELL_SHORT / BUY_BACK(大小写敏感)。 改单 / 撤单路径不带 side,不受此限制(避免误伤运维操作)。

§allowed_acc_ids: Option<String>

v1.4.35: 允许的 acc_id 白名单,逗号分隔(如 10001,10002

operational safety:该 key 只能对这些 acc_id 发 trade / unlock / query 操作;超出列表的 acc_id 直接 403。None / 空 → 不限(向后兼容)。

典型用法(多 agent 隔离): --allowed-acc-ids 10001,10002 → bot-A 只能动 10001/10002 --allowed-acc-ids 10003 → bot-B 只能动 10003

注意:这是 operational 隔离(防 agent bug / LLM 幻觉 / key 泄露 爆炸半径),对纯现金策略用户实质等同财务隔离。真·财务隔离(融资 / 期权组合 / 跨品种保证金)需要多 union card,见 CLAUDE.md 隔离层级。

§allowed_card_nums: Option<String>

v1.4.103 (B10): per-key card_num 白名单, 逗号分隔.

接受 4 位 suffix (App 显示的 “保证金综合账户(<card-suffix>)” 末 4 位) 或 16 位完整 card_num (e.g. <full-card-num>). 示例为 synthetic placeholder, 不是真实账户信息. daemon 启动后通过 GetAccList resolve合并allowed_acc_ids (内部仍用 u64).

设计动机: App 用户看到的是 card_num, 不是内部 acc_id. 直接 写 4 位 / 16 位避免先调 /api/accounts 拿映射.

典型用法 (与 –allowed-acc-ids 等价但用 App 可见的号码): –allowed-card-nums → 末 4 位匹配的账户 –allowed-card-nums → 完整 card_num –allowed-card-nums , → 多个 (e.g. HK + US 各一)

多 suffix 撞 (短 4 位 match 多账户) → daemon 启动 log warn + skip (loud, 不静默接受). 找不到 → log warn + skip (cache load 后可补).

§bind_this_machine: bool

将 key 绑定到本机(软绑定:读 machine-id 计算指纹)

设置后 key 只能在本机使用;复制到别的机器会被拒。 可以和 --bind-machines 同时用来同时允许多台机器。

§bind_machines: Option<String>

追加绑定其他机器(需要对方先跑 futucli machine-id --for-key <id> 拿指纹)

逗号分隔的 64 位 hex 指纹列表,如: –bind-machines aabb…,ccdd…

Trait Implementations§

Source§

impl Args for GenKeyArgs

Source§

fn group_id() -> Option<Id>

Report the [ArgGroup::id][crate::ArgGroup::id] for this set of arguments
Source§

fn augment_args<'b>(__clap_app: Command) -> Command

Append to [Command] so it can instantiate Self via [FromArgMatches::from_arg_matches_mut] Read more
Source§

fn augment_args_for_update<'b>(__clap_app: Command) -> Command

Append to [Command] so it can instantiate self via [FromArgMatches::update_from_arg_matches_mut] Read more
Source§

impl FromArgMatches for GenKeyArgs

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more