Drop obsolete trade-execution and cooling sections from risk policy.
Options/hedge standalone no longer surfaces perpetual manual-risk blurbs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,16 +4,6 @@ from __future__ import annotations
|
||||
import os
|
||||
from typing import Any, Optional
|
||||
|
||||
from lib.trade.account_risk_lib import (
|
||||
cooling_hours_manual,
|
||||
cooling_hours_manual_journal,
|
||||
daily_loss_limit,
|
||||
manual_close_daily_limit,
|
||||
max_active_positions_from_env,
|
||||
mood_issues_daily_freeze_enabled,
|
||||
risk_control_enabled,
|
||||
)
|
||||
from lib.trade.position_sizing_lib import is_full_margin_mode, load_position_sizing_mode, mode_label_zh
|
||||
from lib.trade.trade_policy_lib import TradePolicy
|
||||
|
||||
|
||||
@@ -56,79 +46,13 @@ def build_instance_settings_view(
|
||||
open_guard_enabled: Optional[bool] = None,
|
||||
) -> dict[str, Any]:
|
||||
rs = risk_status or {}
|
||||
sizing_mode = load_position_sizing_mode()
|
||||
reset_hour = _env_int("TRADING_DAY_RESET_HOUR", 8)
|
||||
hard_limit = _env_int("DAILY_OPEN_HARD_LIMIT", 0)
|
||||
alert_threshold = _env_int("DAILY_OPEN_ALERT_THRESHOLD", 5)
|
||||
force_close_on = _env_bool("FORCE_CLOSE_ENABLED", False)
|
||||
force_close_hour = _env_int("FORCE_CLOSE_BJ_HOUR", 0)
|
||||
auto_transfer_on = _env_bool("AUTO_TRANSFER_ENABLED", False)
|
||||
guard_on = (
|
||||
bool(open_guard_enabled)
|
||||
if open_guard_enabled is not None
|
||||
else _env_bool("TRADING_DAY_RESET_OPEN_GUARD_ENABLED", True)
|
||||
)
|
||||
|
||||
sections: list[dict[str, Any]] = []
|
||||
|
||||
sections.append(
|
||||
{
|
||||
"title": "交易执行",
|
||||
"rows": [
|
||||
_row("最大同时持仓", str(max_active_positions_from_env())),
|
||||
_row("计仓模式", mode_label_zh(sizing_mode)),
|
||||
_row("以损定仓风险%", f"{_env_float('RISK_PERCENT', 2):g}%"),
|
||||
_row("人工最低盈亏比", f">= {_env_float('MANUAL_MIN_PLANNED_RR', 1.4):g}:1"),
|
||||
_row(
|
||||
"交易日切点",
|
||||
f"北京时间 {reset_hour}:00",
|
||||
"新交易日统计与部分开仓限制以此为准",
|
||||
),
|
||||
_row(
|
||||
"允许北京时间切点前开仓",
|
||||
"已放开(允许开仓)" if not guard_on else "已限制(禁止开仓)",
|
||||
f"关闭限制后,{reset_hour}:00 前也可斐波成交登记与人工下单;"
|
||||
"环境配置「切点前禁止新开仓」(TRADING_DAY_RESET_OPEN_GUARD_ENABLED)",
|
||||
),
|
||||
_row(
|
||||
"单日开仓提醒",
|
||||
f"第 {alert_threshold} 次",
|
||||
"达次数推送企业微信,不拦单",
|
||||
),
|
||||
_row(
|
||||
"单日开仓硬上限",
|
||||
str(hard_limit) if hard_limit > 0 else "未启用",
|
||||
"达上限后禁止一切新开仓直至下一交易日" if hard_limit > 0 else "",
|
||||
),
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
sections.append(
|
||||
{
|
||||
"title": "账户冷静期",
|
||||
"rows": [
|
||||
_row("风控总开关", _on_off(risk_control_enabled())),
|
||||
_row("手动平仓冷静", f"{cooling_hours_manual():g} 小时"),
|
||||
_row("复盘后冷静", f"{cooling_hours_manual_journal():g} 小时", "手动平仓且填写说明后可缩短"),
|
||||
_row("日手动平仓上限", f"{manual_close_daily_limit()} 次", "超限当日冻结"),
|
||||
_row(
|
||||
"日亏损次数上限",
|
||||
(
|
||||
f"{daily_loss_limit()} 次"
|
||||
if daily_loss_limit() > 0
|
||||
else "未启用"
|
||||
),
|
||||
"平仓亏损达限后当日冻结开仓;0=不启用" if daily_loss_limit() > 0 else "RISK_DAILY_LOSS_LIMIT=0",
|
||||
),
|
||||
_row(
|
||||
"复盘情绪日冻结",
|
||||
_on_off(mood_issues_daily_freeze_enabled()),
|
||||
"复盘勾选心态标签可触发当日冻结",
|
||||
),
|
||||
],
|
||||
}
|
||||
)
|
||||
# 期权/对冲独立版:不再展示永续「交易执行」「账户冷静期」说明
|
||||
|
||||
sections.append(
|
||||
{
|
||||
@@ -153,7 +77,7 @@ def build_instance_settings_view(
|
||||
}
|
||||
)
|
||||
|
||||
if (exchange_key or "").strip().lower() == "okx" and _env_bool("OKX_OPTIONS_ENABLED", False):
|
||||
if (exchange_key or "").strip().lower() == "okx" and _env_bool("OKX_OPTIONS_ENABLED", True):
|
||||
api_key = (os.getenv("OKX_API_KEY") or "").strip()
|
||||
sections.append(
|
||||
{
|
||||
@@ -187,7 +111,7 @@ def build_instance_settings_view(
|
||||
"data_export_version": int(data_export_version),
|
||||
"show_transfer": (exchange_key or "").strip().lower() in ("gate", "binance", "okx"),
|
||||
"options_settings_enabled": (exchange_key or "").strip().lower() == "okx"
|
||||
and _env_bool("OKX_OPTIONS_ENABLED", False),
|
||||
and _env_bool("OKX_OPTIONS_ENABLED", True),
|
||||
"auto_transfer_enabled": auto_transfer_on,
|
||||
"auto_transfer_bj_hour": _env_int("AUTO_TRANSFER_BJ_HOUR", 8),
|
||||
"auto_transfer_amount": _env_float("AUTO_TRANSFER_AMOUNT", 30),
|
||||
|
||||
Reference in New Issue
Block a user