(self, weights, y)
return -(prets.mean(dim=1) - self.rf) / (prets.std(dim=1) + self.eps)
Compute negative sharpe ratio.

        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 sharpe ratio.
Compute negative sharpe ratio.
Compute negative sharpe ratio .
def __call__(self, weights, y):
        """Compute negative sharpe ratio.

        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 sharpe ratio.

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

        return -(prets.mean(dim=1) - self.rf) / (prets.std(dim=1) + self.eps)
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 . mean ( dim = 1 ) - self . rf ) / ( prets . std ( dim = 1 ) + self . eps )