DeltaDeFi
  • About
    • 👋Introduction
    • 📖Learn
      • Architecture
        • Account
        • App Vault
        • Hydra
        • Intent and Process
        • Order Book
      • Trade
        • Order Types
      • Whitepaper
  • Start Trading
    • ⚡Getting Started
      • Create Account
      • Deposit
      • Place Order
      • Cancel Order
      • Withdrawal
      • API Key / Dashboard
    • ⚙️Developers
      • Introduction
        • Base Url
        • Auth
        • Assets
      • Getting started
        • Deposit funds
        • Place a new order
        • Cancel an order
        • Withdraw funds
      • API Documentation
        • Account
          • Create new api key
          • Build deposit transaction
          • Submit deposit transaction
          • Deposit records
          • Withdrawal records
          • Order records
          • Build withdrawal transaction
          • Submit withdrawal transaction
          • Balances
        • App
          • Get mock USDX (testnet only)
          • Submit USDX transaction (testnet only)
        • Market
          • Market Price
          • Market Depth
          • Aggregated trades
        • Order
          • Build order transaction
          • Submit order Transaction
          • Build cancel Order Transaction
          • Submit cancel order transaction
      • Websocket Endpoints
        • Account streams
        • Market price streams
        • Market depth streams
      • SDK
        • Typescript
        • Python
  • FAQ
    • General
    • Product
    • Cardano
    • Disclaimer
Powered by GitBook
On this page
  • Get Order Records
  • Related FAQ
  1. Start Trading
  2. Developers
  3. Getting started

Place a new order

PreviousDeposit fundsNextCancel an order

Last updated 1 month ago

Pre-requisite: You account must have free balances in order to place a new order.

1

Build a limit order transaction

In the following example, we will be creating a limit order.

To place a new order, you must provide the following:

  • price

  • quantity

  • side

  • symbol

  • type

For an in-depth API reference Build order transaction

curl --location 'https://api-staging.deltadefi.io/order/build' \
--header 'x-api-key: <your_api_key>' \
--header 'Content-Type: application/json' \
--data '{
	"symbol": "ADAUSDX",
    "side": "buy",
    "type": "limit",
    "quantity": 100,
    "price": 0.93    
}'

const axios = require('axios');
let data = JSON.stringify({
  "symbol": "ADAUSDX",
  "side": "buy",
  "type": "limit",
  "quantity": 100,
  "price": 0.93
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api-staging.deltadefi.io/order/build',
  headers: { 
    'x-api-key': '<your_api_key>', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "https://api-staging.deltadefi.io/order/build"
  method := "POST"

  payload := strings.NewReader(`{
	"symbol": "ADAUSDX",
    "side": "buy",
    "type": "limit",
    "quantity": 100,
    "price": 0.93
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("x-api-key", "<your_api_key>")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

2

Submit a limit order transaction

After the order transaction is built, you will then need to before submitting it.

To submit:

curl --location 'https://api-staging.deltadefi.io/order/submit' \
--header 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDI1Mzk5NDAsInN1YiI6ImFkZHJfdGVzdDFxcXpnZzVwY2FleWVhNjl1cHRsOWRhNWc3ZmFqbTRtMHl2eG5keDlmNGx4cGtlaHFnZXp5MHMwNHJ0ZHdsYzB0bHZ4YWZwZHJmeG5zZzd3dzY4Z2UzajdsMGxuc3pzdzJ3dCJ9.OAchsj0tv06NxD9Br0aj0Zw5XzpG8kUFKBuVPtz5AKA' \
--header 'X-API-KEY: <your_api_key>' \
--header 'Content-Type: application/json' \
--data '{
    "order_id": "<order_id>",
    "signed_tx":"<signed_tx>"
}'

const axios = require('axios');
let data = JSON.stringify({
  "order_id": "<order_id>",
  "signed_tx": "<signed_tx>"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api-staging.deltadefi.io/order/submit',
  headers: { 
    'Authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDI1Mzk5NDAsInN1YiI6ImFkZHJfdGVzdDFxcXpnZzVwY2FleWVhNjl1cHRsOWRhNWc3ZmFqbTRtMHl2eG5keDlmNGx4cGtlaHFnZXp5MHMwNHJ0ZHdsYzB0bHZ4YWZwZHJmeG5zZzd3dzY4Z2UzajdsMGxuc3pzdzJ3dCJ9.OAchsj0tv06NxD9Br0aj0Zw5XzpG8kUFKBuVPtz5AKA', 
    'X-API-KEY': '<your_api_key>', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "https://api-staging.deltadefi.io/order/submit"
  method := "POST"

  payload := strings.NewReader(`{
    "order_id": "<order_id>",
    "signed_tx":"<signed_tx>"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDI1Mzk5NDAsInN1YiI6ImFkZHJfdGVzdDFxcXpnZzVwY2FleWVhNjl1cHRsOWRhNWc3ZmFqbTRtMHl2eG5keDlmNGx4cGtlaHFnZXp5MHMwNHJ0ZHdsYzB0bHZ4YWZwZHJmeG5zZzd3dzY4Z2UzajdsMGxuc3pzdzJ3dCJ9.OAchsj0tv06NxD9Br0aj0Zw5XzpG8kUFKBuVPtz5AKA")
  req.Header.Add("X-API-KEY", "<your_api_key>")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

3

Build a market order transaction

In this example we will be creating a market order.

For an in-depth API reference Build order transaction

To place a market order, provide the following:

  • price

  • quantity

  • side

  • symbol

  • type

  • limit_slippage / max_slippage_basis_point (either one)

limit_slippage (bool): If set to false, the market order will allow unlimited slippage until the entire order quantity is filled, where the account's purchasing power allows

max_slippage_basis_points (int): Maximum Slippage is the maximum acceptable deviation between the expected price (market price) and the actual executed price in a market order transaction

curl --location 'https://api-staging.deltadefi.io/order/build' \
--header 'x-api-key: <your_api_key>' \
--header 'Content-Type: application/json' \
--data '{
    "symbol": "ADAUSDX",
    "side": "buy",
    "type": "market",
    "quantity": 100,
    "limit_slippage": true
}'
const axios = require('axios');
let data = JSON.stringify({
  "symbol": "ADAUSDX",
  "side": "buy",
  "type": "market",
  "quantity": 100,
  "limit_slippage": false
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api-staging.deltadefi.io/order/build',
  headers: { 
    'x-api-key': '<your_api_key>', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "https://api-staging.deltadefi.io/order/build"
  method := "POST"

  payload := strings.NewReader(`{
    "symbol": "ADAUSDX",
    "side": "buy",
    "type": "market",
    "quantity": 100,
    "limit_slippage":false
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("x-api-key", "<your_api_key>")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

After the transaction is built, follow step 2 above to submit the transaction.


Get Order Records

After an order is created, you can find your order records with the Order records API

For open orders:

  • Pass the query param open

For closed orders:

  • pass the query param closed

curl --location 'https://api-staging.deltadefi.io/accounts/order-records?status=open' \
--header 'x-api-key: <your_api_key>'

const axios = require('axios');

let config = {
  method: 'get',
  maxBodyLength: Infinity,
  url: 'https://api-staging.deltadefi.io/accounts/order-records?status=open',
  headers: { 
    'x-api-key': '<your_api_key>'
  }
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {

  url := "https://api-staging.deltadefi.io/accounts/order-records?status=open"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("x-api-key", "<your_api_key>")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}


Related FAQ

⚙️
✨
📖
What order types are available?
Placing orders through website
What are locked and free balances?
sign it
How can I sign a Cardano transaction?