I've released Cryptocomparex 0.1, an open source Elixir/Erlang client for cryptocompare API. Cryptocomparex provides access to historical daily, hourly and minute OHLCVs for multiple exchanges and aggregates. Also allows to query CryptoCompare API for coin list, exchanges list and other data.
If available in Hex, the package can be installed
by adding cryptocomparex to your list of dependencies in mix.exs:
def deps do
[
{:cryptocomparex, "~> 0.1.0"}
]
end
The docs can be found at https://hexdocs.pm/cryptocomparex.
iex> {:ok, %{body: body}} = Cryptocomparex.get_exchanges()
iex> is_map(body["Bitfinex"])
true
iex> {:ok, %{body: %{data: data}}} = Cryptocomparex.get_coin_list()
iex> is_map(data["BTC"])
true
Get open, high, low, close, volumefrom and volumeto from the daily historical data.The values are based on 00:00 GMT time.It uses BTC conversion if data is not available because the coin is not trading in the specified currency.
iex> alias Cryptocomparex.HistoOhlcvsOpts
iex> opts = %HistoOhlcvsOpts{fsym: "BTC", tsym: "USD"}
iex> {:ok, %{body: body = %{data: data}}} = Cryptocomparex.get_histo_daily_ohlcvs(opts)
iex> {:ok, %{body: _body = %{data: _data}}} = Cryptocomparex.get_histo_hourly_ohlcvs(opts)
iex> {:ok, %{body: _body = %{data: _data}}} = Cryptocomparex.get_histo_minute_ohlcvs(opts)
iex> is_list(data) and is_float(hd(data).high)
true
Get day average price. The values are based on hourly vwap data and the average can be calculated in different ways. It uses BTC conversion if data is not available because the coin is not trading in the specified currency. If tryConversion is set to false it will give you the direct data. If no toTS is given it will automatically do the current day. Also for different timezones use the UTCHourDiff param
The calculation types are:
HourVWAP - a VWAP of the hourly close price
MidHighLow - the average between the 24 H high and low.
VolFVolT - the total volume from / the total volume to (only avilable with tryConversion set to false so only for direct trades but the value should be the most accurate average day price)
iex> {:ok, ndt} = NaiveDateTime.new(2018, 1, 1, 0, 0, 0)
iex> to_ts = ndt |> DateTime.from_naive!("Etc/UTC") |> DateTime.to_unix()
iex> opts = %{fsym: "BTC", tsym: "USD", to_ts: to_ts}
iex> {:ok, %{body: body}} = Cryptocomparex.get_histo_daily_avg(opts)
iex> is_map(body) and is_float(hd(data).high)
(*`□)<炎炎炎炎