fix: Resolve indentation error in main.py by wrapping menu loop in main() function
This commit is contained in:
parent
0b40142bfb
commit
4e5b54c568
96
src/main.py
96
src/main.py
@ -8,6 +8,7 @@ from screener.scanner_controller import run_technical_scanner
|
|||||||
from screener.canslim_controller import run_canslim_screener
|
from screener.canslim_controller import run_canslim_screener
|
||||||
from trading.main import main as trading_main
|
from trading.main import main as trading_main
|
||||||
|
|
||||||
|
def main():
|
||||||
while True:
|
while True:
|
||||||
print_main_menu()
|
print_main_menu()
|
||||||
choice = input("\nSelect an option (1-5): ")
|
choice = input("\nSelect an option (1-5): ")
|
||||||
@ -33,101 +34,6 @@ from trading.main import main as trading_main
|
|||||||
else:
|
else:
|
||||||
print("Invalid choice. Please try again.")
|
print("Invalid choice. Please try again.")
|
||||||
|
|
||||||
def main():
|
|
||||||
print("\nStock Analysis System")
|
|
||||||
print("1. Run CANSLIM Screener")
|
|
||||||
print("2. Run Technical Scanners (SunnyBands/ATR-EMA)")
|
|
||||||
print("3. Launch Trading System")
|
|
||||||
print("4. Trading Journal")
|
|
||||||
print("5. Exit")
|
|
||||||
|
|
||||||
choice = input("\nSelect an option (1-5): ")
|
|
||||||
|
|
||||||
if choice == "1":
|
|
||||||
# 1️⃣ Ask user for start and end date
|
|
||||||
user_start_date = input("Enter start date (YYYY-MM-DD): ")
|
|
||||||
user_end_date = input("Enter end date (YYYY-MM-DD): ")
|
|
||||||
|
|
||||||
# 2️⃣ Validate and adjust date range if needed
|
|
||||||
start_date, end_date = validate_date_range(user_start_date, user_end_date, required_quarters=4)
|
|
||||||
selected_screeners = get_user_screener_selection()
|
|
||||||
symbol_list = get_stocks_in_time_range(start_date, end_date)
|
|
||||||
|
|
||||||
if not symbol_list:
|
|
||||||
print("No stocks found within the given date range.")
|
|
||||||
return
|
|
||||||
|
|
||||||
print(f"Processing {len(symbol_list)} stocks within the given date range...\n")
|
|
||||||
|
|
||||||
for symbol in symbol_list:
|
|
||||||
data = fetch_financial_data(symbol, start_date, end_date)
|
|
||||||
|
|
||||||
if not data:
|
|
||||||
print(f"⚠️ Warning: No data returned for {symbol}. Assigning default score.\n")
|
|
||||||
scores = {screener: 0.25 for category in selected_screeners for screener in selected_screeners[category]}
|
|
||||||
else:
|
|
||||||
scores = {}
|
|
||||||
|
|
||||||
for category, screeners in selected_screeners.items():
|
|
||||||
for screener, threshold in screeners.items():
|
|
||||||
if screener == "EPS_Score":
|
|
||||||
scores[screener] = check_quarterly_earnings(data.get("quarterly_eps", []))
|
|
||||||
elif screener == "Annual_EPS_Score":
|
|
||||||
scores[screener] = check_annual_eps_growth(data.get("annual_eps", []))
|
|
||||||
elif screener == "Sales_Score":
|
|
||||||
scores[screener] = check_sales_growth(data.get("sales_growth", []))
|
|
||||||
elif screener == "ROE_Score":
|
|
||||||
scores[screener] = check_return_on_equity(data.get("roe", []))
|
|
||||||
elif screener == "L_Score":
|
|
||||||
scores[screener] = check_industry_leadership(symbol)
|
|
||||||
print(f"🟢 {symbol} - L_Score: {scores[screener]}")
|
|
||||||
elif screener == "I_Score":
|
|
||||||
scores[screener] = check_institutional_sponsorship(symbol)
|
|
||||||
print(f"🏢 {symbol} - I_Score: {scores[screener]}")
|
|
||||||
|
|
||||||
if isinstance(threshold, (int, float)):
|
|
||||||
scores[screener] = scores[screener] >= threshold
|
|
||||||
|
|
||||||
scores["Total_Score"] = sum(scores.values())
|
|
||||||
append_scores_to_csv(symbol, scores)
|
|
||||||
|
|
||||||
print("✅ Scores saved in data/metrics/stock_scores.csv\n")
|
|
||||||
|
|
||||||
elif choice == "2":
|
|
||||||
print("\nTechnical Scanner Options:")
|
|
||||||
print("1. SunnyBands Scanner")
|
|
||||||
print("2. Standard ATR-EMA Scanner")
|
|
||||||
print("3. Enhanced ATR-EMA v2 Scanner") # NEW OPTION
|
|
||||||
|
|
||||||
scanner_choice = input("\nEnter your choice (1-3): ")
|
|
||||||
|
|
||||||
# Get parameters first for all scanners
|
|
||||||
min_price, max_price, min_volume, portfolio_size = get_scanner_parameters()
|
|
||||||
|
|
||||||
if scanner_choice == "1":
|
|
||||||
from screener.t_sunnyband import run_sunny_scanner
|
|
||||||
run_sunny_scanner(min_price, max_price, min_volume, portfolio_size)
|
|
||||||
elif scanner_choice == "2":
|
|
||||||
from screener.t_atr_ema import run_atr_ema_scanner
|
|
||||||
run_atr_ema_scanner(min_price, max_price, min_volume, portfolio_size)
|
|
||||||
elif scanner_choice == "3": # NEW CASE
|
|
||||||
from screener.t_atr_ema_v2 import run_atr_ema_scanner_v2
|
|
||||||
run_atr_ema_scanner_v2(min_price, max_price, min_volume, portfolio_size)
|
|
||||||
else:
|
|
||||||
print("Invalid choice. Returning to main menu.")
|
|
||||||
|
|
||||||
elif choice == "3":
|
|
||||||
from trading.main import main as trading_main
|
|
||||||
trading_main()
|
|
||||||
|
|
||||||
elif choice == "4":
|
|
||||||
journal_menu()
|
|
||||||
|
|
||||||
elif choice == "5":
|
|
||||||
print("Exiting...")
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
print("Invalid choice. Please try again.")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user