A comprehensive Streamlit application for CAPEX/OPEX financial analysis with multi-scenario comparison.
- Net Present Value (NPV): Calculates the present value of future cash flows
- Internal Rate of Return (IRR): Determines the discount rate at which NPV equals zero
- Return on Investment (ROI): Measures the profitability of an investment
- Payback Period: Calculates the time required to recover the initial investment
- Straight-Line Depreciation
- Declining Balance Depreciation
- Sum-of-Years-Digits Depreciation
- Create up to 10 scenarios for comparison
- Duplicate existing scenarios for sensitivity analysis
- Import/Export scenarios in JSON format
- Interactive comparison charts (NPV, IRR, ROI, Payback)
- Cash flow line charts
- Cumulative cash flow analysis
- Waterfall charts for detailed breakdowns
- Excel reports with formatted tables and charts
- PDF summary reports for presentations
- JSON data export for backup and data transfer
- Python 3.9 or higher
- pip (Python package manager)
- Clone or download this project:
git clone https://github.com/abyansyah052/IPFEST.git
cd IPFEST/financial-scenario-analyzer- Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On macOS/Linux
# or
venv\Scripts\activate # On Windows- Install dependencies:
pip install -r requirements.txtStart the Streamlit application:
streamlit run app.pyThe application will open in your default web browser at http://localhost:8501.
- Home (app.py): Overview and scenario management
- Dashboard: Key metrics summary and comparison charts
- Input Data: Configure scenarios with CAPEX and OPEX items
- Results: Calculate and view financial metrics
- Compare Scenarios: Side-by-side scenario comparison
- Export: Download reports in Excel, PDF, or JSON format
- Create a Scenario: Click "New Scenario" in the sidebar
- Configure Parameters: Set discount rate, tax rate, and analysis period
- Add CAPEX Items: Enter capital expenditure items with depreciation settings
- Add OPEX Items: Enter operating expenses with escalation rates
- Set Revenue: Configure annual revenue and growth rate
- Calculate: Go to Results page and click "Calculate Financial Metrics"
- Compare: Use Compare Scenarios page to evaluate multiple options
- Export: Download reports for presentation or further analysis
financial-scenario-analyzer/
├── app.py # Main application entry point
├── requirements.txt # Python dependencies
├── README.md # This file
├── config/
│ ├── __init__.py
│ └── settings.py # Application configuration
├── models/
│ ├── __init__.py
│ ├── capex_item.py # CAPEX item data model
│ ├── opex_item.py # OPEX item data model
│ ├── scenario.py # Scenario data model
│ └── financial_calculator.py # Financial calculations
├── pages/
│ ├── 1_Dashboard.py # Dashboard page
│ ├── 2_Input_Data.py # Data input page
│ ├── 3_Results.py # Results page
│ ├── 4_Compare_Scenarios.py # Comparison page
│ └── 5_Export.py # Export page
├── utils/
│ ├── __init__.py
│ ├── session_manager.py # Session state management
│ ├── best_scenario.py # Best scenario identification
│ ├── visualizations.py # Plotly chart functions
│ ├── export_excel.py # Excel export functions
│ └── export_pdf.py # PDF export functions
└── tests/
└── test_calculations.py # Unit tests
Execute the test suite:
cd financial-scenario-analyzer
pytest tests/test_calculations.py -vDefault settings can be modified in config/settings.py:
MAX_SCENARIOS: Maximum number of scenarios (default: 10)DEFAULT_DISCOUNT_RATE: Default discount rate (default: 12.0%)DEFAULT_TAX_RATE: Default tax rate (default: 22.0%)DEFAULT_ANALYSIS_PERIOD: Default analysis period (default: 10 years)DEPRECIATION_METHODS: Available depreciation methodsOPEX_CATEGORIES: Available OPEX categories
- Streamlit: Web application framework
- pandas: Data manipulation and analysis
- numpy: Numerical computations
- numpy-financial: Financial calculations (NPV, IRR)
- plotly: Interactive visualizations
- openpyxl: Excel file generation
- fpdf2: PDF file generation
The application uses numpy-financial for accurate NPV and IRR calculations:
- NPV:
npf.npv(rate, cashflows) - IRR:
npf.irr(cashflows) - ROI:
(Total Return - Total Investment) / Total Investment * 100 - Payback: Linear interpolation on cumulative cash flows
This project is provided for educational and demonstration purposes.
Financial Analysis Team - IPFEST Project