1
This commit is contained in:
parent
154f1fbf1d
commit
d3ca06a8ad
|
|
@ -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 的可在交易所按需补挂或保持现状。
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user