Trades
Last updated
// 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"
}
]
}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))import asyncio
import json
import websockets
async def main(uri):
async with websockets.connect(uri) as ws:
await ws.send(json.dumps({
"type": "authenticate",
"apiKey": "<API_KEY>"
}))
# After successful authentication message, subscribe to trades feed
await ws.send(json.dumps({
"type": "subscribe",
"feeds": ["private.user.trades"]
}))
async for msg in ws:
print(msg)
asyncio.run(main("wss://ws.sfox.com/ws"))