My humble attempt to re-write cvxportfolio
package.
I did this mainly because it's easier for me to have the inputs in the format I like. Plus it's a good way to make sure my understanding was correct.
Happy optimizing. Contributon welcome.
This version as of 2021-03 works for latest versions of:
cvxpy 1.1.11
padnas 1.2.3
See code docs for exact data types for these inputs.
T
- timestep indexN
- no. of assets, including cash as there are many cash related constraints. Cash item is assumed to be the last item, i.e. N-th item.K
- no. of factors in a factor model
Return forecasts pd.dataframe
of shape: (T, N)
.
To use factor risk model, multiple factor related matrices must be provided, such as factor and specific risk covariance, factor exposure.
- Factor Covariance
np.ndarray
of shape:(T, K, K)
- Specific Covariance
np.ndarray
ofshape:(T, N, N)
- Factor Exposure
np.ndarray
ofshape:(T, N, K)
Transaction Costs can be either:s
np.ndarray
of shape(N, )
, orpd.dataframe
of shape(T, N)