Okama Documentation
okama is a Python library for investment portfolio analysis and optimization. It applies concepts commonly used in quantitative finance.
okama provides access to free end-of-day historical market data and macroeconomic indicators through an API.
…entities should not be multiplied without necessity
– William of Ockham (c. 1287–1347)
Okama main features
Constrained Markowitz Mean-Variance Analysis (MVA) and portfolio optimization
Multi-period Efficient Frontier optimization with rebalancing constraints
Investment portfolios with contribution and withdrawal cash flows (DCF)
Monte Carlo simulations for financial assets and investment portfolios
Popular risk metrics: VaR, CVaR, semideviation, variance, and drawdowns
Forecasting models based on normal, lognormal, and Student’s t distributions
Distribution fitting and goodness-of-fit testing on historical data
Dividend yield and other dividend indicators for stocks
Backtesting and comparing the historical performance of a broad range of assets and indexes in multiple currencies
Methods for tracking the performance of index funds (ETFs) and comparing them with benchmarks
Main macroeconomic indicators: inflation, central bank rates, and financial ratios
Matplotlib visualizations for the Efficient Frontier, Transition Map, and asset risk/return performance
Financial data and macroeconomic indicators
okama can work with free financial data available through its API.
End of day historical data
Stocks and ETFs for major world markets
Mutual funds
Commodities
Currencies
Stock indexes
Macroeconomic indicators
For several countries, including the USA, the United Kingdom, the European Union, Russia, and Israel:
Inflation
Central bank rates
CAPE10 (Shiller P/E), or cyclically adjusted price-to-earnings ratios
Other historical data
Real estate prices
Top bank rates
Installation
Okama can be installed from PyPI:
pip install okama
The latest development version can be installed directly from GitHub:
git clone https://github.com/mbk-dev/okama@dev
poetry install
Warning
The development version of okama may have technical and financial issues. Use it carefully and at your own risk.
Quick Start
Index Funds Performance
Main
Assets & Portfolio
|
A financial asset, that could be used in a list of assets or in portfolio. |
|
List of financial assets. |
|
Investment portfolio. |
|
Rebalancing strategy for an investment portfolio. |
Cash Flows & DCF
|
Discounted cash flow (DCF) methods for a Portfolio. |
|
Monte Carlo simulation parameters for an investment portfolio. |
|
Cash flow strategy with regular indexed withdrawals or contributions. |
|
Cash flow strategy with regular fixed percentage withdrawals or contributions. |
|
Cash flow strategy with user-defined withdrawals and contributions. |
|
Vanguard Dynamic Spending strategy. |
|
Withdrawal strategy that reduces the withdrawal amount if the portfolio drawdown exceeds a certain threshold. |
Efficient Frontier
|
Efficient Frontier with multi-period optimization. |
Macroeconomics
|
Inflation related data and methods. |
|
Rates of central banks and banks. |
|
Macroeconomic indicators and ratios. |
Data Access & Search
okama.search()Search symbols by ticker, name, or ISIN.
okama.symbols_in_namespace()Return all symbols available in a namespace.
okama.namespacesReturns a dictionary of available data namespaces and their descriptions.