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
-14
View File
@@ -22,7 +22,6 @@ type Store struct {
trader *TraderStore
decision *DecisionStore
backtest *BacktestStore
order *OrderStore
position *PositionStore
strategy *StrategyStore
equity *EquityStore
@@ -135,9 +134,6 @@ func (s *Store) initTables() error {
if err := s.Backtest().initTables(); err != nil {
return fmt.Errorf("failed to initialize backtest tables: %w", err)
}
if err := s.Order().InitTables(); err != nil {
return fmt.Errorf("failed to initialize order tables: %w", err)
}
if err := s.Position().InitTables(); err != nil {
return fmt.Errorf("failed to initialize position tables: %w", err)
}
@@ -241,16 +237,6 @@ func (s *Store) Backtest() *BacktestStore {
return s.backtest
}
// Order gets order storage
func (s *Store) Order() *OrderStore {
s.mu.Lock()
defer s.mu.Unlock()
if s.order == nil {
s.order = NewOrderStore(s.db)
}
return s.order
}
// Position gets position storage
func (s *Store) Position() *PositionStore {
s.mu.Lock()