ℹ Placing an Order [WIP]
🧰 You can think of AlgodexApi#placeOrder as a toolbox: it's got everything you need to tackle order execution
🪜 Steps
- ⚗ Create a
new
instance of the AlgodexApi
- 🔧 Set a default Wallet using AlgodexApi#setWallet
- 🏗 Generate an Order compatible object
- 💸 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 Orderbook in different ways. Algodex supports the
following executions:
📥 Maker Order
A Maker Order will always be placed into the Orderbook. They can be either Buy or Sell order types.
Buy 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 Order
// 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 Orderbook. They can be either Buy or Sell order types.
Buy Order
// 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
// 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 Orderbook for existing orders that match
the current order.
Buy Order
const res = await api.placeOrder({
'asset': {
'id': 15322902,
'decimals': 6,
},
'address': 'WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI',
'price': 3.22,
'amount': 1,
'execution': 'both',
'type': 'buy',
});
Sell Order
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 people 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 Buy & Sell modules to get a better sense of what methods fit your use case