cvxportfolio icon indicating copy to clipboard operation
cvxportfolio copied to clipboard

Error while running HelloWorld.py. ValueError: Cannot broadcast dimensions (562, 5) (5,)

Open ankit-a-aggarwal opened this issue 4 years ago • 1 comments

I have debugged the code and found out the root cause, cvx.multiply at cvxportfolio/policies.py: line number 257. is causing this issue. How should I resolve this?

image

Traceback (most recent call last): File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1438, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/Users/ankitaggarwal/Applications/cvxportfolio/examples/HelloWorld.py", line 92, in policies=[spo_policy, cp.Hold()]) File "/Users/ankitaggarwal/Applications/cvxportfolio/cvxportfolio/simulator.py", line 152, in run_multiple_backtest results = workers.map(_run_backtest, policies) File "/Users/ankitaggarwal/Applications/cvxportfolio/venv/lib/python3.7/site-packages/multiprocess/pool.py", line 268, in map return self._map_async(func, iterable, mapstar, chunksize).get() File "/Users/ankitaggarwal/Applications/cvxportfolio/venv/lib/python3.7/site-packages/multiprocess/pool.py", line 657, in get raise self._value ValueError: Cannot broadcast dimensions (562, 5) (5,)

ankit-a-aggarwal avatar Sep 12 '20 22:09 ankit-a-aggarwal

it works after I made a little change in file 'risks': class FactorModelSigma(BaseRiskModel): self.expression = cvx.sum_squares(cvx.multiply(np.sqrt(values_in_time(self.idiosync, t)), wplus)) +
cvx.quad_form((wplus.T * values_in_time(self.exposures, t).values).T,values_in_time(self.factor_Sigma, t).values)

specialuse avatar Oct 07 '20 07:10 specialuse