This commit is contained in:
薇薇安 2026-02-15 08:32:29 +08:00
parent 154f1fbf1d
commit d3ca06a8ad
2 changed files with 30 additions and 17 deletions

View File

@ -46,7 +46,18 @@
---
## 四、小结
## 四、配置日志与预设不一致时
- 配置已按盈利期对齐并写入代码与预设;**快速使用** = 前端点「山寨币策略(推荐)」或跑一遍 `update_config_profitable_alignment.sql`,再重启交易进程。
交易进程启动时打印的「交易配置」来自:**先读当前账号配置(风险旋钮),再补全局配置**。若出现与山寨推荐不一致,常见原因:
- **单笔最大仓位 2%、每日 250 笔、只做趋势 否、智能入场 关闭** 等:可能是 (1) 全局尚未应用「山寨币策略」或应用后未**重启交易进程**(2) 这些项属于**风险旋钮**,若在「我的配置」里改过,会按**账号**覆盖全局。
- **想让进程与山寨预设一致**:在「全局配置」页点「山寨币策略(推荐)」保存 → **重启该账号的交易进程**;若希望某账号与全局完全一致,不要在「我的配置」里覆盖仓位/每日笔数/只做趋势等。
**前端「山寨快速方案」选中**:已改为按当前全局配置与预设做**类型兼容**比较(如后端返回 `"8"` 与预设 `8` 视为一致),且后端未返回的 key 不参与匹配,避免因缺项导致永远不选中。应用预设后刷新页面应能看到「山寨币策略(推荐)」为选中状态。
---
## 五、小结
- 配置已按盈利期对齐并写入代码与预设;**快速使用** = 前端点「山寨币策略(推荐)」或跑一遍 `update_config_profitable_alignment.sql`,再**重启交易进程**。
- 当前持仓里 7 笔 SL/TP 已在合理范围4 笔无/缺 TP 的可在交易所按需补挂或保持现状。

View File

@ -908,7 +908,20 @@ const GlobalConfig = () => {
// account
const isGlobalStrategyAccount = isAdmin
// 0.65 *100
// string "8" / "true"
const valueMatches = (cur, exp, key) => {
if (exp === true || exp === false) {
const b = cur === true || cur === false ? cur : (cur === 'true' || String(cur).toLowerCase() === 'true')
return b === exp
}
if (typeof exp === 'number') {
const n = typeof cur === 'number' ? cur : parseFloat(cur)
if (Number.isNaN(n)) return false
const tolerance = (key && (key.includes('PERCENT') || key.includes('PCT'))) ? 0.001 : 0.0001
return Math.abs(n - exp) <= tolerance
}
return cur === exp
}
let currentPreset = null
if (configs && Object.keys(configs).length > 0 && presets) {
try {
@ -916,24 +929,13 @@ const GlobalConfig = () => {
let match = true
for (const [key, expectedValue] of Object.entries(preset.configs)) {
const currentConfig = configs[key]
if (!currentConfig) {
match = false
break
}
if (!currentConfig) continue // key
let cur = currentConfig.value
let exp = expectedValue
// 0.65 MAX_CHANGE_PERCENT_FOR_LONG 25 25%
if (key.includes('PERCENT') || key.includes('PCT')) {
if (typeof exp === 'number' && exp > 1) {
exp = exp / 100
}
if (typeof exp === 'number' && exp > 1) exp = exp / 100
}
if (typeof exp === 'number' && typeof cur === 'number') {
if (Math.abs(cur - exp) > 0.01) {
match = false
break
}
} else if (cur !== exp) {
if (!valueMatches(cur, exp, key)) {
match = false
break
}