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:
jackyu66git
2026-05-03 22:25:01 +08:00
parent 6a4b046742
commit 915b316ca7
3 changed files with 31 additions and 11 deletions
+14 -6
View File
@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"math"
"math/big"
"net/http"
"strings"
@@ -171,21 +172,28 @@ func (h *HyperLiquidTrade) signAction(action HLOrderAction, nonce int64) (string
// GetHLSize calculates size for a given USD amount on HyperLiquid.
// Uses szDecimals precision from HL's contract universe.
// Returns size as a decimal string complying with HL precision.
// Uses math.Floor to round DOWN to the nearest valid step, consistent with GetBitgetSize.
func GetHLSize(coin string, amountUSD, price float64) string {
sz := amountUSD / price // raw coin count
switch coin {
case "DOGE":
return fmt.Sprintf("%.0f", sz) // szDecimals=0
sz = math.Floor(sz) // step=1, szDecimals=0
return fmt.Sprintf("%.0f", sz)
case "LINK":
return fmt.Sprintf("%.1f", sz) // szDecimals=1
sz = math.Floor(sz*10) / 10 // step=0.1, szDecimals=1
return fmt.Sprintf("%.1f", sz)
case "ONDO":
return fmt.Sprintf("%.0f", sz) // szDecimals=0
sz = math.Floor(sz) // step=1, szDecimals=0
return fmt.Sprintf("%.0f", sz)
case "OP":
return fmt.Sprintf("%.1f", sz) // szDecimals=1
sz = math.Floor(sz*10) / 10 // step=0.1, szDecimals=1
return fmt.Sprintf("%.1f", sz)
case "WIF":
return fmt.Sprintf("%.0f", sz) // szDecimals=0
sz = math.Floor(sz) // step=1, szDecimals=0
return fmt.Sprintf("%.0f", sz)
case "ARB":
return fmt.Sprintf("%.1f", sz) // szDecimals=1
sz = math.Floor(sz*10) / 10 // step=0.1, szDecimals=1
return fmt.Sprintf("%.1f", sz)
default:
return fmt.Sprintf("%.4f", sz)
}