Beancount.Directives.Price (beancount_ex v0.6.0)

Copy Markdown View Source

The price directive records the price of a commodity in another currency.

See Prices.

Beancount syntax

2026-01-01 price USD 1.20 CAD

General form: YYYY-MM-DD price Commodity Amount Currency

Reads as: one unit of commodity equals amount units of currency.

Elixir struct

%Beancount.Directives.Price{
  date: ~D[2026-01-01],
  commodity: "USD",
  amount: Decimal.new("1.20"),
  currency: "CAD",
  metadata: %{}
}

Or use Beancount.price/5:

Beancount.price(~D[2026-01-01], "USD", Decimal.new("1.20"), "CAD")

Fields

  • date - Date.t() the price is effective (end of day in Beancount).
  • commodity - priced commodity symbol, e.g. "USD" or "HOOL".
  • amount - Decimal.t() price value (unsigned).
  • currency - quote currency the amount is expressed in.
  • metadata - optional map rendered below the directive.

Summary

Types

t()

@type t() :: %Beancount.Directives.Price{
  amount: Decimal.t(),
  commodity: String.t(),
  currency: String.t(),
  date: Date.t(),
  metadata: map()
}