PTAX.Quotation (ptax v1.1.0)
Define a quotation structure for a currency
Link to this section Summary
Functions
Returns the quotation of a currency for the date
Returns a quotation list of a currency for a period
Link to this section Types
@type t() :: %PTAX.Quotation{ bulletin: bulletin(), pair: PTAX.Money.Pair.t(), quoted_in: DateTime.t() }
Link to this section Functions
Link to this function
get(currency, date, bulletin \\ Bulletin.Closing)
@spec get(currency(), date(), bulletin() | nil) :: {:ok, t()} | {:error, PTAX.Error.t()}
Returns the quotation of a currency for the date
examples
Examples
iex> PTAX.Quotation.get(:USD, ~D[2021-12-24])
{
:ok,
%PTAX.Quotation{
pair: PTAX.Money.Pair.new("1.0", "1.0", :USD, :USD),
quoted_in: DateTime.from_naive!(~N[2021-12-24 11:04:02.178], "America/Sao_Paulo"),
bulletin: PTAX.Quotation.Bulletin.Closing
}
}
Link to this function
list(currency, period, bulletin \\ nil)
@spec list( currency(), period(), bulletin() | [bulletin()] | nil ) :: {:ok, [t()]} | {:error, PTAX.Error.t()}
Returns a quotation list of a currency for a period
examples
Examples
iex> PTAX.Quotation.list(:GBP, Date.range(~D[2021-12-24], ~D[2021-12-24]))
{
:ok,
[
%PTAX.Quotation{
pair: PTAX.Money.Pair.new("1.3417", "1.3421", :GBP, :USD),
quoted_in: DateTime.from_naive!(~N[2021-12-24 10:08:31.922], "America/Sao_Paulo"),
bulletin: PTAX.Quotation.Bulletin.Opening
},
%PTAX.Quotation{
pair: PTAX.Money.Pair.new("1.3402", "1.3406", :GBP, :USD),
quoted_in: DateTime.from_naive!(~N[2021-12-24 11:04:02.173], "America/Sao_Paulo"),
bulletin: PTAX.Quotation.Bulletin.Intermediary
},
%PTAX.Quotation{
pair: PTAX.Money.Pair.new("1.3402", "1.3406", :GBP, :USD),
quoted_in: DateTime.from_naive!(~N[2021-12-24 11:04:02.178], "America/Sao_Paulo"),
bulletin: PTAX.Quotation.Bulletin.Closing
}
]
}