watchTickers
Receba atualizações de preço em tempo real para todos os pares de trading disponíveis.
Subscrição
{
"action": "subscribe",
"channel": "watchTickers",
"data": {
"onlyPriority": true
}
}
Parâmetros
| Parâmetro | Tipo | Default | Descrição |
|---|---|---|---|
onlyPriority | boolean | true | true: retorna um ticker por par (usando regra SOR). false: retorna tickers de todas as exchanges |
Payload de Dados
{
"channel": "watchTickers",
"message": {
"coinbaseprime": [
{
"symbol": "BTC/BRL",
"timestamp": "1748271792909",
"high": 625036.68,
"low": 604342.25,
"bid": 615169.39,
"ask": 627779.20,
"bidVolume": 0.06122,
"askVolume": 1.14199,
"open": 618046.33,
"close": 621512.49,
"last": 621512.49,
"baseVolume": 4445.0876,
"quoteVolume": 2762677452.45,
"currentFeeTierRate": 0.0025,
"priceWithoutCustomerSpread": 627779.20,
"rule": "exchange 'coinbaseprime' selected as priority by general rule"
}
]
}
}
Os dados são organizados por exchange, cada uma contendo um array de tickers com os mesmos campos do watchTicker, além de:
| Campo Adicional | Descrição |
|---|---|
priceWithoutCustomerSpread | Preço sem spread do cliente aplicado |
rule | Regra SOR utilizada para selecionar a exchange prioritária |
Exemplo
const ws = new WebSocket('wss://websocket-caas-it-sandbox.liqi.app.br/');
ws.onopen = () => {
ws.send(JSON.stringify({
action: 'subscribe',
channel: 'watchTickers',
data: { onlyPriority: true }
}));
};
ws.onmessage = (event) => {
const { channel, message } = JSON.parse(event.data);
if (channel === 'watchTickers') {
for (const [exchange, tickers] of Object.entries(message)) {
for (const ticker of tickers) {
console.log(`[${exchange}] ${ticker.symbol}: R$ ${ticker.last}`);
}
}
}
};