2026-09-06 13:12:48 +08:00
|
|
|
"""账户启动概览日志。"""
|
|
|
|
|
|
|
|
|
|
import logging as log
|
|
|
|
|
|
|
|
|
|
import config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def Overview(assets, positions, account_cfg=None) -> None:
|
|
|
|
|
"""记录策略启动时的账户、资金和持仓概览。"""
|
|
|
|
|
account_cfg = account_cfg or config.account_config
|
|
|
|
|
|
|
|
|
|
if account_cfg is not None:
|
|
|
|
|
log.info(
|
|
|
|
|
"[启动] 账户=%s,主机=%s,单笔金额=%.2f",
|
|
|
|
|
account_cfg.account_id,
|
|
|
|
|
account_cfg.host_key,
|
|
|
|
|
account_cfg.buy_value,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if assets is not None:
|
|
|
|
|
log.info("[启动] 总资产=%.2f,可用资金=%.2f", assets.total, assets.available)
|
|
|
|
|
else:
|
|
|
|
|
log.warning("[启动] 获取资金概览失败")
|
|
|
|
|
|
|
|
|
|
for position in positions:
|
|
|
|
|
if position.volume <= 0:
|
|
|
|
|
continue
|
|
|
|
|
log.info(
|
2026-09-07 14:04:26 +08:00
|
|
|
"[启动] %s %s,持仓=%d,可用=%d,成本=%.2f(%.2f),现价=%.2f,盈亏=%.2f%%",
|
2026-09-06 13:12:48 +08:00
|
|
|
position.stock_code,
|
|
|
|
|
position.stock_name,
|
|
|
|
|
position.volume,
|
|
|
|
|
position.can_use_volume,
|
|
|
|
|
position.open_price,
|
|
|
|
|
position.open_cost,
|
|
|
|
|
position.last_price,
|
|
|
|
|
position.profit_rate * 100,
|
|
|
|
|
)
|