import streamlit as st from data_fetcher.yfinance_client import fetch_intraday_data from indicators.ema import calculate_ema from indicators.rsi import calculate_rsi from indicators.macd import calculate_macd from indicators.bollinger_bands import calculate_bollinger_bands from signals.strategy import generate_combined_signals from utils.plotting import plot_stock_data_with_signals from utils.plotting_interactive import plot_stock_data_with_signals_interactive import pandas as pd # Streamlit app title with emoji st.title('Stock Intraday Signal App 📈') # Introduction and instructions with emojis st.write(""" ## Introduction 🌟 Welcome to the Stock Intraday Signal App! This application analyzes stock data to generate buy/sell signals 🚦 based on technical indicators such as EMA, RSI, MACD, and Bollinger Bands. It's designed to help day traders 📊 make informed decisions. ## How to Use 🛠️ 1. Enter a stock symbol in the sidebar. 📝 2. Choose the date range for the analysis. 🗓️ 3. Click on "Analyze" to view the stock data, indicators, and signals. 🔍 ### Optimal Time Frame for Best Visualization 🕒 For the best experience, it's recommended to select a time range of up to 2 weeks when using the 15-minute data. This will ensure the charts remain clear and interactive features perform well. """) # Sidebar inputs with emojis st.sidebar.header('User Input Parameters 📋') stock_symbol = st.sidebar.text_input('Stock Symbol', value='AAPL', max_chars=5) start_date = st.sidebar.date_input('Start Date') end_date = st.sidebar.date_input('End Date') analyze_button = st.sidebar.button('Analyze 🚀') # Option for selecting chart type chart_type = st.sidebar.radio("Chart Type:", ('Static', 'Interactive')) # Main functionality if analyze_button: st.write(f"Fetching data for {stock_symbol} from {start_date} to {end_date}... 🔄") data = fetch_intraday_data(stock_symbol, start_date.isoformat(), end_date.isoformat()) if data.empty: st.error("No data found for the given parameters. Please try different dates or stock symbols. ❌") else: st.write("Calculating indicators... 🔍") ema_periods = [20, 50] # Example periods for EMA for period in ema_periods: data[f'EMA_{period}'] = calculate_ema(data['Close'], period) data['RSI'] = calculate_rsi(data['Close']) macd_result = calculate_macd(data['Close']) data = pd.concat([data, macd_result], axis=1) bb_result = calculate_bollinger_bands(data['Close']) data = pd.concat([data, bb_result], axis=1) st.write("Generating signals... 🚦") data = generate_combined_signals(data) st.write("Visualizing data, indicators, and signals... 📊") if chart_type == 'Static': plot_stock_data_with_signals(data) else: plot_stock_data_with_signals_interactive(data)