fix: scanner netProfit 漏算exit fees + 孤儿仓位标记failed
- scanner.go: netProfit 扣费改为 2*(buyFee+sellFee) 匹配 calcArbPnL - trader.go: 第二腿失败时设 pos.Status=failed,避免语义混淆
This commit is contained in:
+1
-1
@@ -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).
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user