Spaces:
Running
Running
File size: 2,578 Bytes
9d82034 4ef2d29 9d82034 4ef2d29 9d82034 4ef2d29 9d82034 4ef2d29 9d82034 4ef2d29 9d82034 4ef2d29 9d82034 4ef2d29 9d82034 4ef2d29 9d82034 4ef2d29 9d82034 4ef2d29 9d82034 4ef2d29 9d82034 4ef2d29 9d82034 4ef2d29 9d82034 |
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# app.py
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
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. π
""")
# 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 π')
# 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
ema_data = calculate_ema(data['Close'], ema_periods)
for period, ema_series in ema_data.items():
data[f'EMA_{period}'] = ema_series
rsi_results = calculate_rsi(data['Close'])
data = data.join(rsi_results) # Merge the RSI results back into the main DataFrame
macd_data = calculate_macd(data['Close'])
data = pd.concat([data, macd_data], axis=1)
bb_data = calculate_bollinger_bands(data['Close'])
data = pd.concat([data, bb_data], axis=1)
st.write("Generating signals... π¦")
data = generate_combined_signals(data)
st.write("Visualizing data, indicators, and signals... π")
plot_stock_data_with_signals(data)
|