Skip to content

kashfifahim/flask-stocks-web-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Stock Portfolio Web Application

This Flask web application fetches real-time stock prices using the Alpha Vantage API and displays them along with the total value of a predefined stock portfolio. It features server-side caching to optimize API usage and improve performance.

Features

  • Real-Time Stock Prices: Fetches the latest prices for a set of stocks.
  • Portfolio Management: Displays quantities and total values of selected stocks.
  • Server-Side Caching: Implements file-based caching to limit API calls.
  • User-Friendly Interface: Presents data in a neatly formatted table.

Setup and Installation

  1. Clone the Repository
git clone [repository_url]
cd [repository_name]
  1. Create and Activate a Virtual Environment (optional, but recommended)
  • For Windows:
python -m venv venv
venv\Scripts\activate
  • For macOS and Linux:
python3 -m venv venv
source venv/bin/activate
  1. Install Dependencies:
pip install Flask requests
  1. Set Environment Variables
  • For Windows:
set FLASK_APP=app.py
set FLASK_ENV=development
  • For macOS and Linux:
export FLASK_APP=app.py
export FLASK_ENV=development
  1. Run the Application
flask run

Usage

  • Access the web application via http://127.0.0.1:5000 in your web browser.
  • View real-time stock prices and the total value of the stock portfolio.

File Structure

  • app.py: Main Flask application file.
  • templates/: Folder containing HTML templates.
    • index.html: The main template for displaying stock prices.
  • static/: Folder for static files.
    • style.css: CSS stylesheet for styling the web interface.

Caching Mechanism

  • Caching is implemented to reduce the frequency of API calls.
  • Stock prices are stored in the cache directory with a defined expiration time.
  • Cached data is used when available and not expired; otherwise, an API call is made.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published