Spaces:
Runtime error
Runtime error
# 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: """) | |