Liking cljdoc? Tell your friends :D

edgar.reclass

Reclassification rule engine (roadmap 4.1c).

Approximates commercial-database item definitions (currently Compustat) by reclassifying standardized line items: stripping D&A out of COGS, folding R&D into SG&A, adding special-item charges back to operating income, netting excise taxes from revenue, etc.

Rules are data, loaded from EDN under resources/edgar/reclass/ and applied per [unit start end] period group on top of the :standardized row set. Reclassified rows are ADDED alongside the original items (never replacing them) and carry provenance: :method :reclassified :rule the rule :id that produced the row :derived-from labels of the operand line items actually used

Rule format: {:id :cogs-ex-da ; unique keyword :target "COGS (Compustat)" ; emitted line-item label :formula [:- "Cost of Revenue" "D&A"] :guards [[:lt "D&A" "Cost of Revenue"]] :compustat "COGS" ; documentation only :notes "..."} ; documentation only

Formula operators: [:= a] - copy operand a [:+ a b ...] - sum [:- a b ...] - first minus the rest [:neg-sum a ..] - negated sum of the operands present with a non-zero value (nil when none are) Operands are line-item labels; wrap as [:opt label] to treat a missing operand as 0 instead of blocking the rule. Targets of earlier rules can be operands of later ones (applied iteratively, capped at 4 passes).

Guards (all must pass; operands referenced by label): [:lt a b] - value of a strictly less than value of b [:gt a b] - value of a strictly greater than value of b [:concept-not-in a #{c ...}] - a's winning XBRL concept is not in the set (rows without a concept, e.g. derived rows, pass)

Rules are tried in order; for a given :target the first rule whose operands and guards are satisfied wins (the target is skipped once present).

Reclassification rule engine (roadmap 4.1c).

Approximates commercial-database item definitions (currently Compustat)
by reclassifying standardized line items: stripping D&A out of COGS,
folding R&D into SG&A, adding special-item charges back to operating
income, netting excise taxes from revenue, etc.

Rules are data, loaded from EDN under resources/edgar/reclass/ and applied
per [unit start end] period group on top of the :standardized row set.
Reclassified rows are ADDED alongside the original items (never replacing
them) and carry provenance:
  :method       :reclassified
  :rule         the rule :id that produced the row
  :derived-from labels of the operand line items actually used

Rule format:
  {:id      :cogs-ex-da           ; unique keyword
   :target  "COGS (Compustat)"  ; emitted line-item label
   :formula [:- "Cost of Revenue" "D&A"]
   :guards  [[:lt "D&A" "Cost of Revenue"]]
   :compustat "COGS"            ; documentation only
   :notes   "..."}              ; documentation only

Formula operators:
  [:= a]          - copy operand a
  [:+ a b ...]    - sum
  [:- a b ...]    - first minus the rest
  [:neg-sum a ..] - negated sum of the operands present with a non-zero
                    value (nil when none are)
Operands are line-item labels; wrap as [:opt label] to treat a missing
operand as 0 instead of blocking the rule. Targets of earlier rules can be
operands of later ones (applied iteratively, capped at 4 passes).

Guards (all must pass; operands referenced by label):
  [:lt a b]                    - value of a strictly less than value of b
  [:gt a b]                    - value of a strictly greater than value of b
  [:concept-not-in a #{c ...}] - a's winning XBRL concept is not in the set
                                 (rows without a concept, e.g. derived rows,
                                 pass)

Rules are tried in order; for a given :target the first rule whose operands
and guards are satisfied wins (the target is skipped once present).
raw docstring

apply-rulesetclj

(apply-ruleset rows aux-rows ruleset)

Apply a reclassification ruleset to statement rows.

rows - standardized statement rows (seq of maps with :line-item :val :unit :start :end ...) aux-rows - rows from other statements made available as operands per period (e.g. the cash-flow statement's "D&A" for income reclass); they are matched into period groups by [unit start end] and are not included in the output ruleset - EDN ruleset map with a :rules vector (see namespace docstring)

Returns rows plus the reclassified rows. When ruleset is nil or has no rules, returns rows unchanged.

Apply a reclassification ruleset to statement rows.

rows     - standardized statement rows (seq of maps with :line-item :val
           :unit :start :end ...)
aux-rows - rows from other statements made available as operands per period
           (e.g. the cash-flow statement's "D&A" for income reclass);
           they are matched into period groups by [unit start end] and are
           not included in the output
ruleset  - EDN ruleset map with a :rules vector (see namespace docstring)

Returns rows plus the reclassified rows. When ruleset is nil or has no
rules, returns rows unchanged.
sourceraw docstring

compustat-income-rulesetclj

Compustat reclassification ruleset for the income statement. Source: resources/edgar/reclass/compustat-income.edn

Compustat reclassification ruleset for the income statement.
Source: resources/edgar/reclass/compustat-income.edn
sourceraw docstring

ruleset-forclj

(ruleset-for statement)

Return the active reclassification ruleset for a statement, for inspection. statement: :income | :balance | :cash-flow Returns the full EDN ruleset map, or nil when the statement has no rules.

Return the active reclassification ruleset for a statement, for inspection.
statement: :income | :balance | :cash-flow
Returns the full EDN ruleset map, or nil when the statement has no rules.
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