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 2 imports · 7 importers
imports: nx_syscalls.nxnx_vecmath.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
| 11 | func me_isqrt(n: i64) -> i64 { return vm_isqrt(n) } called by 6: as_sharpe_tstat_millibs_sqrt_fplq_impact_bpsme_stddevme_downside_devmain calls 1: vm_isqrt |
| 13 | 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 |
| 16 | func me_mean(vals: *i64, n: i64) -> i64 { if n <= 0 { return 0 } return me_sum(vals, n) / n } |
| 19 | func me_stddev(vals: *i64, n: i64) -> i64 |
| 28 | func me_sharpe_milli(vals: *i64, n: i64, rf: i64) -> i64 |
| 35 | func me_downside_dev(vals: *i64, n: i64, mar: i64) -> i64 |
| 43 | func me_sortino_milli(vals: *i64, n: i64, mar: i64) -> i64 |