cryptocomparex v0.1.2 Cryptocomparex

Documentation for Cryptocomparex.

Link to this section Summary

Functions

Perform a DELETE request

Perform a DELETE request

Perform a GET request

Perform a GET request

Returns coin list

Returns exchanges

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

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

Get open, high, low, close, volumefrom and volumeto from the hourly historical data. It uses BTC conversion if data is not available because the coin is not trading in the specified currency

Get open, high, low, close, volumefrom and volumeto from the hourly historical data. It uses BTC conversion if data is not available because the coin is not trading in the specified currency

Perform a HEAD request

Perform a HEAD request

Perform a OPTIONS request

Perform a OPTIONS request

Perform a PATCH request

Perform a PATCH request

Perform a POST request

Perform a POST request

Perform a PUT request

Perform a PUT request

Perform request and raise in case of error

Perform a TRACE request

Perform a TRACE request

Link to this section Types

Link to this type option()
option() ::
  {:method, Tesla.Env.method()}
  | {:url, Tesla.Env.url()}
  | {:query, Tesla.Env.query()}
  | {:headers, Tesla.Env.headers()}
  | {:body, Tesla.Env.body()}
  | {:opts, Tesla.Env.opts()}

Link to this section Functions

Link to this function delete!(client, url, opts)

Perform a DELETE request.

See request!/1 or request!/2 for options definition.

delete!("/users")
delete!("/users", query: [scope: "admin"])
delete!(client, "/users")
delete!(client, "/users", query: [scope: "admin"])
Link to this function delete(client, url, opts)

Perform a DELETE request.

See request/1 or request/2 for options definition.

delete("/users")
delete("/users", query: [scope: "admin"])
delete(client, "/users")
delete(client, "/users", query: [scope: "admin"])
Link to this function get!(client, url, opts)

Perform a GET request.

See request!/1 or request!/2 for options definition.

get!("/users")
get!("/users", query: [scope: "admin"])
get!(client, "/users")
get!(client, "/users", query: [scope: "admin"])

Perform a GET request.

See request/1 or request/2 for options definition.

get("/users")
get("/users", query: [scope: "admin"])
get(client, "/users")
get(client, "/users", query: [scope: "admin"])
Link to this function get_coin_list()
get_coin_list() :: {:ok, Tesla.Env.t()} | {:error, any()}

Returns coin list

Examples

iex> {:ok, %{body: %{data: data}}} = Cryptocomparex.get_coin_list()
iex> is_map(data["BTC"])
true
Link to this function get_exchanges()
get_exchanges() :: {:ok, Tesla.Env.t()} | {:error, any()}

Returns exchanges

Examples

iex> {:ok, %{body: body}} = Cryptocomparex.get_exchanges()
iex> is_map(body["Bitfinex"])
true
Link to this function get_histo_daily_avg(params)
get_histo_daily_avg(map()) :: {:ok, Tesla.Env.t()} | {:error, any()}

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)

try_conversion If set to false, it will try to get only direct trading values fsym REQUIRED The cryptocurrency symbol of interest [Max character length: 10] tsym REQUIRED The currency symbol to convert into [Max character length: 10] e The exchange to obtain data from (our aggregated average - CCCAGG - by default) [Max character length: 30] avg_type Type of average to calculate (HourVWAP - a HourVWAP of hourly price, MidHighLow - the average between the 24 H high and low, VolFVolT - the total volume to / the total volume from) [Max character length: 30] UTC_hour_diff By deafult it does UTC, if you want a different time zone just pass the hour difference. For PST you would pass -8 for example. to_ts Last unix timestamp to return data for extra_params The name of your application (we recommend you send it) [Max character length: 50] sign If set to true, the server will sign the requests (be default we don’t sign them), this is useful for usage in smart contracts

Link to this function get_histo_daily_ohlcvs(params)
get_histo_daily_ohlcvs(%Cryptocomparex.HistoOhlcvsOpts{
  aggregate: term(),
  all_data: term(),
  e: term(),
  extra_params: term(),
  fsym: term(),
  limit: term(),
  sign: term(),
  to_ts: term(),
  tsym: term()
}) :: {:ok, Tesla.Env.t()} | {:error, any()}

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.

try_conversion If set to false, it will try to get only direct trading values fsym REQUIRED The cryptocurrency symbol of interest [Max character length: 10] tsym REQUIRED The currency symbol to convert into [Max character length: 10] e The exchange to obtain data from (our aggregated average - CCCAGG - by default) [Max character length: 30] aggregate Time period to aggregate the data over (for daily it’s days, for hourly it’s hours and for minute histo it’s minutes) limit The number of data points to return all_data Returns all data (only available on histo day) to_ts Last unix timestamp to return data for extraParams The name of your application (we recommend you send it) [Max character length: 50] sign if set to true, the server will sign the requests (be default we don’t sign them), this is useful for usage in smart contracts

## Examples

iex> alias Cryptocomparex.HistoOhlcvsOpts
iex> opts = %HistoOhlcvsOpts{fsym: "BTC", tsym: "USD"}
iex> {:ok, %{body: _body = %{data: data}}} = Cryptocomparex.get_histo_daily_ohlcvs(opts)
iex> is_list(data) and is_float(hd(data).high)
true
Link to this function get_histo_hourly_ohlcvs(params)
get_histo_hourly_ohlcvs(%Cryptocomparex.HistoOhlcvsOpts{
  aggregate: term(),
  all_data: term(),
  e: term(),
  extra_params: term(),
  fsym: term(),
  limit: term(),
  sign: term(),
  to_ts: term(),
  tsym: term()
}) :: {:ok, Tesla.Env.t()} | {:error, any()}

Get open, high, low, close, volumefrom and volumeto from the hourly historical data. It uses BTC conversion if data is not available because the coin is not trading in the specified currency.

try_conversion If set to false, it will try to get only direct trading values fsym REQUIRED The cryptocurrency symbol of interest [Max character length: 10] tsym REQUIRED The currency symbol to convert into [Max character length: 10] e The exchange to obtain data from (our aggregated average - CCCAGG - by default) [Max character length: 30] aggregate Time period to aggregate the data over (for daily it’s days, for hourly it’s hours and for minute histo it’s minutes) limit The number of data points to return to_ts Last unix timestamp to return data for extra_params The name of your application (we recommend you send it) [Max character length: 50] sign If set to true, the server will sign the requests (be default we don’t sign them), this is useful for usage in smart contracts

## Examples

iex> alias Cryptocomparex.HistoOhlcvsOpts iex> opts = %HistoOhlcvsOpts{fsym: “BTC”, tsym: “USD”} iex> {:ok, %{body: _body = %{data: data}}} = Cryptocomparex.get_histo_hourly_ohlcvs(opts) iex> is_list(data) and is_float(hd(data).high) true

Link to this function get_histo_minute_ohlcvs(params)
get_histo_minute_ohlcvs(%Cryptocomparex.HistoOhlcvsOpts{
  aggregate: term(),
  all_data: term(),
  e: term(),
  extra_params: term(),
  fsym: term(),
  limit: term(),
  sign: term(),
  to_ts: term(),
  tsym: term()
}) :: {:ok, Tesla.Env.t()} | {:error, any()}

Get open, high, low, close, volumefrom and volumeto from the hourly historical data. It uses BTC conversion if data is not available because the coin is not trading in the specified currency.

try_conversion If set to false, it will try to get only direct trading values fsym REQUIRED The cryptocurrency symbol of interest [Max character length: 10] tsym REQUIRED The currency symbol to convert into [Max character length: 10] e The exchange to obtain data from (our aggregated average - CCCAGG - by default) [Max character length: 30] aggregate Time period to aggregate the data over (for daily it’s days, for hourly it’s hours and for minute histo it’s minutes) limit The number of data points to return to_ts Last unix timestamp to return data for extra_params The name of your application (we recommend you send it) [Max character length: 50] sign If set to true, the server will sign the requests (be default we don’t sign them), this is useful for usage in smart contracts

## Examples

iex> alias Cryptocomparex.HistoOhlcvsOpts iex> opts = %HistoOhlcvsOpts{fsym: “BTC”, tsym: “USD”} iex> {:ok, %{body: _body = %{data: data}}} = Cryptocomparex.get_histo_minute_ohlcvs(opts) iex> is_list(data) and is_float(hd(data).high) true

Link to this function head!(client, url, opts)

Perform a HEAD request.

See request!/1 or request!/2 for options definition.

head!("/users")
head!("/users", query: [scope: "admin"])
head!(client, "/users")
head!(client, "/users", query: [scope: "admin"])

Perform a HEAD request.

See request/1 or request/2 for options definition.

head("/users")
head("/users", query: [scope: "admin"])
head(client, "/users")
head(client, "/users", query: [scope: "admin"])
Link to this function options!(client, url, opts)

Perform a OPTIONS request.

See request!/1 or request!/2 for options definition.

options!("/users")
options!("/users", query: [scope: "admin"])
options!(client, "/users")
options!(client, "/users", query: [scope: "admin"])
Link to this function options(client, url, opts)

Perform a OPTIONS request.

See request/1 or request/2 for options definition.

options("/users")
options("/users", query: [scope: "admin"])
options(client, "/users")
options(client, "/users", query: [scope: "admin"])
Link to this function patch!(client, url, body, opts)

Perform a PATCH request.

See request!/1 or request!/2 for options definition.

patch!("/users", %{name: "Jon"})
patch!("/users", %{name: "Jon"}, query: [scope: "admin"])
patch!(client, "/users", %{name: "Jon"})
patch!(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function patch(client, url, body, opts)

Perform a PATCH request.

See request/1 or request/2 for options definition.

patch("/users", %{name: "Jon"})
patch("/users", %{name: "Jon"}, query: [scope: "admin"])
patch(client, "/users", %{name: "Jon"})
patch(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function post!(client, url, body, opts)

Perform a POST request.

See request!/1 or request!/2 for options definition.

post!("/users", %{name: "Jon"})
post!("/users", %{name: "Jon"}, query: [scope: "admin"])
post!(client, "/users", %{name: "Jon"})
post!(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function post(client, url, body, opts)

Perform a POST request.

See request/1 or request/2 for options definition.

post("/users", %{name: "Jon"})
post("/users", %{name: "Jon"}, query: [scope: "admin"])
post(client, "/users", %{name: "Jon"})
post(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function put!(client, url, body, opts)

Perform a PUT request.

See request!/1 or request!/2 for options definition.

put!("/users", %{name: "Jon"})
put!("/users", %{name: "Jon"}, query: [scope: "admin"])
put!(client, "/users", %{name: "Jon"})
put!(client, "/users", %{name: "Jon"}, query: [scope: "admin"])

Perform a PUT request.

See request/1 or request/2 for options definition.

put("/users", %{name: "Jon"})
put("/users", %{name: "Jon"}, query: [scope: "admin"])
put(client, "/users", %{name: "Jon"})
put(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function request!(client \\ %Tesla.Client{}, options)
request!(Tesla.Env.client(), [option()]) :: Tesla.Env.t() | no_return()

Perform request and raise in case of error.

This is similar to request/2 behaviour from Tesla 0.x

See request/2 for list of available options.

Link to this function request(client \\ %Tesla.Client{}, options)

Perform a request

Options:

  • :method - the request method, one of [:head, :get, :delete, :trace, :options, :post, :put, :patch]
  • :url - either full url e.g. “http://example.com/some/path” or just “/some/path” if using Tesla.Middleware.BaseUrl
  • :query - a keyword list of query params, e.g. [page: 1, per_page: 100]
  • :headers - a keyworld list of headers, e.g. [{"content-type", "text/plain"}]
  • :body - depends on used middleware:

    • by default it can be a binary
    • if using e.g. JSON encoding middleware it can be a nested map
    • if adapter supports it it can be a Stream with any of the above
  • :opts - custom, per-request middleware or adapter options

Examples:

ExampleApi.request(method: :get, url: "/users/path")

You can also use shortcut methods like:

ExampleApi.get("/users/1")

or

ExampleApi.post(client, "/users", %{name: "Jon"})
Link to this function trace!(client, url, opts)

Perform a TRACE request.

See request!/1 or request!/2 for options definition.

trace!("/users")
trace!("/users", query: [scope: "admin"])
trace!(client, "/users")
trace!(client, "/users", query: [scope: "admin"])
Link to this function trace(client, url, opts)

Perform a TRACE request.

See request/1 or request/2 for options definition.

trace("/users")
trace("/users", query: [scope: "admin"])
trace(client, "/users")
trace(client, "/users", query: [scope: "admin"])