Liking cljdoc? Tell your friends :D

commensura.cpi

Historical U.S. purchasing power (CPI). A period dollar is a unit worth (CPI_current / CPI_period) · dollar, so it composes with the core verbs and, because two of them share the dollar basis, to between them converts across years — inflation-adjustment:

(require '[commensura.cpi :as cpi] '[commensura.core :as c] '[commensura.units :as u]) (c/to (u/dollar 1250) (cpi/usd 1913)) ; 1913 dollars → current dollars (c/to (c/by 50 (cpi/cent 1955 11)) (cpi/usd 1985 10)) ;=> 2.020446096654275 (exact)

Data (BLS CPI-U series CPIAUCNS, via FRED) ships as resources/commensura/cpi.edn — exact rationals; :current is the latest shipped period. dev/commensura/cpi/{fetch,frink}.clj regenerate it (FRED API) / a Frink-parity oracle fixture. Live refresh is M4.2.

Historical U.S. purchasing power (CPI). A *period dollar* is a unit worth
`(CPI_current / CPI_period) · dollar`, so it composes with the core verbs and, because two of
them share the `dollar` basis, `to` between them converts across years — inflation-adjustment:

  (require '[commensura.cpi :as cpi]
           '[commensura.core :as c]
           '[commensura.units :as u])
  (c/to (u/dollar 1250) (cpi/usd 1913))                 ; 1913 dollars → current dollars
  (c/to (c/by 50 (cpi/cent 1955 11)) (cpi/usd 1985 10)) ;=> 2.020446096654275 (exact)

Data (BLS CPI-U series CPIAUCNS, via FRED) ships as `resources/commensura/cpi.edn` — exact
rationals; `:current` is the latest shipped period. `dev/commensura/cpi/{fetch,frink}.clj`
regenerate it (FRED API) / a Frink-parity oracle fixture. Live refresh is M4.2.
raw docstring

*cpi-source*clj

The active CPI data source — a 0-arg fn returning the cpi data map. Defaults to the shipped snapshot; use-live! / with-live swap in live FRED data.

The active CPI data source — a 0-arg fn returning the cpi data map. Defaults to the shipped
snapshot; `use-live!` / `with-live` swap in live FRED data.
sourceraw docstring

centclj

(cent year)
(cent year month)

A historical U.S. cent (= 1/100 · usd).

A historical U.S. cent (= 1/100 · `usd`).
sourceraw docstring

historical-name?clj

(historical-name? s)

True if s is a historical-currency unit name — dollar_1960 / dollars_1960 / USD_1960 / cent_1910 / cents_1965_10 (case-insensitive). The #commensura/unit reader uses this to reify these commensura-provided units on demand.

True if `s` is a historical-currency unit name — `dollar_1960` / `dollars_1960` / `USD_1960` /
`cent_1910` / `cents_1965_10` (case-insensitive). The `#commensura/unit` reader uses this to
reify these commensura-provided units on demand.
sourceraw docstring

shipped-sourceclj

(shipped-source)

The default CPI source: the data shipped in resources/commensura/cpi.edn.

The default CPI source: the data shipped in `resources/commensura/cpi.edn`.
sourceraw docstring

unitclj

(unit s)

Reify a historical-currency name (see historical-name?) into the corresponding unit.

Reify a historical-currency name (see `historical-name?`) into the corresponding unit.
sourceraw docstring

usdclj

(usd year)
(usd year month)

A historical U.S. dollar as a callable unit: (usd 1960) (annual average) or (usd 1969 8) (a specific month, 1913+). Equals (CPI_current / CPI_period) · dollar.

A historical U.S. dollar as a callable unit: `(usd 1960)` (annual average) or
`(usd 1969 8)` (a specific month, 1913+). Equals `(CPI_current / CPI_period) · dollar`.
sourceraw docstring

use-live!clj

(use-live!)
(use-live! api-key)

Globally switch to a cached live FRED source (their key; defaults to the FRED_API_KEY env var). A fetch failure falls back to the shipped snapshot. Historical months never change — only the latest available month (and thus :current) advances beyond what shipped.

Globally switch to a cached live FRED source (their key; defaults to the `FRED_API_KEY` env var).
A fetch failure falls back to the shipped snapshot. Historical months never change — only the
latest available month (and thus `:current`) advances beyond what shipped.
sourceraw docstring

use-shipped!clj

(use-shipped!)

Revert to the shipped cpi.edn source (undo use-live!).

Revert to the shipped `cpi.edn` source (undo `use-live!`).
sourceraw docstring

with-livecljmacro

(with-live api-key & body)

Evaluate body with a live FRED source bound for the current thread.

Evaluate `body` with a live FRED source bound for the current thread.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close