nx_fin_competitor_census.nx source
↩ module page · 81 lines · 7606 B
1// nx_fin_competitor_census.nx -- S-CLASS-EXCEED census: measure the Nishi trading+tax+grants stack against the
2// COMPETITOR/SOTA bar (Backtrader / Zipline / QuantConnect-LEAN / pyfolio-empyrical / Bloomberg-IBKR / Lopez de
3// Prado), grounded in the banked competitor research (knowledge/fetched/fin_cmp_*) + our REAL organs. Each axis
4// gets an HONEST 3-way verdict: BEHIND(0) / PARITY(1) / EXCEED(2). NO false-green, NO false-exceed: a PARITY or
5// EXCEED claim is LIAR-KILLED to BEHIND unless the organ actually opens on disk (gate-derived), and the only
6// EXCEEDs claimed are STRUCTURAL + MEASURABLE (sovereignty=0-deps, integer-determinism, free-data doctrine,
7// integrated tax, unified stack) -- never subjective/feature exceeds (the nx_visual_exceed lesson). permille =
8// (parity+exceed)*1000/total; AHEAD = measured exceeds; BEHIND = the honest build list. license_tier: ORIGINAL
9import "nx_gate.nx"
10
11const CX_BEHIND: i64 = 0
12const CX_PARITY: i64 = 1
13const CX_EXCEED: i64 = 2
14
15func cx_have(path: *u8) -> i64 {
16 if path[0] == (0 as u8) { return 0 } // empty path = an honest gap (BEHIND), no organ
17 let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 }
18 sys_close(fd); return 1
19}
20// st: [0]=behind [1]=parity [2]=exceed [3]=liarkill [4]=total
21func cx_ax(label: *u8, path: *u8, claimed: i64, note: *u8, st: *i64) -> i64 {
22 var tier: i64 = claimed
23 let have: i64 = cx_have(path)
24 var killed: i64 = 0
25 if claimed >= CX_PARITY { if have != 1 { tier = CX_BEHIND; killed = 1 } } // no organ -> can't claim par/exceed
26 if tier == CX_EXCEED { gw(" [EXCEED] " as *u8); st[2] = st[2] + 1 }
27 else { if tier == CX_PARITY { gw(" [PARITY] " as *u8); st[1] = st[1] + 1 }
28 else { gw(" [BEHIND] " as *u8); st[0] = st[0] + 1 } }
29 gw(label); gw(" -> " as *u8); gw(note)
30 if killed == 1 { gw(" <<LIAR-KILL: claimed>=parity but organ absent>>" as *u8); st[3] = st[3] + 1 }
31 gw("\n" as *u8)
32 st[4] = st[4] + 1
33 return 0
34}
35
36func main() -> i64 {
37 let st: *i64 = sys_mmap(64) as *i64
38 st[0]=0; st[1]=0; st[2]=0; st[3]=0; st[4]=0
39 gw("=== nx_fin_competitor_census: Nishi stack vs the quant-platform SOTA bar (measured exceed, liar-kill armed) ===\n\n" as *u8)
40
41 gw("-- PARITY: core quant capability at par with Backtrader/Zipline/QuantConnect-LEAN/pyfolio --\n" as *u8)
42 cx_ax("point-in-time backtester " as *u8, "runtime/nx_fin_backtest.nx" as *u8, CX_PARITY, "vs Backtrader/Zipline/LEAN event engines" as *u8, st)
43 cx_ax("no-look-ahead (enforced) " as *u8, "runtime/nx_fin_strategy.nx" as *u8, CX_PARITY, "signals through bar i-1 (they offer, we enforce)" as *u8, st)
44 cx_ax("slippage + commission model " as *u8, "runtime/nx_fin_backtest.nx" as *u8, CX_PARITY, "vs Zipline/Backtrader cost models" as *u8, st)
45 cx_ax("risk metrics Sharpe/Sortino/DD" as *u8, "runtime/nx_fin_metrics.nx" as *u8, CX_PARITY, "vs pyfolio / empyrical" as *u8, st)
46 cx_ax("position sizing Kelly/vol/1% " as *u8, "runtime/nx_fin_risk_engine.nx" as *u8, CX_PARITY, "vs QuantConnect sizing helpers" as *u8, st)
47 cx_ax("strategy framework (pluggable)" as *u8, "runtime/nx_fin_strategy.nx" as *u8, CX_PARITY, "signal API (indicator BREADTH is behind)" as *u8, st)
48 cx_ax("OOS / walk-forward validation " as *u8, "runtime/nx_fin_paper.nx" as *u8, CX_PARITY, "standard SOTA; we match (not exceed)" as *u8, st)
49 cx_ax("advanced stats (DSR + PBO) " as *u8, "runtime/nx_fin_advstats.nx" as *u8, CX_PARITY, "deflated-Sharpe + PBO overfit suite (Lopez de Prado); CPCV next" as *u8, st)
50 cx_ax("portfolio optimizer (mean-var)" as *u8, "runtime/nx_fin_optimizer.nx" as *u8, CX_PARITY, "analytic MV: diag max-Sharpe + inv-var + 2-asset min-var; full-cov convex QP next" as *u8, st)
51 cx_ax("multi-asset: opt+futures+fx" as *u8, "runtime/nx_fin_bs.nx" as *u8, CX_PARITY, "Black-Scholes options+delta + futures cost-of-carry + FX interest-parity (nx_fin_assets), integer-exact; vol-surface/American next" as *u8, st)
52 cx_ax("market-impact model " as *u8, "runtime/nx_fin_liquidity.nx" as *u8, CX_PARITY, "sqrt-law; Almgren-Chriss is fuller" as *u8, st)
53 cx_ax("OHLCV market-data ingestion " as *u8, "runtime/nx_fin_marketdata_fetch.nx" as *u8, CX_PARITY, "live Alpha Vantage (breadth behind)" as *u8, st)
54 cx_ax("fundamentals ingestion (XBRL) " as *u8, "runtime/nx_fin_edgar_fetch.nx" as *u8, CX_PARITY, "raw EDGAR vs normalized vendor feeds" as *u8, st)
55 cx_ax("quality screen (fund+liquidity)" as *u8, "runtime/nx_fin_microcap.nx" as *u8, CX_PARITY, "composes mgmt_grade+Z; vs stock screeners" as *u8, st)
56
57 gw("\n-- EXCEED (MEASURED + STRUCTURAL only -- liar-kill armed) --\n" as *u8)
58 cx_ax("sovereignty / zero dependency " as *u8, "runtime/nx_fin_backtest.nx" as *u8, CX_EXCEED, "0 ext deps (nx_cc->nxasm, no gcc/Python/cloud) vs QuantConnect cloud-lock + Zipline/Backtrader Python tree" as *u8, st)
59 cx_ax("deterministic integer (no float)" as *u8, "runtime/nx_fin_marketdata.nx" as *u8, CX_EXCEED, "bit-exact i64 cents/bps, zero float rounding vs float-based backtesters" as *u8, st)
60 cx_ax("free-first legal/polite data " as *u8, "runtime/nx_fin_datasource.nx" as *u8, CX_EXCEED, "enforced free-raw/polite/paid-wall doctrine; competitors assume paid feeds" as *u8, st)
61 cx_ax("integrated tax-lot + QSBS/opt " as *u8, "runtime/nx_fin_taxlot.nx" as *u8, CX_EXCEED, "wash-sale/ST-LT/harvest/QSBS INSIDE the stack; quant platforms have NO tax module" as *u8, st)
62 cx_ax("unified trade + tax + grants " as *u8, "runtime/nx_fin_grant.nx" as *u8, CX_EXCEED, "one sovereign stack spans all three; no competitor unifies them" as *u8, st)
63
64 gw("\n-- BEHIND: the HONEST build list (where competitors beat us today) --\n" as *u8)
65 cx_ax("live brokerage execution " as *u8, "" as *u8, CX_BEHIND, "IBKR/Alpaca live orders; ours R6 GATED by design till edge proven" as *u8, st)
66 cx_ax("data breadth (history/tick/univ)" as *u8, "" as *u8, CX_BEHIND, "QuantConnect decades of tick; ours 1 free symbol till a real key" as *u8, st)
67 cx_ax("indicator / strategy breadth " as *u8, "" as *u8, CX_BEHIND, "platforms ship 100s of indicators; ours 3" as *u8, st)
68 cx_ax("ML / factor models " as *u8, "" as *u8, CX_BEHIND, "sklearn/TF integration; ours none" as *u8, st)
69 cx_ax("vectorized speed / scale " as *u8, "" as *u8, CX_BEHIND, "VectorBT vectorization + cloud compute; ours single-pass" as *u8, st)
70 cx_ax("community / marketplace / live" as *u8, "" as *u8, CX_BEHIND, "QuantConnect community + live infra; ours none" as *u8, st)
71
72 let tot: i64 = st[4]
73 let cov: i64 = (st[1] + st[2]) * 1000 / tot
74 gw("\n=== EXCEED=" as *u8); gn(st[2]); gw(" PARITY=" as *u8); gn(st[1]); gw(" BEHIND=" as *u8); gn(st[0])
75 gw(" (of " as *u8); gn(tot); gw(") coverage=" as *u8); gn(cov); gw(" permille LIAR-KILL=" as *u8); gn(st[3]); gw(" ===\n" as *u8)
76 gw("HONEST: " as *u8); gn(st[2]); gw(" MEASURED STRUCTURAL exceeds (sovereignty / integer-determinism / free-data doctrine / integrated-tax / unified-stack).\n" as *u8)
77 gw("PARITY on core quant logic. " as *u8); gn(st[0]); gw(" BEHIND = the roadmap (breadth / live-exec / indicators / asset-depth / ML / scale / community; +CPCV refinement).\n" as *u8)
78 if st[3] == 0 { gw("NO false exceeds (liar-kill=0): every EXCEED + PARITY is backed by an organ on disk.\n" as *u8) }
79 gw("VERDICT: STRUCTURALLY s-class-exceed (control/determinism/legality/unification); FEATURE-BEHIND on breadth -- not yet s-class until the build list lands. No wave.\n" as *u8)
80 sys_exit(0); return 0
81}