feat: order sync for multiple exchanges and position tracking improvements

- Add order sync support for Binance, Hyperliquid, Bybit, OKX, Bitget, Aster exchanges
- Fix weighted average exit price calculation for partial closes
- Handle position flip (翻仓) scenarios correctly
- Fix symbol normalization (ETH vs ETHUSDT)
- Skip order recording for exchanges with OrderSync to avoid duplicates
- Add chart timezone localization
This commit is contained in:
tinkle-community
2025-12-27 19:13:04 +08:00
parent 46922f8c53
commit 8fb0d2e7e9
20 changed files with 1459 additions and 1409 deletions

View File

@@ -3,6 +3,7 @@ package trader
import (
"fmt"
"nofx/logger"
"nofx/market"
"nofx/store"
"time"
)
@@ -44,7 +45,8 @@ func CreatePositionSnapshot(traderID, exchangeID, exchangeType string, trader Tr
for _, posMap := range positions {
// Parse position data
symbol, _ := posMap["symbol"].(string)
rawSymbol, _ := posMap["symbol"].(string)
symbol := market.Normalize(rawSymbol)
sideStr, _ := posMap["side"].(string)
positionAmt, _ := posMap["positionAmt"].(float64)
entryPrice, _ := posMap["entryPrice"].(float64)