A modular Python library for quantitative financial analysis: option and bond pricing, portfolio optimization, risk measurement, technical analysis, and strategy backtesting.
- Option Pricing: Analytical Black-Scholes, Monte Carlo, and binomial trees (European, American, Cox-Ross-Rubinstein, Leisen-Reimer with delta and gamma).
- Fixed Income: Present/future value, zero-coupon and coupon bond pricing, yield to maturity, modified duration, convexity, yield-curve bootstrapping, and forward rates.
- Portfolio Construction: A
Portfoliocontainer plus mean-variance optimization — maximum Sharpe, minimum variance, and the efficient frontier. - Risk & Performance: Parametric and Monte Carlo Value at Risk; total/annualized return, volatility, Sharpe ratio, and maximum drawdown.
- Factor Models: CAPM beta and alpha, OLS factor regression, and PCA on asset returns.
- Technical Analysis Library: Composable indicators (SMA, EMA, RSI, MACD, Bollinger Bands) that take a price Series and return a Series or DataFrame.
- Econometrics & Simulation: GARCH volatility fitting, ADF/KPSS stationarity tests, Engle-Granger cointegration, and stochastic process simulation (GBM, Ornstein-Uhlenbeck, Wiener).
- Backtesting Engine: A
backtrader-based runner supporting single- and multi-asset data feeds, with a set of example technical, pairs-trading, and machine-learning strategies.
- Python 3.9+
- Git
-
Clone the repository:
git clone https://github.com/noahbean33/financial_analysis_platform.git cd financial_analysis_platform -
Install the required dependencies:
pip install -r requirements.txt
from src.portfolio import Portfolio
from src.performance import buy_and_hold_performance
portfolio = Portfolio(['AAPL', 'MSFT', 'GOOG'], start_date='2020-01-01', end_date='2023-01-01')
metrics = buy_and_hold_performance(portfolio)
print(f"Sharpe ratio: {metrics['sharpe_ratio']:.2f}")For detailed information on how to use and extend the platform, please see our guides:
- User Guide: For users who want to run backtests, analyze data, and use the platform's features.
- Developer Guide: For developers who want to contribute to the platform by adding new strategies or indicators.
pytest- Enhance the Risk Module: Add historical VaR, Conditional VaR (Expected Shortfall), and rolling volatility alongside the existing parametric and Monte Carlo VaR.
- Add Option Greeks: Analytical delta, gamma, vega, theta and rho, plus an implied volatility solver.
- Broaden Data Access: Abstract the data layer behind a provider-agnostic interface so sources other than yfinance can be plugged in, with caching and retries.
- Extend Portfolio Optimization: Risk parity, Black-Litterman, weight constraints, and transaction-cost-aware rebalancing.
This platform is for informational and educational purposes only. The information and tools provided should not be construed as investment advice. All financial decisions are your own responsibility. The creators and contributors of this platform are not liable for any losses or damages arising from the use of this software. Always do your own research.