Tutorial : Placing Orders
You can think of AlgodexApi#placeOrder as a toolbox: it's got everything you need to tackle order execution.
- 1.
- 2.
- 3.
- 4.
If you are unsure of which execution type to choose input
execution:'both'
and we'll handle the rest!A Maker Order will always be placed into the Order book. They can be either Buy or Sell order types.
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.
When a user places an order, if no one immediately agrees to the terms of the order, the order is considered a Maker Order.
- 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.
- 3.The order is now visible to other users of Algodex and will be fulfilled when another user agrees to "take" the order.
//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 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',
});
A Taker Order will always execute existing orders in the Order book. They can be either Buy or Sell order types.
A Taker Order is an order that executes instantly. A taker order closes or modifies an existing order in the Algodex Order book.
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.
The user submitted order changes the state of the Order book in 1 of 3 ways:
- 1.The user does not "take" the entire order. The remainder of the order remains open.
- 2.The user takes the entire order removing it from the order book.
- 3.The user takes multiple orders, removing them from the order book.
// Buy Example
const res = await api.placeOrder({
'asset': {
'id': 15322902,
'decimals': 6,
},
'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
'price': 3.22,
'amount': 1,
'execution': 'taker',
'type': 'buy',
});
// Sell Example
const res = await api.placeOrder({
'asset': {
'id': 15322902,
'decimals': 6,
},
'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
'price': 80000,
'amount': 1,
'execution': 'taker',
'type': 'sell',
});
const res = await api.placeOrder({
'asset': {
'id': 15322902,
'decimals': 6,
},
'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
'price': 3.22,
'amount': 1,
'execution': 'both',
'type': 'buy',
});
const res = await api.placeOrder({
'asset': {
'id': 15322902,
'decimals': 6,
},
'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
'price': 80000,
'amount': 1,
'execution': 'both',
'type': 'sell',
});
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.
Last modified 8mo ago