nx_fin_metrics.nx
buildroot/runtime/nx_fin_metrics.nx
about
nx_fin_metrics.nx -- risk-adjusted performance metrics, i64 fixed-point, NO floats. Provides the integer
sqrt primitive (me_isqrt, Newton's method) the float-free runtime needs, then mean / standard-deviation /
SHARPE / downside-deviation / SORTINO over a returns array (per-period returns in basis points). Sharpe and
Sortino are returned in MILLI-units (x1000) for integer resolution. Risk-free / MAR passed in (default 0).
These are the numbers that grade an edge HONESTLY -- reward per unit of risk, not raw return. Pure; composes
with nx_fin_backtest's per-trade/per-period returns. license_tier: ORIGINAL
dependencies 1 imports · 7 importers
imports: nx_syscalls.nx
imported by: nx_fin_advstats.nxnx_fin_advstats_gate.nxnx_fin_bs.nxnx_fin_bs_gate.nxnx_fin_liquidity.nxnx_fin_liquidity_gate.nxnx_fin_metrics_gate.nx
structs
| none |
consts
| none |
functions
| 10 | func me_isqrt(n: i64) -> i64 |
| 18 | func me_sum(vals: *i64, n: i64) -> i64 { var s: i64 = 0; var i: i64 = 0; while i < n { s = s + vals[i]; i = i + 1 } return s } called by 1: me_mean |
| 21 | func me_mean(vals: *i64, n: i64) -> i64 { if n <= 0 { return 0 } return me_sum(vals, n) / n } |
| 24 | func me_stddev(vals: *i64, n: i64) -> i64 |
| 33 | func me_sharpe_milli(vals: *i64, n: i64, rf: i64) -> i64 |
| 40 | func me_downside_dev(vals: *i64, n: i64, mar: i64) -> i64 |
| 48 | func me_sortino_milli(vals: *i64, n: i64, mar: i64) -> i64 |