Marigold / universal-portfolios

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

undefined self.window in update_tco() in algo.py #63

Closed GXY2017 closed 3 years ago

GXY2017 commented 3 years ago

I don't understand where self.window is defined. Guess self.window =1 since update in one step.

    def update_tco(self, b, x_pred):
        """
        Transaction Costs Optimization
        Paper : https://ink.library.smu.edu.sg/cgi/viewcontent.cgi?referer=&httpsredir=1&article=4761&context=sis_research
        """

        lambd = 10 * self.trx_fee_pct

        # last price adjusted weights
        updated_b = np.multiply(b, x_pred) / np.dot(b, x_pred)

        # Calculate variables
        vt = x_pred / np.dot(updated_b, x_pred)
        v_t_ = np.dot(1, vt) / **self.window**

        # Update portfolio
        b_1 = self.trx_fee_n * (vt - np.dot(v_t_, 1))
        b_ = b_1 + np.sign(b_1) * np.maximum(np.zeros(len(b_1)), np.abs(b_1) - lambd)

        # project it onto simplex
        return tools.simplex_proj(y=b_)
Marigold commented 3 years ago

You're right, it's a bug. It shouldn't use window at all. Thanks for spotting that. I've read more about TCO (https://ink.library.smu.edu.sg/cgi/viewcontent.cgi?referer=&httpsredir=1&article=4761&context=sis_research) and decided to move it to a separate algorithm. The algo "TCO" is available in the newest package version.

cc @DrPaprikaa I took your code and moved it to a separate file (plus fixed a few bugs), hope you don't mind