暗夜模式开关、表格折叠、振幅算法说明与悬停计算明细

This commit is contained in:
2026-07-23 22:55:25 +08:00
parent 297ce190be
commit 2a1e0bd2f6
+94 -10
View File
@@ -5,24 +5,47 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>振幅锁仓策略 — SA2611 & FG2611</title> <title>振幅锁仓策略 — SA2611 & FG2611</title>
<style> <style>
body { font-family: -apple-system, 'Segoe UI', system-ui, sans-serif; padding: 24px; max-width: 1100px; margin: 0 auto; color: #1e293b; } :root {
--bg: #fff; --fg: #1e293b; --sub: #64748b;
--th-bg: #f1f5f9; --th-fg: #334155; --th-border: #cbd5e1;
--td-border: #e2e8f0; --td-even: #f8fafc; --td-first: #334155;
--na: #94a3b8;
}
[data-theme="dark"] {
--bg: #0f172a; --fg: #e2e8f0; --sub: #94a3b8;
--th-bg: #1e293b; --th-fg: #cbd5e1; --th-border: #334155;
--td-border: #1e293b; --td-even: #1a2332; --td-first: #e2e8f0;
--na: #64748b;
}
body { font-family: -apple-system, 'Segoe UI', system-ui, sans-serif; padding: 24px; max-width: 1100px; margin: 0 auto; color: var(--fg); background: var(--bg); }
h1 { font-size: 1.4rem; margin-bottom: 8px; } h1 { font-size: 1.4rem; margin-bottom: 8px; }
.sub { color: #64748b; font-size: 0.85rem; margin-bottom: 28px; } .sub { color: var(--sub); font-size: 0.85rem; margin-bottom: 28px; }
.formula { color: var(--sub); font-size: 0.8rem; margin-bottom: 20px; padding: 6px 12px; background: var(--th-bg); border-radius: 4px; display: inline-block; }
h2 { font-size: 1.1rem; margin: 28px 0 10px; } h2 { font-size: 1.1rem; margin: 28px 0 10px; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; } table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th { background: #f1f5f9; color: #334155; font-weight: 600; padding: 8px 10px; border: 1px solid #cbd5e1; text-align: center; white-space: nowrap; } th { background: var(--th-bg); color: var(--th-fg); font-weight: 600; padding: 8px 10px; border: 1px solid var(--th-border); text-align: center; white-space: nowrap; }
td { padding: 6px 10px; border: 1px solid #e2e8f0; text-align: center; } td { padding: 6px 10px; border: 1px solid var(--td-border); text-align: center; }
tr:nth-child(even) td { background: #f8fafc; } tr:nth-child(even) td { background: var(--td-even); }
td:first-child { font-weight: 500; color: #334155; } td:first-child { font-weight: 500; color: var(--td-first); }
.na { color: #94a3b8; } .na { color: var(--na); }
.toggle { position: fixed; top: 16px; right: 24px; background: var(--th-bg); border: 1px solid var(--th-border); color: var(--th-fg); padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 0.82rem; z-index: 10; }
.section h2 { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px; }
.section h2 .arrow { display: inline-block; transition: transform .2s; font-size: 0.8rem; }
.section.collapsed h2 .arrow { transform: rotate(-90deg); }
.tip { position: fixed; pointer-events: none; z-index: 100; background: var(--th-bg); color: var(--fg); border: 1px solid var(--th-border); padding: 8px 12px; border-radius: 6px; font-size: 0.8rem; line-height: 1.6; white-space: pre; box-shadow: 0 4px 12px rgba(0,0,0,.25); display: none; max-width: 220px; }
.section.collapsed table { display: none; }
.toggle:hover { opacity: 0.8; }
</style> </style>
</head> </head>
<body> <body>
<button class="toggle" id="toggle" onclick="toggleTheme()">🌙 暗夜</button>
<h1>振幅锁仓策略</h1> <h1>振幅锁仓策略</h1>
<p class="sub">SA2611 (纯碱) &nbsp;|&nbsp; FG2611 (玻璃) &nbsp;|&nbsp; 2026年7月</p> <p class="sub">SA2611 (纯碱) &nbsp;|&nbsp; FG2611 (玻璃) &nbsp;|&nbsp; 2026年7月</p>
<p class="formula">振幅算法:近 5 日均振幅 = 过去 5 个交易日 (最高 − 最低) 的均值</p>
<h2>SA2611 纯碱</h2> <div class="section collapsed" id="sa-section">
<h2 onclick="toggleSection('sa-section')"><span class="arrow"></span> SA2611 纯碱</h2>
<table> <table>
<tr><th>日期</th><th>开盘</th><th>收盘</th><th>最高</th><th>最低</th><th>最高最低差价</th><th>振幅</th></tr> <tr><th>日期</th><th>开盘</th><th>收盘</th><th>最高</th><th>最低</th><th>最高最低差价</th><th>振幅</th></tr>
<tr><td>2026/7/1</td><td>1117</td><td>1118</td><td>1128</td><td>1112</td><td>16</td><td class="na">-</td></tr> <tr><td>2026/7/1</td><td>1117</td><td>1118</td><td>1128</td><td>1112</td><td>16</td><td class="na">-</td></tr>
@@ -44,8 +67,10 @@
<tr><td>2026/7/23</td><td>1042</td><td>1037</td><td>1046</td><td>1026</td><td>20</td><td>23</td></tr> <tr><td>2026/7/23</td><td>1042</td><td>1037</td><td>1046</td><td>1026</td><td>20</td><td>23</td></tr>
<tr><td>2026/7/24</td><td class="na">-</td><td class="na">-</td><td class="na">-</td><td class="na">-</td><td>0</td><td>22</td></tr> <tr><td>2026/7/24</td><td class="na">-</td><td class="na">-</td><td class="na">-</td><td class="na">-</td><td>0</td><td>22</td></tr>
</table> </table>
</div>
<h2>FG2611 玻璃</h2> <div class="section collapsed" id="fg-section">
<h2 onclick="toggleSection('fg-section')"><span class="arrow"></span> FG2611 玻璃</h2>
<table> <table>
<tr><th>日期</th><th>开盘</th><th>收盘</th><th>最高</th><th>最低</th><th>最高最低差价</th><th>振幅</th></tr> <tr><th>日期</th><th>开盘</th><th>收盘</th><th>最高</th><th>最低</th><th>最高最低差价</th><th>振幅</th></tr>
<tr><td>2026/7/1</td><td>1011</td><td>1001</td><td>1011</td><td>994</td><td>17</td><td class="na">-</td></tr> <tr><td>2026/7/1</td><td>1011</td><td>1001</td><td>1011</td><td>994</td><td>17</td><td class="na">-</td></tr>
@@ -67,6 +92,65 @@
<tr><td>2026/7/23</td><td>938</td><td>931</td><td>941</td><td>925</td><td>16</td><td>20</td></tr> <tr><td>2026/7/23</td><td>938</td><td>931</td><td>941</td><td>925</td><td>16</td><td>20</td></tr>
<tr><td>2026/7/24</td><td class="na">-</td><td class="na">-</td><td class="na">-</td><td class="na">-</td><td>0</td><td>19</td></tr> <tr><td>2026/7/24</td><td class="na">-</td><td class="na">-</td><td class="na">-</td><td class="na">-</td><td>0</td><td>19</td></tr>
</table> </table>
</div>
<div class="tip" id="tip"></div>
<script>
var btn = document.getElementById('toggle');
function setTheme(dark) {
document.documentElement.setAttribute('data-theme', dark ? 'dark' : '');
btn.textContent = dark ? '☀️ 日间' : '🌙 暗夜';
localStorage.setItem('theme', dark ? 'dark' : 'light');
}
function toggleTheme() { setTheme(!document.documentElement.hasAttribute('data-theme')); }
var saved = localStorage.getItem('theme');
if (saved === 'dark' || (!saved && window.matchMedia('(prefers-color-scheme: dark)').matches)) setTheme(true);
function toggleSection(id) { document.getElementById(id).classList.toggle('collapsed'); }
// 振幅 tooltip: 展示近 5 日计算明细
var tip = document.getElementById('tip');
document.querySelectorAll('table').forEach(function(tbl) {
var rows = tbl.querySelectorAll('tr');
var ranges = [];
for (var i = 1; i < rows.length; i++) {
var cells = rows[i].querySelectorAll('td');
if (cells.length < 7) continue;
var date = cells[0].textContent.trim();
var diff = parseInt(cells[5].textContent) || 0;
ranges.push({ date: date, diff: diff });
var ampCell = cells[6];
var ampVal = parseInt(ampCell.textContent);
if (isNaN(ampVal)) continue;
(function(cell, idx) {
var start = idx - 5;
if (start < 0) return;
var parts = [];
var sum = 0;
for (var j = start; j < idx; j++) {
parts.push(ranges[j].date + ': ' + ranges[j].diff);
sum += ranges[j].diff;
}
var text = parts.join('\n') + '\n───────\n合计 ' + sum + ' ÷ 5 = ' + (sum / 5).toFixed(1) + ' → ' + Math.round(sum / 5);
cell.style.cursor = 'help';
cell.addEventListener('mouseenter', function(e) {
tip.textContent = text;
tip.style.display = 'block';
});
cell.addEventListener('mousemove', function(e) {
var x = e.clientX + 14, y = e.clientY + 14;
if (x + 230 > window.innerWidth) x = e.clientX - 230;
if (y + 120 > window.innerHeight) y = e.clientY - 130;
tip.style.left = x + 'px';
tip.style.top = y + 'px';
});
cell.addEventListener('mouseleave', function() {
tip.style.display = 'none';
});
})(ampCell, ranges.length - 1);
}
});
</script>
</body> </body>
</html> </html>