feat: Add current price retrieval for Sunny Band scanner
This commit is contained in:
parent
6af7ce4bcd
commit
af392bbaec
@ -343,6 +343,10 @@ def run_sunny_scanner(min_price: float, max_price: float, min_volume: int, portf
|
|||||||
|
|
||||||
for ticker in tickers:
|
for ticker in tickers:
|
||||||
try:
|
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)
|
df = get_stock_data(ticker, start_date, end_date, interval)
|
||||||
if df.empty or len(df) < 50:
|
if df.empty or len(df) < 50:
|
||||||
continue
|
continue
|
||||||
@ -351,14 +355,15 @@ def run_sunny_scanner(min_price: float, max_price: float, min_volume: int, portf
|
|||||||
last_day = df.iloc[-1]
|
last_day = df.iloc[-1]
|
||||||
|
|
||||||
if results['bullish_signal'].iloc[-1]:
|
if results['bullish_signal'].iloc[-1]:
|
||||||
entry_price = last_day['close']
|
entry_price = current_price # Use current price instead of last_day['close']
|
||||||
target_price = results['target'].iloc[-1] # Use the new target calculation
|
target_price = results['target'].iloc[-1]
|
||||||
|
|
||||||
if calculator:
|
if calculator:
|
||||||
position = calculator.calculate_position_size(entry_price, target_price)
|
position = calculator.calculate_position_size(entry_price, target_price)
|
||||||
if position['shares'] > 0:
|
if position['shares'] > 0:
|
||||||
signal_data = {
|
signal_data = {
|
||||||
'ticker': ticker,
|
'ticker': ticker,
|
||||||
|
'current': current_price, # Add current price to signal data
|
||||||
'entry': entry_price,
|
'entry': entry_price,
|
||||||
'target': target_price,
|
'target': target_price,
|
||||||
'shares': position['shares'],
|
'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']
|
'r_r': position['risk_reward_ratio']
|
||||||
}
|
}
|
||||||
bullish_signals.append(signal_data)
|
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} | "
|
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}")
|
f"Reward: ${signal_data['reward']:.2f} | R/R: {signal_data['r_r']:.2f}")
|
||||||
|
|
||||||
elif results['bearish_signal'].iloc[-1]:
|
elif results['bearish_signal'].iloc[-1]:
|
||||||
bearish_signals.append({
|
bearish_signals.append({
|
||||||
'ticker': ticker,
|
'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:
|
except Exception as e:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user