diff --git a/docs/env配置说明.md b/docs/env配置说明.md index 176dc6a..bcb1e26 100644 --- a/docs/env配置说明.md +++ b/docs/env配置说明.md @@ -107,8 +107,8 @@ AI 相关环境变量(`AI_PROVIDER`,`OPENAI_*`,`OLLAMA_*`,`AI_MODEL`,`AI_TIMEOUT | 切点前禁止新开仓 | | | 最大同时持仓 | | | 人工最低盈亏比 | | -| 强制清仓开关 | | -| 强制清仓整点(北京) | | +| 强制清仓开关 | `FORCE_CLOSE_ENABLED`;开启后在指定北京整点小时内,市价平掉本地 active 监控仓 | +| 强制清仓整点(北京) | `FORCE_CLOSE_BJ_HOUR`(0–23);例 `8` 表示 08:00~08:59;仅扫监控仓,不含交易所裸仓 | --- diff --git a/docs/strategy/gate-intraday.md b/docs/strategy/gate-intraday.md index 661a929..049df7f 100644 --- a/docs/strategy/gate-intraday.md +++ b/docs/strategy/gate-intraday.md @@ -186,21 +186,22 @@ - **禁止** 盘中亏着 **手点平仓** 充当止损(破坏统计与连错规则). - 若违规手动平亏:**视为当日纪律失败,建议停手**;复盘结果 **不得** 记为「止损」糊弄统计. -### 9.3 时间出场:仅 0 点(程序已实现) +### 9.3 时间出场:整点强制清仓(程序已实现,可开关) -- **唯一** 时间类出场:**当日 0:00(北京时间)前必须空仓**(赚赔都平). - **不使用** 下单表单里的 1h / 2h / 4h「开仓后 N 小时平」(`time_close`);与本策略无关. -- **程序兜底**(三所共用,Gate 已启用): +- **程序兜底**(三所共用;Gate 可用 env 开关): | env | 说明 | |-----|------| -| `FORCE_CLOSE_ENABLED=true` | 开启整点强制清仓 | -| `FORCE_CLOSE_BJ_HOUR=0` | 北京时间 **0 点那一小时**(00:00~00:59)执行 | +| `FORCE_CLOSE_ENABLED` | `true` 开启 / `false` 关闭整点强制清仓 | +| `FORCE_CLOSE_BJ_HOUR` | 北京时间整点小时(如 `0`=`00:00~00:59`,`8`=`08:00~08:59`) | - 实现:`force_close_before_reset()`(各实例 `app.py` 后台循环调用). -- 行为:对该小时仍 **active** 的 `order_monitors` **市价全平**,取消交易所触发单,写交易记录. -- **系统结果字段**:`result = 强制清仓`;备注含「北京时间 0:00 整点风控清仓」. -- **策略口语「0 点平仓」= 系统「强制清仓」**,统计连错时按 §8 盈亏判定,不按字段名区分. +- 行为:开启时,在该整点小时内对仍 **active** 的 `order_monitors` **市价全平**,取消交易所触发单,写交易记录. +- **系统结果字段**:`result = 强制清仓`;备注含「北京时间 X:00 整点风控清仓」. +- **仅扫本地监控仓**;交易所裸仓且无 active 监控时**不会**被此逻辑平掉. +- UI:开仓规则说明「平仓 / 委托 / 强制清仓」折叠区 + 顶栏徽章(开启时). +- 持仓卡可手动「平仓 / 委托 / 撤止盈止损」(与纪律策略并行;策略上仍不建议亏着手平充当止损). > **与 `TRADING_DAY_RESET_HOUR=8` 无关**:后者只切 **交易日**(统计,8 点前禁开等),**不会**自动平仓. @@ -244,16 +245,16 @@ | 项 | 说明 | |----|------| | 日内 profile 判定 | `is_intraday_trading_profile()`(`lib/trade/entry_model_lib.py`) | -| 0 点强制清仓 | `FORCE_CLOSE_ENABLED` + `FORCE_CLOSE_BJ_HOUR`;`force_close_before_reset()`;结果 **`强制清仓`** | -| UI 标识 | 顶栏 **强制清仓 已开启** 徽章 + 持仓卡片 **倒计时**(三所 + 中控) | +| 整点强制清仓 | `FORCE_CLOSE_ENABLED` + `FORCE_CLOSE_BJ_HOUR`;`force_close_before_reset()`;结果 **`强制清仓`** | +| UI 标识 | 顶栏徽章(开启时) + 开仓规则说明折叠区;持仓卡可手动平仓/委托 | | 交易记录展示 | 三所 UI / 中控:`强制清仓` 与止损同类 badge | -| 三所统一 | 币安 / OKX / Gate 同一函数与 env;**将来改日内只需各所 `.env` 打开,无需改代码** | +| 三所统一 | 币安 / OKX / Gate 同一函数与 env;**改日内只需各所 `.env`**,无需改代码 | -Gate 当前建议 env(节选): +Gate 示例 env(节选;是否开启按账户纪律决定): ```env -FORCE_CLOSE_ENABLED=true -FORCE_CLOSE_BJ_HOUR=0 +FORCE_CLOSE_ENABLED=false +FORCE_CLOSE_BJ_HOUR=8 TRADING_DAY_RESET_HOUR=8 ``` diff --git a/lib/instance/templates/embed_boot_scripts.html b/lib/instance/templates/embed_boot_scripts.html index b2e3d70..7c2edba 100644 --- a/lib/instance/templates/embed_boot_scripts.html +++ b/lib/instance/templates/embed_boot_scripts.html @@ -741,13 +741,10 @@ function paintExchangeTpslRow(orderId, tpsl){ const tpText = document.getElementById(`ex-tp-text-${orderId}`); const slBtn = document.getElementById(`ex-sl-cancel-${orderId}`); const tpBtn = document.getElementById(`ex-tp-cancel-${orderId}`); - const intraday = (document.body && document.body.getAttribute("data-intraday-discipline")) === "1"; if(slText) slText.innerText = formatExTpslLine('sl', data.sl); if(tpText) tpText.innerText = formatExTpslLine('tp', data.tp); - if(!intraday){ - if(slBtn) slBtn.disabled = !(data.sl && data.sl.order_id); - if(tpBtn) tpBtn.disabled = !(data.tp && data.tp.order_id); - } + if(slBtn) slBtn.disabled = !(data.sl && data.sl.order_id); + if(tpBtn) tpBtn.disabled = !(data.tp && data.tp.order_id); } function toggleTpslModalMode(){ const mode = (document.getElementById('tpsl-modal-mode')||{}).value || 'price'; diff --git a/lib/instance/templates/embed_page_fragment.html b/lib/instance/templates/embed_page_fragment.html index 285148a..e49a528 100644 --- a/lib/instance/templates/embed_page_fragment.html +++ b/lib/instance/templates/embed_page_fragment.html @@ -175,10 +175,8 @@ {{ '做多' if o.direction == 'long' else '做空' }}
FORCE_CLOSE_ENABLED=false);开启后按 FORCE_CLOSE_BJ_HOUR 在北京时间该整点小时内清掉 active 监控仓。
+ {% endif %}
+ 仅影响本系统监控中的仓;交易所裸仓且无本地监控时不会被此逻辑平掉。
+