there was a mention in the index arbitrage unit to have the OLS constrained so that weights are positive in the replicating portfolio. Any suggestions on how you'd do that in Python?
many thanks
From my understanding of what you're asking here, you're probably looking for non-negative least squares regression. You can read more about it in the official scipy docs. Here is an example:
from scipy.optimize import nnls
A = np.array([[1, 0], [1, 0], [0, 1]])
b = np.array([2, 1, 1])
print(nnls(A, b))
>>> (array([1.5, 1. ]), 0.7071067811865475)
Do get back if we haven't gotten it right.