Tradehub.Exchange (Tradehub v0.1.13) View Source

This module allows developers to interact with the public endpoints mainly focusing on the exchange information.

Link to this section Summary

Types

Query params for /get_markets endpoint

Functions

Get insurance fund balances of the chain.

Request information about a market

Requests all markets or filtered markets

Requests oracle information about a given oracle id

Requests oracle informations of the Tradehub

Get the latest orderbook of given market

Request information about a token

Requests all known tokens on the Tradehub chain.

Link to this section Types

Specs

id_to_oracle() :: %{required(oracle_id()) => Tradehub.oracle()}

Specs

market_options() :: %{
  market_type: :future | :spot,
  is_active: boolean(),
  is_settled: boolean()
}

Query params for /get_markets endpoint

  • market_type - type of the market, futures or spot
  • is_active - if only active markets should be returned
  • is_settled - if only settled markets should be returned

Specs

oracle_id() :: String.t()

Link to this section Functions

Specs

insurance_balances() ::
  {:ok, [Tradehub.amount()]} | {:error, HTTPoison.Error.t()}

Get insurance fund balances of the chain.

Examples

iex> Tradehub.Exchange.insurance_balances

iex> Tradehub.Exchange.insurance_balances!

Specs

market(String.t()) :: {:ok, Tradehub.market()} | {:error, HTTPoison.Error.t()}

Request information about a market

Examples

iex> Tradehub.Exchange.market("swth_eth1")

iex> Tradehub.Exchange.market!("swth_eth1")
Link to this function

markets(market_options \\ %{})

View Source

Specs

markets(%{}) :: {:error, HTTPoison.Error.t()} | {:ok, [Tradehub.market()]}
markets(market_options()) ::
  {:error, HTTPoison.Error.t()} | {:ok, [Tradehub.market()]}

Requests all markets or filtered markets

Examples

iex> Tradehub.Exchange.markets

iex> Tradehub.Exchange.markets!
Link to this function

oracle_result(oracle_id)

View Source

Specs

oracle_result(oracle_id()) ::
  {:ok, Tradehub.oracle()} | {:error, HTTPoison.Error.t()}

Requests oracle information about a given oracle id

Examples

iex> Tradehub.Exchange.oracle_result("SIDXBTC")

iex> Tradehub.Exchange.oracle_result!("SIDXBTC")

Specs

oracle_results() :: {:ok, id_to_oracle()} | {:error, HTTPoison.Error.t()}

Requests oracle informations of the Tradehub

Examples

iex> Tradehub.Exchange.oracle_results

iex> Tradehub.Exchange.oracle_results!
Link to this function

orderbook(market, limit \\ 50)

View Source

Specs

orderbook(String.t(), integer()) ::
  {:ok, Tradehub.orderbook()} | {:error, HTTPoison.Error.t()}

Get the latest orderbook of given market

Parameters

  • market: a market ticker used by the chain, e.g swth_eth1
  • limit: number of results per side (asks, bids)

Examples

iex> Tradehub.Exchange.orderbook("swth_eth1")

iex> Tradehub.Exchange.orderbook!("swth_eth1")

Specs

token(String.t()) :: {:error, HTTPoison.Error.t()} | {:ok, Tradehub.token()}

Request information about a token

Examples

iex> Tradehub.Exchange.token("swth")

iex> Tradehub.Exchange.token!("swth")

Specs

tokens() :: {:error, HTTPoison.Error.t()} | {:ok, [Tradehub.token()]}

Requests all known tokens on the Tradehub chain.

Examples

iex> Tradehub.Exchange.tokens

iex> Tradehub.Exchange.tokens!