lib/xtb_client/messages/profit_mode.ex
defmodule XtbClient.Messages.ProfitMode do
@moduledoc """
Atoms representing profit mode.
"""
@type t :: :forex | :cfd
@type proft_code :: 5 | 6
@doc """
Parse an integer value to valid atom of profit mode.
"""
@spec parse(proft_code()) :: t()
def parse(value) when is_number(value) and value in [5, 6] do
parse_profit_mode(value)
end
defp parse_profit_mode(value) do
case value do
5 -> :forex
6 -> :cfd
end
end
end