nx_fin_census.nx source
↩ module page · 76 lines · 8032 B
1// nx_fin_census.nx -- HONEST HAVE-vs-GAP census for the NISHI MARKETS-INVESTING / TRADING stack (the "finmkt"
2// RACI arc, sibling of personal-finance nx_fin_member). For each capability of a COMPLETE modern trading +
3// accounting/tax + grants platform: HAVE iff a clean sovereign organ actually opens on disk (no-false-green --
4// ax_have opens the REAL file); GAP = a capability the team must still build. permille = have*1000/tot.
5// Mirrors nx_agent_ops_census's auditor discipline: this grades COVERAGE (organ exists), not per-organ
6// correctness -- QUALITY is the later ratchet (existence != full-correctness). Goal: a sovereign organ for
7// every rung R1..R8 of the hardware-up trading ladder, sim-first BY CONSTRUCTION (R6 live stays GAP until the
8// backtester + paper rungs prove an edge). Placement: extends the markets-investing arc (nx_fin_* + the
9// nx_markets_member "finmkt" channel). Composes nx_gate (gw/gn). Grounded in the 107-source nx_fin_research_fetch
10// corpus. license_tier: ORIGINAL
11import "nx_gate.nx"
12
13func ax_have(path: *u8) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0 { return 0 } sys_close(fd); return 1 }
14func ax(label: *u8, path: *u8, note: *u8) -> i64 {
15 let h: i64=ax_have(path)
16 if h==1 { gw(" [HAVE] " as *u8) } else { gw(" [GAP ] " as *u8) }
17 gw(label); gw(" -> " as *u8); gw(note); gw("\n" as *u8)
18 return h
19}
20
21func main() -> i64 {
22 gw("=== nx_fin_census: how much of a COMPLETE sovereign TRADING + TAX + GRANTS stack do we HAVE? ===\n" as *u8)
23 gw(" (HAVE = a clean sovereign organ opens on disk; GAP = the team must build it. no-false-green.)\n\n" as *u8)
24 var have: i64=0; var tot: i64=0
25
26 gw("-- ANALYSIS BRAIN: is this a real business worth owning? (the microcap quality filter) --\n" as *u8)
27 have=have+ax("financial researcher (107 src) " as *u8, "runtime/nx_fin_research_fetch.nx" as *u8, "sovereign TLS fetch of markets/EDGAR/valuation/tax corpus" as *u8); tot=tot+1
28 have=have+ax("fund / 13F researcher " as *u8, "runtime/nx_fin_fund_research_fetch.nx" as *u8, "institutional holdings + fund analysis sources" as *u8); tot=tot+1
29 have=have+ax("management stewardship grade " as *u8, "runtime/nx_fin_mgmt_grade.nx" as *u8, "grade the PEOPLE: insider buys, ROCE, board, say-on-pay (8 tests)" as *u8); tot=tot+1
30 have=have+ax("bankruptcy / distress Z-score " as *u8, "runtime/nx_fin_zscore.nx" as *u8, "Altman-Z survival signal -- keeps microcap junk out" as *u8); tot=tot+1
31 have=have+ax("filing / data extractor " as *u8, "runtime/nx_fin_extract.nx" as *u8, "parse EDGAR / statement data into signals" as *u8); tot=tot+1
32 have=have+ax("valuation / financial compute " as *u8, "runtime/nx_fin_finance.nx" as *u8, "DCF / ratios / statement math (integer-exact)" as *u8); tot=tot+1
33
34 gw("\n-- LEDGER / GOVERNANCE SUBSTRATE (additive-only, Cardinal 13) --\n" as *u8)
35 have=have+ax("additive financial ledger " as *u8, "runtime/nx_fin_ledger.nx" as *u8, "append-only, versioned record of positions and PnL" as *u8); tot=tot+1
36 have=have+ax("audit trail " as *u8, "runtime/nx_fin_audit.nx" as *u8, "every entry justified and contestable" as *u8); tot=tot+1
37 have=have+ax("dispute / reversal " as *u8, "runtime/nx_fin_dispute.nx" as *u8, "correct without destroying history" as *u8); tot=tot+1
38 have=have+ax("tax / compliance rules engine " as *u8, "runtime/nx_fin_rules.nx" as *u8, "data-driven tax and compliance rules (Cardinal 11)" as *u8); tot=tot+1
39 have=have+ax("finance dashboard (UI seed) " as *u8, "runtime/nx_fin_dashboard.nx" as *u8, "surface -- must become a login-gated page (visibility = done)" as *u8); tot=tot+1
40 have=have+ax("markets arc RACI / team owner " as *u8, "runtime/_hdl_build/nx_markets_member.nx" as *u8, "finmkt channel: the arc is OWNED, not an orphan" as *u8); tot=tot+1
41
42 gw("\n-- COMPOSABLE PRIMITIVES the trading body will build on --\n" as *u8)
43 have=have+ax("sovereign TLS-1.3 fetch (pipe) " as *u8, "runtime/nx_https_fetch_follow.nx" as *u8, "market-data ingestion over own TLS (no curl)" as *u8); tot=tot+1
44 have=have+ax("sovereign data store " as *u8, "runtime/nx_seg_store.nx" as *u8, "OHLCV / tick / ledger store (retires sqlite and TSV)" as *u8); tot=tot+1
45 have=have+ax("writing engine (grant drafting) " as *u8, "runtime/nx_writecraft.nx" as *u8, "Nishi Writer craft for grant applications" as *u8); tot=tot+1
46
47 gw("\n-- TRADING BODY: when / how much / how not to blow up (R1..R6 -- GREENFIELD) --\n" as *u8)
48 have=have+ax("R1 quote/OHLCV + ADV ingestion " as *u8, "runtime/nx_fin_marketdata.nx" as *u8, "the price and LIQUIDITY sensor everything else needs" as *u8); tot=tot+1
49 have=have+ax("liquidity / market-impact model " as *u8, "runtime/nx_fin_liquidity.nx" as *u8, "the SCALING WALL: can a small stake grow to 1M in this name? (ADV/impact)" as *u8); tot=tot+1
50 have=have+ax("R2 point-in-time backtester " as *u8, "runtime/nx_fin_backtest.nx" as *u8, "TRUTH engine: proves or kills an edge before a dollar is risked" as *u8); tot=tot+1
51 have=have+ax("risk-adjusted metrics " as *u8, "runtime/nx_fin_metrics.nx" as *u8, "expectancy / Sharpe / Sortino / max-drawdown -- not the no-loss fantasy" as *u8); tot=tot+1
52 have=have+ax("R3 trading-signal strategy lib " as *u8, "runtime/nx_fin_strategy.nx" as *u8, "composes mgmt_grade + zscore + technical/catalyst signals" as *u8); tot=tot+1
53 have=have+ax("microcap quality+catalyst screen " as *u8, "runtime/nx_fin_microcap.nx" as *u8, "funnel the 1000 microcaps down to the few worth trading" as *u8); tot=tot+1
54 have=have+ax("R4 position-sizing / risk engine " as *u8, "runtime/nx_fin_risk_engine.nx" as *u8, "fractional-Kelly / vol-target sizing + max-drawdown circuit breaker" as *u8); tot=tot+1
55 have=have+ax("portfolio construction " as *u8, "runtime/nx_fin_portfolio.nx" as *u8, "diversify so no single loss can kill the account" as *u8); tot=tot+1
56 have=have+ax("R5 paper / sim execution " as *u8, "runtime/nx_fin_paper.nx" as *u8, "forward-test vs REAL quotes, no capital (the overfit check)" as *u8); tot=tot+1
57 have=have+ax("R6 live broker adapter (GATED) " as *u8, "runtime/nx_fin_broker.nx" as *u8, "real orders ONLY after R2 out-of-sample + R5 forward edge" as *u8); tot=tot+1
58
59 gw("\n-- ACCOUNTING / TAX (R7) + GRANTS (R8) -- park gains + pull in non-dilutive cash --\n" as *u8)
60 have=have+ax("tax-lot accounting " as *u8, "runtime/nx_fin_taxlot.nx" as *u8, "wash-sale + short/long-term + loss-harvest, per lot" as *u8); tot=tot+1
61 have=have+ax("tax-optimization / entity model " as *u8, "runtime/nx_fin_taxopt.nx" as *u8, "QSBS / deferral / entity structuring -- AI drafts, CPA signs" as *u8); tot=tot+1
62 have=have+ax("grant discovery / draft " as *u8, "runtime/nx_fin_grant.nx" as *u8, "SBIR/STTR/state: match eligibility + draft (Writer x Grants)" as *u8); tot=tot+1
63
64 let permille: i64=have*1000/tot
65 gw("\n=== TRADING + TAX + GRANTS stack: " as *u8); gn(have); gw("/" as *u8); gn(tot); gw(" HAVE = " as *u8); gn(permille); gw(" permille ===\n" as *u8)
66 gw("HONEST: the ANALYSIS BRAIN + ledger/governance substrate exist; the TRADING BODY (R1..R6), tax-lots (R7)\n" as *u8)
67 gw("and grants (R8) are the build. Sim-first BY CONSTRUCTION: R6 live orders stay GAP until R2 out-of-sample\n" as *u8)
68 gw("and R5 forward-paper edge is proven. Build order: R1 market-data -> R2 backtester -> R3 strategy ->\n" as *u8)
69 gw("R4 risk -> R5 paper -> R6 live; R7 tax-lots + R8 grants in parallel. permille ratchets as each organ lands.\n" as *u8)
70 if permille >= 1000 {
71 gw("FIN-STACK GREEN -- a sovereign organ for every rung of the trading + tax + grants ladder.\n" as *u8)
72 sys_exit(0); return 0
73 }
74 gw("FIN-STACK HONEST -- strong analysis brain, greenfield trading body; NOT s-class until the rungs land.\n" as *u8)
75 sys_exit(0); return 0
76}