feat: add selectable leverage threshold on ops map (90-300 step 10)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Vendored
+19
-1
@@ -126,6 +126,9 @@
|
||||
<label class="date-field">距离到期 ≥
|
||||
<select id="minHours" aria-label="距离到期最小小时数"></select>
|
||||
</label>
|
||||
<label class="date-field">达标线 ≥
|
||||
<select id="minLeverage" aria-label="杠杆达标线"></select>
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="tile"><div class="label">范围</div><div class="value" id="opsRange" style="font-size:1.05rem">—</div><div class="hint" id="opsSamples">—</div></div>
|
||||
@@ -214,7 +217,7 @@
|
||||
</div>
|
||||
<script>
|
||||
const TOKEN_KEY = "mi_token";
|
||||
const state = { page: "dash", range: "day", side: "both", moveMode: "abs", minHours: 12, lastMov: null, authRequired: false, loadedUsername: "admin" };
|
||||
const state = { page: "dash", range: "day", side: "both", moveMode: "abs", minHours: 12, minLeverage: 100, lastMov: null, authRequired: false, loadedUsername: "admin" };
|
||||
function getToken() { try { return localStorage.getItem(TOKEN_KEY); } catch { return null; } }
|
||||
function setToken(t) { try { if (t) localStorage.setItem(TOKEN_KEY, t); else localStorage.removeItem(TOKEN_KEY); } catch {} }
|
||||
function authHeaders() {
|
||||
@@ -246,6 +249,16 @@
|
||||
sel.appendChild(opt);
|
||||
}
|
||||
})();
|
||||
(function initMinLeverage() {
|
||||
const sel = document.getElementById("minLeverage");
|
||||
for (let v = 90; v <= 300; v += 10) {
|
||||
const opt = document.createElement("option");
|
||||
opt.value = String(v);
|
||||
opt.textContent = String(v);
|
||||
if (v === state.minLeverage) opt.selected = true;
|
||||
sel.appendChild(opt);
|
||||
}
|
||||
})();
|
||||
|
||||
function showLogin() {
|
||||
document.getElementById("page-login").classList.remove("hidden");
|
||||
@@ -557,6 +570,10 @@
|
||||
state.minHours = Number(document.getElementById("minHours").value) || 12;
|
||||
loadOps();
|
||||
});
|
||||
document.getElementById("minLeverage").addEventListener("change", () => {
|
||||
state.minLeverage = Number(document.getElementById("minLeverage").value) || 100;
|
||||
loadOps();
|
||||
});
|
||||
|
||||
function drawChart(buckets, minLev) {
|
||||
const svg = document.getElementById("levChart");
|
||||
@@ -704,6 +721,7 @@
|
||||
bucket_minutes: "60",
|
||||
date,
|
||||
min_hours: String(state.minHours || 12),
|
||||
min_leverage: String(state.minLeverage || 100),
|
||||
});
|
||||
try {
|
||||
const d = await apiFetch("/api/stats/ops-map?" + q).then(r => {
|
||||
|
||||
Reference in New Issue
Block a user