ForexFactory (ForexFactory v0.1.5)
Elixir library for https://www.forexfactory.com
API.
Summary
Functions
Return data series for a given event
or error if something goes wrong.
Return a specific event for given type
and currency
or error if not found.
Return a specific event for given type
and currency
or raise error if not found.
Return all events for a given type
.
Types
Link to this type
currency()
@type currency() :: :AUD | :CAD | :CHF | :CNY | :EUR | :GBP | :JPY | :NZD | :USD
Link to this type
event()
@type event() :: ForexFactory.Event.t()
Link to this type
opts()
@type opts() :: keyword()
Link to this type
type()
@type type() :: ForexFactory.Events.Type.t()
Functions
Link to this function
currencies()
@spec currencies() :: [currency()]
Link to this function
data(event, opts \\ [])
Return data series for a given event
or error if something goes wrong.
iex> ForexFactory.Events.Inflation.CPI |> ForexFactory.event!(:USD) |> ForexFactory.data(limit: 1)
{:ok,
%{
"data" => %{
"events" => [
%{
"actual" => 3.2,
"actual_formatted" => "3.2%",
"date" => "Mar 12, 2024",
"dateline" => 1710246600,
"forecast" => 3.1,
"forecast_formatted" => "3.1%",
"id" => 136044,
"is_active" => false,
"is_most_recent" => true,
"revision" => nil,
"revision_formatted" => nil
}
],
"future_timestamps" => [1712005200],
"past_timestamps" => [1707831000]
},
"meta" => %{
"decimals" => 1,
"ebase_event_id" => 884,
"interval_name" => "MN1",
"is_more" => true,
"zero_line" => 0
}
}}
iex> nil |> ForexFactory.data(limit: 1)
{:error, "nil event"}
Link to this function
event(type, currency)
Return a specific event for given type
and currency
or error if not found.
iex> ForexFactory.Events.Inflation.CoreCPI |> ForexFactory.event(:USD)
{:ok,
%ForexFactory.Event{
id: "136038",
type: ForexFactory.Events.Inflation.CoreCPI,
currency: :USD,
frequency: :MoM
}}
iex> ForexFactory.Events.Inflation.CoreCPI |> ForexFactory.event(:NZD)
{:error,
"missing 'NZD' event of type Elixir.ForexFactory.Events.Inflation.CoreCPI"}
Link to this function
event!(type, currency)
Return a specific event for given type
and currency
or raise error if not found.
iex> ForexFactory.Events.Inflation.CoreCPI |> ForexFactory.event!(:USD)
%ForexFactory.Event{
id: "136038",
type: ForexFactory.Events.Inflation.CoreCPI,
currency: :USD,
frequency: :MoM
}
iex> ForexFactory.Events.Inflation.CoreCPI |> ForexFactory.event!(:NZD)
** (ArgumentError) missing 'NZD' event of type Elixir.ForexFactory.Events.Inflation.CoreCPI
Link to this function
events(type)
Return all events for a given type
.
iex> ForexFactory.Events.Inflation.CoreCPI |> ForexFactory.events()
[
%ForexFactory.Event{
id: "136038",
type: ForexFactory.Events.Inflation.CoreCPI,
currency: :USD,
frequency: :MoM
},
%ForexFactory.Event{
id: "139672",
type: ForexFactory.Events.Inflation.CoreCPI,
currency: :JPY,
frequency: :YoY
},
%ForexFactory.Event{
id: "138961",
type: ForexFactory.Events.Inflation.CoreCPI,
currency: :EUR,
frequency: :YoY
}
]