code wiki / (root) / nx_fin_optimizer.nx

nx_fin_optimizer.nx

buildroot/runtime/nx_fin_optimizer.nx

2762 B60 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic fin
docsdependenciesstructsconstsfunctions

about

nx_fin_optimizer.nx -- portfolio OPTIMIZATION, analytic (no matrix inverse needed): the closed-form mean-variance solutions. (1) inverse-variance weighting (risk-parity's simple cousin): w_i ~ 1/var_i; (2) diagonal max-Sharpe / tangency for uncorrelated assets: w_i ~ max(0,mu_i)/var_i (long-only); (3) 2-asset min-variance WITH correlation, closed form; (4) portfolio variance of ANY weight vector given the full covariance (the objective to evaluate/compare allocations). Weights in bps (sum ~10000). i64 fixed-point. The full N-asset correlated convex QP (cvxpy/PyPortfolioOpt) is the refinement still ahead. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_fin_optimizer.nx nx_fin_optimizer_gate.nx

imports: nx_syscalls.nx

imported by: nx_fin_optimizer_gate.nx

structs

none

consts

8const K_MAGIC_1000000000: i64 = 1000000000
9const K_MAGIC_10000: i64 = 10000
10const K_MAGIC_1000000: i64 = 1000000
11const K_MAGIC_5000: i64 = 5000
12const K_MAGIC_100000000: i64 = 100000000

functions

15func op_inv_var_weight(varr: *i64, n: i64, wout: *i64) -> i64
called by 1: main calls 1: sys_mmap
25func op_max_sharpe_diag(mu: *i64, varr: *i64, n: i64, wout: *i64) -> i64
called by 1: main calls 1: sys_mmap
41func op_minvar_2asset(v1: i64, v2: i64, cov: i64) -> i64
called by 1: main
52func op_port_variance(w: *i64, cov: *i64, n: i64) -> i64
called by 1: main