A Flask-based web application for tracking stock portfolios, dividends, and portfolio analysis.
- User Authentication: Create an account and securely login to manage your portfolio
- Portfolio Management: Add, edit, and remove stocks from your portfolio
- Real-time Data: Fetches current stock prices and information using Yahoo Finance API
- Dividend Tracking: Monitor dividend income and analyze dividend performance
- Risk Analysis: Advanced portfolio risk metrics
- Historical Returns: Individual stock and portfolio returns
- Responsive Design: Works on desktop and mobile devices
portfolio-tracker/
├── app.py # Main application file
├── requirements.txt # Python dependencies
├── portfolio.db # SQLite database
├── static/ # Static files
│ ├── css/
│ │ └── style.css # Custom CSS
│ └── images/
│ ├── risk_formulas.png
│ ├── sharp.png
│ └── wallstreet.jpeg
└── templates/ # HTML templates
├── base.html # Base template with common elements
├── index.html # Landing page
├── login.html # Login page
├── signup.html # Signup page
├── portfolio.html # Portfolio management page
├── dividends.html # Dividend tracking page
└── analysis.html # Portfolio analysis page
-
Clone the repository or download the source code
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install the required dependencies:
pip install -r requirements.txt
-
Create the database directory:
mkdir -p instance
-
Create the images directory in static folder and add required images:
mkdir -p static/images
Copy the following images to the
static/images
folder:- risk_formulas.png
- sharp.png
- wallstreet.jpg
-
Run the application:
python app.py
-
Open your web browser and navigate to
http://127.0.0.1:5000
-
Create an account on PythonAnywhere
-
Upload your project files to PythonAnywhere using their file uploader or by cloning from a Git repository
-
Create a virtual environment and install dependencies:
mkvirtualenv --python=/usr/bin/python3.9 myenv pip install -r requirements.txt
-
Configure a new web app:
- Go to the Web tab
- Create a new web app
- Select "Flask" as the framework
- Set the Python version to match your local development environment
- Set the path to your Flask application (app.py)
- Set the working directory to your project directory
-
Configure WSGI file to point to your app:
import sys path = '/home/yourusername/portfolio-tracker' if path not in sys.path: sys.path.insert(0, path) from app import app as application
-
Restart your web app
-
Create a Procfile in your project root:
web: gunicorn app:app
-
Create a runtime.txt file to specify Python version:
python-3.9.16
-
Ensure your app uses environment variables for sensitive data:
import os app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'your-default-key') app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL', 'sqlite:///portfolio.db')
-
Install the Heroku CLI and login:
heroku login
-
Create a new Heroku app:
heroku create portfolio-tracker
-
Set environment variables:
heroku config:set SECRET_KEY=your-secret-key
-
Push your code to Heroku:
git add . git commit -m "Initial commit" git push heroku main
-
Set up a PostgreSQL database on Heroku:
heroku addons:create heroku-postgresql:hobby-dev
-
Open your deployed application:
heroku open
- Account Types: Modify the account options in the app.py file to match your personal accounts
- UI Theme: Customize the colors and styles in the static/css/style.css file
- Add Features: Extend the application with additional features like tax optimization or asset allocation
This project is licensed under the MIT License - see the LICENSE file for details.