A comprehensive financial planning tool
Project description
Prism
A Python-based financial planning library for projecting net worth over time using Monte Carlo simulation. This tool helps individuals and families model their financial future by simulating various income, expense, investment, and tax scenarios across multiple years, with a focus on FIRE (Financial Independence, Retire Early) planning.
Table of Contents
- Prism
Features
- 💰 Income Modeling: Multiple sources (salaries, bonuses, RSUs) with growth and variability
- 📊 Tax Calculations: Federal, state, and payroll taxes with proper filing status
- 💸 Expense Tracking: Fixed, inflation-adjusted, or percentage-based expenses
- 📈 Investment Simulation: Monte Carlo simulation with correlated returns
- 🏦 Portfolio Management: Real market data integration for individual stocks
- 📉 Stock Analysis: Comprehensive metrics (alpha, beta, Sharpe, VaR, drawdown, etc.)
- 🔄 Trading: High-performance backtesting framework for trading strategies
- 🔥 FIRE Planning: Calculate timelines for Coast, Lean, Chubby, and Fat FIRE
- 💵 Paycheck Calculations: Detailed per-paycheck breakdowns with taxes and deductions
Quick Start
Installation
From Source
# Clone the repository
git clone https://github.com/adityahemanth/prism.git
cd prism
# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Using pip (when published)
pip install prism
Basic Usage
Create a simple config file:
# my_config.yaml
persons:
- name: "Person 1"
income_sources:
- type: "base_salary"
base_amount: 200000.0
Run the simulation:
python src/main.py my_config.yaml
This uses smart defaults for taxes, retirement, expenses, and investments. See Getting Started Guide for details.
Using as a Python Library
from prism import FinanceProjection
# Load configuration and run simulation
projection = FinanceProjection.from_config("config.yaml")
results = projection.run_simulation()
median_net_worth = results['net_worth_percentiles'][50]
print(f"Median net worth: ${median_net_worth:,.2f}")
Example: Calculate Stock Metrics
from prism import calculate_stock_metrics, format_stock_metrics
# Calculate comprehensive metrics for a stock
metrics = calculate_stock_metrics("AAPL", years=5, benchmark_ticker="SPY")
# Print formatted output
print(format_stock_metrics(metrics))
# Access individual metrics
print(f"Sharpe Ratio: {metrics.sharpe_ratio:.2f}")
print(f"Beta: {metrics.beta:.2f}")
print(f"Max Drawdown: {metrics.max_drawdown:.2%}")
Example: Risk Calculations
import pandas as pd
from prism import (
calculate_volatility,
calculate_max_drawdown,
calculate_sharpe_ratio
)
# Daily returns
returns = pd.Series([0.01, -0.02, 0.03, -0.01, 0.02] * 50)
# Calculate risk metrics
volatility = calculate_volatility(returns, annualized=True, periods_per_year=252)
max_dd = calculate_max_drawdown(returns)
sharpe = calculate_sharpe_ratio(returns, risk_free_rate=0.02, periods_per_year=252)
print(f"Volatility: {volatility:.2%}")
print(f"Max Drawdown: {max_dd:.2%}")
print(f"Sharpe Ratio: {sharpe:.2f}")
Documentation
📚 Full Documentation - Complete documentation index
Quick Links
- Getting Started - Installation and basic usage
- Configuration Guide - Creating and customizing config files
- Financial Metrics Guide - Comprehensive guide to metrics (Sharpe, Beta, VaR, etc.)
- Risk Calculations Guide - Step-by-step risk analysis
- API Reference - Complete API documentation
- Examples - Code examples
Documentation Sections
- Guides - Step-by-step guides for common tasks
- Topics - Deep dives into specific features
- API Reference - Complete API documentation
- Reference - Methodology and configuration reference
Examples
Check out the examples directory for complete working examples:
library_usage.py- Basic library usagetrading_example.py- Simple backtesting exampleadvanced_trading_example.py- Advanced backtesting strategiesportfolio_holdings_example.py- Portfolio analysisstock_metrics_example.py- Stock metrics calculation
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Development Setup
# Clone and setup
git clone https://github.com/adityahemanth/prism.git
cd prism
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run tests
pytest
# Run tests with coverage
pytest --cov=src --cov-report=html
Code Style
- Follow PEP 8 style guidelines
- Use type hints where appropriate
- Write tests for new features
- Update documentation for API changes
Requirements
- Python 3.9+
- NumPy >= 2.0.0
- pandas >= 2.0.0
- PyYAML >= 6.0.0
- yfinance >= 0.2.0
- scipy >= 1.10.0
- vectorbt >= 0.25.0 (for trading/backtesting)
See requirements.txt for the complete list.
License
This project is licensed under the MIT License. See the LICENSE file for details (if available).
Future Enhancements
For a comprehensive list of planned features, see TODO.md.
Acknowledgments
- Built with NumPy and pandas for numerical computing
- Market data provided by yfinance
- Backtesting powered by vectorbt
Note: This library is for educational and personal financial planning purposes. Always consult with a qualified financial advisor for professional financial advice.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pfisca-0.1.0.tar.gz.
File metadata
- Download URL: pfisca-0.1.0.tar.gz
- Upload date:
- Size: 90.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a290805859519eaed73e5eaa55c4fda45f12bd63c284da3aa860da6b40332721
|
|
| MD5 |
52b9d2f430073e85ae66dfa56a550a38
|
|
| BLAKE2b-256 |
5eb1033ecbfbe3e1689a1b9237e0095861a739b24e13947a2ab6b986581d1f1b
|
File details
Details for the file pfisca-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pfisca-0.1.0-py3-none-any.whl
- Upload date:
- Size: 108.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85ae37b2b18d247a5b5ee954cd799a0f5173b98e0e6d89e61b4c694e1e485f84
|
|
| MD5 |
8208470cf4e0cb595df91f763292d285
|
|
| BLAKE2b-256 |
def1712556b1ede628f9333434bdcaa6e5d4d25b5fad93fa36fe31fb25344cc4
|