Trades
Receive real-time updates regarding completed trades in your account–fills on orders you've placed. Complete trade history can also be retrieved from the REST API. See Get All Trades for details.
Subscribing
Feed name
private.user.trades
// Request -> trades feed
{
"type": "subscribe",
"feeds": ["private.user.trades"]
}
Trades Message
Trade Object
trade_id
The ID of the trade
order_id
The ID of the order that this trade is associated with
date_updated
The date and time the trade was completed
action
Buy or Sell
currency_pair
The currency pair this trade was executed on
quantity
The base currency quantity bought or sold in this trade
amount
The gross quote currency amount cost or proceeds from this trade
price
The fill price of this trade
fees
The fees charged on this trade (always in the quote currency)
net_amount
The net quote currency amount cost or proceeds from this trade (amount
net fees)
Trades Message
// Trades feed message
{
"sequence": 3,
"recipient": "private.user.trades",
"timestamp": 1708630086193678496,
"payload": [
{
"trade_id": 830151520,
"order_id": 759514460,
"date_updated": "2024-02-22T19:28:06.000Z",
"action": "Sell",
"currency_pair": "compusd",
"quantity": "1.65911629",
"amount": "99.47066469",
"price": "59.954004",
"fees": "0.04973533",
"net_amount": "99.42092936"
}
]
}
Example Code
const WebSocket = require('ws')
const ws = new WebSocket('wss://ws.sfox.com/ws')
ws.on('open', function() {
const authMessage = {
type: 'authenticate',
apiKey: '<API_KEY>'
}
ws.send(JSON.stringify(authMessage))
})
// After successful authentication, subscribe to trades feed
const subscribeMsg = {
type: 'subscribe',
feeds: ['private.user.trades']
}
ws.send(JSON.stringify(subscribeMsg))
Last updated