fix: use actual fill price from exchange API for position records

- Remove trader_orders table and OrderSyncManager (never worked correctly)
- Poll GetOrderStatus to get actual avgPrice, executedQty, and commission
- Get entry price from exchange GetPositions API when closing positions
- Pass fee to trader_positions table on close
- Move TraderStats type to position.go
This commit is contained in:
tinkle-community
2025-12-08 12:15:41 +08:00
parent f39fc8af23
commit 8a5744e0a0
9 changed files with 135 additions and 904 deletions

View File

@@ -7,6 +7,21 @@ import (
"time"
)
// TraderStats trading statistics metrics
type TraderStats struct {
TotalTrades int `json:"total_trades"` // Total trades (closed)
WinTrades int `json:"win_trades"` // Winning trades
LossTrades int `json:"loss_trades"` // Losing trades
WinRate float64 `json:"win_rate"` // Win rate (%)
ProfitFactor float64 `json:"profit_factor"` // Profit factor
SharpeRatio float64 `json:"sharpe_ratio"` // Sharpe ratio
TotalPnL float64 `json:"total_pnl"` // Total PnL
TotalFee float64 `json:"total_fee"` // Total fees
AvgWin float64 `json:"avg_win"` // Average win
AvgLoss float64 `json:"avg_loss"` // Average loss
MaxDrawdownPct float64 `json:"max_drawdown_pct"` // Max drawdown (%)
}
// TraderPosition position record (complete open/close position tracking)
type TraderPosition struct {
ID int64 `json:"id"`