code wiki / (root) / nx_beneish_lib.nx

nx_beneish_lib.nx

buildroot/runtime/nx_beneish_lib.nx

3183 B56 linesdepth 7pulls 12 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_beneish_lib.nx -- BENEISH M-SCORE: forensic detection of earnings manipulation, integer-exact. The fourth lens on a company, and the darkest one: Altman asks if it is in distress, Piotroski if it is strengthening, mgmt-grade if the stewards are good -- Beneish asks if the numbers are being COOKED. It is the standard forensic-accounting model (Beneish 1999); students using it flagged Enron a year before it collapsed. Eight indices comparing this year to last across receivables, margins, asset quality, sales growth, depreciation, SG&A, accruals, and leverage combine into one M-score; above the -1.78 threshold the profile matches known manipulators. M = -4.84 + 0.920*DSRI + 0.528*GMI + 0.404*AQI + 0.892*SGI + 0.115*DEPI - 0.172*SGAI + 4.679*TATA - 0.327*LVGI NO FLOATS: each index is scaled x1000 (a ratio of 1.000 -> 1000, i.e. basis points), coefficients are scaled x1000, the accumulation is x1e6, and the result is returned as M x1000 -- exact integer arithmetic, the only reproducible way to score fraud. Threshold is DATA. ★FAIL-CLOSED + COMPOSES: the missing-input sentinel BEN_NA is the pipeline value (-999999999). If any index could not be computed from the filings, ben_mscore returns BEN_INCOMPLETE rather than a fraud verdict on partial data -- accusing a company of cooking books on missing facts is the worst false signal. license_tier: ORIGINAL No hw writes (Rule 26). LIB.

dependencies 1 imports · 1 importers

nx_matter_lib.nx nx_beneish_lib.nx nx_beneish_gate.nx

imports: nx_matter_lib.nx

imported by: nx_beneish_gate.nx

structs

none

consts

22const BEN_MAGIC_4840000: i64 = 4840000
23const BEN_MAGIC_4679: i64 = 4679
25const BEN_NA: i64 = 0 - 999999999 // a required index is missing (matches the pipeline sentinel)
26const BEN_INCOMPLETE: i64 = 0 - 2000000000 // M not computable (well outside the real M x1000 range)
27const BEN_THRESHOLD: i64 = 0 - 1780 // M x1000; ABOVE this the profile matches manipulators

functions

30func ben_mscore(dsri: i64, gmi: i64, aqi: i64, sgi: i64, depi: i64, sgai: i64, tata: i64, lvgi: i64) -> i64
called by 1: main
45func ben_is_manipulator(m1000: i64) -> i64
called by 1: main
52func ben_verdict_str(m1000: i64) -> *u8
called by 1: main