code wiki / (root) / nx_fin_microcap_gate.nx

nx_fin_microcap_gate.nx source

↩ module page · 44 lines · 3021 B

1// nx_fin_microcap_gate.nx -- GATE for the microcap funnel: one PASS plus each reject gate fired in isolation, 2// proving the screen composes mg_grade + Altman-Z + liquidity/capacity + cap-band + price honestly. Config used: 3// cap band 50..300 $M, min ADV $1M (100000000c), min price $1 (100c), Z>=3.00 (300), min grade B (3), 4// participation 100 bps. Exits 0 iff all pass. license_tier: ORIGINAL 5import "nx_gate.nx" 6import "nx_fin_marketdata.nx" 7import "nx_fin_mgmt_grade.nx" 8import "nx_fin_microcap.nx" 9 10func chk(name: *u8, got: i64, want: i64, st: *i64) -> i64 { 11 if got == want { st[0] = st[0] + 1; gw(" PASS " as *u8); gw(name); gw("\n" as *u8) } 12 else { st[1] = st[1] + 1; gw(" FAIL " as *u8); gw(name); gw(" got=" as *u8); gn(got); gw(" want=" as *u8); gn(want); gw("\n" as *u8) } 13 return 0 14} 15 16func main() -> i64 { 17 let st: *i64 = sys_mmap(16) as *i64 18 st[0] = 0; st[1] = 0 19 20 // config: min_cap=50, max_cap=300, min_adv=100000000c($1M), min_price=100c($1), z_safe=300, min_grade=MG_B(3), part=100bps 21 // A clean microcap: cap $150M, ADV $5M, price $5, Z=3.50, mgmt 7 (grade A), target position $50k == capacity -> PASS 22 chk("clean microcap -> PASS(0)" as *u8, mc_screen(150, 500000000, 500, 350, 7, 5000000, 50, 300, 100000000, 100, 300, MG_B, 100), MC_PASS, st) 23 // large cap (outside band) 24 chk("large-cap -> REJ_CAPBAND(1)" as *u8, mc_screen(5000, 500000000, 500, 350, 7, 5000000, 50, 300, 100000000, 100, 300, MG_B, 100), MC_REJ_CAPBAND, st) 25 // illiquid (ADV $100k < $1M) 26 chk("illiquid -> REJ_LIQUIDITY(2)" as *u8, mc_screen(150, 10000000, 500, 350, 7, 5000000, 50, 300, 100000000, 100, 300, MG_B, 100), MC_REJ_LIQUIDITY, st) 27 // penny (price $0.50 < $1) 28 chk("penny -> REJ_PRICE(3)" as *u8, mc_screen(150, 500000000, 50, 350, 7, 5000000, 50, 300, 100000000, 100, 300, MG_B, 100), MC_REJ_PRICE, st) 29 // distressed (Z=1.50 < 3.00) 30 chk("distressed -> REJ_DISTRESS(4)" as *u8, mc_screen(150, 500000000, 500, 150, 7, 5000000, 50, 300, 100000000, 100, 300, MG_B, 100), MC_REJ_DISTRESS, st) 31 // bad stewards (mgmt 2 -> grade D < B) 32 chk("bad-stewards -> REJ_STEWARD(5)" as *u8, mc_screen(150, 500000000, 500, 350, 2, 5000000, 50, 300, 100000000, 100, 300, MG_B, 100), MC_REJ_STEWARD, st) 33 // capacity: target $100k > 1% of $5M ADV ($50k) 34 chk("too-big-for-liquidity -> REJ_CAPACITY(6)" as *u8, mc_screen(150, 500000000, 500, 350, 7, 10000000, 50, 300, 100000000, 100, 300, MG_B, 100), MC_REJ_CAPACITY, st) 35 36 // ranking score: Z=350 + mgmt 7*50 + catalyst 200 = 900 ; no catalyst = 700 37 chk("mc_score with catalyst = 900" as *u8, mc_score(350, 7, 1, 50, 200), 900, st) 38 chk("mc_score no catalyst = 700" as *u8, mc_score(350, 7, 0, 50, 200), 700, st) 39 40 gw("nx_fin_microcap_gate: PASS=" as *u8); gn(st[0]); gw(" FAIL=" as *u8); gn(st[1]); gw("\n" as *u8) 41 if st[1] == 0 { gw("nx_fin_microcap: GREEN (funnel composes mgmt_grade + Z + liquidity)\n" as *u8); return 0 } 42 gw("nx_fin_microcap: RED\n" as *u8) 43 return 1 44}