Tutorial : Placing Orders
You can think of AlgodexApi#placeOrder as a toolbox: it's got everything you need to tackle order execution.

Steps

  1. 1.
    Create a new instance of the AlgodexApi.
  2. 2.
    Set a default Wallet using AlgodexApi#setWallet.
  3. 3.
    Generate an Order compatible object.
  4. 4.
    Pass in the Order object to AlgodexApi#placeOrder.

Order Executions

If you are unsure of which execution type to choose input execution:'both' and we'll handle the rest!

Details:

The Order object has an execution key that determines how the SDK will handle the Order. Each execution will interact with the Order book in different ways. Algodex supports the following executions: Maker, Taker, Both.

Maker Order

A Maker Order will always be placed into the Order book. They can be either Buy or Sell order types.

What is a Maker Order?

A Maker Order is an order that does not execute instantly. A maker order has no active takers, therefore it "makes" its own order to be fulfilled at a later date.

Condition

When a user places an order, if no one immediately agrees to the terms of the order, the order is considered a Maker Order.

Walkthrough

  1. 1.
    There are no existing orders in the Algodex Order book that fulfill the user's criteria so they decide to "make" their own order.
  2. 2.
    The users submitted order is added to the Algodex Order book.
  3. 3.
    The order is now visible to other users of Algodex and will be fulfilled when another user agrees to "take" the order.

Buy Order [JavaScript]

//Buy Example:
const res = await api.placeOrder({
'asset': {
'id': 15322902,
'decimals': 6,
},
'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
'price': 3.22, // Limit price for the asset
'amount': 1, // Amount willing to purchase (The total amount sent will be price * amount)
'execution': 'maker',
'type': 'buy',
});

Sell Order [JavaScript]

// Sell Example:
const res = await api.placeOrder({
'asset': {
'id': 15322902,
'decimals': 6,
},
'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
'price': 80000, // Limit price for the asset to sell
'amount': 1, // Amount of the asset for sale
'execution': 'maker',
'type': 'sell',
});

Taker Order

A Taker Order will always execute existing orders in the Order book. They can be either Buy or Sell order types.

What is a Taker Order?

A Taker Order is an order that executes instantly. A taker order closes or modifies an existing order in the Algodex Order book.

Condition

There must be at least one existing order in the order book that fulfills the user's criteria. Therefore, the user "takes" from an existing order.

Walkthrough

The user submitted order changes the state of the Order book in 1 of 3 ways:
  1. 1.
    The user does not "take" the entire order. The remainder of the order remains open.
  2. 2.
    The user takes the entire order removing it from the order book.
  3. 3.
    The user takes multiple orders, removing them from the order book.

Buy Order [JavaScript]

// Buy Example
const res = await api.placeOrder({
'asset': {
'id': 15322902,
'decimals': 6,
},
'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
'price': 3.22,
'amount': 1,
'execution': 'taker',
'type': 'buy',
});

Sell Order [JavaScript]

// Sell Example
const res = await api.placeOrder({
'asset': {
'id': 15322902,
'decimals': 6,
},
'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
'price': 80000,
'amount': 1,
'execution': 'taker',
'type': 'sell',
});

Maker/Taker Order

Maker/Taker will first check the Order book for existing orders that match the current order.

Buy Order [JavaScript]

const res = await api.placeOrder({
'asset': {
'id': 15322902,
'decimals': 6,
},
'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
'price': 3.22,
'amount': 1,
'execution': 'both',
'type': 'buy',
});

Sell Order [JavaScript]

const res = await api.placeOrder({
'asset': {
'id': 15322902,
'decimals': 6,
},
'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
'price': 80000,
'amount': 1,
'execution': 'both',
'type': 'sell',
});

Advanced

There are multiple ways to place an order using our SDK.

If you are curious about the internal processes of placing an order and how they relate to the different execution types, the Structure Module is a great place to start.
Some users find it clunky to lug around a toolbox if they only need one or two tools.
If that sounds like you, we recommend checking out the Buy & Sell modules to get a better sense of what methods fit your use case.
Copy link
On this page
Steps
Order Executions
Maker Order
What is a Maker Order?
Condition
Walkthrough
Taker Order
What is a Taker Order?
Condition
Walkthrough
Maker/Taker Order
Advanced