https://github.com/mbk-dev/okama
Investment portfolio and stocks analyzing tools for Python with free historical data
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 7 committers (14.3%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.9%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Investment portfolio and stocks analyzing tools for Python with free historical data
Basic Info
- Host: GitHub
- Owner: mbk-dev
- License: mit
- Language: Jupyter Notebook
- Default Branch: master
- Homepage: https://okama.io/
- Size: 50.5 MB
Statistics
- Stars: 238
- Watchers: 12
- Forks: 43
- Open Issues: 7
- Releases: 41
Topics
Metadata Files
README.md
Okama
okama is a library with investment portfolio analyzing & optimization tools. CFA recommendations are used in quantitative finance.
okama goes with free «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 contents
- Okama main features
- Financial data and macroeconomic indicators
- Installation
- Getting started
- Documentation
- Financial Widgets
- RoadMap
- Contributing to okama
- Communication
Okama main features
- Investment portfolio constrained Markowitz Mean-Variance Analysis (MVA) and optimization
- Rebalanced portfolio optimization with constraints (multi-period Efficient Frontier)
- Advanced rebalancing strategies: Rebalancing-bands (threshold-based), Calendar-based or hybrid
- Investment portfolios with complex contributions / withdrawals cash flows (DCF)
- Monte Carlo Simulations for financial assets and investment portfolios
- Popular risk metrics: VAR, CVaR, semi-deviation, variance and drawdowns
- Different financial ratios: CAPE10, Sharpe ratio, Sortino ratio, Diversification ratio
- Forecasting models according to normal, lognormal and other popular distributions
- Testing distribution on historical data
- Dividend yield and other dividend indicators for stocks
- Backtesting and comparing historical performance of broad range of assets and indexes in multiple currencies
- Methods to track the performance of index funds (ETF) and compare them with benchmarks
- Main macroeconomic indicators: inflation, central banks rates
- Matplotlib visualization scripts for the Efficient Frontier, Transition map and assets risk / return performance
Financial data and macroeconomic indicators
End of day historical data
- Stocks and ETF for main world markets
- Mutual funds
- Commodities
- Stock indexes
Currencies
- FX currencies
- Crypto currencies
- Central bank exchange rates
Macroeconomic indicators
For many countries (China, USA, United Kingdom, European Union, Russia, Israel etc.):
- Inflation
- Central bank rates
- CAPE10 (Shiller P/E) Cyclically adjusted price-to-earnings ratios
Other historical data
- Real estate prices
- Top bank rates
Installation
pip install okama
The latest development version can be installed directly from GitHub:
python
git clone https://github.com/mbk-dev/okama@dev
poetry install
Getting started
1. Compare several assets from different stock markets. Get USD-adjusted performance
```python import okama as ok
x = 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:
python
x.describe()
Get the assets accumulated return, plot it and compare with the USD inflation:
python
x.wealth_indexes.plot()
2. Create a dividend stocks portfolio with base currency EUR
python
weights = [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.table
Plot the dividend yield of the portfolio (adjusted to the base currency).
python
pf.dividend_yield.plot()
3. Draw an Efficient Frontier for 2 popular ETF: SPY and GLD
```python ls = ['SPY.US', 'GLD.US'] curr = 'USD' last_date='2020-10'
Rebalancing periods is one year (default value)
frontier = ok.EfficientFrontierReb(ls, lastdate=lastdate, ccy=curr, rebalancing_strategy=ok.Rebalance(period='year'))
frontier.names
```
Get the Efficient Frontier points for rebalanced portfolios and plot the chart with the assets risk/CAGR points: ```python import matplotlib.pyplot as plt
points = frontier.ef_points
fig = plt.figure(figsize=(12,6))
fig.subplotsadjust(bottom=0.2, top=1.5)
frontier.plotassets(kind='cagr') # plots the assets points on the chart
ax = plt.gca()
ax.plot(points.Risk, points.CAGR)
```

4. Get a Transition Map for allocations
python
ls = ['SPY.US', 'GLD.US', 'BND.US']
map = ok.EfficientFrontier(ls, ccy='USD').plot_transition_map(x_axe='risk')
More examples are available in form of Jupyter Notebooks.
Documentation
The official documentation is hosted on readthedocs.org: https://okama.readthedocs.io/
Financial Widgets
okama-dash repository has interactive financial widgets (multi-page web application) build with okama package and Dash (plotly) framework. Working example is available at okama.io.
RoadMap
The plan for okama is 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.
- Add Black-Litterman asset allocation
- Accelerate optimization for multi-period Efficient Frontier: minimizerisk and maximizerisk methods of EfficientFrontierReb class.
- Make a single EfficientFrontier class for all optimizations: single-period or multu-period with rebalancing strategy 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 okama
Contributions are most welcome. Have a look at the Contribution Guide for more.
Feel free to ask questions on Discussuions.
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 Conduct
Communication
For basic usage questions (e.g., "Is XXX currency supported by okama?") and for sharing ideas please use GitHub Discussions. Russian language community is available at okama.io forums.
License
MIT
Owner
- Name: MBK Development
- Login: mbk-dev
- Kind: organization
- Email: info@okama.io
- Location: Russian Federation
- Website: okama.io
- Repositories: 3
- Profile: https://github.com/mbk-dev
Financial advising and IT solutions.
GitHub Events
Total
- Create event: 3
- Issues event: 3
- Watch event: 32
- Delete event: 1
- Member event: 1
- Issue comment event: 8
- Push event: 66
- Pull request review comment event: 5
- Pull request review event: 4
- Pull request event: 8
- Fork event: 7
Last Year
- Create event: 3
- Issues event: 3
- Watch event: 32
- Delete event: 1
- Member event: 1
- Issue comment event: 8
- Push event: 66
- Pull request review comment event: 5
- Pull request review event: 4
- Pull request event: 8
- Fork event: 7
Committers
Last synced: about 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Sergey Kikevich | s****y@r****u | 445 |
| Sergey Kikevich | c****4@g****m | 8 |
| Ruslan Chernenko | r****e@g****m | 7 |
| Alexander Myltsev | a****r@m****m | 2 |
| MATHIVANAN M | m****0@b****n | 1 |
| Anton Pak | a****k@l****n | 1 |
| dependabot[bot] | 4****] | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 37
- Total pull requests: 35
- Average time to close issues: 2 months
- Average time to close pull requests: 5 days
- Total issue authors: 6
- Total pull request authors: 12
- Average comments per issue: 1.73
- Average comments per pull request: 1.0
- Merged pull requests: 15
- Bot issues: 0
- Bot pull requests: 11
Past Year
- Issues: 1
- Pull requests: 8
- Average time to close issues: N/A
- Average time to close pull requests: about 22 hours
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 0.0
- Average comments per pull request: 1.25
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- chilango74 (27)
- nenkoru (3)
- dknugo (3)
- reflechant (1)
- PineTreePizza (1)
- chicago-joe (1)
- sugizo (1)
Pull Request Authors
- DNTNTRSRNM (8)
- sourcery-ai[bot] (8)
- dependabot[bot] (5)
- nenkoru (4)
- chilango74 (4)
- Mathii0402 (2)
- JVthearchitect (2)
- vkhomyakov (2)
- alexander-myltsev (1)
- Aadityajoshi151 (1)
- avpak (1)
- welld7 (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 622 last-month
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 1
(may contain duplicates) - Total versions: 64
- Total maintainers: 1
proxy.golang.org: github.com/mbk-dev/okama
- Documentation: https://pkg.go.dev/github.com/mbk-dev/okama#section-documentation
- License: mit
-
Latest release: v1.5.0
published 8 months ago
Rankings
pypi.org: okama
Investment portfolio analyzing & optimization tools
- Homepage: https://okama.io
- Documentation: https://okama.readthedocs.io/en/master
- License: MIT
-
Latest release: 1.5.0
published 8 months ago
Rankings
Maintainers (1)
Dependencies
- ipython >=7.20.0
- jinja2 ==3.0.3
- nbsphinx ==0.8.7
- nbsphinx-link >=1.3.0
- numpydoc ==1.1.0
- pandoc >=1.1.0
- recommonmark ==0.7.1
- sphinx ==3.5.4
- sphinx_rtd_theme ==0.5.2
- Jinja2 3.0.3 develop
- black ^22.3.0 develop
- ipykernel ^6.13.0 develop
- ipython <8.0.0 develop
- jupyter ^1.0.0 develop
- nbmake ^1.2 develop
- nbsphinx ^0.8.8 develop
- nbsphinx-link ^1.3.0 develop
- numpydoc ^1.2.1 develop
- pandoc ^2.2 develop
- pytest ^6.0.0 develop
- recommonmark ^0.7.1 develop
- sphinx ^3 develop
- sphinx-rtd-theme ^1.0.0 develop
- importlib-metadata ^4.11.1
- joblib ^1.1.0
- matplotlib ^3.5.1
- pandas >=1.0.0
- python >=3.7, <4.0.0
- requests ^2.27.1
- scipy >=0.14.0
- actions/checkout v2 composite
- psf/black stable composite
- actions/checkout v2 composite
- github/codeql-action/analyze v1 composite
- github/codeql-action/autobuild v1 composite
- github/codeql-action/init v1 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite