code wiki / _hdl_build / nx_price_hist.nx

nx_price_hist.nx

buildroot/runtime/_hdl_build/nx_price_hist.nx

9058 B143 linesdepth 5pulls 6 transitivereach 1 importersview sourcekind librarytopic price
docsdependenciesstructsconstsfunctions

about

nx_price_hist.nx -- LIB: PRICE HISTORY + TRENDS (R-PRICE-R1). Turns single price observations into an ADDITIVE time series (rule 13: history is sacred) so "how a store is doing" becomes "how prices are MOVING". Each recorded observation is appended; the trend = latest minus earliest over the recorded series (signed: rising/falling/flat), the basket trend = the sum across items. HONEST: trends are computed from RECORDED dated observations, NEVER a prediction. Keeps nx_price's latest-observation in sync (pr_get_price still works). Sovereign seg-store (knowledge/store/price-*), integer cents no-float. license_tier: ORIGINAL

dependencies 4 imports · 1 importers

nx_price.nx nx_food_science.nx nx_seg_store.nx nx_syscalls.nx nx_price_hist.nx nx_price_hist_gate.nx

imports: nx_price.nxnx_food_science.nxnx_seg_store.nxnx_syscalls.nx

imported by: nx_price_hist_gate.nx

structs

none

consts

none

functions

12func ph_put(prefix: *u8, key: *u8, val: *u8) -> i64
21func ph_sign(v: i64) -> i64 { if v > 0 { return 1 } if v < 0 { return 0 - 1 } return 0 }
23func ph_histn_key(sid: *u8, item: *u8, out: *u8) -> i64 { var o: i64 = 0; o = as_append(out, o, "price:histn:" as *u8); o = as_append(out, o, sid); out[o] = 58 as u8; o = o + 1; o = as_append(out, o, item); out[o] = 0 as u8; return o }
called by 2: ph_countph_record calls 1: as_append
24func ph_hist_key(sid: *u8, item: *u8, seq: i64, out: *u8) -> i64 { var o: i64 = 0; o = as_append(out, o, "price:hist:" as *u8); o = as_append(out, o, sid); out[o] = 58 as u8; o = o + 1; o = as_append(out, o, item); out[o] = 58 as u8; o = o + 1; o = fd_apnum(out, o, seq); out[o] = 0 as u8; return o }
called by 2: ph_recordph_at calls 2: as_appendfd_apnum
26func ph_count(prefix: *u8, sid: *u8, item: *u8) -> i64
34func ph_set_latest(prefix: *u8, sid: *u8, item: *u8, price: i64, day: i64, source: *u8) -> i64
44func ph_record(prefix: *u8, sid: *u8, item: *u8, price: i64, day: i64, source: *u8) -> i64
58func ph_at(prefix: *u8, sid: *u8, item: *u8, seq: i64) -> i64
67func ph_earliest(prefix: *u8, sid: *u8, item: *u8) -> i64 { if ph_count(prefix, sid, item) == 0 { return 0 - 1 } return ph_at(prefix, sid, item, 0) }
calls 2: ph_countph_at
68func ph_latest(prefix: *u8, sid: *u8, item: *u8) -> i64 { let n: i64 = ph_count(prefix, sid, item); if n == 0 { return 0 - 1 } return ph_at(prefix, sid, item, n - 1) }
called by 1: ph_render_trend calls 2: ph_countph_at
70func ph_trend(prefix: *u8, sid: *u8, item: *u8) -> i64
75func ph_trend_dir(prefix: *u8, sid: *u8, item: *u8) -> i64 { return ph_sign(ph_trend(prefix, sid, item)) }
called by 2: ph_render_trendmain calls 2: ph_signph_trend
76func ph_min(prefix: *u8, sid: *u8, item: *u8) -> i64
called by 2: ph_render_trendmain calls 2: ph_countph_at
84func ph_max(prefix: *u8, sid: *u8, item: *u8) -> i64
called by 2: ph_render_trendmain calls 2: ph_countph_at
93func ph_basket_trend(prefix: *u8, sid: *u8, items: *i64, n: i64) -> i64
called by 2: ph_render_trendmain calls 1: ph_trend
100func ph_money_signed(dst: *u8, off: i64, cents: i64) -> i64
called by 1: ph_render_trend calls 1: fd_apnum
112func ph_trend_word(dir: i64) -> *u8
called by 1: ph_render_trend
119func ph_render_trend(prefix: *u8, sid: *u8, items: *i64, n: i64, out: *u8) -> i64