Reputation: 113
To perform risk parity portfolio optimization (a type of portfolio allocation problem in finance), I used the riskfolio library. This is supposed to automate the calibration of asset weights for me based on a set of returns that I have provided to the library and its functions.
A brief summary of the functions include:
import riskfolio as rp
# The risk budgets/contributions that I specify per asset for a portfolio of 26 assets
RB_list = [1/48,1/48,1/48,1/48,1/48,1/48,1/48,1/48,1/48,1/48,1/48,1/48,1/48,1/48,1/48,1/48,
1/9,1/9,1/9,
1/21,1/21,1/21,1/21,1/21,1/21,1/21]
RB_arry = np.array(RB_list)
# df_ret.iloc[idx_bgn:idx_end,:26] is a dataframe of 26 asset returns provided as an input
RPP = rp.Portfolio(returns=df_ret.iloc[idx_bgn:idx_end,:26])
# The code fails at this stage, strangely
w_RPP = RPP.rp_optimization(model="Classic", rm="MV", rf=0, b=RB_arry, hist=True)
I tried changing the data structure of the risk budgets into a list, changing the number of elements in the array - to no avail. I looked at other packages and raw algorithms, but ultimately I would like something that is swiftly implementable.
Upvotes: 0
Views: 104