diff --git a/Beginner_Projects/Stock App/Readme.md b/Beginner_Projects/Stock App/Readme.md new file mode 100644 index 00000000..0c9c212e --- /dev/null +++ b/Beginner_Projects/Stock App/Readme.md @@ -0,0 +1,46 @@ +## **STOCK APP** + +### ๐ŸŽฏ **Goal** + +Python Project - This App show stock details of the entered ticker. + - Compnay Profile + - Income Statement Details + - EPS Chart + - Company Current Quotes + + Modules Used: + - Financial Modelling Perp API + - requests + - Flask + + +### ๐Ÿงพ **Description** + +This project allows users to fetch detailed stock-related information using the Financial Modeling Prep API. The app returns essential financial data of a company based on the ticker entered by the user. Data includes the company's profile, income statements, EPS trends, and real-time stock quotes. + +### ๐Ÿงฎ **What I had done!** + +1. Created a Flask-based web app to collect the stock ticker from the user. +2. Used the Financial Modeling Prep API to fetch the stock details. +3. Processed the API data and displayed it in a user-friendly format. +4. Created an EPS chart visualization using the stock data. +5. Added company profile and income statement details to the app for easy analysis. +6. Integrated real-time stock quotes into the app for instant updates. + +### ๐Ÿš€ **Models Implemented** + +No machine learning models were implemented in this app. The stock data is purely fetched from the Financial Modeling Prep API and visualized as-is. The EPS trend is displayed in a chart for easier interpretation. + +### ๐Ÿ“ข **Conclusion** + +`The app successfully displays comprehensive financial data for any entered stock ticker. This includes a company's profile, income statement, real-time quotes, and an EPS trend chart to analyze the company's financial health. It serves as a basic stock data retrieval and visualization tool for quick reference.` + +### โœ’๏ธ **Your Signature** + + +`Ananya Gupta` +[GitHub Profile](https://github.com/ananyag309) + + + + diff --git a/Beginner_Projects/Stock App/Templates/base.html b/Beginner_Projects/Stock App/Templates/base.html new file mode 100644 index 00000000..853c9f10 --- /dev/null +++ b/Beginner_Projects/Stock App/Templates/base.html @@ -0,0 +1,37 @@ + + + + + + + + + StockPage | {% block title %} {% endblock title %} + + + + + + + +
+ {% block content %} + + {% endblock content %} +
+ + + + + \ No newline at end of file diff --git a/Beginner_Projects/Stock App/Templates/financials.html b/Beginner_Projects/Stock App/Templates/financials.html new file mode 100644 index 00000000..a3dd3c17 --- /dev/null +++ b/Beginner_Projects/Stock App/Templates/financials.html @@ -0,0 +1,60 @@ +
Financials
+ + + + + + + + + + + + + + {% for f in financials %} + + + + + + + + {% endfor %} + + +
As of Revenue Grosss profit NET income EPS
{{ f["date"] }} {{ f['revenue'] }} {{ f['grossProfit'] }} {{ f['netIncome'] }} {{ f['eps'] }}
+ +
+ chart + +
+ +
+
Today's Quotes
+ {% for item in quotes %} + +

Open: {{item['open']}} | + Close: {{item['previousClose']}}

+

Price change(%): {{item['changesPercentage']}} | Price Change($): {{item['change']}}

+

+ Today's Low: {{item['dayLow']}} | + Today's High: {{item['dayHigh']}} +

+

+ Year's Low: {{item['yearLow']}} | + Year's High: {{item['yearHigh']}} +

+

+ Price Average(50 days): {{item['priceAvg50']}} | + Total Volume: {{item['volume']}} +

+

+ Price to Earnings: {{item['pe']}} | + Shares outstanding:{{item['sharesOutstanding']}} +

+ + {% endfor %} +
+
+ diff --git a/Beginner_Projects/Stock App/Templates/index.html b/Beginner_Projects/Stock App/Templates/index.html new file mode 100644 index 00000000..c8820e78 --- /dev/null +++ b/Beginner_Projects/Stock App/Templates/index.html @@ -0,0 +1,36 @@ +{% extends "base.html" %} + +{% block title %} Home {% endblock title %} + + + + + + + +{% block content %} + + +
+
+

Welcome to my Stock Page

+
A Quick way to find stock details.
+
+ + +
+
+ + + +
+
+ + +
+ + +{% endblock content %} + + + diff --git a/Beginner_Projects/Stock App/server.py b/Beginner_Projects/Stock App/server.py new file mode 100644 index 00000000..1d1aea73 --- /dev/null +++ b/Beginner_Projects/Stock App/server.py @@ -0,0 +1,81 @@ +from flask import Flask, redirect, render_template, url_for, request +import requests + +app = Flask(__name__) + +API_key = '***************************' +api_url ="https://financialmodelingprep.com/api/v3/quote-short/{ticker}" + +def fetch_price(ticker): + data = requests.get(api_url.format(ticker=ticker.upper()), params = {'apikey': API_key}).json() + for p in data: + return p['price'] + + +def fetch_volume(ticker): + data = requests.get(api_url.format(ticker=ticker.upper()), params = {'apikey': API_key}).json() + for p in data: + return p['volume'] + + + +def fetch_income_stat(ticker): + api_url = 'https://financialmodelingprep.com/api/v3/income-statement/{ticker}?period=quarter?limit=8' + financials = requests.get(api_url.format(ticker=ticker.upper()), params={'apikey':API_key}).json() + financials.sort(key=lambda quarter: quarter['date']) + return financials + + +def financial_chart(ticker): + data = fetch_income_stat(ticker) + chart_data= [float(q['eps']) for q in data if q['eps']] + chart_process= {"type": 'line', + 'data':{ + 'labels':[q['date'] for q in data if q['eps']], + 'datasets':[{'label':'EPS','data':chart_data}] + } + } + return chart_process + + +def profile(ticker): + company_profile = requests.get(f"https://financialmodelingprep.com/api/v3/profile/{ticker}?apikey={API_key}").json() + return company_profile + + + +def todayQuote(ticker): + quotes = requests.get(f"https://financialmodelingprep.com/api/v3/quote/{ticker.upper()}?apikey={API_key}").json() + try: + return quotes + except Exception: + return ("Quotes not avialble right now!") + + +@app.route("/stock/") +def fetch_ticker(ticker): + price = fetch_price(ticker) + volume = fetch_volume(ticker) + financials = fetch_income_stat(ticker) + epsChart= financial_chart(ticker) + companyprofile = profile(ticker) + quotes = todayQuote(ticker) + return render_template("stockpage.html", price=price, volume=volume, financials=financials, epsChart=epsChart, profile=companyprofile, quotes=quotes, ticker=ticker) + + + +@app.route("/search", methods=['POST']) +def search(): + return redirect(url_for('fetch_ticker', ticker=request.form['searchticker'])) + + + + +@app.route("/") +def home_page(): + return render_template("index.html") + + + +if __name__ == "__main__": + app.run(debug=True, threaded=True) \ No newline at end of file