// ==================== 辅助函数(格式化) ==================== function formatTimestamp(ms) { if (!ms || ms === 0) return '—'; try { return new Date(parseInt(ms)).toLocaleString('zh-CN', { hour12: false }); } catch(e) { return ms; } } function formatPrice(v) { if (v === undefined || v === null) return '—'; let n = parseFloat(v); if (isNaN(n)) return v; if (Math.abs(n) > 1e6) return n.toFixed(2); if (Math.abs(n) > 1) return n.toFixed(4); return n.toFixed(8); } function copyToClipboard(text, successMsg) { navigator.clipboard.writeText(text).then(() => { alert(successMsg || '已复制到剪贴板'); }).catch(err => { console.error('复制失败:', err); alert('复制失败,请手动复制'); }); } function tableToText(tableElement) { const rows = tableElement.querySelectorAll('tr'); let textRows = []; rows.forEach(row => { const cells = row.querySelectorAll('th, td'); const cellTexts = Array.from(cells).map(cell => { if (cell.querySelector('button')) return ''; return cell.innerText.trim(); }).filter(t => t !== ''); if (cellTexts.length > 0) textRows.push(cellTexts.join('\t')); }); return textRows.join('\n'); } // ==================== 公共排序函数 ==================== /** * 对币种符号数组进行排序(按预设顺序:BTC, ETH, SOL, LINK, AVAX, BNB, LTC) * @param {Array} symbols 币种符号数组 * @returns {Array} 排序后的数组 */ function sortSymbols(symbols) { const orderHint = ['BTCUSDT', 'ETHUSDT', 'SOLUSDT', 'LINKUSDT', 'AVAXUSDT', 'BNBUSDT', 'LTCUSDT']; return symbols.sort((a, b) => { let ia = orderHint.indexOf(a), ib = orderHint.indexOf(b); if (ia !== -1 && ib !== -1) return ia - ib; if (ia !== -1) return -1; if (ib !== -1) return 1; return a.localeCompare(b); }); } // ==================== 动态指标卡片常量 ==================== const MACRO_ITEMS = [ ['macro_close_4h', 'MACRO BTC 4H 收盘价', ''], ['macro_ema200_4h', 'MACRO BTC 4H EMA200', ''], ['macro_adx_4h', 'MACRO BTC 4H ADX', ''], ['macro_drop_4h_pct', 'MACRO BTC 4H 跌幅 (%)', '%'], ['macro_rsi_prelim_4h', 'MACRO BTC 4H RSI (初步筛选)', ''], ['macro_ema20_4h', 'MACRO BTC 4H EMA20', ''], ['macro_ema50_4h', 'MACRO BTC 4H EMA50', ''], ['macro_ema100_4h', 'MACRO BTC 4H EMA100', ''], ['macro_volume_4h', 'MACRO BTC 4H 成交量', ''], ['macro_macd_line_1h', 'MACRO BTC 1H MACD 线', ''], ['macro_macd_signal_1h', 'MACRO BTC 1H MACD 信号线', ''], ['macro_adx_1h', 'MACRO BTC 1H ADX (L1)', ''], ['macro_volume_1h', 'MACRO BTC 1H 成交量', ''], ['macro_vol_sma20_1h', 'MACRO BTC 1H 成交量SMA20', ''], ['macro_pivot_high_15m', 'MACRO BTC 15m Pivot High', ''], ['macro_pivot_low_15m', 'MACRO BTC 15m Pivot Low', ''], ['macro_volume_5m', 'MACRO BTC 5m 成交量', ''], ['macro_vol_sma20_5m', 'MACRO BTC 5m 成交量SMA20', ''], ['macro_pivot_high_5m', 'MACRO BTC 5m Pivot High', ''], ['macro_pivot_low_5m', 'MACRO BTC 5m Pivot Low', ''] ]; const CURRENT_ITEMS = [ ['current_close_4h', 'CURRENT 4H 收盘价', ''], ['current_ema20_4h', 'CURRENT 4H EMA20', ''], ['current_ema50_4h', 'CURRENT 4H EMA50', ''], ['current_ema100_4h', 'CURRENT 4H EMA100', ''], ['current_volume_4h', 'CURRENT 4H 成交量', ''], ['current_quoteVolume_4h', 'CURRENT 4H 成交额', ''], ['current_rsi14_4h', 'CURRENT 4H RSI14', ''], ['current_drop_4h_pct', 'CURRENT 4H 跌幅 (%)', '%'], ['current_trend_4h', 'CURRENT 4H 趋势', ''], ['current_close_1h', 'CURRENT 1H 收盘价', ''], ['current_ema20_1h', 'CURRENT 1H EMA20', ''], ['current_ema50_1h', 'CURRENT 1H EMA50', ''], ['current_ema100_1h', 'CURRENT 1H EMA100', ''], ['current_volume_1h', 'CURRENT 1H 成交量', ''], ['current_vol_sma20_1h', 'CURRENT 1H 成交量SMA20', ''], ['current_rsi14_1h', 'CURRENT 1H RSI14', ''], ['current_macd_line_1h', 'CURRENT 1H MACD 线', ''], ['current_macd_signal_1h', 'CURRENT 1H MACD 信号线', ''], ['current_macd_hist_1h', 'CURRENT 1H MACD 柱', ''], ['current_adx_1h', 'CURRENT 1H ADX', ''], ['current_trend_1h', 'CURRENT 1H 趋势', ''], ['current_close_5m', 'CURRENT 5m 收盘价', ''], ['current_volume_5m', 'CURRENT 5m 成交量', ''], ['current_vol_sma20_5m', 'CURRENT 5m 成交量SMA20', ''], ['current_rsi14_5m', 'CURRENT 5m RSI (L2)', ''], ['current_atr14_5m', 'CURRENT 5m ATR(14)', ''], ['current_atr_sma20_5m', 'CURRENT 5m ATR SMA20', ''], ['current_recent_low20_5m', 'CURRENT 5m 近期低点(20)', ''], ['current_avg_body20_5m', 'CURRENT 5m 平均实体(20)', ''], ['current_pivot_high_5m', 'CURRENT 5m Pivot High', ''], ['current_pivot_low_5m', 'CURRENT 5m Pivot Low', ''], ['current_prev_pivot_high_5m', 'CURRENT 5m 前一Pivot High', ''], ['current_prev_pivot_low_5m', 'CURRENT 5m 前一Pivot Low', ''], ['current_big_green_5m', 'CURRENT 5m 大阳线', '', 'bool'], ['current_flash_move_5m', 'CURRENT 5m 急跌', '', 'bool'], ['current_pivot_low_15m', 'CURRENT 15m Pivot Low', ''], ['current_prev_pivot_low_15m', 'CURRENT 15m 前一Pivot Low', ''], ['current_L1_total_score', 'CURRENT L1 总分', ''], ['current_L2_total_score', 'CURRENT L2 总分', ''], ['current_L1_go', 'CURRENT L1 通过', '', 'bool'], ['current_L2_go', 'CURRENT L2 通过', '', 'bool'] ];