misc: binance momentum, telegram, frontend updates

This commit is contained in:
jackyu66git
2026-06-03 09:39:54 +08:00
parent b2ff322ef3
commit 23f3c61c9f
20 changed files with 928 additions and 86 deletions
+36
View File
@@ -32,6 +32,12 @@ type Config struct {
TrendAnomalyMul float64 // z-score multiplier for alert threshold (default: 3.0)
TrendConfirmTicks int // ticks needed for state confirmation (default: 3)
TrendAlertCooldown int64 // ms cooldown between alerts for same coin (default: 60000)
// Binance momentum detection (1-minute Binance-only price change)
BinanceMomentumEnabled bool
BinanceMomentumThresholdPct float64 // default: 10.0
BinanceMomentumCooldownSec int // default: 300 (5 min)
BinanceMomentumWindowSec int // default: 60
}
// jsonConfig maps config.json fields (non-secret defaults checked into git).
@@ -57,6 +63,12 @@ type jsonConfig struct {
TrendAnomalyMul float64 `json:"trend_anomaly_mul"`
TrendConfirmTicks int `json:"trend_confirm_ticks"`
TrendAlertCooldown int64 `json:"trend_alert_cooldown_ms"`
// Binance momentum detection
BinanceMomentumEnabled bool `json:"binance_momentum_enabled"`
BinanceMomentumThresholdPct float64 `json:"binance_momentum_threshold_pct"`
BinanceMomentumCooldownSec int `json:"binance_momentum_cooldown_sec"`
BinanceMomentumWindowSec int `json:"binance_momentum_window_sec"`
}
func LoadConfig() *Config {
@@ -113,6 +125,12 @@ func LoadConfig() *Config {
TrendAnomalyMul: getFloat("TREND_ANOMALY_MUL", jsonCfg.TrendAnomalyMul),
TrendConfirmTicks: int(getFloat("TREND_CONFIRM_TICKS", float64(jsonCfg.TrendConfirmTicks))),
TrendAlertCooldown: int64(getFloat("TREND_ALERT_COOLDOWN_MS", float64(jsonCfg.TrendAlertCooldown))),
// Binance momentum detection
BinanceMomentumEnabled: getBool("BINANCE_MOMENTUM_ENABLED", jsonCfg.BinanceMomentumEnabled),
BinanceMomentumThresholdPct: getFloat("BINANCE_MOMENTUM_THRESHOLD_PCT", jsonCfg.BinanceMomentumThresholdPct),
BinanceMomentumCooldownSec: int(getFloat("BINANCE_MOMENTUM_COOLDOWN_SEC", float64(jsonCfg.BinanceMomentumCooldownSec))),
BinanceMomentumWindowSec: int(getFloat("BINANCE_MOMENTUM_WINDOW_SEC", float64(jsonCfg.BinanceMomentumWindowSec))),
}
}
@@ -137,6 +155,12 @@ func loadJSONConfig() jsonConfig {
TrendAnomalyMul: 3.0, // 3 sigma z-score threshold
TrendConfirmTicks: 3, // 3 consecutive ticks for confirmation
TrendAlertCooldown: 60000, // 1 min cooldown
// Binance momentum detection
BinanceMomentumEnabled: true,
BinanceMomentumThresholdPct: 10.0,
BinanceMomentumCooldownSec: 300, // 5 minutes between alerts per coin
BinanceMomentumWindowSec: 60, // 1-minute lookback
}
data, err := os.ReadFile("config.json")
@@ -192,10 +216,22 @@ func loadJSONConfig() jsonConfig {
def.TrendAlertCooldown = cfg.TrendAlertCooldown
}
// Binance momentum JSON overrides
if cfg.BinanceMomentumThresholdPct != 0 {
def.BinanceMomentumThresholdPct = cfg.BinanceMomentumThresholdPct
}
if cfg.BinanceMomentumCooldownSec != 0 {
def.BinanceMomentumCooldownSec = cfg.BinanceMomentumCooldownSec
}
if cfg.BinanceMomentumWindowSec != 0 {
def.BinanceMomentumWindowSec = cfg.BinanceMomentumWindowSec
}
// Boolean fields: zero default is false, so use OR logic
def.MomentumEnabled = cfg.MomentumEnabled || def.MomentumEnabled
def.TrendEnabled = cfg.TrendEnabled || def.TrendEnabled
def.SurgeEnabled = cfg.SurgeEnabled || def.SurgeEnabled
def.BinanceMomentumEnabled = cfg.BinanceMomentumEnabled || def.BinanceMomentumEnabled
return def
}