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:
parent
b3975789fa
commit
78657f5ff4
1 changed files with 15 additions and 7 deletions
|
|
@ -451,9 +451,16 @@ async function loadTicker() {
|
|||
document.getElementById('pb-low').textContent = fmt(t.lowPrice);
|
||||
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);
|
||||
setWhaleLimits(vol);
|
||||
} 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() {
|
||||
if (priceWs) priceWs.close();
|
||||
const sym = bot.symbol.toLowerCase();
|
||||
|
|
@ -615,11 +622,12 @@ function drawSupportResistance(candles) {
|
|||
}
|
||||
|
||||
// ── Whale trades (aggTrade canvas overlay) ────────
|
||||
const WHALE_THRESHOLD = 10000; // USDT
|
||||
const WHALE_MAX_AGE = 120; // saniye, ekranda kalma süresi
|
||||
const WHALE_MAX_R = 28; // maks çember yarıçapı (px)
|
||||
const WHALE_MIN_R = 6; // min çember yarıçapı (px)
|
||||
const WHALE_SCALE_AT = 500000; // bu hacimde max boyuta ulaşır
|
||||
const WHALE_MAX_AGE = 120; // saniye, ekranda kalma süresi
|
||||
const WHALE_MAX_R = 28; // maks ç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)
|
||||
let whaleThreshold = 50000;
|
||||
let whaleScaleAt = 500000;
|
||||
|
||||
let whaleCanvas = null;
|
||||
let whaleCtx = null;
|
||||
|
|
@ -636,7 +644,7 @@ function startAggTradeWs() {
|
|||
const price = parseFloat(t.p);
|
||||
const qty = parseFloat(t.q);
|
||||
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 });
|
||||
if (whaleTrades.length > 500) whaleTrades.shift();
|
||||
};
|
||||
|
|
@ -676,7 +684,7 @@ function renderWhaleTrades() {
|
|||
|
||||
const age = now - t.ts;
|
||||
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 alpha = fade * (t.isBuy ? 0.75 : 0.65);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue