perf: scan interval 50ms fixed
HL allMids pushes ~200ms, scan at 50ms catches every update within 1 tick. Async entry goroutine means no blocking.
This commit is contained in:
@@ -19,8 +19,7 @@ PriceStore ─────────┼─────────────
|
||||
└──────────────┘
|
||||
│
|
||||
┌─────────▼─────────┐
|
||||
│ ScanBGHL (50-250ms │
|
||||
│ random jitter) │
|
||||
│ ScanBGHL (50ms) │
|
||||
│ BG ↔ HL only │
|
||||
└─────────┬─────────┘
|
||||
│
|
||||
@@ -98,7 +97,7 @@ Then open [http://localhost:8888](http://localhost:8888) for the Web dashboard.
|
||||
| `BITGET_API_KEY` / `BITGET_API_SECRET` / `BITGET_PASSPHRASE` | — | Bitget API credentials (test mode skips) |
|
||||
| `HL_PRIVATE_KEY` / `HL_ADDRESS` | — | HyperLiquid wallet credentials (test mode skips) |
|
||||
|
||||
> **Note:** Scan interval is fixed at **50-250ms random jitter** (not configurable). This prevents lock-step with HyperLiquid's ~200ms push cycle.
|
||||
> **Note:** Scan interval is fixed at **50ms**. At this rate the scanner catches every HyperLiquid ~200ms push without any jitter.
|
||||
|
||||
## Fee Model
|
||||
|
||||
@@ -113,7 +112,7 @@ Round trip (2 legs entry + 2 legs exit): **0.07%** total fees.
|
||||
|
||||
## Trading Logic
|
||||
|
||||
1. **Scanner** runs every 50-250ms (random jitter to avoid lock-step with exchange push cycles), checks all 6 coins for BG ↔ HL spread
|
||||
1. **Scanner** runs every 50ms, checks all 6 coins for BG ↔ HL spread
|
||||
2. **Entry** when net profit ≥ `TRADE_THRESHOLD` (after full round-trip fees)
|
||||
- Uses scan-time prices directly (no re-read from store to avoid WS jitter)
|
||||
- Synchronous execution in the scanner tick (no goroutine delay)
|
||||
|
||||
@@ -115,15 +115,15 @@ func main() {
|
||||
// Main loop
|
||||
lastHour := -1
|
||||
|
||||
// Random jitter 50-250ms to avoid lock-step with exchange push cycles
|
||||
jitterMin, jitterMax := 50, 250
|
||||
// Fixed 50ms scan interval
|
||||
jitterMin, jitterMax := 50, 50
|
||||
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 %d-%dms (random jitter)", jitterMin, jitterMax)
|
||||
log.Printf("[Monitor] Scanner running every %dms", jitterMin)
|
||||
|
||||
runLoop := true
|
||||
for runLoop {
|
||||
|
||||
Reference in New Issue
Block a user