mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 09:58:22 +08:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user