A collection of advanced quantitative finance and risk modeling tasks.
This repository contains a suite of Python-based solutions for real-world quantitative research and risk management problems, including:
- Natural Gas Price Estimation & Storage Contract Valuation
- Loan Default Probability (PD) Modeling & Expected Loss Calculation
- FICO Score Quantization & Rating Map Optimization
Each module is designed for clarity, extensibility, and practical use in a professional or academic setting.
gas_price_analysis.py
Estimate natural gas prices for any date and value storage contracts with custom cash flows.loan_default_analysis.py
Predict loan default probability (PD) and expected loss using machine learning.task4.py
FICO score bucketing and quantization using dynamic programming and log-likelihood/MSE optimization.Task 3 and 4_Loan_Data.csv
Loan borrower dataset for PD modeling and quantization.Nat_Gas.csv
Monthly natural gas price data for time series modeling.requirements.txt
All required Python dependencies.
- Interpolate and extrapolate gas prices for any date (past or future)
- Value storage contracts with custom injection/withdrawal schedules, storage costs, and volume constraints
- Detailed cash flow breakdown and storage level tracking
- Train and compare Logistic Regression and Random Forest models
- Predict PD for any borrower profile
- Calculate expected loss using a configurable recovery rate
- Feature importance visualization for model interpretability
- Optimal bucketing of FICO scores using dynamic programming
- Supports both log-likelihood and MSE as optimization criteria
- Maps FICO scores to ratings for robust credit risk segmentation
Contract Value: $-5,995.53
Cash Flows:
2023-01-01: injection $-23,232.26
2023-02-01: storage_cost $-930.00
... (truncated)
Model Performance:
Logistic Regression ROC AUC: 1.0000
Random Forest ROC AUC: 0.9997
Example Loan Analysis:
Loan Amount: $10,000.00
Probability of Default: 2.13%
Expected Loss: $1,917.00
Optimal FICO boundaries: [545, 602, 650, 700, 750]
Sample mapping:
fico_score rating
0 605 2
1 720 5
...
- Install dependencies:
pip install -r requirements.txt
- Run any module:
python gas_price_analysis.py python loan_default_analysis.py python task4.py
Pull requests and suggestions are welcome! For major changes, please open an issue first to discuss what you would like to change.