dynamic profitabiliy reward
This commit is contained in:
@@ -1985,6 +1985,53 @@ class TradingOrchestrator:
|
||||
self.trading_executor = trading_executor
|
||||
logger.info("Trading executor set for position tracking and P&L feedback")
|
||||
|
||||
def get_profitability_reward_multiplier(self) -> float:
|
||||
"""Get the current profitability reward multiplier from trading executor
|
||||
|
||||
Returns:
|
||||
float: Current profitability reward multiplier (0.0 to 2.0)
|
||||
"""
|
||||
try:
|
||||
if self.trading_executor and hasattr(self.trading_executor, 'get_profitability_reward_multiplier'):
|
||||
multiplier = self.trading_executor.get_profitability_reward_multiplier()
|
||||
logger.debug(f"Current profitability reward multiplier: {multiplier:.2f}")
|
||||
return multiplier
|
||||
return 0.0
|
||||
except Exception as e:
|
||||
logger.error(f"Error getting profitability reward multiplier: {e}")
|
||||
return 0.0
|
||||
|
||||
def calculate_enhanced_reward(self, base_pnl: float, confidence: float = 1.0) -> float:
|
||||
"""Calculate enhanced reward with profitability multiplier
|
||||
|
||||
Args:
|
||||
base_pnl: Base P&L from the trade
|
||||
confidence: Confidence level of the prediction (0.0 to 1.0)
|
||||
|
||||
Returns:
|
||||
float: Enhanced reward with profitability multiplier applied
|
||||
"""
|
||||
try:
|
||||
# Get the dynamic profitability multiplier
|
||||
profitability_multiplier = self.get_profitability_reward_multiplier()
|
||||
|
||||
# Base reward is the P&L
|
||||
base_reward = base_pnl
|
||||
|
||||
# Apply profitability multiplier only to positive P&L (profitable trades)
|
||||
if base_pnl > 0 and profitability_multiplier > 0:
|
||||
# Enhance profitable trades with the multiplier
|
||||
enhanced_reward = base_pnl * (1.0 + profitability_multiplier)
|
||||
logger.debug(f"Enhanced reward: ${base_pnl:.2f} → ${enhanced_reward:.2f} (multiplier: {profitability_multiplier:.2f})")
|
||||
return enhanced_reward
|
||||
else:
|
||||
# No enhancement for losing trades or when multiplier is 0
|
||||
return base_reward
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error calculating enhanced reward: {e}")
|
||||
return base_pnl
|
||||
|
||||
def _check_signal_confirmation(self, symbol: str, signal_data: Dict) -> Optional[str]:
|
||||
"""Check if we have enough signal confirmations for trend confirmation with rate limiting"""
|
||||
try:
|
||||
|
Reference in New Issue
Block a user