Algodex Documentation
  • Algodex Documentation
  • Algodex
    • Algodex FAQ
    • Trading Guide
    • Trading Bot Guide
    • Token Listing Guide
  • Algodex Mailbox
    • Mailbox FAQ
    • Mailbox User Guide
  • Rewards Program
    • ALGX Liquidity Rewards Program
    • Community Leadership
    • ALGX Tokenomics
  • Developer Tools
    • Algodex SDK v2
      • Tutorial : Placing Orders
      • Tutorial: Order book
      • Tutorial: Closing Orders
    • Algodex API v1
  • Archives
    • Algodex Whitepaper v1
    • ALGX Airdrop Plan
    • Testnet Liquidity Rewards
  • App Links
    • Algodex
    • Algodex Mailbox
    • Rewards
    • Support
  • social media links
    • REDDIT
    • TWITTER
    • DISCORD
    • TELEGRAM
    • GITHUB
Powered by GitBook
On this page
  • What is an Order book?
  • Condition
  • Walkthrough
  1. Developer Tools
  2. Algodex SDK v2

Tutorial: Order book

What is an Order book?

An orderbook is a collection of Buy and Sell orders that were originally placed using a Maker execution type.

Condition

If Algodex supports an asset then a unique orderbook exists for that asset.

Walkthrough

  1. A user is interested in the price of a particular asset so they fetch the Algodex orderbook related to that asset.

  2. The Algodex order book contains the most recent unfulfilled Buy and Sell order's related to that asset.

  3. An order remains in the order book until someone places an order using a Taker execution type.

Fetch Order book [JavaScript]

When using api.placeOrder() if an orderbook is not provided we fetch the orderbook based off the asset id specified in the order object. However, it is possible to fetch the orderbook ahead of time, as shown in the example below.

order = {
  'asset': {
    'id': 15322902,
    'decimals': 6,
  },
  'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
  'price': 3.22,
  'amount': 1,
  'execution': 'taker',
  'type': 'buy',
}


const res = await api.http.dexd.fetchAssetOrders(order.asset.id)
const orderbook = api.http.dexd.mapToAllEscrowOrders({
  buy: res.buyASAOrdersInEscrow,
  sell: res.sellASAOrdersInEscrow,
 })

await api.placeOrder(order, {orderbook})
PreviousTutorial : Placing OrdersNextTutorial: Closing Orders

Last updated 2 years ago