#include <time.h>
#include "indicators.h"
Go to the source code of this file.
|
| #define | wu_portfolio_stats_update(stats, cash, value, timestamp) |
| | Updates portfolio state in stats.
|
| #define | wu_portfolio_stats_record_trade(stats, pnl, reason) |
| | Records a trade in the stats.
|
| #define | wu_portfolio_stats_update_position(stats, idx, sym, qty, val, price) |
| | Updates position info for a specific asset.
|
| #define | wu_portfolio_stats_to_keyvalue(stats) |
| | Converts stats to key=value format string.
|
| #define | wu_portfolio_stats_to_json(stats, pretty) |
| | Converts stats to JSON format string.
|
| #define | wu_portfolio_stats_reset(stats) |
| #define | wu_portfolio_stats_delete(stats) |
|
| WU_SharpeRatio | wu_sharpe_ratio_new (double initial_value, double risk_free_rate) |
| | Creates a new Sharpe Ratio calculator.
|
| WU_SortinoRatio | wu_sortino_ratio_new (double initial_value, double risk_free_rate) |
| | Creates a new Sortino Ratio calculator.
|
| WU_CalmarRatio | wu_calmar_ratio_new (double initial_value) |
| WU_PortfolioStats | wu_portfolio_stats_new (double initial_cash, double risk_free_rate) |
| | Creates a new WU_PortfolioStats instance.
|
◆ wu_portfolio_stats_delete
| #define wu_portfolio_stats_delete |
( |
| stats | ) |
|
Value: do { \
if ((stats) && (stats)->delete) \
(stats)->delete((stats)); \
} while(0)
Definition at line 170 of file stats.h.
◆ wu_portfolio_stats_record_trade
| #define wu_portfolio_stats_record_trade |
( |
| stats, |
|
|
| pnl, |
|
|
| reason ) |
Value: do { \
if ((stats)->record_trade) \
(stats)->record_trade((stats), (pnl), (reason)); \
} while(0)
Records a trade in the stats.
Definition at line 138 of file stats.h.
◆ wu_portfolio_stats_reset
| #define wu_portfolio_stats_reset |
( |
| stats | ) |
|
Value: do { \
if ((stats)->reset) \
(stats)->reset((stats)); \
} while(0)
Definition at line 165 of file stats.h.
◆ wu_portfolio_stats_to_json
| #define wu_portfolio_stats_to_json |
( |
| stats, |
|
|
| pretty ) |
Value:((stats)->to_json ? (stats)->to_json((stats), (pretty)) : NULL)
Converts stats to JSON format string.
Caller must free the returned string.
Definition at line 162 of file stats.h.
◆ wu_portfolio_stats_to_keyvalue
| #define wu_portfolio_stats_to_keyvalue |
( |
| stats | ) |
|
Value:((stats)->to_keyvalue ? (stats)->to_keyvalue((stats)) : NULL)
Converts stats to key=value format string.
Caller must free the returned string.
Definition at line 155 of file stats.h.
◆ wu_portfolio_stats_update
| #define wu_portfolio_stats_update |
( |
| stats, |
|
|
| cash, |
|
|
| value, |
|
|
| timestamp ) |
Value: do { \
(stats)->
update((stats), (cash), (value), (timestamp)); \
} while(0)
static double update(WU_EMA ema, double value)
Updates portfolio state in stats.
Definition at line 130 of file stats.h.
◆ wu_portfolio_stats_update_position
| #define wu_portfolio_stats_update_position |
( |
| stats, |
|
|
| idx, |
|
|
| sym, |
|
|
| qty, |
|
|
| val, |
|
|
| price ) |
Value: do { \
if ((stats)->update_position) \
(stats)->update_position((stats), (idx), (sym), (qty), (val), (price)); \
} while(0)
Updates position info for a specific asset.
Definition at line 146 of file stats.h.
◆ wu_calmar_ratio_new()
| WU_CalmarRatio wu_calmar_ratio_new |
( |
double | initial_value | ) |
|
◆ 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_cash | Initial cash amount |
| risk_free_rate | Annual risk-free rate for Sharpe/Sortino calculations (e.g., 0.03 for 3%) |
Definition at line 295 of file stats.c.
◆ wu_sharpe_ratio_new()
| WU_SharpeRatio wu_sharpe_ratio_new |
( |
double | initial_value, |
|
|
double | risk_free_rate ) |
Creates a new Sharpe Ratio calculator.
Definition at line 106 of file sharpe.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.