chaitjo / markowitz-portfolio-optimization

Markowitz portfolio optimization on synthetic and real stocks
https://www.chaitjo.com/archived/markowitz-portfolio-optimization/
MIT License
74 stars 24 forks source link

Issue with sign #2

Closed leryan36 closed 1 year ago

leryan36 commented 1 year ago

Hi, thanks for sharing your work. I am getting the following error and I cannot figure it out if you have any ideas. I already replaced ix by loc and min_ret = Parameters(nonneg=True):


TypeError Traceback (most recent call last) ~/Documents/Python/markowitz-portfolio-optimization-original/main.py in () 52 while date_index_iter + 20 < end_index: 53 date = index[date_index_iter] ---> 54 portfolio_alloc = MarkowitzOpt(shift_returns_mean.loc[date], shift_returns_var.loc[date], covariance.loc[date], interest_rate, min_return) 55 distribution[date.strftime('%Y-%m-%d')] = portfolio_alloc 56

~/Documents/Python/markowitz-portfolio-optimization-original/markowitz.py in MarkowitzOpt(mean, variance, covariance, interest_rate, min_return) 31 ret = mu.T* w 32 risk = quad_form(w, Sigma) ---> 33 min_ret = Parameter(nonneg=True) 34 min_ret.value = min_return 35 prob = Problem(Minimize(risk), # Restricting to long-only portfolio

/opt/anaconda3/envs/financial-analysis/lib/python3.10/site-packages/cvxpy/expressions/constants/parameter.py in init(self, shape, name, value, id, kwargs) 59 self._value = None 60 self.delta = None ---> 61 #self.gradient = None 62 super(Parameter, self).init(shape, value, kwargs) 63 self._is_constant = True

TypeError: Leaf.init() got an unexpected keyword argument 'sign'

chaitjo commented 1 year ago

Sorry, I'm not maintaining this project any more. I'm sure the various libraries and dependencies have changed their APIs since this code was last run (years ago).