WU Trading Library 0.2.0
A backtesting and trading strategy library
Loading...
Searching...
No Matches
sortino.c File Reference
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include "wu.h"

Go to the source code of this file.

Macros

#define SORTINO_MIN_OBSERVATIONS   30
 The Sortino Ratio is a variation of the Sharpe Ratio that differentiates between harmful volatility (downside) and total volatility.

Functions

static double wu_sortino_ratio_update (WU_SortinoRatio self, WU_PerformanceUpdate perf)
 Updates the Sortino Ratio calculation with a new portfolio value.
static void wu_sortino_ratio_free (WU_SortinoRatio self)
 Frees resources allocated by the Sortino Ratio object.
WU_SortinoRatio wu_sortino_ratio_new (double initial_value, double risk_free_rate)
 Creates a new Sortino Ratio calculator.

Macro Definition Documentation

◆ SORTINO_MIN_OBSERVATIONS

#define SORTINO_MIN_OBSERVATIONS   30

The Sortino Ratio is a variation of the Sharpe Ratio that differentiates between harmful volatility (downside) and total volatility.

It uses only the standard deviation of negative returns (downside deviation) in the denominator.

Formula: Sortino = (R_p - R_f) / σ_d where:

R_p = mean portfolio return (annualized) R_f = risk-free rate (annualized) σ_d = downside deviation (annualized) Minimum number of observations required for statistically meaningful Sortino ratio calculation. Below this threshold, the ratio is unreliable.

Definition at line 24 of file sortino.c.

Function Documentation

◆ wu_sortino_ratio_free()

void wu_sortino_ratio_free ( WU_SortinoRatio self)
static

Frees resources allocated by the Sortino Ratio object.

Definition at line 95 of file sortino.c.

◆ wu_sortino_ratio_new()

WU_SortinoRatio wu_sortino_ratio_new ( double initial_value,
double risk_free_rate )

Creates a new Sortino Ratio calculator.

Definition at line 105 of file sortino.c.

◆ wu_sortino_ratio_update()

double wu_sortino_ratio_update ( WU_SortinoRatio self,
WU_PerformanceUpdate perf )
static

Updates the Sortino Ratio calculation with a new portfolio value.

Definition at line 29 of file sortino.c.