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

Go to the source code of this file.

Functions

static char * wu_strdup (const char *s)
static void stats_update (struct WU_PortfolioStats_ *stats, double cash, double portfolio_value, WU_TimeStamp timestamp)
static void stats_record_trade (struct WU_PortfolioStats_ *stats, double pnl, WU_CloseReason reason)
static void stats_update_position (struct WU_PortfolioStats_ *stats, int asset_index, const char *symbol, double quantity, double value, double last_price)
static char * stats_to_keyvalue (struct WU_PortfolioStats_ *stats)
static char * stats_to_json (struct WU_PortfolioStats_ *stats, bool pretty)
static void stats_reset (struct WU_PortfolioStats_ *stats)
static void stats_free (struct WU_PortfolioStats_ *stats)
WU_PortfolioStats wu_portfolio_stats_new (double initial_cash, double risk_free_rate)
 Creates a new WU_PortfolioStats instance.

Function Documentation

◆ stats_free()

void stats_free ( struct WU_PortfolioStats_ * stats)
static

Definition at line 276 of file stats.c.

◆ stats_record_trade()

void stats_record_trade ( struct WU_PortfolioStats_ * stats,
double pnl,
WU_CloseReason reason )
static

Definition at line 33 of file stats.c.

◆ stats_reset()

void stats_reset ( struct WU_PortfolioStats_ * stats)
static

Definition at line 252 of file stats.c.

◆ stats_to_json()

char * stats_to_json ( struct WU_PortfolioStats_ * stats,
bool pretty )
static

Definition at line 149 of file stats.c.

◆ stats_to_keyvalue()

char * stats_to_keyvalue ( struct WU_PortfolioStats_ * stats)
static

Definition at line 92 of file stats.c.

◆ stats_update()

void stats_update ( struct WU_PortfolioStats_ * stats,
double cash,
double portfolio_value,
WU_TimeStamp timestamp )
static

Definition at line 15 of file stats.c.

◆ stats_update_position()

void stats_update_position ( struct WU_PortfolioStats_ * stats,
int asset_index,
const char * symbol,
double quantity,
double value,
double last_price )
static

Definition at line 60 of file stats.c.

◆ wu_portfolio_stats_new()

WU_PortfolioStats wu_portfolio_stats_new ( double initial_cash,
double risk_free_rate )

Creates a new WU_PortfolioStats instance.

Parameters
initial_cashInitial cash amount
risk_free_rateAnnual risk-free rate for Sharpe/Sortino calculations (e.g., 0.03 for 3%)

Definition at line 295 of file stats.c.

◆ wu_strdup()

char * wu_strdup ( const char * s)
static

Definition at line 7 of file stats.c.