Releases: mbk-dev/okama
Okama 1.4.1
Okama 1.4.1 adds custom exceptions for time period and Student's t distribution for Monte-Carlo methods in Portfolio and AssetList.
New features
Custom exceptions for time periods issues
ShortPeriodLengthError
is raised when an asset has less then 3 months of history in AssetList, Portfolio and EfficentFrontier classesRollingWindowLengthBelowOneYearError
is raised when rolling windows size is below one yearLongRollingWindowLengthError
is raised when rolling window size is more than data history depth
Student's t distribution in Monte-Carlo methods
- set
distr="t"
in methods likePortfolio.dcf.monte_carlo_wealth
orAssetList.kstest
Changes in existing methods & properties
Portfolio.dcf.monte_carlo_wealth
usesinitial_amount
value by default.
Bugs fixed
- wrong formula for 0 period rate of return in
helpers.Rebalance.return_ror_ts
Okama 1.4.0
Okama 1.4.0 introduces investment strategies with contributions and withdrawals in Portfolio
class. New methods support discounted cash flows (DCF) and Monte Carlo simulation for portfolio longevity.
New features
DCF methods for contributions and withdrawals in Portfolio
class
New Portfolio
class attributes (all are optional):
initial_amount
- Portfolio initial investment FV (at last_date)cashflow
- portfolio monthly cash flow FV (at last_date). Negative value corresponds to withdrawals.
Positive value corresponds to contributions. Cash flow value is indexed each month by inflation.discount_rate
- cash flow discount rate required to calculate PV values.
New dcf.
methods in Portfolio
class:
dcf.plot_forecast_monte_carlo()
method to plot Monte Carlo simulation for portfolio future wealth indexes optionally together with historical wealth index.dcf.monte_carlo_survival_period()
method to generate a survival period distribution for a portfolio with cash flows by Monte Carlo simulation.dcf.wealth_index
property to calculate wealth index time series for the portfolio with contributions and
withdrawals.dcf.survival_period
property to calculate the period when the portfolio has positive balance considering withdrawals on the historical data.dcf.survival_date
property to get the date when the portfolio balance become negative considering withdrawals on the historical data.dcf.cashflow_pv
property to calculate the discounted value (PV) of the cash flow amount at the historicalfirst_date
.dcf.initial_amount_pv
property to calculate the discounted value (PV) of the initial investments at the historicalfirst_date
.
New properties in Portfolio
class
assets_dividend_yield
property to calculate last twelve months (LTM) dividend yield time series (monthly) for each assetdividends_annual
property to get calendar year dividends sum time series for each asset.
New methods and properties in AssetList
class
get_rolling_risk_annual()
method to calculate annualized risk rolling time series for each asset.get_dividend_mean_yield()
method to calculate the arithmetic mean for annual dividend yield over a specified period.dividend_yield_annual
property to calculate last twelve months (LTM) dividend yield annual time series.
Changes in existing methods & properties
Asset_List.risk_annual
returns expanding risk time series (not float)Portfolio.recovery_period
returns time series of recovery periods over historical data (not a single period)describe()
method shows the rate of return arithmetic mean (expected return) inPortfolio
,AssetList
classes- new
xy_text
argument inplot_assets()
method to position better point labels
inPortofolio
,AssetList
classes
New Jupyter Notebooks with examples
- 04 investment portfolios with DCF.ipynb for investment strategies with cash flow - portfolio withdrawals / contributions. Backtest the portfolio and forecast portfolio longevity with Monte Carlo simulation.
- 05 macroeconomics - inflation rates.ipynb to analyze inflation, key rates and other macro indicators historical data.
Bugs fixed
- Duplicate tickers in the assets are no longer allowed and are automatically corrected (
AssetList
,Portfolio
,EfficientFrontier
,EfficientFrontierReb
)
Okama 1.3.2
Okama now supports Panadas 2.0.0 and further versions. There is no backward compatibility with previous Pandas versions.
New features:
- New rebalancing periods for portfolios: "half-year" and "quarter"
- new
set_values_monthly()
method in Inflation to forecast data and change previos values - new
dividend_yield_annual
property in AssetList calculates dividend yield time series for calendar years - new
get_dividend_mean_yield()
method in AssetList shows mean dividend yield for a given period plot_cml()
has newy_axe
parameter to switch from CAGR to mean rate of returns in the plotsasset_dividend_yield
property renamed todividend_yield
in AssetList
Okama 1.3.1
okama works with Python 3.11 now.
FIX:
- aliases
symbols_in_namespace
andno_dividends_namespaces
were not imported in__init__.py
Okama 1.3.0
New features:
- rolling_window parameter in AssetList functions:
index_corr()
,index_beta()
,tracking_error()
index_corr()
andindex_rolling_corr()
are combined into a single functionindex_corr()
in the AssetList- AssetList, Prtfolio, EfficentFrontier and EfficentFrontierReb are now sequences and has
__getitem__
,__iter__
methods.
Fix:
- Avoid running
get_namspaces()
and other aliases in init.py (this resulted in the database requests during library import) EfficientFrontier.plot_pair_ef()
faled if inflation=False- Tickers with dot "." like BRK.B
Okama 1.2.3
The release uses runtime Python 3.8. This version is recomended for development. Previous versions of okama were using legacy Python 3.7.
New features:
EfficentFrontier().get_monte_carlo()
method return risk, return and weights data for random portfolios.
Fix:
- Columns order is lost in
Portfolio().weights_ts
- minor bugs
Okama 1.2.2 (the last Python 3.7 compatible version)
Version 1.2.2 will be the last Python 3.7 release. In further development we will use Python 3.8.
Updated:
- Update classes for new FOREX data format (AssetList, Portfolio and all ListMaker inherited classes are affected)
Fixed:
- compatible issues with
importlib-metadata
package
Okama 1.2.1
New features:
get_tangency_portfolio()
can calculate tangency portfolio weights for CAGR (rate of return with geometric mean).
Fix:
- base currency
first_date
andlast_date
were calculated wrong in AssetList, Portfolio and EfficientFrontier
Okama 1.2.0
New Macroeconomic class Indicator
3 macroeconomic classes are available (and Documented):
Indicator
: Macroeconomic indicators and ratios. (.RATIO
NEW namespace)Inflation
: Inflation related data and methods (.INFL
namespace)Rates
: Rates of central banks and banks (.RATE
namesapce)
Cyclically adjusted price-to-earnings ratios (CAPE10) for 20+ countries are in the DataBase: USA_CAPE10.RATIO, CHN_CAPE10.RATIO, CHN_CAPE10.RATIO etc.
Daily value time series for Macro classes
Rate
class has .values_daily
property which can be used with bak raters and some other symbols:
ok.Rate("RUONIA.RATE").values_daily
all Macro classes have .values_monthly
property.
.describe()
methods in all macroeconomic classes
.describe()
methods show descriptive statistics for YTD and given periods:
- arithmetic mean
- median
- max and min values
Inflation
class .describe()
method is different. It generates inflation-specific statistics:
- YTD compound inflation
- Annual inflation (geometric mean) for a given list of periods
- max 12 months inflation for the periods
- Annual inflation (geometric mean) for the whole history
Rolling tracking difference for stock indexes and ETFs
.tracking_difference()
and tracking_difference_annualized()
in AssetList
class are now methods (where properties). Methods have rolling_window
attribute to set wolling window size (in months).
To calclulate 24 months movig tracking difference:
x.tracking_difference(rolling_window=24)
Full Changelog: v1.1.6...v1.2.0
Okama 1.1.6
Introduce parallel computing for heavy calculations in multi-period portfolio optimization (Efficient Frontier).
Minor changes:
- okama uses
black
for code formatting - development dependencies use Python 3.7 to stay compatible with Google Colab