Workspace allocation error when using PyPortfolioOptimisation

Viewed 374

Thanks in advance!

I am working on portfolio optimisation with PyPortfolioOptimisation.

I have the prices of my underlying assets starting from 2015-01-01 up till 2021-05-19 The dataframe shape is [1666 rows x 20 columns]

I ran the following codes

mu = expected_returns.mean_historical_return(df)
cov = risk_models.sample_cov(df)
print('Mean' '\n'+str(mu))
print('Covariance: ' '\n' +str(cov))
ef = EfficientFrontier(mu,cov)
weights = ef.max_sharpe()
cleaned_w = ef.cleaned_weights()
print(cleaned_w)
ef.portfolio_performance(verbose=True)

But it gives an error stating workspace allocation error pointing to line weights = ef.max_sharpe()

Traceback (most recent call last):
  File "F:\Python projects\KS\Investment\Efficient frontier.py", line 34, in <module>
    weights = ef.max_sharpe()
  File "F:\Python projects\KS\lib\site-packages\pypfopt\efficient_frontier\efficient_frontier.py", line 278, in max_sharpe
    self._solve_cvxpy_opt_problem()
  File "F:\Python projects\KS\lib\site-packages\pypfopt\base_optimizer.py", line 239, in _solve_cvxpy_opt_problem
    self._opt.solve(verbose=self._verbose, **self._solver_options)
  File "F:\Python projects\KS\lib\site-packages\cvxpy\problems\problem.py", line 459, in solve
    return solve_func(self, *args, **kwargs)
  File "F:\Python projects\KS\lib\site-packages\cvxpy\problems\problem.py", line 947, in _solve
    solution = solving_chain.solve_via_data(
  File "F:\Python projects\KS\lib\site-packages\cvxpy\reductions\solvers\solving_chain.py", line 343, in solve_via_data
    return self.solver.solve_via_data(data, warm_start, verbose,
  File "F:\Python projects\KS\lib\site-packages\cvxpy\reductions\solvers\qp_solvers\osqp_qpif.py", line 103, in solve_via_data
    solver.setup(P, q, A, lA, uA, verbose=verbose, **solver_opts)
  File "F:\Python projects\KS\lib\site-packages\osqp\interface.py", line 37, in setup
    self._model.setup(*unpacked_data, **settings)
ValueError: Workspace allocation error!

I tried changing the memory setting in Pycharm but to no avail. Is memory the same as workspace allocation? Sorry for these fundamental questions... Cheers mate

0 Answers
Related