This commit is contained in:
薇薇安 2026-01-31 10:35:55 +08:00
parent 380ce7cda9
commit cf86c64296

View File

@ -468,13 +468,35 @@ const GlobalConfig = () => {
} }
} }
//
const KNOWN_GLOBAL_CONFIG_DEFAULTS = {
MAX_RSI_FOR_LONG: { value: 70, type: 'number', category: 'strategy', description: '做多时 RSI 超过此值则不开多避免超买区追多。2026-01-31新增。' },
MAX_CHANGE_PERCENT_FOR_LONG: { value: 25, type: 'number', category: 'strategy', description: '做多时 24h 涨跌幅超过此值则不开多(避免追大涨)。单位:百分比数值,如 25 表示 25%。' },
MIN_RSI_FOR_SHORT: { value: 30, type: 'number', category: 'strategy', description: '做空时 RSI 低于此值则不做空避免深超卖反弹。2026-01-31新增。' },
MAX_CHANGE_PERCENT_FOR_SHORT: { value: 10, type: 'number', category: 'strategy', description: '做空时 24h 涨跌幅超过此值则不做空24h 仍大涨时不做空)。单位:百分比数值。' },
TAKE_PROFIT_1_PERCENT: { value: 0.15, type: 'number', category: 'strategy', description: '分步止盈第一目标(保证金百分比,如 0.15=15%。第一目标触发后了结50%仓位。' },
SCAN_EXTRA_SYMBOLS_FOR_SUPPLEMENT: { value: 8, type: 'number', category: 'scan', description: '智能补单:多返回的候选数量,冷却时仍可尝试后续交易对。' },
SYMBOL_LOSS_COOLDOWN_ENABLED: { value: true, type: 'boolean', category: 'strategy', description: '是否启用同一交易对连续亏损后的冷却。' },
SYMBOL_MAX_CONSECUTIVE_LOSSES: { value: 2, type: 'number', category: 'strategy', description: '最大允许连续亏损次数(超过则禁止交易该交易对一段时间)。' },
SYMBOL_LOSS_COOLDOWN_SEC: { value: 3600, type: 'number', category: 'strategy', description: '连续亏损后的冷却时间默认1小时。' },
BETA_FILTER_ENABLED: { value: true, type: 'boolean', category: 'strategy', description: '大盘共振过滤BTC/ETH 下跌时屏蔽多单。' },
BETA_FILTER_THRESHOLD: { value: -0.005, type: 'number', category: 'strategy', description: '大盘共振阈值(比例,如 -0.005 表示 -0.5%)。' },
}
const loadConfigs = async () => { const loadConfigs = async () => {
try { try {
// account // account
if (isAdmin) { if (isAdmin) {
const data = await api.getGlobalConfigs() const data = await api.getGlobalConfigs()
console.log('Loaded global configs:', data, 'Keys:', Object.keys(data || {})) //
setConfigs(data || {}) const merged = { ...(data || {}) }
Object.keys(KNOWN_GLOBAL_CONFIG_DEFAULTS).forEach(key => {
if (!(key in merged)) {
merged[key] = KNOWN_GLOBAL_CONFIG_DEFAULTS[key]
}
})
console.log('Loaded global configs:', Object.keys(merged).length, 'keys')
setConfigs(merged)
} else { } else {
// 访 // 访
setConfigs({}) setConfigs({})