Liking cljdoc? Tell your friends :D

gridx.pricing

Higher-level functions for working with GridX pricing data.

Two layers:

  • Raw: camelCase keys, string values — direct from the API JSON.
  • Coerced: namespaced keywords, BigDecimals, OffsetDateTimes — Clojure-friendly.

The coerced layer preserves raw data as metadata via :gridx/raw.

Schemas are in separate namespaces for consumer use:

  • gridx.pricing.schema — coerced entity schemas (Component, Interval, Curve)
  • gridx.pricing.schema.raw — raw API response schemas
Higher-level functions for working with GridX pricing data.

Two layers:
- Raw: camelCase keys, string values — direct from the API JSON.
- Coerced: namespaced keywords, BigDecimals, OffsetDateTimes — Clojure-friendly.

The coerced layer preserves raw data as metadata via :gridx/raw.

Schemas are in separate namespaces for consumer use:
- `gridx.pricing.schema`     — coerced entity schemas (Component, Interval, Curve)
- `gridx.pricing.schema.raw` — raw API response schemas
raw docstring

->componentclj

(->component raw)

Coerce a raw price component map into a namespaced Component.

Transforms: "cld" → :gridx.component/cld "0.000351" → 0.000351M "generation" → :gridx.price-type/generation

Attaches the original raw map as :gridx/raw metadata.

Coerce a raw price component map into a namespaced Component.

Transforms:
  "cld"        → :gridx.component/cld
  "0.000351"   → 0.000351M
  "generation" → :gridx.price-type/generation

Attaches the original raw map as :gridx/raw metadata.
sourceraw docstring

->curveclj

(->curve raw)

Coerce a raw price curve map into a namespaced Curve.

The curve header's start/end times are preserved as OffsetDateTimes (market-local context) in :gridx.curve/start and :gridx.curve/end.

The entity map also carries :tick/beginning and :tick/end (UTC Instants) directly, making it a tick interval usable with Allen's interval algebra.

Note: the API reports end time as 23:59:59 (inclusive), while tick intervals are half-open [start, end). This means :tick/end is 1 second before the last interval's computed end. This is faithful to the API; we do not adjust it.

Attaches the original raw map as :gridx/raw metadata.

Coerce a raw price curve map into a namespaced Curve.

The curve header's start/end times are preserved as OffsetDateTimes
(market-local context) in :gridx.curve/start and :gridx.curve/end.

The entity map also carries :tick/beginning and :tick/end (UTC Instants)
directly, making it a tick interval usable with Allen's interval algebra.

Note: the API reports end time as 23:59:59 (inclusive), while tick
intervals are half-open [start, end). This means :tick/end is 1 second
before the last interval's computed end. This is faithful to the API;
we do not adjust it.

Attaches the original raw map as :gridx/raw metadata.
sourceraw docstring

->gridx-dateclj

(->gridx-date d)

Convert a tick date (or ISO string) to GridX YYYYMMDD format.

Examples: (->gridx-date (t/date "2026-03-08")) ;=> "20260308" (->gridx-date (t/today)) ;=> "20260308"

Convert a tick date (or ISO string) to GridX YYYYMMDD format.

Examples:
  (->gridx-date (t/date "2026-03-08")) ;=> "20260308"
  (->gridx-date (t/today))               ;=> "20260308"
sourceraw docstring

->intervalclj

(->interval duration raw)

Coerce a raw price detail map into a namespaced Interval.

duration is a java.time.Duration for the interval length (from the curve header's intervalLengthInMinutes). Used to compute the interval's end time from its start.

The entity map carries :tick/beginning and :tick/end directly, making it a tick interval usable with Allen's interval algebra (t/relation, t/contains?, etc.) without unwrapping.

Timestamps are converted to UTC Instants. Prices become BigDecimals. Status strings become namespaced keywords (e.g. :gridx.status/final). Attaches the original raw map as :gridx/raw metadata.

Coerce a raw price detail map into a namespaced Interval.

`duration` is a java.time.Duration for the interval length (from the
curve header's intervalLengthInMinutes). Used to compute the interval's
end time from its start.

The entity map carries :tick/beginning and :tick/end directly, making
it a tick interval usable with Allen's interval algebra (t/relation,
t/contains?, etc.) without unwrapping.

Timestamps are converted to UTC Instants. Prices become BigDecimals.
Status strings become namespaced keywords (e.g. :gridx.status/final).
Attaches the original raw map as :gridx/raw metadata.
sourceraw docstring

curvesclj

(curves response)

Extract and coerce price curves from a successful API response.

This is the main entry point for the coerced layer. Returns a vector of Curve maps with namespaced keywords, native types (BigDecimal, Instant, OffsetDateTime), and tick intervals. Each entity at every level carries :gridx/raw metadata with the original API data.

See raw-curves for the uncoerced version.

Extract and coerce price curves from a successful API response.

This is the main entry point for the coerced layer. Returns a vector
of Curve maps with namespaced keywords, native types (BigDecimal,
Instant, OffsetDateTime), and tick intervals. Each entity at every
level carries :gridx/raw metadata with the original API data.

See `raw-curves` for the uncoerced version.
sourceraw docstring

raw-curvesclj

(raw-curves response)

Extract the vector of raw price curves from a successful API response. Returns the data as-is from the JSON: camelCase keys, string values. See curves for the coerced version.

Extract the vector of raw price curves from a successful API response.
Returns the data as-is from the JSON: camelCase keys, string values.
See `curves` for the coerced version.
sourceraw docstring

success?clj

(success? response)

True if the API response indicates success (HTTP 200 and meta code 200). Use this to check before extracting curves.

True if the API response indicates success (HTTP 200 and meta code 200).
Use this to check before extracting curves.
sourceraw docstring

validate-rawclj

(validate-raw body)

Validate a parsed response body against the raw Malli schema. Returns nil on success, or a Malli explanation map on failure. Operates on the :body of the HTTP response, not the full response.

Validate a parsed response body against the raw Malli schema.
Returns nil on success, or a Malli explanation map on failure.
Operates on the :body of the HTTP response, not the full response.
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