Package: okama
Okamaokamais a library with investment portfolio analyzing & optimization tools. CFA recommendations are used in quantitative finance.okamagoes withfree«end of day» historical stock markets data and macroeconomic indicators through API....entities should not be multiplied without necessity--William of Ockham (c. 1287–1347)Table of contentsOkama main featuresFinancial data and macroeconomic indicatorsEnd of day historical dataMacroeconomic indicatorsOther historical dataInstallationGetting startedDocumentationFinancial WidgetsRoadMapContributing to okamaCommunicationOkama main featuresInvestment portfolio constrained Markowitz Mean-Variance Analysis (MVA) and optimizationRebalanced portfolio optimization with constraints (multi-period Efficient Frontier)Investment portfolios with contributions / withdrawals cash flows (DCF)Monte Carlo Simulations for financial assets and investment portfoliosPopular risk metrics: VAR, CVaR, semi-deviation, variance and drawdownsDifferent financial ratios: CAPE10, Sharpe ratio, Sortino ratio, Diversification ratioForecasting models according to normal, lognormal and other popular distributionsTesting distribution on historical dataDividend yield and other dividend indicators for stocksBacktesting and comparing historical performance of broad range of assets and indexes in multiple currenciesMethods to track the performance of index funds (ETF) and compare them with benchmarksMain macroeconomic indicators: inflation, central banks ratesMatplotlib visualization scripts for the Efficient Frontier, Transition map and assets risk / return performanceFinancial data and macroeconomic indicatorsEnd of day historical dataStocks and ETF for main world marketsMutual fundsCommoditiesStock indexesCurrenciesFX currenciesCrypto currenciesCentral bank exchange ratesMacroeconomic indicatorsFor many countries (China, USA, United Kingdom, European Union, Russia, Israel etc.):InflationCentral bank ratesCAPE10 (Shiller P/E) Cyclically adjusted price-to-earnings ratiosOther historical dataReal estate pricesTop bank ratesInstallationpip install okamaThe latest development version can be installed directly from GitHub:git clone https://github.com/mbk-dev/okama@devpoetry installGetting started1. Compare several assets from different stock markets. Get USD-adjusted performanceimportokamaasokx=ok.AssetList(['SPY.US','BND.US','DBXD.XFRA'],ccy='USD')x# all examples are for Jupyter Notebook/iPython. For raw Python interpreter use 'print(x)' instead.Get the main parameters for the set:x.describe()Get the assets accumulated return, plot it and compare with the USD inflation:x.wealth_indexes.plot()2. Create a dividend stocks portfolio with base currency EURweights=[0.3,0.2,0.2,0.2,0.1]assets=['T.US','XOM.US','FRE.XFRA','SNW.XFRA','LKOH.MOEX']pf=ok.Portfolio(assets,weights=weights,ccy='EUR')pf.tablePlot the dividend yield of the portfolio (adjusted to the base currency).pf.dividend_yield.plot()3. Draw an Efficient Frontier for 2 popular ETF: SPY and GLDls=['SPY.US','GLD.US']curr='USD'last_date='2020-10'# Rebalancing periods is one year (default value)frontier=ok.EfficientFrontierReb(ls,last_date=last_date,ccy=curr,rebalancing_period='year')frontier.namesGet the Efficient Frontier points for rebalanced portfolios and plot the chart with the assets risk/CAGR points:importmatplotlib.pyplotaspltpoints=frontier.ef_pointsfig=plt.figure(figsize=(12,6))fig.subplots_adjust(bottom=0.2,top=1.5)frontier.plot_assets(kind='cagr')# plots the assets points on the chartax=plt.gca()ax.plot(points.Risk,points.CAGR)* -rebalancing period is one year.4. Get a Transition Map for allocationsls=['SPY.US','GLD.US','BND.US']map=ok.EfficientFrontier(ls,ccy='USD').plot_transition_map(x_axe='risk')More examples are available in form ofJupyter Notebooks.DocumentationThe official documentation is hosted on readthedocs.org:https://okama.readthedocs.io/Financial Widgetsokama-dashrepository has interactive financial widgets (multi-page web application)
build withokamapackage andDash (plotly)framework. Working example is available atokama.io.RoadMapThe plan forokamais to add more functions that will be useful to investors and asset managers.Add Omega ratio to EfficientFrontier, EfficientFrontierReb and Portfolio classes.Make complex withdrawals / contributions strategies in Portfolio class.Make complex portfolio rebalancing strategies.Add Black-Litterman asset allocationAccelerate optimization for multi-period Efficient Frontier: minimize_risk and maximize_risk methods of EfficientFrontierReb class.Make a single EfficientFrontier class for all optimizations: single-period or multu-period with rebalancing period as a parameter.Add different utility functions for optimizers: IRR, portfolio survival period, semi-deviation, VaR, CVaR, drawdowns etc.Add more functions based on suggestion of users.Contributing to okamaContributions aremost welcome. Have a look at theContribution Guidefor more.Feel free to ask questions onDiscussuions.As contributors and maintainers to this project, you are expected to abide by okama' code of conduct. More information can be found at:Contributor Code of ConductCommunicationFor basic usage questions (e.g., "Is XXX currency supported by okama?") and for sharing ideas please useGitHub Discussions.
Russian language community is available atokama.io forums.LicenseMIT