This project creates a complete machine learning + web application where the user can:
✔ Enter a stock symbol (AAPL, TCS, RELIANCE, BTC-USD, etc.)
✔ See historical price charts
✔ Run ML prediction for next 7–30 days
✔ Visualize forecast
✔ Access it via browser (Flask / Streamlit)
This is similar to what apps like TradingView, MarketMojo, Tickertape provide.
🛠️ Tech Stack
- Python
- yfinance (stock data)
- scikit-learn / Prophet / LSTM (ML prediction)
- Streamlit / Flask (web UI)
- Plotly / Matplotlib (graphs)
📦 Install Requirements
pip install yfinance pandas numpy scikit-learn matplotlib streamlit prophet plotly
📁 Project Structure
stock_predictor/
│── app.py
│── model.py
└── requirements.txt
📊 1. Fetch Historical Data
import yfinance as yf
def get_stock_data(symbol):
data = yf.download(symbol, period="5y")
return data
🔮 2. Simple Prediction (Prophet Model)
from prophet import Prophet
import pandas as pd
def predict_stock(data, days=30):
df = data.reset_index()[["Date", "Close"]]
df.columns = ["ds", "y"]
model = Prophet()
model.fit(df)
future = model.make_future_dataframe(periods=days)
forecast = model.predict(future)
return forecast
🌐 3. Streamlit Web App (app.py)
import streamlit as st
import plotly.express as px
from model import get_stock_data, predict_stock
st.title("📈 Stock Prediction Web App")
symbol = st.text_input("Enter Stock Symbol", "AAPL")
if st.button("Predict"):
data = get_stock_data(symbol)
st.subheader("Historical Close Prices")
fig = px.line(data, y="Close")
st.plotly_chart(fig)
forecast = predict_stock(data)
st.subheader("Forecasted Prices")
fig2 = px.line(forecast, x="ds", y="yhat")
st.plotly_chart(fig2)
🚀 Run the App
streamlit run app.py
Open browser:
http://localhost:8501

Leave a Reply