code wiki / _hdl_build / nx_price_hist.nx
nx_price_hist.nx
buildroot/runtime/_hdl_build/nx_price_hist.nx
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
imports: nx_price.nxnx_food_science.nxnx_seg_store.nxnx_syscalls.nx
imported by: nx_price_hist_gate.nx
structs
| none |
consts
| none |
functions
| 12 | func ph_put(prefix: *u8, key: *u8, val: *u8) -> i64 |
| 21 | func ph_sign(v: i64) -> i64 { if v > 0 { return 1 } if v < 0 { return 0 - 1 } return 0 } |
| 23 | func 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 } |
| 24 | func 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 } |
| 26 | func ph_count(prefix: *u8, sid: *u8, item: *u8) -> i64 called by 7: ph_recordph_earliestph_latestph_trendph_minph_max+1 calls 4: sys_mmapph_histn_keyss_getfd_atoi |
| 34 | func ph_set_latest(prefix: *u8, sid: *u8, item: *u8, price: i64, day: i64, source: *u8) -> i64 |
| 44 | func ph_record(prefix: *u8, sid: *u8, item: *u8, price: i64, day: i64, source: *u8) -> i64 |
| 58 | func ph_at(prefix: *u8, sid: *u8, item: *u8, seq: i64) -> i64 |
| 67 | func 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) } |
| 68 | func 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) } |
| 70 | func ph_trend(prefix: *u8, sid: *u8, item: *u8) -> i64 |
| 75 | func ph_trend_dir(prefix: *u8, sid: *u8, item: *u8) -> i64 { return ph_sign(ph_trend(prefix, sid, item)) } |
| 76 | func ph_min(prefix: *u8, sid: *u8, item: *u8) -> i64 |
| 84 | func ph_max(prefix: *u8, sid: *u8, item: *u8) -> i64 |
| 93 | func ph_basket_trend(prefix: *u8, sid: *u8, items: *i64, n: i64) -> i64 |
| 100 | func ph_money_signed(dst: *u8, off: i64, cents: i64) -> i64 |
| 112 | func ph_trend_word(dir: i64) -> *u8 called by 1: ph_render_trend |
| 119 | func ph_render_trend(prefix: *u8, sid: *u8, items: *i64, n: i64, out: *u8) -> i64 called by 1: main calls 14: sys_mmappr_store_fieldas_appendas_append_escapedph_trend_dirim_money_local+8 |