Der Standard-Z-Score basiert auf dem Mittelwert und der Standardabweichung. In Krypto kann eine einzelne Liquidation- Kaskade extreme Ausreißer erzeugen, die den Mittelwert verzerren und die Standardabweichung erhöhen. Dadurch verfehlt der Standard-Z-Score nachfolgende schädliche Volumen-Spikes.

Der robuste Z-Score ersetzt den Mittelwert und die Standardabweichung durch den Median und MAD (Median Absolute Deviation), wodurch er gegenüber Ausreißern immun ist:

$$\text{Robuster Z} = 0.6745 \times \frac{x - \text{Median}}{\text{MAD}}$$

1. Das Matheproblem: Standard-Z-Score vs. Ausreißer

Angenommen, wir betrachten ein rollierendes Fenster der Orderbook- Handelsvolumina: [10, 12, 11, 15, 100, 14] (wobei 100 ein plötzlicher Liquidations- Spike ist).

  • Standard-Z-Score für ein neues Volumen von 25:

    • Mittelwert = 27.0, Standardabweichung = 32.8

    • Standard-Z = (25 - 27.0) / 32.8 = -0.06 (Löst keine Warnung aus!)

  • Robust-Z-Score für ein neues Volumen von 25:

    • Median = 13.0, MAD = 2.5

    • Robust-Z = 0.6745 × (25 - 13.0) / 2.5 = 3.24 (Löst eine toxische Volumenwarnung aus!)

2. Reine Python-Implementierung (Standard-Z-Score)

Wenn du Volumen-Anomalien manuell ohne MAD berechnest, bricht deine Ausführungs-Benchmark bei hoher Volatilität:

def calculate_z_score( list[float]) -> float:

if not data or len(data) < 2:

return 0.0

mean = sum(data) / len(data) variance = sum((x - mean) ** 2 for x in data) / len(data

std = variance**0.5 return (data[-1] - mean) / std if std else 0.0

# Beispielverwendung:

volumes = [10.0, 12.0, 11.0, 15.0, 100.0, 25.0]

z = calculate_z_score(volumes)

print(f"Standard-Z-Score: {z:.2f}")

# Ausgabe: -0.06 (Irreführend)

3. Produktionsreife SDK-Alternative

Überspringe die manuelle Orderbook-Aggregation und die Ausreißer-Mathematik mit @followsm/sdk:

npm i @followsm/sdk

import { FollowSMClient } from "@followsm/sdk"; // Client initialisieren (apiKey für Free-Tier weglassen) const client = new FollowSMClient({ apiKey: "fsm_live_..." });

// Abruf der Echtzeit-Orderbook-Toxizität & robuste Z-Metriken

const snapshot = await client.getToxicitySnapshot("BTCUSDT");

if (snapshot.is_toxic_alert) {

console.log(`⚠️ Toxischer Flow! VPIN: ${snapshot.vpin}, Volumen robuster Z: ${snapshot.volume_z_score}`);

}

4. Echtzeit-Snapshot-Payload

{ "symbol": "BTCUSDT",

"timestamp": 1758412800.0,

"price": 62150.5,

"vpin": 0.72,

"ob_toxicity_1pct": 2.35,

"ob_imbalance_l1": 0.61,

"depth_bands": { "0.5%": { "bid_notional": 184320.0, "ask_notional": 96410.0, "imbalance_ratio": 0.657 }, "1.0%": { "bid_notional": 312500.0, "ask_notional": 210800.0, "imbalance_ratio": 0.597 }, "2.0%": { "bid_notional": 590100.0, "ask_notional": 470200.0, "imbalance_ratio": 0.556 } },

"volume_z_score": 3.23,

"natr_15m": 0.84,

"taker_buy_ratio": 0.58,

"is_toxic_alert": true

}

#Crypto #TradingBot #Quant #BinanceSquareTalks #HFT $BTC $ETH