(self, weights, y)
return -prets.topk(1, dim=1, largest=False)[0].view(-1)
Compute negative of the worst return of the portfolio return over the horizon.

        Parameters
        ----------
        weights : torch.Tensor
            Tensor of shape `(n_samples, n_assets)` representing the predicted weights by our portfolio optimizer.

        y : torch.Tensor
            Tensor of shape `(n_samples, n_channels, horizon, n_assets)` representing the evolution over the next
            `horizon` timesteps.


        Returns
        -------
        torch.Tensor
            Tensor of shape `(n_samples,)` representing the per sample negative worst return over the horizon.
Compute negative of the worst return of the portfolio return over the horizon.
Compute negative of the worst return of the portfolio return over the horizon .
def __call__(self, weights, y):
        """Compute negative of the worst return of the portfolio return over the horizon.

        Parameters
        ----------
        weights : torch.Tensor
            Tensor of shape `(n_samples, n_assets)` representing the predicted weights by our portfolio optimizer.

        y : torch.Tensor
            Tensor of shape `(n_samples, n_channels, horizon, n_assets)` representing the evolution over the next
            `horizon` timesteps.


        Returns
        -------
        torch.Tensor
            Tensor of shape `(n_samples,)` representing the per sample negative worst return over the horizon.

        """
        prets = portfolio_returns(weights,
                                  y[:, self.returns_channel, ...],
                                  input_type=self.input_type,
                                  output_type=self.output_type)

        return -prets.topk(1, dim=1, largest=False)[0].view(-1)
def __call__ ( self , weights , y ) : prets = portfolio_returns ( weights , y [ : , self . returns_channel , ... ] , input_type = self . input_type , output_type = self . output_type ) return - prets . topk ( 1 , dim = 1 , largest = False ) [ 0 ] . view ( - 1 )