feat(mse): dynamic whale threshold/scale based on 24h quote volume

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mukan Erkin TÖRÜK 2026-04-25 13:46:18 +03:00
parent b3975789fa
commit 78657f5ff4

View file

@ -451,9 +451,16 @@ async function loadTicker() {
document.getElementById('pb-low').textContent = fmt(t.lowPrice); document.getElementById('pb-low').textContent = fmt(t.lowPrice);
const vol = parseFloat(t.quoteVolume); const vol = parseFloat(t.quoteVolume);
document.getElementById('pb-vol').textContent = vol >= 1e9 ? (vol/1e9).toFixed(2)+'B' : vol >= 1e6 ? (vol/1e6).toFixed(2)+'M' : fmt(vol, 0); document.getElementById('pb-vol').textContent = vol >= 1e9 ? (vol/1e9).toFixed(2)+'B' : vol >= 1e6 ? (vol/1e6).toFixed(2)+'M' : fmt(vol, 0);
setWhaleLimits(vol);
} catch(e) {} } catch(e) {}
} }
function setWhaleLimits(dailyVolume) {
// günlük hacmin %0.01'i = balina eşiği, %0.5'i = max çember boyutu
whaleThreshold = Math.max(5000, dailyVolume * 0.0001);
whaleScaleAt = Math.max(50000, dailyVolume * 0.005);
}
function startPriceWs() { function startPriceWs() {
if (priceWs) priceWs.close(); if (priceWs) priceWs.close();
const sym = bot.symbol.toLowerCase(); const sym = bot.symbol.toLowerCase();
@ -615,11 +622,12 @@ function drawSupportResistance(candles) {
} }
// ── Whale trades (aggTrade canvas overlay) ──────── // ── Whale trades (aggTrade canvas overlay) ────────
const WHALE_THRESHOLD = 10000; // USDT const WHALE_MAX_AGE = 120; // saniye, ekranda kalma süresi
const WHALE_MAX_AGE = 120; // saniye, ekranda kalma süresi const WHALE_MAX_R = 28; // maks çember yarıçapı (px)
const WHALE_MAX_R = 28; // maks çember yarıçapı (px) const WHALE_MIN_R = 6; // min çember yarıçapı (px)
const WHALE_MIN_R = 6; // min çember yarıçapı (px) // eşik ve skala günlük hacme göre dinamik hesaplanır (setWhaleLimits)
const WHALE_SCALE_AT = 500000; // bu hacimde max boyuta ulaşır let whaleThreshold = 50000;
let whaleScaleAt = 500000;
let whaleCanvas = null; let whaleCanvas = null;
let whaleCtx = null; let whaleCtx = null;
@ -636,7 +644,7 @@ function startAggTradeWs() {
const price = parseFloat(t.p); const price = parseFloat(t.p);
const qty = parseFloat(t.q); const qty = parseFloat(t.q);
const usdtVal = price * qty; const usdtVal = price * qty;
if (usdtVal < WHALE_THRESHOLD) return; if (usdtVal < whaleThreshold) return;
whaleTrades.push({ price, qty, isBuy: !t.m, usdtVal, ts: Date.now() / 1000 }); whaleTrades.push({ price, qty, isBuy: !t.m, usdtVal, ts: Date.now() / 1000 });
if (whaleTrades.length > 500) whaleTrades.shift(); if (whaleTrades.length > 500) whaleTrades.shift();
}; };
@ -676,7 +684,7 @@ function renderWhaleTrades() {
const age = now - t.ts; const age = now - t.ts;
const fade = Math.max(0, 1 - age / WHALE_MAX_AGE); const fade = Math.max(0, 1 - age / WHALE_MAX_AGE);
const ratio = Math.min(t.usdtVal / WHALE_SCALE_AT, 1); const ratio = Math.min(t.usdtVal / whaleScaleAt, 1);
const r = WHALE_MIN_R + (WHALE_MAX_R - WHALE_MIN_R) * ratio; const r = WHALE_MIN_R + (WHALE_MAX_R - WHALE_MIN_R) * ratio;
const alpha = fade * (t.isBuy ? 0.75 : 0.65); const alpha = fade * (t.isBuy ? 0.75 : 0.65);