(self, x)
return result
Invest all money into the asset with the highest return over the horizon.
Invest all money into the asset with the highest return over the horizon.
Invest all money into the asset with the highest return over the horizon .
def __call__(self, x):
        """Invest all money into the asset with the highest return over the horizon."""
        n_samples, n_channels, lookback, n_assets = x.shape

        assert n_channels == 1

        x_np = x.detach().numpy()  # (n_samples, n_channels, lookback, n_assets)
        weights_list = [forecast(x_np[i, 0], self.process.coefs, None, 1).argmax() for i in range(n_samples)]

        result = torch.zeros(n_samples, n_assets).to(x.dtype)

        for i, w_ix in enumerate(weights_list):
            result[i, w_ix] = 1

        return result
def __call__ ( self , x ) : n_samples , n_channels , lookback , n_assets = x . shape assert n_channels == 1 x_np = x . detach ( ) . numpy ( ) # (n_samples, n_channels, lookback, n_assets) weights_list = [ forecast ( x_np [ i , 0 ] , self . process . coefs , None , 1 ) . argmax ( ) for i in range ( n_samples ) ] result = torch . zeros ( n_samples , n_assets ) . to ( x . dtype ) for i , w_ix in enumerate ( weights_list ) : result [ i , w_ix ] = 1 return result