stock_system/src/screener/user_input.py
2025-02-03 23:33:42 -08:00

41 lines
1.8 KiB
Python

from screener.screeners import SCREENERS # Import SCREENERS dictionary
def get_user_screener_selection():
"""
Ask the user which screeners they want to run and whether to use defaults.
Returns a dictionary of selected screeners with default/customization choices.
"""
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()
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