code wiki / (root) / nx_fin_taxlot.nx

nx_fin_taxlot.nx

buildroot/runtime/nx_fin_taxlot.nx

2931 B57 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic fin
docsdependenciesstructsconstsfunctions

about

nx_fin_taxlot.nx -- R7 (Nishi Accounting): tax-lot accounting = the machinery to PARK gains legally. Exact integer date math (Hinnant's civil-days algorithm) for holding periods, short/long-term classification (the difference between ordinary-income and the lower long-term cap-gains rate), realized gain/loss, WASH-SALE detection (a loss re-bought within +/-30 days is DISALLOWED), and the tax saved by harvesting a real loss. Pure, i64 (cents/bps/days), NO floats. AI drafts + models; a licensed CPA signs the return. Pairs with the additive nx_fin_ledger. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_fin_taxlot.nx nx_fin_taxlot_gate.nx

imports: nx_syscalls.nx

imported by: nx_fin_taxlot_gate.nx

structs

none

consts

8const TL_MAGIC_146097: i64 = 146097
9const TL_MAGIC_719468: i64 = 719468
10const TL_MAGIC_10000: i64 = 10000
12const TL_LONGTERM_DAYS: i64 = 365 // held MORE than this (>1 year) = long-term
13const TL_WASH_WINDOW: i64 = 30 // +/- 30 days = the wash-sale window

functions

16func tl_days_from_civil(y0: i64, m: i64, d: i64) -> i64
called by 1: tl_days_between
31func tl_days_between(d1_key: i64, d2_key: i64) -> i64
called by 1: main calls 1: tl_days_from_civil
38func tl_is_longterm(holding_days: i64) -> i64 { if holding_days > TL_LONGTERM_DAYS { return 1 } return 0 }
called by 1: main
41func tl_realized_cents(sale_px_cents: i64, cost_px_cents: i64, shares: i64) -> i64 { return (sale_px_cents - cost_px_cents) * shares }
called by 1: main
45func tl_is_wash(realized_cents: i64, days_to_repurchase: i64) -> i64
called by 1: main
53func tl_harvest_benefit(realized_cents: i64, tax_rate_bps: i64) -> i64
called by 1: main