fix: HL size floor, random scan jitter 50-250ms
- GetHLSize: change rounding from Sprintf (round-to-nearest) to math.Floor (floor), consistent with GetBitgetSize - Scan interval: fixed 200ms → random 50-250ms to avoid lock-step with HyperLiquid's ~200ms allMids push cycle - README: update architecture diagram, trading logic, config note
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
@@ -113,10 +114,16 @@ func main() {
|
||||
|
||||
// Main loop
|
||||
lastHour := -1
|
||||
scannerTick := time.NewTicker(time.Duration(cfg.ScanIntervalMs) * time.Millisecond)
|
||||
|
||||
// Random jitter 50-250ms to avoid lock-step with exchange push cycles
|
||||
jitterMin, jitterMax := 50, 250
|
||||
randInterval := func() time.Duration {
|
||||
return time.Duration(jitterMin+rand.Intn(jitterMax-jitterMin+1)) * time.Millisecond
|
||||
}
|
||||
scannerTick := time.NewTimer(randInterval())
|
||||
statusTick := time.NewTicker(30 * time.Second)
|
||||
|
||||
log.Printf("[Monitor] Scanner running every %dms", cfg.ScanIntervalMs)
|
||||
log.Printf("[Monitor] Scanner running every %d-%dms (random jitter)", jitterMin, jitterMax)
|
||||
|
||||
runLoop := true
|
||||
for runLoop {
|
||||
@@ -202,6 +209,8 @@ func main() {
|
||||
notifier.SendTradeSummary(positions, now.Format("2006-01-02 15:04"))
|
||||
lastHour = hour
|
||||
}
|
||||
|
||||
scannerTick.Reset(randInterval())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user