- Overview
- Tech Stack
- Environment variables
- Installation
- API Reference (summary)
- Database Schema (reference)
- Screenshots
- License
- Contributing
- Author & Contact
Monte Carlo Portfolio is a web app for running Monte Carlo simulations on user-defined portfolios (stocks, ETFs, cryptocurrencies). Users specify tickers, an allocation distribution, and an initial portfolio value. Registered users can save their settings for reuse. The app uses historical price data (default: last 1000 days) to estimate portfolio trajectories over a future window (default: 100 days). This tool is educational and intended to help explore possible outcomes — it is not financial advice.
- Frontend: React (TypeScript), Vite
- Backend: FastAPI (Python)
- Database: PostgreSQL (or SQLite for local development)
- Docker
Backend (examples):
SECRET_KEY— JWT secretALGORITHM— JWT algorithm (e.g.HS256)API_URL— frontend URLDB_URL— database connection string (e.g.sqlite:///./mydborpostgresql://user:pass@host/dbname)DEPLOYMENT_ENVIRONMENT—DEVorPRODUCTION
Frontend (examples):
VITE_API_URL— backend base URLVITE_API_PORT— backend port (default:8000)VITE_PORT— frontend port (default:5173)
Note:
- Using SQLite (
sqlite:///./mydb) is convenient for local development; PostgreSQL is recommended for production.
- Node.js and Python 3.12+
or
- Docker
git clone https://github.com/Sebastijan-Dominis/monte_carlo_portfolio.git
cd monte_carlo_portfolioIf using Anaconda:
cd backend
conda create -n monte-carlo-portfolio python=3.12
conda activate monte-carlo-portfoliopip install -r requirements.txtuvicorn main:app --reloadcd frontendnpm installnpm run devtypically
http://localhost:5173/.
git clone https://github.com/Sebastijan-Dominis/monte_carlo_portfolio.git
cd monte_carlo_portfolio- Do this for both backend and frontend
docker-compose build --no-cachedocker compose uptypically
http://localhost:5173/.
/— general health/health— checks DB connectivity
-
POST /simulations/— run a Monte Carlo simulation.- Body example:
{ "distribution": [0.4, 0.3, 0.3], "distribution_type": "exact", "initial_portfolio": 10000, "tickers": ["TSLA", "GOOGL", "META"] } - Returns: 201 and an image (graph) of simulated outcomes.
- Body example:
-
POST /simulations/user/{settings_id}— run simulation using a user's saved settings.
POST /auth/create-user— create a new user (email + password). Returns 201 on success.POST /auth/authorize— obtain JWT (form data withusernameandpassword). Returns access token.GET /auth/all-users— list users (admin/internal use).DELETE /auth/delete-user/{user_id}— delete user (admin/internal use).
GET /portfolio_settings/all— user-specific saved settingsPOST /portfolio_settings/add— add new settingsPUT /portfolio_settings/update/{settings_id}— update settingsDELETE /portfolio_settings/{settings_id}— delete settingsGET /portfolio_settings/— fetch all settings (admin/internal use)
Refer to the source backend/routers/ for full request/response details and validation rules.
Example SQL used to create the core tables:
DROP TABLE IF EXISTS users;
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email TEXT UNIQUE NOT NULL,
hashed_password TEXT NOT NULL
);
DROP TABLE IF EXISTS portfolio_settings;
CREATE TABLE portfolio_settings (
id SERIAL PRIMARY KEY,
tickers JSONB NOT NULL,
distribution_type TEXT NOT NULL CHECK (distribution_type IN ('random', 'equal', 'exact')),
distribution JSONB NOT NULL,
initial_portfolio DOUBLE PRECISION NOT NULL,
owner_id INTEGER NOT NULL REFERENCES users(id)
);- This repository includes a
LICENSEfile — please review it for terms of reuse.
- Improvements and bug fixes welcome. Open an issue or submit a pull request with a clear description of the change.
- Author: Sebastijan Dominis
- Contact: sebastijan.dominis99@gmail.com






