refactor: Remove duplicate code block in user input handling

This commit is contained in:
Bobby (aider) 2025-02-08 10:50:00 -08:00
parent 27ffc80432
commit 389975605c

View File

@ -55,63 +55,3 @@ def get_user_screener_selection() -> dict:
print(f"\n✅ Selected Screeners: {selected_screeners}\n") # ✅ DEBUG LOG
return selected_screeners
return selected_screeners
print("\nAvailable Screener Categories:")
for category in SCREENERS:
print(f"- {category}")
selected_categories = input("\nEnter the categories you want to screen (comma-separated), or type 'all' for all: ").strip().lower()
if selected_categories == "all":
selected_categories = SCREENERS.keys()
else:
selected_categories = [c.strip().title() for c in selected_categories.split(",") if c.strip().title() in SCREENERS]
for category in selected_categories:
print(f"\nCategory: {category}")
use_defaults = input(f"Use default settings for {category}? (y/n): ").strip().lower()
# Add Three_ATR_EMA_Score to Fundamentals or Technical categories
if category == "Fundamentals":
if "Three_ATR_EMA_Score" not in selected_screeners[category]:
selected_screeners[category]["Three_ATR_EMA_Score"] = "default"
else:
use_three_atr_ema = input(f"Would you like to use Three ATR EMA as a screener? (y/n): ").strip().lower()
if use_three_atr_ema == 'y':
custom_value = input(f"Three_ATR_EMA_Score - Enter custom threshold or press Enter to use default: ").strip()
selected_screeners[category]["Three_ATR_EMA_Score"] = float(custom_value) if custom_value else "default"
elif use_three_atr_ema == 'n':
# Remove Three_ATR_EMA_Score if they don't want it
if "Three_ATR_EMA_Score" in selected_screeners[category]:
del selected_screeners[category]["Three_ATR_EMA_Score"]
elif category == "Technical":
if "Three_ATR_EMA_Score" not in selected_screeners[category]:
selected_screeners[category]["Three_ATR_EMA_Score"] = "default"
else:
use_three_atr_ema = input(f"Would you like to use Three ATR EMA as a screener? (y/n): ").strip().lower()
if use_three_atr_ema == 'y':
custom_value = input(f"Three_ATR_EMA_Score - Enter custom threshold or press Enter to use default: ").strip()
selected_screeners[category]["Three_ATR_EMA_Score"] = float(custom_value) if custom_value else "default"
elif use_three_atr_ema == 'n':
# Remove Three_ATR_EMA_Score if they don't want it
if "Three_ATR_EMA_Score" in selected_screeners[category]:
del selected_screeners[category]["Three_ATR_EMA_Score"]
selected_screeners[category] = {}
for screener, description in SCREENERS[category].items():
if use_defaults == "y":
selected_screeners[category][screener] = "default"
else:
custom_value = input(f"{screener} ({description}) - Enter custom threshold or press Enter to use default: ").strip()
selected_screeners[category][screener] = float(custom_value) if custom_value else "default"
# ✅ Ensure L_Score is added if Fundamentals is selected
if "Fundamentals" in selected_screeners and "L_Score" not in selected_screeners["Fundamentals"]:
selected_screeners["Fundamentals"]["L_Score"] = "default" # ✅ Ensure L_Score is included
print(f"\n✅ Selected Screeners: {selected_screeners}\n") # ✅ DEBUG LOG
return selected_screeners