def weight_ew(r, cap_weights=None, max_cw_mult=None, microcap_threshold=None, **kwargs):
    '\n    Returns the weights of the EW portfolio based on the asset returns "r" as a DataFrame\n    If supplied a set of capweights and a capweight tether, it is applied and reweighted \n    '
    n = len(r.columns)
    ew = pd.Series((1 / n), index=r.columns)
    if (cap_weights is not None):
        cw = cap_weights.loc[r.index[0]]
        if ((microcap_threshold is not None) and (microcap_threshold > 0)):
            microcap = (cw < microcap_threshold)
            ew[microcap] = 0
            ew = (ew / ew.sum())
        if ((max_cw_mult is not None) and (max_cw_mult > 0)):
            ew = np.minimum(ew, (cw * max_cw_mult))
            ew = (ew / ew.sum())
    return ew
Returns the weights of the EW portfolio based on the asset returns "r" as a DataFrame
If supplied a set of capweights and a capweight tether, it is applied and reweighted
def weight_ew(r, cap_weights=None, max_cw_mult=None, microcap_threshold=None, **kwargs):
    '\n    Returns the weights of the EW portfolio based on the asset returns "r" as a DataFrame\n    If supplied a set of capweights and a capweight tether, it is applied and reweighted \n    '
    n = len(r.columns)
    ew = pd.Series((1 / n), index=r.columns)
    if (cap_weights is not None):
        cw = cap_weights.loc[r.index[0]]
        if ((microcap_threshold is not None) and (microcap_threshold > 0)):
            microcap = (cw < microcap_threshold)
            ew[microcap] = 0
            ew = (ew / ew.sum())
        if ((max_cw_mult is not None) and (max_cw_mult > 0)):
            ew = np.minimum(ew, (cw * max_cw_mult))
            ew = (ew / ew.sum())
    return ew