Tradehub.Exchange (Tradehub v0.1.7) View Source
This module allows developers to interact with the public endpoints mainly focusing on the exchange information.
Link to this section Summary
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
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
Specs
market(String.t()) :: {:ok, Tradehub.market()} | {:error, HTTPoison.Error.t()}
Request information about a market
Examples
iex> Tradehub.Exchange.market("swth_eth1")
Specs
markets(nil, nil, nil) :: {:error, HTTPoison.Error.t()} | {:ok, [Tradehub.market()]}
markets(String.t(), boolean(), boolean()) :: {:error, HTTPoison.Error.t()} | {:ok, [Tradehub.market()]}
Requests all markets or filtered markets
Parameters
- market_type - type of the market,
future
orspot
- is_active - if only active markets should be returned
- is_settled - if only settled markets should be returned
Examples
iex> Tradehub.Exchange.markets
iex> Tradehub.Exchange.markets("spot")
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")
Specs
oracle_results() :: {:ok, id_to_oracle()} | {:error, HTTPoison.Error.t()}
Requests oracle informations of the Tradehub
Examples
iex> Tradehub.Exchange.oracle_results
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")
Specs
token(String.t()) :: {:error, HTTPoison.Error.t()} | {:ok, Tradehub.token()}
Request information about a token
Examples
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