diff --git a/scanner.go b/scanner.go index c2e48d6..0cfdcef 100644 --- a/scanner.go +++ b/scanner.go @@ -203,7 +203,7 @@ func netProfit(buyPrice, sellPrice, buyFee, sellFee float64) float64 { revenue := sellPrice * (1 - sellFee/100) // Exit: sell long (pay sellFee), buy back short (pay buyFee) // Total fees = 2 * (buyFee + sellFee), first round already in formula above - return (revenue/cost - 1)*100 - (buyFee + sellFee) + return (revenue/cost - 1)*100 - 2*(buyFee + sellFee) } // ScanBGHL scans coins for arbitrage ONLY between Bitget and HyperLiquid (P3-1). diff --git a/trader.go b/trader.go index ab57cfd..f95dc4a 100644 --- a/trader.go +++ b/trader.go @@ -426,6 +426,7 @@ func (t *Trader) executeEntry(opp *ArbOpportunity, store *PriceStore, notifier * time.Sleep(t.cfg.LegDelay) if err := t.placeOrder(pos.ShortLeg, "sell", store); err != "" { // Leg1 placed successfully, leg2 failed — try to close leg1 + pos.Status = "failed" if closeErr := t.closeLeg(pos.LongLeg); closeErr != "" { // CRITICAL: leg1 is still open on the exchange! // Record the orphan so we don't silently lose tracking