timeprice 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +55 -0
  3. data/DATA_LICENSES.md +2 -1
  4. data/README.md +20 -4
  5. data/data/cpi/eu.json +422 -397
  6. data/data/cpi/jp.json +91 -72
  7. data/data/cpi/uk.json +529 -504
  8. data/data/cpi/us.json +507 -476
  9. data/data/cpi/vn.json +368 -37
  10. data/data/fx/usd/1999.json +281 -524
  11. data/data/fx/usd/2000.json +277 -516
  12. data/data/fx/usd/2001.json +276 -511
  13. data/data/fx/usd/2002.json +277 -513
  14. data/data/fx/usd/2003.json +277 -513
  15. data/data/fx/usd/2004.json +281 -521
  16. data/data/fx/usd/2005.json +279 -520
  17. data/data/fx/usd/2006.json +277 -513
  18. data/data/fx/usd/2007.json +277 -513
  19. data/data/fx/usd/2008.json +278 -515
  20. data/data/fx/usd/2009.json +278 -515
  21. data/data/fx/usd/2010.json +280 -522
  22. data/data/fx/usd/2011.json +279 -520
  23. data/data/fx/usd/2012.json +278 -515
  24. data/data/fx/usd/2013.json +277 -513
  25. data/data/fx/usd/2014.json +277 -513
  26. data/data/fx/usd/2015.json +278 -515
  27. data/data/fx/usd/2016.json +279 -520
  28. data/data/fx/usd/2017.json +277 -513
  29. data/data/fx/usd/2018.json +277 -513
  30. data/data/fx/usd/2019.json +277 -513
  31. data/data/fx/usd/2020.json +279 -517
  32. data/data/fx/usd/2021.json +280 -522
  33. data/data/fx/usd/2022.json +279 -520
  34. data/data/fx/usd/2023.json +277 -513
  35. data/data/fx/usd/2024.json +278 -515
  36. data/data/fx/usd/2025.json +22 -3
  37. data/data/fx/usd/2026.json +22 -3
  38. data/data/fx/usd/_annual.json +145 -0
  39. data/data/manifest.json +90 -0
  40. data/lib/timeprice/cli/presenters/compare.rb +3 -1
  41. data/lib/timeprice/cli/presenters/inflation.rb +2 -1
  42. data/lib/timeprice/compare.rb +3 -2
  43. data/lib/timeprice/cpi_lookup.rb +9 -7
  44. data/lib/timeprice/data_loader.rb +42 -7
  45. data/lib/timeprice/errors.rb +4 -4
  46. data/lib/timeprice/exchange.rb +34 -17
  47. data/lib/timeprice/granularity.rb +46 -0
  48. data/lib/timeprice/inflation.rb +6 -19
  49. data/lib/timeprice/sources/coverage.rb +27 -32
  50. data/lib/timeprice/sources.rb +5 -5
  51. data/lib/timeprice/supported.rb +39 -22
  52. data/lib/timeprice/version.rb +1 -1
  53. data/lib/timeprice.rb +2 -2
  54. metadata +4 -15
  55. data/data/fx/usd/1983.json +0 -12
  56. data/data/fx/usd/1986.json +0 -12
  57. data/data/fx/usd/1987.json +0 -12
  58. data/data/fx/usd/1988.json +0 -12
  59. data/data/fx/usd/1989.json +0 -12
  60. data/data/fx/usd/1990.json +0 -12
  61. data/data/fx/usd/1991.json +0 -12
  62. data/data/fx/usd/1992.json +0 -12
  63. data/data/fx/usd/1993.json +0 -12
  64. data/data/fx/usd/1994.json +0 -12
  65. data/data/fx/usd/1995.json +0 -12
  66. data/data/fx/usd/1996.json +0 -12
  67. data/data/fx/usd/1997.json +0 -12
  68. data/data/fx/usd/1998.json +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b400f9dc1652d4476d884f59a2721e4f07338e76c5cc7afab50896267e1123c
4
- data.tar.gz: 1a894e2464aa1f1495ddaa24c284b819a8afc07309cd3080f7c8c70744959ef2
3
+ metadata.gz: 6f5a76db32571e7ab2f09f9e22e1d90d420b5bdcf474baff6b523f2c8998c72b
4
+ data.tar.gz: 96e212aaa5aac2cfe4defc28364498ef49241de34161cb3e301f4886a19650d0
5
5
  SHA512:
6
- metadata.gz: 1f2c0b9ae5a4f8de71bdfdfb28f911b676773d406f86149b0c12ad5fbeb002ad51e42d43ed9f21d41c6ddd1a5b2760c2df58796759f66e7b78ac0dc784cee971
7
- data.tar.gz: 8dc9e2ff73ddf7d0126538794bb4612a8709881628b713a1e878fe8fba7eddd510597f5a4f0a07e8c9d3b63cc751880df9150db208616f7fc52306ae2474bd10
6
+ metadata.gz: 4148766e8c3dee2243ed933868d23cb2d79959db1581d07de654e1bab87325de98eacb2cd41200e1f765f3d94dde03472dc5d02a37e2e2f059fc8a651ac40666
7
+ data.tar.gz: a51e3132f616bc0e468b0f9afdff9ab71a2017abd25eed5ffd45cecc4c385d58f4670ffeeb5cc8bc5f4143f639a42d92f88a2d6e4f81957171d6c3207982d5ee
data/CHANGELOG.md CHANGED
@@ -5,6 +5,61 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.5.0] - 2026-05-11
9
+
10
+ ### Changed
11
+ - **Schema v2 → v3.** Breaking change to the bundled data contract. v0.4.x
12
+ data files will not load on v0.5.0.
13
+ - New top-level `data/manifest.json` — single source of truth for which
14
+ countries and currencies the bundle supports. `Supported.countries` /
15
+ `Supported.currencies` derive from it at runtime; the hardcoded Ruby
16
+ constants `Supported::COUNTRIES` / `CURRENCIES` are gone. Custom callers
17
+ that referenced those constants must switch to the method form.
18
+ - CPI files use nested `series: { monthly, annual }` and a structured
19
+ `index: { base_period, rebased_at }` block in place of the freeform
20
+ `base_year` string. Top-level `source` and `updated_at` removed —
21
+ `providers[]` is the source of truth for provenance.
22
+ - FX year files now carry `provenance` + `providers` blocks, symmetric
23
+ with CPI.
24
+ - All annual FX (today only VND from World Bank) lives in
25
+ `data/fx/usd/_annual.json` — the single canonical source, every year.
26
+ Per-year files (`data/fx/usd/<year>.json`) hold daily rates only. Pre-1999
27
+ stub year files are gone. `Exchange.lookup_usd_base` collapses to a
28
+ two-tier chain (daily → annual fallback), one source per tier.
29
+
30
+ ## [0.4.0] - 2026-05-11
31
+
32
+ ### Changed
33
+ - **Schema v1 → v2.** Two structural data-layer changes, bundled under a
34
+ single bump:
35
+ - FX year files gain an optional top-level `annual` block. World Bank's
36
+ annual VND/USD average is stored there exactly once per year instead of
37
+ being broadcast across every daily date key. `Exchange.lookup_usd_base`
38
+ falls back from daily to annual when no daily entry exists within ±7
39
+ days and tags the result with `Granularity::ANNUAL`. `Compare` merges
40
+ FX granularity with CPI granularity (worst-precision wins).
41
+ - CPI provenance moves from a per-period map (`{"2025-01": "bls", ...}`)
42
+ to a compact range list (`[{series, from, to, provider}, ...]`). Single
43
+ -provider files (US/UK/EU/JP) collapse to 1–2 ranges; VN keeps the
44
+ WB→IMF transition explicit. ~42 kb saved across the 5 CPI files; one
45
+ real US data gap at 2025-10 is now visible instead of buried.
46
+ - `country_file.rb` rebase label now preserves the original base reference
47
+ alongside the rebase date (e.g. `"2010=100 (rebased 2026-05-11)"`).
48
+
49
+ ### Added
50
+ - Multi-source CPI chain for Vietnam: IMF Data Portal CPI dataflow
51
+ (`api.imf.org`, SDMX 2.1) is the monthly primary; World Bank `FP.CPI.TOTL`
52
+ remains as the annual fallback. The on-disk `data/cpi/vn.json` gains two
53
+ additive fields — `provenance` (per-period source id) and `providers`
54
+ (per-source status array) — so consumers can see which upstream supplied
55
+ each datapoint. Schema version is unchanged; old readers ignore the new
56
+ fields. Other country files (US, UK, EU, JP) gain the same fields on the
57
+ next refresh.
58
+ - Internal: `Sources::Provider` / `Sources::CountryFile` / `Sources::MergePolicy`
59
+ seam for layering multiple providers into a single country file with
60
+ per-period provenance. Designed so future fresher sources (e.g. JP via
61
+ e-Stat) can be added as one more entry without further plumbing.
62
+
8
63
  ## [0.3.0] - 2026-05-11
9
64
 
10
65
  ### Added
data/DATA_LICENSES.md CHANGED
@@ -12,7 +12,8 @@ string.
12
12
  | UK Office for National Statistics | `D7BT` (UK CPI all-items) | Open Government Licence v3.0 | https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/ | Contains public sector information licensed under the Open Government Licence v3.0 |
13
13
  | Eurostat | `prc_hicp_midx` (Euro area HICP) | Eurostat reuse policy — free reuse with source attribution | https://ec.europa.eu/eurostat/about-us/policies/copyright | Source: Eurostat |
14
14
  | World Bank | `FP.CPI.TOTL` (JP CPI fallback) | Creative Commons Attribution 4.0 International (CC BY 4.0) | https://datacatalog.worldbank.org/public-licenses#cc-by | Source: World Bank, FP.CPI.TOTL |
15
- | World Bank | `FP.CPI.TOTL` (VN CPI) | Creative Commons Attribution 4.0 International (CC BY 4.0) | https://datacatalog.worldbank.org/public-licenses#cc-by | Source: World Bank, FP.CPI.TOTL |
15
+ | World Bank | `FP.CPI.TOTL` (VN CPI, annual fallback) | Creative Commons Attribution 4.0 International (CC BY 4.0) | https://datacatalog.worldbank.org/public-licenses#cc-by | Source: World Bank, FP.CPI.TOTL |
16
+ | International Monetary Fund | CPI dataflow `VNM.CPI._T.IX.M` via IMF Data Portal (VN CPI, monthly primary) | Free reuse with attribution per IMF terms | https://www.imf.org/external/terms.htm | Source: IMF Data Portal CPI dataflow |
16
17
  | European Central Bank (via Frankfurter) | Daily reference rates, USD base, EUR/GBP/JPY | ECB reference rates — free reuse; Frankfurter is a non-commercial republisher with no separate license | https://www.ecb.europa.eu/services/disclaimer/html/index.en.html | FX data: European Central Bank reference rates via Frankfurter |
17
18
  | World Bank | `PA.NUS.FCRF` (VND annual average FX, broadcast daily) | Creative Commons Attribution 4.0 International (CC BY 4.0) | https://datacatalog.worldbank.org/public-licenses#cc-by | VND FX: World Bank, PA.NUS.FCRF |
18
19
 
data/README.md CHANGED
@@ -98,11 +98,12 @@ Coverage is derived from the bundled `data/` files. Re-check with `timeprice sou
98
98
  | United Kingdom | GBP | ONS CPI all-items (`D7BT`) | Monthly + annual | 1988-01 → present |
99
99
  | Eurozone (EA) | EUR | Eurostat HICP (`prc_hicp_midx`) | Monthly + annual | 1996-01 → present |
100
100
  | Japan | JPY | World Bank `FP.CPI.TOTL` (fallback) | Annual | 1960 → 2024 |
101
- | Vietnam | VND | World Bank `FP.CPI.TOTL` | Annual | 1995 → 2024 |
101
+ | Vietnam | VND | IMF Data Portal CPI dataflow (monthly primary) + World Bank `FP.CPI.TOTL` (annual fallback) | Monthly + annual | 1995 → present |
102
102
 
103
103
  **FX (USD base):** ECB reference rates via Frankfurter for **EUR / GBP / JPY**, daily
104
- 1999 → present. **VND** uses the World Bank annual average (`PA.NUS.FCRF`) broadcast to
105
- every day in the year, from 1983 → present.
104
+ 1999 → present. **VND** uses the World Bank annual average (`PA.NUS.FCRF`), one value
105
+ per year, from 1983 → present. VND results are tagged `granularity: :annual` so callers
106
+ know they got the annual fallback rather than a daily rate.
106
107
 
107
108
  Triangulated cross-rates (e.g. GBP → JPY) go through USD on the same effective date.
108
109
  Weekend/holiday dates fall back up to 7 days to the nearest prior trading day.
@@ -258,13 +259,28 @@ license — see `DATA_LICENSES.md` and `NOTICE` for the full table and license U
258
259
  - **UK CPI:** Contains public sector information licensed under the Open Government Licence v3.0.
259
260
  - **Eurozone HICP:** Source: Eurostat (reuse permitted with attribution).
260
261
  - **Japan CPI (fallback):** Source: World Bank, FP.CPI.TOTL (CC BY 4.0).
261
- - **Vietnam CPI:** Source: World Bank, FP.CPI.TOTL (CC BY 4.0).
262
+ - **Vietnam CPI:** Sources: IMF Data Portal CPI dataflow (monthly primary); World Bank, FP.CPI.TOTL (annual fallback, CC BY 4.0).
262
263
  - **FX rates:** European Central Bank reference rates via Frankfurter.
263
264
  - **VND FX (annual broadcast):** World Bank, PA.NUS.FCRF (CC BY 4.0).
264
265
 
265
266
  If you redistribute results derived from this gem, reproduce the relevant attribution
266
267
  strings. `timeprice sources` prints them in plain text and as JSON.
267
268
 
269
+ ## Data format
270
+
271
+ Bundled data lives under `data/` in schema v3 and is self-describing:
272
+
273
+ - `data/manifest.json` — the supported set (countries, currencies, FX years).
274
+ - `data/cpi/<country>.json` — CPI for one country: `series.{monthly,annual}`,
275
+ structured `index` block, `provenance` ranges, `providers` attribution.
276
+ - `data/fx/usd/<year>.json` — daily USD-base FX rates for one year (one file
277
+ per year, EUR/GBP/JPY).
278
+ - `data/fx/usd/_annual.json` — annual USD-base FX rates across all years for
279
+ currencies sourced at annual resolution (today only VND). Used as the
280
+ fallback tier when no daily rate covers the requested date.
281
+
282
+ `scripts/check_schema_stability.rb` enforces the shape in CI.
283
+
268
284
  ## Author
269
285
 
270
286
  Built by [Patrick](https://github.com/patrick204nqh).