function renderParameterList(params, state) {
if (!params) {
const errorDiv = document.createElement('div');
errorDiv.className = 'no-data';
errorDiv.textContent = '❌ 参数数据为空,无法渲染';
return errorDiv;
}
const template = document.getElementById('template-param-container');
if (!template) {
const errorDiv = document.createElement('div');
errorDiv.className = 'no-data';
errorDiv.textContent = '❌ 参数模板 (template-param-container) 不存在,请检查 HTML';
return errorDiv;
}
const clone = template.content.cloneNode(true);
const b1Grid = clone.querySelector('[data-section="B1"] .param-grid');
const b2Grid = clone.querySelector('[data-section="B2"] .param-grid');
const b3Grid = clone.querySelector('[data-section="B3"] .param-grid');
if (!b1Grid || !b2Grid || !b3Grid) {
const errorDiv = document.createElement('div');
errorDiv.className = 'no-data';
errorDiv.textContent = '❌ 参数模板结构错误,缺少 .param-grid 容器';
return errorDiv;
}
b1Grid.innerHTML = '';
b2Grid.innerHTML = '';
b3Grid.innerHTML = '';
// 移除了内部的 formatValue 函数,改用全局 formatParamValue (定义在 04.02_Utils.php)
const macroB1Keys = ['MACRO_ADX_THRESHOLD', 'MACRO_ADX_LEN'];
const allB1Keys = [
'DROP_THRESHOLD_PCT', 'MACRO_ADX_THRESHOLD', 'MACRO_ADX_LEN',
'L1_ADX_THRESHOLD', 'L1_ADX_LEN', 'RSI_PRELIM_THRESHOLD', 'RSI_PRELIM_LEN',
'RSI_L2_THRESHOLD', 'RSI_L2_LEN', 'BIG_GREEN_MULTIPLIER', 'BIG_GREEN_COOLDOWN_SEC',
'FLASH_MOVE_THRESHOLD_PCT', 'MACD_FAST', 'MACD_SLOW', 'MACD_SIGNAL',
'ATR_LEN', 'ATR_SMA_LEN', 'RECENT_LOW_PERIOD', 'PIVOT_LEN', 'TURNOVER_THRESHOLDS'
];
const macroDiv = document.createElement('div');
macroDiv.innerHTML = '[MACRO] 宏观阈值
';
const currentDiv = document.createElement('div');
currentDiv.innerHTML = '[CURRENT] 交易币种阈值
';
b1Grid.appendChild(macroDiv);
b1Grid.appendChild(currentDiv);
for (let key of allB1Keys) {
if (params[key] !== undefined) {
const itemDiv = document.createElement('div');
// 使用全局 formatParamValue 进行格式化
itemDiv.innerHTML = `${key}: ${formatParamValue(key, params[key])}`;
if (macroB1Keys.includes(key)) macroDiv.appendChild(itemDiv);
else currentDiv.appendChild(itemDiv);
}
}
const macroDiv2 = document.createElement('div');
macroDiv2.innerHTML = '[MACRO] 宏观共用参数
';
const currentDiv2 = document.createElement('div');
currentDiv2.innerHTML = '[CURRENT] 交易币种列表
';
b2Grid.appendChild(macroDiv2);
b2Grid.appendChild(currentDiv2);
if (params['MACRO_BASE'] !== undefined) {
const itemDiv = document.createElement('div');
itemDiv.innerHTML = `MACRO_BASE: ${params['MACRO_BASE']}`;
macroDiv2.appendChild(itemDiv);
}
if (params['EMA_PERIODS'] !== undefined) {
const itemDiv = document.createElement('div');
// 也可以使用 formatParamValue,但为了与旧格式一致,保持原样(join)
itemDiv.innerHTML = `EMA_PERIODS: ${params['EMA_PERIODS'].join(', ')}`;
macroDiv2.appendChild(itemDiv);
}
// 根据当前激活的数据源显示对应的币种列表
let activeCoins = [];
if (state && state.activeSource) {
if (state.activeSource === 'mexc' && params['MEXC_COINS']) {
activeCoins = params['MEXC_COINS'];
currentDiv2.innerHTML = '[CURRENT] 交易币种列表 (MEXC 4币种)
';
} else if (state.activeSource === 'binance' && params['BINANCE_COINS']) {
activeCoins = params['BINANCE_COINS'];
currentDiv2.innerHTML = '[CURRENT] 交易币种列表 (Binance 7币种)
';
} else {
// 默认显示 MEXC 列表(如果存在)
if (params['MEXC_COINS']) activeCoins = params['MEXC_COINS'];
}
} else {
// 未选择数据源时,默认显示 MEXC 列表
if (params['MEXC_COINS']) activeCoins = params['MEXC_COINS'];
}
if (activeCoins.length > 0) {
const itemDiv = document.createElement('div');
itemDiv.innerHTML = `当前币种: ${activeCoins.join(', ')}`;
currentDiv2.appendChild(itemDiv);
} else {
const itemDiv = document.createElement('div');
itemDiv.innerHTML = `当前币种: 未选择数据源,请先点击 MEXC 或 Binance 按钮`;
currentDiv2.appendChild(itemDiv);
}
const scoringKeys = ['L1_PASS_SCORE', 'L2_PASS_SCORE', 'L1_MAX_SCORE', 'L2_MAX_SCORE'];
const scoringDiv = document.createElement('div');
scoringDiv.innerHTML = '[CURRENT] 评分阈值
';
b3Grid.appendChild(scoringDiv);
for (let key of scoringKeys) {
if (params[key] !== undefined) {
const itemDiv = document.createElement('div');
itemDiv.innerHTML = `${key}: ${params[key]}`;
scoringDiv.appendChild(itemDiv);
}
}
return clone;
}