netflypsb commited on
Commit
4ef2d29
1 Parent(s): aa4f8e5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from data_fetcher.yfinance_client import fetch_intraday_data
3
+ from indicators.ema import calculate_ema
4
+ from indicators.rsi import calculate_rsi
5
+ from indicators.macd import calculate_macd
6
+ from indicators.bollinger_bands import calculate_bollinger_bands
7
+ from signals.strategy import generate_combined_signals
8
+ from utils.plotting import plot_stock_data_with_signals
9
+ import pandas as pd
10
+
11
+ # Streamlit app title
12
+ st.title('Stock Intraday Signal App')
13
+
14
+ # Introduction and instructions
15
+ st.write("""
16
+ ## Introduction
17
+ 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.
18
+
19
+ ## How to Use
20
+ 1. Enter a stock symbol in the sidebar.
21
+ 2. Choose the date range for the analysis.
22
+ 3. Click on "Analyze" to view the stock data, indicators, and signals.
23
+ """)
24
+
25
+ # Sidebar inputs
26
+ st.sidebar.header('User Input Parameters')
27
+ stock_symbol = st.sidebar.text_input('Stock Symbol', value='AAPL', max_chars=5)
28
+ start_date = st.sidebar.date_input('Start Date')
29
+ end_date = st.sidebar.date_input('End Date')
30
+ analyze_button = st.sidebar.button('Analyze')
31
+
32
+ # Main functionality
33
+ if analyze_button:
34
+ # Fetch stock data
35
+ st.write(f"Fetching data for {stock_symbol} from {start_date} to {end_date}...")
36
+ data = fetch_intraday_data(stock_symbol, start_date.isoformat(), end_date.isoformat())
37
+
38
+ if data.empty:
39
+ st.error("No data found for the given parameters. Please try different dates or stock symbols.")
40
+ else:
41
+ # Calculate indicators
42
+ st.write("Calculating indicators...")
43
+ ema_periods = [20, 50] # Example periods for EMA
44
+ data = calculate_ema(data, ema_periods)
45
+ data = calculate_rsi(data)
46
+ data = calculate_macd(data)
47
+ data = calculate_bollinger_bands(data)
48
+
49
+ # Generate signals
50
+ st.write("Generating signals...")
51
+ data = generate_combined_signals(data)
52
+
53
+ # Plot results
54
+ st.write("Visualizing data, indicators, and signals...")
55
+ plot_stock_data_with_signals(data)