️ DEPRECATED GITLAB INSTANCE ️ This GitLab is now read-only for reference. Please use https://gitlab.iauro.co for all new work.

Migration completed on September 17, 2025

Assignment 3 completed

parent e395c0c9
import streamlit as st
import yfinance as yf
import pandas as pd
from sumy.parsers.plaintext import PlaintextParser
from sumy.nlp.tokenizers import Tokenizer
from sumy.summarizers.lsa import LsaSummarizer
# --------------------------------
# Page configuration
# --------------------------------
st.set_page_config(page_title="Stock Dashboard & Summarizer", layout="wide")
# --------------------------------
# App Title and Description
# --------------------------------
st.title("📈 Stock Price Dashboard & 📝 Summarizer")
st.markdown("""
Welcome to the **Stock Analysis App** built with Streamlit.
- Search and visualize **stock price trends**
- Paste stock-related news or description for **automatic summarization**
""")
# --------------------------------
# User Input Section
# --------------------------------
st.sidebar.header("User Input")
stock_symbol = st.sidebar.text_input("Enter Stock Symbol (e.g., AAPL, MSFT)", value="AAPL")
days = st.sidebar.slider("Select number of past days", min_value=5, max_value=365, value=30)
# --------------------------------
# Function to fetch stock data
# --------------------------------
@st.cache_data
def fetch_stock_data(symbol, days):
return yf.download(symbol, period=f"{days}d")
# --------------------------------
# Display stock chart
# --------------------------------
st.subheader(f"📊 Stock Price Chart for {stock_symbol}")
if st.sidebar.button("Load Stock Data"):
try:
stock_data = fetch_stock_data(stock_symbol, days)
if not stock_data.empty:
st.line_chart(stock_data['Close'])
st.metric("Latest Close Price", f"${stock_data['Close'].iloc[-1]:.2f}")
else:
st.warning("No data found for this symbol.")
except Exception as e:
st.error(f"Error fetching data: {e}")
# --------------------------------
# Text Summarization Section
# --------------------------------
st.markdown("---")
st.subheader("📝 Stock News or Description Summarizer")
text_input = st.text_area("Paste any stock-related text here to summarize")
# Function to summarize text
def summarize_text(text, sentence_count=2):
parser = PlaintextParser.from_string(text, Tokenizer("english"))
summarizer = LsaSummarizer()
summary = summarizer(parser.document, sentence_count)
return " ".join(str(sentence) for sentence in summary)
# Button to trigger summarization
if st.button("Generate Summary"):
if text_input.strip():
summary = summarize_text(text_input)
st.success("**Summary:**")
st.write(summary)
else:
st.warning("Please enter some text first.")
# --------------------------------
# Footer
# --------------------------------
st.markdown("---")
st.markdown("Built with [Streamlit](https://streamlit.io/) | By Mitul Lakkad")
\ No newline at end of file
streamlit
yfinance
sumy
pandas
numpy
nltk
scikit-learn
matplotlib
seaborn
plotly
requests
beautifulsoup4
lxml
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment