Tradehub.Trade (Tradehub v0.1.17) View Source

This module uses to fetch trade, orders information of the chain.

Link to this section Summary

Types

Query params for the /get_liquidations endpoint.

Query params for the /get_trades_by_account endpoint.

Query params for the /get_trades endpoint.

Functions

Requests an order details information by its order id

Requests orders of the given account

Get leverage of the given account in a specific market

Requests the position of the given account in a particular market

positions(account) deprecated

Requests avaiable positions of the given account in all markets which the account get involved

Get positions sorted by pnl of the given market.

Get positions sorted by risk of the given market.

Get positions sorted by size of the given market.

Requests recent trades of the market or filtered by the specific params

Requests recent trades by the given account

Link to this section Types

Specs

liquidation_options() :: %{
  before_id: String.t(),
  after_id: String.t(),
  order_by: String.t(),
  limit: String.t()
}

Query params for the /get_liquidations endpoint.

  • before_id: filter trades before id
  • after_id: filter trades after id
  • order_by: TODO
  • limit: limit the responsed results, max is 200
Link to this type

trade_account_options()

View Source

Specs

trade_account_options() :: %{
  before_id: String.t(),
  after_id: String.t(),
  order_by: String.t(),
  limit: String.t()
}

Query params for the /get_trades_by_account endpoint.

  • before_id: filter trades before id
  • after_id: filter trades after id
  • order_by: TODO
  • limit: limit the responsed results, max is 200

Specs

trade_options() :: %{
  market: String.t(),
  before_id: String.t(),
  after_id: String.t(),
  order_by: String.t(),
  limit: String.t()
}

Query params for the /get_trades endpoint.

  • market: market ticker used by the chain, e.g swth_eth1
  • before_id: filter trades before id
  • after_id: filter trades after id
  • order_by: TODO
  • limit: limit the responsed results, max is 200

Link to this section Functions

Specs

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

Requests an order details information by its order id

Examples

iex> Tradehub.Trade.get_order("A186AC5F560BBD4B2C1F9B21C6EF1814F3295EBD863FA3655F74942CDB198530")

Specs

get_orders(String.t()) ::
  {:ok, [Tradehub.order()]} | {:error, HTTPoison.Error.t()}

Requests orders of the given account

Examples

iex> Tradehub.Trade.get_orders("swth1fdqkq5gc5x8h6a0j9hamc30stlvea6zldprt6q")
Link to this function

leverage(account, market)

View Source

Specs

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

Get leverage of the given account in a specific market

Examples

iex> Tradehub.Trade.leverage("swth1fdqkq5gc5x8h6a0j9hamc30stlvea6zldprt6q", "eth_h21")
Link to this function

liquidations(before_id \\ nil, after_id \\ nil, order_by \\ nil, limit \\ nil)

View Source

Requests recent liquidations

Examples

iex> Tradehub.Trade.liquidations
Link to this function

position(account, market)

View Source

Specs

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

Requests the position of the given account in a particular market

Examples

iex> Tradehub.Trade.position("swth1fdqkq5gc5x8h6a0j9hamc30stlvea6zldprt6q", "swth_eth1")
This function is deprecated. The API does not well documetation, and I do not have much info about this endpoint.

Specs

positions(String.t()) ::
  {:ok, [Tradehub.position()]} | {:error, HTTPoison.Error.t()}

Requests avaiable positions of the given account in all markets which the account get involved

Examples

iex> Tradehub.Trade.positions("swth1fdqkq5gc5x8h6a0j9hamc30stlvea6zldprt6q")
Link to this function

positions_sorted_pnl(market)

View Source
This function is deprecated. The API is not well documentation.

Specs

positions_sorted_pnl(String.t()) :: {:error, HTTPoison.Error.t()} | {:ok, any()}

Get positions sorted by pnl of the given market.

Examples

iex> Tradehub.Trade.positions_sorted_pnl("swth_eth1")
Link to this function

positions_sorted_risk(market, direction)

View Source
This function is deprecated. The API is not well documentation.

Specs

positions_sorted_risk(String.t(), String.t()) ::
  {:error, HTTPoison.Error.t()} | {:ok, any()}

Get positions sorted by risk of the given market.

Examples

iex> Tradehub.Trade.positions_sorted_risk("swth_eth1", "unknown")
Link to this function

positions_sorted_size(market)

View Source
This function is deprecated. The API is not well documentation.

Specs

positions_sorted_size(String.t()) ::
  {:error, HTTPoison.Error.t()} | {:ok, any()}

Get positions sorted by size of the given market.

Examples

iex> Tradehub.Trade.positions_sorted_size("swth_eth1")
Link to this function

trades(trade_options \\ %{})

View Source

Specs

trades(%{}) :: {:ok, [Tradehub.trade()]} | {:error, HTTPoison.Error.t()}
trades(trade_options()) ::
  {:ok, [Tradehub.trade()]} | {:error, HTTPoison.Error.t()}

Requests recent trades of the market or filtered by the specific params

Examples

iex> Tradehub.Trade.trades
Link to this function

trades_by_account(account, trade_account_options \\ %{})

View Source

Specs

trades_by_account(String.t(), %{}) ::
  {:ok, [Tradehub.account_trade()]} | {:error, HTTPoison.Error.t()}
trades_by_account(String.t(), trade_account_options()) ::
  {:ok, [Tradehub.account_trade()]} | {:error, HTTPoison.Error.t()}

Requests recent trades by the given account

Examples

iex> Tradehub.Trade.trades_by_account("swth1fdqkq5gc5x8h6a0j9hamc30stlvea6zldprt6q")