code wiki / (root) / nx_fin_portfolio.nx

nx_fin_portfolio.nx

buildroot/runtime/nx_fin_portfolio.nx

2606 B51 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic fin
docsdependenciesstructsconstsfunctions

about

nx_fin_portfolio.nx -- portfolio construction / DIVERSIFICATION: allocate across many names so NO single position or correlated cluster can sink the account (the portfolio-level complement to R4's per-trade sizing). Equal- or score-weighted allocation, each capped by a per-name concentration limit; sector-exposure and total- exposure (no-leverage) checks; and a Herfindahl concentration index (lower = more diversified; 10000/N at equal weight). Pure, i64 (cents/bps), data-driven caps (Cardinal 11). license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_fin_portfolio.nx nx_fin_portfolio_gate.nx

imports: nx_syscalls.nx

imported by: nx_fin_portfolio_gate.nx

structs

none

consts

7const K_MAGIC_10000: i64 = 10000

functions

10func pf_equal_weight(equity_cents: i64, n_positions: i64, max_weight_bps: i64) -> i64
called by 1: main
19func pf_score_weight(equity_cents: i64, score: i64, total_score: i64, max_weight_bps: i64) -> i64
called by 1: main
28func pf_concentration_ok(position_cents: i64, equity_cents: i64, max_weight_bps: i64) -> i64
called by 1: main
34func pf_sector_ok(sector_exposure_cents: i64, new_position_cents: i64, equity_cents: i64, max_sector_bps: i64) -> i64
called by 1: main
40func pf_total_exposure_ok(deployed_cents: i64, new_position_cents: i64, equity_cents: i64) -> i64
called by 1: main
47func pf_herfindahl(weights_bps: *i64, n: i64) -> i64
called by 1: main