View Source Stellar.Horizon.OrderBooks (Elixir Stellar SDK v0.8.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/

Link to this section Summary

Functions

Retrieve order books

Link to this section Types

@type args() :: Keyword.t()
@type resource() :: Stellar.Horizon.OrderBook.t()
@type response() :: {:ok, resource()} | {:error, Stellar.Horizon.Error.t()}

Link to this section Functions

@spec retrieve(args :: args()) :: response()

Retrieve order books

parameters

Parameters

  • 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

Options

  • limit: The maximum number of records returned

examples

Examples

# Retrieve order books iex> OrderBooks.retrieve(selling_asset: :native, buying_asset: :native) {:ok, %OrderBook{bids: [%Price{}...], asks: [%Price{}...], ...}

# Retrieve with more options iex> OrderBooks.retrieve(selling_asset: :native,

                       buying_asset: [
                          code: "BB1",
                          issuer: "GD5J6HLF5666X4AZLTFTXLY46J5SW7EXRKBLEYPJP33S33MXZGV6CWFN"
                        ],
                       limit: 2
                      )

...], asks: [%Price{}...], ...}