diff --git a/src/screener/t_sunnyband.py b/src/screener/t_sunnyband.py index f76a005..25d7bc5 100644 --- a/src/screener/t_sunnyband.py +++ b/src/screener/t_sunnyband.py @@ -355,10 +355,15 @@ def run_sunny_scanner(min_price: float, max_price: float, min_volume: int, portf try: entry_price = last_day['close'] upper_band = results['upper_band'].iloc[-1] - # Calculate a more aggressive target price (2x the distance to upper band) - band_distance = upper_band - entry_price - target_price = entry_price + (band_distance * 2) - print(f"Debug: Entry: ${entry_price:.2f}, Upper Band: ${upper_band:.2f}, Target: ${target_price:.2f}") # Debug line + dma = results['dma'].iloc[-1] + + # Calculate band distances + band_range = upper_band - dma # Distance from middle to upper band + + # Set target as one full band range above the upper band + target_price = upper_band + band_range + + print(f"Debug: Entry: ${entry_price:.2f}, DMA: ${dma:.2f}, Upper Band: ${upper_band:.2f}, Target: ${target_price:.2f}") position = calculator.calculate_position_size( entry_price=entry_price, target_price=target_price