refactor: Improve position details display with float conversion and percentage calculations
This commit is contained in:
parent
0648265c62
commit
c248fd05df
@ -416,16 +416,26 @@ def run_sunny_scanner(min_price: float, max_price: float, min_volume: int, portf
|
||||
print(f"Target (Upper Band): ${signal['upper_band']:.2f}")
|
||||
|
||||
if 'shares' in signal:
|
||||
profit_potential = signal['potential_profit']
|
||||
profit_percentage = (profit_potential / (signal['price'] * signal['shares'])) * 100
|
||||
# Convert numpy float64 to regular float if needed
|
||||
position_value = float(signal['position_value'])
|
||||
stop_loss = float(signal['stop_loss'])
|
||||
potential_loss = float(signal['potential_loss'])
|
||||
potential_profit = float(signal['potential_profit'])
|
||||
risk_reward = float(signal['risk_reward_ratio'])
|
||||
|
||||
# Calculate percentage gains/losses
|
||||
profit_percentage = (potential_profit / position_value) * 100
|
||||
loss_percentage = (abs(potential_loss) / position_value) * 100
|
||||
|
||||
print("\nPosition Details:")
|
||||
print(f"Shares: {signal['shares']:,}")
|
||||
print(f"Position Size: ${signal['position_value']:,.2f}")
|
||||
print(f"Stop Loss: ${signal['stop_loss']:.2f} (-6%)")
|
||||
print(f"Risk Amount: ${abs(signal['potential_loss']):,.2f}")
|
||||
print(f"Potential Profit: ${signal['potential_profit']:,.2f} ({profit_percentage:.1f}%)")
|
||||
print(f"Risk/Reward Ratio: {signal['risk_reward_ratio']:.2f}")
|
||||
print(f"Position Size: ${position_value:,.2f}")
|
||||
print(f"Entry Price: ${signal['price']:.2f}")
|
||||
print(f"Stop Loss: ${stop_loss:.2f} (-6%)")
|
||||
print(f"Target Price: ${signal['upper_band']:.2f}")
|
||||
print(f"Risk Amount: ${abs(potential_loss):,.2f} ({loss_percentage:.1f}%)")
|
||||
print(f"Potential Profit: ${potential_profit:,.2f} ({profit_percentage:.1f}%)")
|
||||
print(f"Risk/Reward Ratio: {risk_reward:.2f}")
|
||||
|
||||
if bearish_signals:
|
||||
print(f"\n🔴 Found {len(bearish_signals)} Bearish Signals:")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user