# `Beancount.Directives.Price`
[🔗](https://github.com/thanos/beancount_ex/blob/v0.6.0/lib/beancount/directives/price.ex#L1)

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

See [Prices](https://beancount.github.io/docs/beancount_language_syntax/#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.

# `t`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
