View Source Stellar.Horizon.OrderBooks (Elixir Stellar SDK v0.22.0)
Exposes functions to interact with OrderBooks in Horizon.
You can:
- Retrieve an order book’s bids and asks
Horizon API reference: https://developers.stellar.org/api/aggregations/order-books/object/
Summary
Functions
Retrieve order books
Types
@type args() :: Keyword.t()
@type resource() :: Stellar.Horizon.OrderBook.t()
@type response() :: {:ok, resource()} | {:error, Stellar.Horizon.Error.t()}
@type server() :: Stellar.Horizon.Server.t()
Functions
Retrieve order books
Parameters
server
: The Horizon server to query.selling_asset
::native
or[code: "selling_asset_code", issuer: "selling_asset_issuer"]
buying_asset
::native
or[code: "buying_asset_code", issuer: "buying_asset_issuer"]
Options
limit
: The maximum number of records returned
Examples
# Retrieve order books
iex> OrderBooks.retrieve(Stellar.Horizon.Server.testnet(), selling_asset: :native, buying_asset: :native)
{:ok, %OrderBook{bids: [%Price{}...], asks: [%Price{}...], ...}
# Retrieve with more options
iex> OrderBooks.retrieve(
Stellar.Horizon.Server.testnet(),
selling_asset: :native,
buying_asset: [
code: "BB1",
issuer: "GD5J6HLF5666X4AZLTFTXLY46J5SW7EXRKBLEYPJP33S33MXZGV6CWFN"
],
limit: 2
)
)
{:ok, %OrderBook{bids: [%Price{}...], asks: [%Price{}...], ...}