|
@@ -5,7 +5,6 @@ from datetime import datetime, timezone
|
|
|
|
|
|
from ..clients.hyperliquid_client import HyperliquidClient
|
|
from ..clients.hyperliquid_client import HyperliquidClient
|
|
from ..notifications.notification_manager import NotificationManager
|
|
from ..notifications.notification_manager import NotificationManager
|
|
-from ..stats.trading_stats import TradingStats
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@@ -18,7 +17,7 @@ class PositionTracker:
|
|
def __init__(self, hl_client: HyperliquidClient, notification_manager: NotificationManager):
|
|
def __init__(self, hl_client: HyperliquidClient, notification_manager: NotificationManager):
|
|
self.hl_client = hl_client
|
|
self.hl_client = hl_client
|
|
self.notification_manager = notification_manager
|
|
self.notification_manager = notification_manager
|
|
- self.trading_stats = TradingStats()
|
|
|
|
|
|
+ self.trading_stats = None # Will be lazy loaded
|
|
|
|
|
|
# Track current positions
|
|
# Track current positions
|
|
self.current_positions: Dict[str, Dict] = {}
|
|
self.current_positions: Dict[str, Dict] = {}
|
|
@@ -209,6 +208,11 @@ class PositionTracker:
|
|
entry_price: float, exit_price: float, pnl: float):
|
|
entry_price: float, exit_price: float, pnl: float):
|
|
"""Save position statistics to database using existing TradingStats interface"""
|
|
"""Save position statistics to database using existing TradingStats interface"""
|
|
try:
|
|
try:
|
|
|
|
+ # Lazy load TradingStats to avoid circular imports
|
|
|
|
+ if self.trading_stats is None:
|
|
|
|
+ from ..stats.trading_stats import TradingStats
|
|
|
|
+ self.trading_stats = TradingStats()
|
|
|
|
+
|
|
# Use the existing process_trade_complete_cycle method
|
|
# Use the existing process_trade_complete_cycle method
|
|
lifecycle_id = self.trading_stats.process_trade_complete_cycle(
|
|
lifecycle_id = self.trading_stats.process_trade_complete_cycle(
|
|
symbol=symbol,
|
|
symbol=symbol,
|