File size: 1,343 Bytes
c0f4173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# app.py

import streamlit as st
import pandas as pd
from datetime import datetime, timedelta

# Import your modules here
from yfinance_data.fetcher import fetch_data_for_indicators
from indicators.sma import add_sma_columns
from indicators.bollinger_bands import calculate_bollinger_bands
from signals.strategy import generate_buy_signals, generate_sell_signals
from utils.plotting import plot_stock_data

# Initialize the app with Streamlit
st.title('StockSwingApp: Stock Signal Generator')

# User input for the stock symbol
symbol = st.text_input('Enter the stock symbol:', value='AAPL')

# Fetch the stock data
data_4h, data_1h = fetch_data_for_indicators(symbol, days=90)  # Fetching more days to ensure we have enough data

# Calculate indicators
add_sma_columns(data_4h)
add_sma_columns(data_1h)
calculate_bollinger_bands(data_4h)

# Generate signals
buy_signals = generate_buy_signals(data_4h, data_1h)
sell_signals = generate_sell_signals(data_4h)

# Plotting
st.write(f"Displaying indicators and signals for: {symbol}")
plot_stock_data(data_4h, buy_signals=buy_signals, sell_signals=sell_signals, title=f"{symbol} Stock Analysis")

# Instructions for running the app
st.markdown("""
To run this app, ensure you have Streamlit and all required packages installed. Then, navigate to the directory containing this script and run: """)