WU Trading Library 0.2.0
A backtesting and trading strategy library
Loading...
Searching...
No Matches
calmar.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 CALMAR_MIN_OBSERVATIONS   30
 The Calmar Ratio measures risk-adjusted return by comparing annualized returns to the maximum drawdown.

Functions

static double wu_calmar_ratio_update (WU_CalmarRatio self, WU_PerformanceUpdate perf)
 Updates the Calmar Ratio calculation with a new portfolio value.
static void wu_calmar_ratio_free (WU_CalmarRatio self)
 Frees resources allocated by the Calmar Ratio object.
WU_CalmarRatio wu_calmar_ratio_new (double initial_value)

Macro Definition Documentation

◆ CALMAR_MIN_OBSERVATIONS

#define CALMAR_MIN_OBSERVATIONS   30

The Calmar Ratio measures risk-adjusted return by comparing annualized returns to the maximum drawdown.

Unlike Sharpe/Sortino, it uses maximum drawdown as the risk measure instead of volatility.

Formula: Calmar = Annualized_Return / |Maximum_Drawdown| where:

Annualized_Return = (Total_Return)^(1/years) - 1 [compound] or Total_Return * periods_per_year [simple]

This implementation uses simple annualization for consistency with other risk metrics in this library. Minimum observations required before calculating Calmar ratio. This ensures we have enough data for a meaningful drawdown measurement.

Definition at line 25 of file calmar.c.

Function Documentation

◆ wu_calmar_ratio_free()

void wu_calmar_ratio_free ( WU_CalmarRatio self)
static

Frees resources allocated by the Calmar Ratio object.

Definition at line 104 of file calmar.c.

◆ wu_calmar_ratio_new()

WU_CalmarRatio wu_calmar_ratio_new ( double initial_value)

Definition at line 112 of file calmar.c.

◆ wu_calmar_ratio_update()

double wu_calmar_ratio_update ( WU_CalmarRatio self,
WU_PerformanceUpdate perf )
static

Updates the Calmar Ratio calculation with a new portfolio value.

Parameters
selfThe Calmar Ratio object
perfPerformance update containing portfolio value and timestamp
Returns
The updated Calmar Ratio value, or NAN if insufficient data

Definition at line 34 of file calmar.c.