Marigold / universal-portfolios

Collection of algorithms for online portfolio selection
Other
768 stars 211 forks source link

Try to include transaction cost into OLMAR, but does not work #89

Closed GXY2017 closed 1 year ago

GXY2017 commented 1 year ago

I tried to include transaction cost into OLMAR in the def update() , but doing this does not change the result.

self.trx_fee_pct = trx_fee_pct  

this line has already been added to the OLMAR() class.

    def update(self, b, x_pred, eps):
        """Update portfolio weights to satisfy constraint b * x >= eps
        and minimize distance to previous weights."""
        x_pred_mean = np.mean(x_pred)
        lam = max(
            0.0, (eps - np.dot(b, x_pred)) / np.linalg.norm(x_pred - x_pred_mean) ** 2
        )

        # limit lambda to avoid numerical problems
        lam = min(100000, lam)

        # update portfolio
        b = b + lam * (x_pred - x_pred_mean)

        lambd = self.trx_fee_pct
        # Calculate variables
        vt = x_pred / np.dot(b, x_pred)
        v_t_ = np.mean(vt)

        # Update portfolio
        b_1 = (vt - np.dot(v_t_, 1))
        b_ = b + np.sign(b_1) * (np.abs(b_1) - lambd)

        # project it onto simplex
        return tools.simplex_proj(b_)
GXY2017 commented 1 year ago

there is a result.fee property