View Source Stellar.Horizon.Trades (Elixir Stellar SDK v0.10.0)
Exposes functions to interact with Trades in Horizon.
You can:
- List all trades.
Horizon API reference: https://developers.stellar.org/api/resources/trades/
Link to this section Summary
Functions
Lists all trades.
Link to this section Types
@type options() :: Keyword.t()
@type resource() :: Stellar.Horizon.Trade.t() | Stellar.Horizon.Collection.t()
@type response() :: {:ok, resource()} | {:error, Stellar.Horizon.Error.t()}
Link to this section Functions
Lists all trades.
options
Options
offer_id
: The offer ID. Used to filter for trades originating from a specific offer.base_asset_type
: The type for the base asset. Eithernative
,credit_alphanum4
, orcredit_alphanum12
.base_asset_issuer
: The account ID of the base asset’s issuer.base_asset_code
: The code for the base asset.counter_asset_type
: The type for the counter asset. Eithernative
,credit_alphanum4
, orcredit_alphanum12
.counter_asset_issuer
: The account ID of the counter asset’s issuer.counter_asset_code
: The code for the counter asset.trade_type
: Can be set toall
,orderbook
, orliquidity_pools
to filter only trades executed across a given mechanism.cursor
: A number that points to a specific location in a collection of responses and is pulled from thepaging_token
value of a record.order
: A designation of the order in which records should appear. Options includeasc
(ascending) ordesc
(descending).limit
: The maximum number of records returned. The limit can range from 1 to 200. Defaults to 10.
examples
Examples
iex> Trades.all(limit: 20, order: :asc)
{:ok, %Collection{records: [%Trade{}, ...]}}
# list by offer_id
iex> Trades.all(offer_id: 165563085)
{:ok, %Collection{records: [%Trade{}, ...]}}
# list by base_asset_type and base_asset_code
iex> Trades.all(base_asset_type: "credit_alphanum4", base_asset_code: "TEST")
{:ok, %Collection{records: [%Trade{}, ...]}}
# list by counter_asset_issuer
iex> Trades.all(counter_asset_issuer: "GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", limit: 20)
{:ok, %Collection{records: [%Trade{}, ...]}}
# list by trade_type
iex> Trades.all(trade_type: "liquidity_pools", limit: 20)
{:ok, %Collection{records: [%Trade{}, ...]}}