fix dash
This commit is contained in:
@ -157,6 +157,13 @@ class EnhancedTradingOrchestrator(TradingOrchestrator):
|
||||
# Enhanced RL training flag
|
||||
self.enhanced_rl_training = enhanced_rl_training
|
||||
|
||||
# Missing attributes fix - Initialize position tracking and thresholds
|
||||
self.current_positions = {} # Track current positions by symbol
|
||||
self.entry_threshold = 0.65 # Threshold for opening new positions
|
||||
self.exit_threshold = 0.30 # Threshold for closing positions
|
||||
self.uninvested_threshold = 0.50 # Threshold below which to stay uninvested
|
||||
self.last_signals = {} # Track last signal for each symbol
|
||||
|
||||
# Enhanced state tracking
|
||||
self.latest_cob_features = {} # Symbol -> COB features array
|
||||
self.latest_cob_state = {} # Symbol -> COB state array
|
||||
@ -3455,4 +3462,29 @@ class EnhancedTradingOrchestrator(TradingOrchestrator):
|
||||
except Exception as e:
|
||||
logger.error(f"Error calculating enhanced pivot reward: {e}")
|
||||
# Fallback to simple PnL-based reward
|
||||
return trade_outcome.get('net_pnl', 0) / 100.0
|
||||
return trade_outcome.get('net_pnl', 0) / 100.0
|
||||
|
||||
def _get_current_position_side(self, symbol: str) -> str:
|
||||
"""Get current position side for a symbol"""
|
||||
try:
|
||||
position = self.current_positions.get(symbol)
|
||||
if position is None:
|
||||
return 'FLAT'
|
||||
return position.get('side', 'FLAT')
|
||||
except Exception as e:
|
||||
logger.error(f"Error getting position side for {symbol}: {e}")
|
||||
return 'FLAT'
|
||||
|
||||
def _calculate_position_size(self, symbol: str, action: str, confidence: float) -> float:
|
||||
"""Calculate position size based on action and confidence"""
|
||||
try:
|
||||
# Base position size - could be made configurable
|
||||
base_size = 0.01 # 0.01 BTC or ETH equivalent
|
||||
|
||||
# Adjust size based on confidence
|
||||
confidence_multiplier = min(confidence * 1.5, 2.0) # Max 2x multiplier
|
||||
|
||||
return base_size * confidence_multiplier
|
||||
except Exception as e:
|
||||
logger.error(f"Error calculating position size for {symbol}: {e}")
|
||||
return 0.01 # Default small size
|
Reference in New Issue
Block a user