feat: add multi-exchange order sync and position tracking

- Add order sync implementations for Hyperliquid, Bybit, OKX, Bitget, Aster
- Add position snapshot functionality for exchange position reset
- Update TraderOrder and TraderFill structures with exchange_type field
- Add exchange sync tests
- Update frontend charts components
- Remove deprecated position_sync.go
This commit is contained in:
tinkle-community
2025-12-27 02:09:48 +08:00
parent 2172b252a5
commit 46922f8c53
19 changed files with 2405 additions and 898 deletions

View File

@@ -11,7 +11,6 @@ import (
"nofx/manager"
"nofx/mcp"
"nofx/store"
"nofx/trader"
"os"
"os/signal"
"path/filepath"
@@ -115,11 +114,6 @@ func main() {
logger.Warnf("⚠️ Failed to restore backtest history: %v", err)
}
// Start position sync manager (detects manual closures, TP/SL triggers)
positionSyncManager := trader.NewPositionSyncManager(st, 0) // 0 = use default 10s interval
positionSyncManager.Start()
defer positionSyncManager.Stop()
// Load all traders from database to memory (may auto-start traders with IsRunning=true)
if err := traderManager.LoadTradersFromStore(st); err != nil {
logger.Fatalf("❌ Failed to load traders: %v", err)