netflypsb commited on
Commit
9d82034
β€’
1 Parent(s): 4ef2d29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -25
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import streamlit as st
2
  from data_fetcher.yfinance_client import fetch_intraday_data
3
  from indicators.ema import calculate_ema
@@ -8,48 +10,53 @@ 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)
 
 
1
+ # app.py
2
+
3
  import streamlit as st
4
  from data_fetcher.yfinance_client import fetch_intraday_data
5
  from indicators.ema import calculate_ema
 
10
  from utils.plotting import plot_stock_data_with_signals
11
  import pandas as pd
12
 
13
+ # Streamlit app title with emoji
14
+ st.title('Stock Intraday Signal App πŸ“ˆ')
15
 
16
+ # Introduction and instructions with emojis
17
  st.write("""
18
+ ## Introduction 🌟
19
+ 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.
20
 
21
+ ## How to Use πŸ› οΈ
22
+ 1. Enter a stock symbol in the sidebar. πŸ“
23
+ 2. Choose the date range for the analysis. πŸ—“οΈ
24
+ 3. Click on "Analyze" to view the stock data, indicators, and signals. πŸ”
25
  """)
26
 
27
+ # Sidebar inputs with emojis
28
+ st.sidebar.header('User Input Parameters πŸ“‹')
29
  stock_symbol = st.sidebar.text_input('Stock Symbol', value='AAPL', max_chars=5)
30
  start_date = st.sidebar.date_input('Start Date')
31
  end_date = st.sidebar.date_input('End Date')
32
+ analyze_button = st.sidebar.button('Analyze πŸš€')
33
 
34
  # Main functionality
35
  if analyze_button:
36
+ st.write(f"Fetching data for {stock_symbol} from {start_date} to {end_date}... πŸ”„")
 
37
  data = fetch_intraday_data(stock_symbol, start_date.isoformat(), end_date.isoformat())
38
 
39
  if data.empty:
40
+ st.error("No data found for the given parameters. Please try different dates or stock symbols. ❌")
41
  else:
42
+ st.write("Calculating indicators... πŸ”")
 
43
  ema_periods = [20, 50] # Example periods for EMA
44
+ ema_data = calculate_ema(data['Close'], ema_periods)
45
+ for period, ema_series in ema_data.items():
46
+ data[f'EMA_{period}'] = ema_series
47
+
48
+ rsi_results = calculate_rsi(data['Close'])
49
+ data = data.join(rsi_results) # Merge the RSI results back into the main DataFrame
50
+
51
+ macd_data = calculate_macd(data['Close'])
52
+ data = pd.concat([data, macd_data], axis=1)
53
+
54
+ bb_data = calculate_bollinger_bands(data['Close'])
55
+ data = pd.concat([data, bb_data], axis=1)
56
 
57
+ st.write("Generating signals... 🚦")
 
58
  data = generate_combined_signals(data)
59
 
60
+ st.write("Visualizing data, indicators, and signals... πŸ“Š")
 
61
  plot_stock_data_with_signals(data)
62
+