fix: data race, scale-in PnL, nonce mutex, dead code, hourly check

- 🔴 Data race: Add GetPositionsCopy() returning deep copies (no shared
  ArbPosition pointers). Use it in dashboard broadcastLoop + handleStatus.
- 🟡 Scale-in PnL: Track LongEntryPrices/ShortEntryPrices on ArbPosition,
  compute weighted average (harmonic mean) at exit for accurate PnL.
- 🟢 CalcNetProfit: Delete dead code from exchange/helpers.go.
- 🟢 HL nonce: Add sync.Mutex around lastNonce++ (thread safety).
- 🟢 Hourly check: Change from 5-second window to minute window.
- 🟢 ExitPrice: Test mode closeLeg already handled by checkExit.
This commit is contained in:
jackyu66git
2026-05-03 18:31:14 +08:00
parent ab48e207a5
commit b08d8490fc
6 changed files with 94 additions and 54 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ func (n *Notifier) SendAlert(opp *ArbOpportunity) {
}
// SendTradeSummary sends a summary of open positions at each hour.
func (n *Notifier) SendTradeSummary(positions []*ArbPosition, timeStr string) {
func (n *Notifier) SendTradeSummary(positions []ArbPosition, timeStr string) {
if n.BotToken == "" || n.ChatID == "" {
return
}