code wiki / (root) / nx_fin_metrics.nx

nx_fin_metrics.nx

buildroot/runtime/nx_fin_metrics.nx

2325 B52 linesdepth 2pulls 2 transitivereach 9 importersview sourcekind librarytopic fin
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_fin_metrics.nx nx_fin_advstats.nx nx_fin_advstats_gate.nx nx_fin_bs.nx nx_fin_bs_gate.nx nx_fin_liquidity.nx nx_fin_liquidity_gate.nx nx_fin_metrics_gate.nx

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

10func me_isqrt(n: i64) -> i64
18func 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
21func me_mean(vals: *i64, n: i64) -> i64 { if n <= 0 { return 0 } return me_sum(vals, n) / n }
24func me_stddev(vals: *i64, n: i64) -> i64
called by 2: me_sharpe_millimain calls 2: me_meanme_isqrt
33func me_sharpe_milli(vals: *i64, n: i64, rf: i64) -> i64
called by 1: main calls 2: me_stddevme_mean
40func me_downside_dev(vals: *i64, n: i64, mar: i64) -> i64
called by 2: me_sortino_millimain calls 1: me_isqrt
48func me_sortino_milli(vals: *i64, n: i64, mar: i64) -> i64
called by 1: main calls 2: me_downside_devme_mean