better log
This commit is contained in:
@@ -3984,7 +3984,8 @@ class RealTrainingAdapter:
|
||||
}
|
||||
})
|
||||
else:
|
||||
logger.info(f"Live Signal (NOT executed): {signal['action']} @ {signal['price']:.2f} (conf: {signal['confidence']:.2f}) - {self._get_rejection_reason(session, signal)}")
|
||||
rejection_reason = self._get_rejection_reason(session, signal, current_price)
|
||||
logger.info(f"Live Signal (NOT executed): {signal['action']} @ {signal['price']:.2f} (conf: {signal['confidence']:.2f}) - {rejection_reason}")
|
||||
|
||||
# Store prediction for visualization (INCLUDE predicted_candle for ghost candles!)
|
||||
if self.orchestrator and hasattr(self.orchestrator, 'store_transformer_prediction'):
|
||||
@@ -4263,7 +4264,7 @@ class RealTrainingAdapter:
|
||||
# HOLD or position already open in same direction
|
||||
return None
|
||||
|
||||
def _get_rejection_reason(self, session: Dict, signal: Dict) -> str:
|
||||
def _get_rejection_reason(self, session: Dict, signal: Dict, current_price: float = 0.0) -> str:
|
||||
"""Get reason why a signal was not executed"""
|
||||
action = signal['action']
|
||||
confidence = signal['confidence']
|
||||
@@ -4276,10 +4277,19 @@ class RealTrainingAdapter:
|
||||
return "HOLD signal (no trade)"
|
||||
|
||||
if position:
|
||||
entry_price = position.get('entry_price', 0.0)
|
||||
position_type = position.get('type', '').upper()
|
||||
|
||||
if action == 'BUY' and position['type'] == 'long':
|
||||
return "Already in LONG position"
|
||||
# Calculate current PnL
|
||||
unrealized_pnl = self._calculate_unrealized_pnl(session, current_price) if current_price > 0 else 0.0
|
||||
pnl_sign = '+' if unrealized_pnl >= 0 else ''
|
||||
return f"Already in LONG position (entry: ${entry_price:.2f}, PnL: {pnl_sign}{unrealized_pnl:.2f}%)"
|
||||
elif action == 'SELL' and position['type'] == 'short':
|
||||
return "Already in SHORT position"
|
||||
# Calculate current PnL
|
||||
unrealized_pnl = self._calculate_unrealized_pnl(session, current_price) if current_price > 0 else 0.0
|
||||
pnl_sign = '+' if unrealized_pnl >= 0 else ''
|
||||
return f"Already in SHORT position (entry: ${entry_price:.2f}, PnL: {pnl_sign}{unrealized_pnl:.2f}%)"
|
||||
|
||||
return "Unknown reason"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user