fix trend,zt
This commit is contained in:
39
py-client/libs/overview.py
Normal file
39
py-client/libs/overview.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""账户启动概览日志。"""
|
||||
|
||||
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(
|
||||
"[启动] %s %s %s,持仓=%d,可用=%d,成本=%.2f(%.2f),现价=%.2f,盈亏=%.2f%%",
|
||||
position.trade_id,
|
||||
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,
|
||||
)
|
||||
Reference in New Issue
Block a user