优化: 共用一次 store.GetAll() 快照,消除每 tick 两次 map 分配
This commit is contained in:
@@ -179,12 +179,12 @@ func main() {
|
|||||||
t1 := time.Now()
|
t1 := time.Now()
|
||||||
|
|
||||||
// Scan for arbitrage entries using maker fees (limit orders)
|
// Scan for arbitrage entries using maker fees (limit orders)
|
||||||
makerOpps := ScanBGHL(store)
|
snap := store.GetAll()
|
||||||
|
makerOpps := ScanBGHL(snap)
|
||||||
dashboard.UpdateScan(makerOpps)
|
dashboard.UpdateScan(makerOpps)
|
||||||
t2 := time.Now()
|
t2 := time.Now()
|
||||||
|
|
||||||
// Track spread window durations (how long each opportunity stays alive)
|
// Track spread window durations (how long each opportunity stays alive)
|
||||||
snap := store.GetAll()
|
|
||||||
spreadTracker.Tick(snap, cfg.TradeThreshold)
|
spreadTracker.Tick(snap, cfg.TradeThreshold)
|
||||||
|
|
||||||
for _, opp := range makerOpps {
|
for _, opp := range makerOpps {
|
||||||
|
|||||||
+2
-3
@@ -208,12 +208,11 @@ func netProfit(buyPrice, sellPrice, buyFee, sellFee float64) float64 {
|
|||||||
|
|
||||||
// ScanBGHL scans coins for arbitrage ONLY between Bitget and HyperLiquid (P3-1).
|
// ScanBGHL scans coins for arbitrage ONLY between Bitget and HyperLiquid (P3-1).
|
||||||
// Returns both directions (BG->HL and HL->BG) sorted by net profit descending.
|
// Returns both directions (BG->HL and HL->BG) sorted by net profit descending.
|
||||||
func ScanBGHL(store *PriceStore) []*ArbOpportunity {
|
func ScanBGHL(snap map[string]map[string]float64) []*ArbOpportunity {
|
||||||
snapshot := store.GetAll()
|
|
||||||
var results []*ArbOpportunity
|
var results []*ArbOpportunity
|
||||||
|
|
||||||
for _, coin := range TrackedCoins {
|
for _, coin := range TrackedCoins {
|
||||||
exMap := snapshot[coin.Name]
|
exMap := snap[coin.Name]
|
||||||
if exMap == nil {
|
if exMap == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user