OmegaLossΒΆ

Defined in fynance.models.loss

class OmegaLoss(threshold=0., **kwargs)[source]

Bases: BaseLoss

Negative Omega ratio as a differentiable loss.

\(\Omega = \frac{E[\max(r - L, 0)]}{E[\max(L - r, 0)] + \varepsilon}\), the ratio of expected gains to expected losses relative to a threshold L. Fully differentiable through torch.relu. Minimizing the loss maximizes the Omega ratio.

Parameters:
thresholdfloat, optional

Return threshold L separating gains from losses. Default 0.

**kwargs

Forwarded to BaseLoss (rf, period, eps).

forward(y_pred, y_true=None)[source]

Compute the negative Omega ratio (scalar).