Skip to content

Commit

Permalink
Fix types (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsienkiewicz authored Feb 15, 2024
1 parent 5162832 commit a6c6b9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/xtb_client/messages/chart_range.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ defmodule XtbClient.Messages.ChartRange do

alias XtbClient.Messages.{DateRange, Period}

import Period

@type t :: %__MODULE__{
start: integer(),
end: integer(),
period: Period.t(),
period: Period.minute_period(),
symbol: String.t(),
ticks: integer()
}
Expand All @@ -48,7 +50,7 @@ defmodule XtbClient.Messages.ChartRange do
period: period,
symbol: symbol
})
when is_atom(period) and is_binary(symbol) do
when is_period(period) and is_binary(symbol) do
%__MODULE__{
start: start,
end: end_value,
Expand Down
3 changes: 3 additions & 0 deletions lib/xtb_client/messages/period.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ defmodule XtbClient.Messages.Period do
mn1: 43_200
]

defguard is_period(atom)
when is_atom(atom) and atom in [:m1, :m5, :m15, :m30, :h1, :h4, :d1, :w1, :mn1]

@doc """
Parses value given as number of minutes to `Period` atom type.
"""
Expand Down

0 comments on commit a6c6b9c

Please sign in to comment.