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:
+1
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user