A currency converter backed by the Brazilian Central Bank (BCB) PTAX closing rates.

Rates are the mid-point between BCB's closing bid and ask quotes for each currency pair.

Installation

def deps do
  [
    {:ptax, "~> 2.0"}
  ]
end

Configuration

PTAX integrates with ex_money's exchange rate system. Add it to your config:

# config/config.exs
config :ex_money, api_module: PTAX.ExchangeRates

Usage

Convert using the latest known rates

iex> PTAX.exchange(Money.new!(:USD, "100"), :BRL)
{:ok, %Money{}}

The lookup automatically walks back up to 7 days to find the most recent available data.

Convert using rates for a specific date

iex> PTAX.exchange(Money.new!(:GBP, "50"), :BRL, ~D[2026-05-15])
{:ok, Money.new!(:BRL, "337.63")}

Dates with no BCB data (weekends, holidays) return {:error, {Money.ExchangeRateError, "404"}}.

See also

PTAX only provides the rate source. Once configured (see Configuration), you can use ex_money directly for richer operations: