diff --git a/src/screener/t_sunnyband.py b/src/screener/t_sunnyband.py index 01c3944..37e88fd 100644 --- a/src/screener/t_sunnyband.py +++ b/src/screener/t_sunnyband.py @@ -343,6 +343,10 @@ def run_sunny_scanner(min_price: float, max_price: float, min_volume: int, portf for ticker in tickers: try: + current_price = get_current_price(ticker) # Get current price + if current_price is None: + continue + df = get_stock_data(ticker, start_date, end_date, interval) if df.empty or len(df) < 50: continue @@ -351,14 +355,15 @@ def run_sunny_scanner(min_price: float, max_price: float, min_volume: int, portf last_day = df.iloc[-1] if results['bullish_signal'].iloc[-1]: - entry_price = last_day['close'] - target_price = results['target'].iloc[-1] # Use the new target calculation + entry_price = current_price # Use current price instead of last_day['close'] + target_price = results['target'].iloc[-1] if calculator: position = calculator.calculate_position_size(entry_price, target_price) if position['shares'] > 0: signal_data = { 'ticker': ticker, + 'current': current_price, # Add current price to signal data 'entry': entry_price, 'target': target_price, 'shares': position['shares'], @@ -369,16 +374,16 @@ def run_sunny_scanner(min_price: float, max_price: float, min_volume: int, portf 'r_r': position['risk_reward_ratio'] } bullish_signals.append(signal_data) - print(f"\n🟢 {ticker} Current: ${last_day['close']:.2f} Entry: ${entry_price:.2f} Target: ${target_price:.2f}") + print(f"\n🟢 {ticker} Current: ${current_price:.2f} Entry: ${entry_price:.2f} Target: ${target_price:.2f}") print(f" Shares: {signal_data['shares']} | Risk: ${abs(signal_data['risk']):.2f} | " f"Reward: ${signal_data['reward']:.2f} | R/R: {signal_data['r_r']:.2f}") elif results['bearish_signal'].iloc[-1]: bearish_signals.append({ 'ticker': ticker, - 'price': last_day['close'] + 'price': current_price # Use current price here too }) - print(f"\n🔴 {ticker} Current: ${last_day['close']:.2f}") + print(f"\n🔴 {ticker} Current: ${current_price:.2f}") except Exception as e: continue