Multi-period portfolio optimization in python -


scenario: trying multiple portfolio optimizations, different constraints (weights, risk, risk aversion...) in multi-period scenario.

what did: examples of cvxpy found how optimize portfolio under non-linear quadratic formula results in list of weights assets in portfolio composition. problem that, although have 15 years of monthly data, don't know how optimize different periods (the code, of current form, yields best composition entire time span of data).

question 1: possible make code optimize different periods. such 1, 3, 4, 6, 9, 12 months (in case, yielding different weights each of periods) if so, how 1 that?.

question 2: possible restrain number of assets in each portfolio composition? best way achieve that? (the current code uses of them, test when number of assets limited, control turnover level).

code:

from cvxpy import * cvxopt import * import pandas pd import numpy np   prices = pd.dataframe() logret = pd.dataframe() normret = pd.dataframe() returns = pd.dataframe()  prices = pd.read_excel(open('//folder//dgms89//calculation v3.xlsx', 'rb'), sheetname='prices final') logret = pd.read_excel(open('//folder//dgms89//calculation v3.xlsx', 'rb'), sheetname='returns log') normret = pd.read_excel(open('//folder//dgms89//calculation v3.xlsx', 'rb'), sheetname='returns normal')  returns = normret  def calculate_portfolio(returns, selected_solver):      cov_mat = returns.cov()     sigma = np.asarray(cov_mat.values)     w = variable(len(cov_mat))     gamma = quad_form(w, sigma)     prob = problem(minimize(gamma), [sum_entries(w) == 1])         prob.solve(solver=selected_solver)      weights = []     weight in w.value:         weights.append(float(weight[0]))      return weights 

  1. the standard mean-variance portfolio model static model. no dynamics in model. (time series used estimate variance-covariance matrix , expected return). related models can answer questions when , how rebalance.
  2. restricting number of assets in portfolio leads called cardinality-constrained portfolio problem. becomes miqp (mixed-integer quadratic programming problem).

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -