Execute Trades
How do I execute a trade?
Use the POST /api/trades endpoint
Now that we know how to generate a quote, we can proceed to execute a trade using the POST /api/trades endpoint. You’ll see there’s only one input to the request body JSON, and that’s the Quote ID. The trade process is simply executing the details from the Quote ID you provide.
In the JSON request body, enter the Quote ID from the previous step, ensuring that you generated the quote less than 30 seconds ago. If the quote is still valid, you’ll see something similar to this:
{
"guid": "your_trade_guid",
"customer_guid": "your_customer_guid",
"quote_guid": "your_quote_guid",
"symbol": "BTC-USD",
"side": "buy",
"state": "storing",
"receive_amount": 10000000,
"deliver_amount": 293063,
"fee": 0,
"created_at": "2022-05-11T19:56:42.856Z"
}
Note that the state is initially storing. To check if the trade completed successfully, expand the GET /api/trades/{trade_guid} endpoint, and enter the trade GUID from the executed trade. Assuming all is well, you should see something similar to this:
{
"guid": "your_trade_guid",
"customer_guid": "your_customer_guid",
"quote_guid": "your_quote_guid",
"symbol": "BTC-USD",
"side": "buy",
"state": "completed",
"receive_amount": 10000000,
"deliver_amount": 293063,
"fee": 0,
"created_at": "2022-05-11T19:56:42.856Z"
}
The trade state is now completed. There’s a few other states that the trade can be in, including:
- Storing - Trade details are being stored in the platform
- Initiating - Trade execution has begun
- Settling - Platform is waiting for the trade to complete
- Completed - Trade has successfully completed
- Failed - Platform was not able to successfully complete the trade
Updated 3 months ago