Opening a new Trade (2/4)

Opening a new Trade with Virtual Accounts

Steps

Step_1: Open a trade (BUY)

Example request:

  • The response is the ID of this open trade. You can open a trade (SELL) using the same endpoint.
curl --location --request POST 'https://api.tatum.io/v3/trade' \
--header 'x-api-key: {YOUR_API_KEY}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "type": "BUY",
    "price": "40",
    "amount": "1",
    "pair": "BTC/ETH",
    "currency1AccountId": "5f914e372e47312bc56d8d3d",
    "currency2AccountId": "5f914e0a2e47312bc56d8d3b"
}'
//Response:
{
  "id": "5e68c66581f2ee32bc354087"
}

Step_2: List the blockages

Request example:

  • You will see that there is a blockage of 40 ETH.
  • Additional information is present in the blockage, such as the trade ID as a description.
curl --location --request GET 'https://api.tatum.io/v3/ledger/account/block/5f914e0a2e47312bc56d8d3b?pageSize=10' \
--header 'x-api-key: {YOUR_API_KEY}' \
--header 'Content-Type: application/json' \
//Response:
[
    {
        "amount": "40",
        "type": "TRADE",
        "description": "5ff0d13a5f4813e187a2a498",
        "accountId": "5e68c66581f2ee32bc354087",
        "id": "5ff0d13a5f4813e187a2a499"
    }
]

πŸ“˜

No transaction has been performed yet, only the blockage.

Good to Know

  • Every trade must be filled and closed at some point.
  • It is possible to fill only the part of the trade.
  • It is your responsibility to ensure on-chain asset liquidity.