Hercle
WebSocket Subscription

Pair Price Stream

Subscribe to the real-time feed of price updates of a pair with the selected size.

Receive continuous price updates including buy price and sell price for the specified trading pair.

Auth:API Key
Tags:
Subscriptions
Market Data

Subscribe

Command Name
SubscribePairPriceChannel

Arguments

ClientId
Required
Type:
string
Description:

Custom client ID (max 36 characters)

Example: "my-client-123"
PairName
Required
Type:
string
Description:

Pair name without separators (e.g.: BTCUSDT)

Example: "BTCUSDT"
Size
Required
Type:
number
Description:

Selected size

Example: 1
Invocation Example:
connection.invoke('SubscribePairPriceChannel', 'my-client-123', 'BTCUSDT', 1.0)

Unsubscribe

Command Name
UnsubscribePairPriceChannel

Arguments

ClientId
Required
Type:
string
Description:

Custom client ID (max 36 characters)

Example: "my-client-123"
PairName
Required
Type:
string
Description:

Pair name without separators (e.g.: BTCUSDT)

Example: "BTCUSDT"
Size
Required
Type:
number
Description:

Selected size

Example: 1
Invocation Example:
connection.invoke('UnsubscribePairPriceChannel', 'my-client-123', 'BTCUSDT', 1.0)

Subscription Events

Event Name
subscriptions
Subject
execution.feeds.priceUpdate

Event Data Fields

FieldTypeDescription
idstringPrice update ID
buyPricenumberBest buy price of pair with selected quantity
sellPricenumberBest sell price of pair with selected quantity
sizenumberSelected size
pairstringPair name
markPricenumberMark price of pair with selected quantity
timestampstringDatetime of price update

Example Event

{
  "data": {
    "id": "xxxx",
    "buyPrice": 26798.5,
    "sellPrice": 26790.5,
    "size": 1,
    "pair": "BTCUSDT",
    "markPrice": 26794.575,
    "timestamp": "2023-10-11T23:00:57.93094Z"
  }
}

Code Examples

const signalR = require('@microsoft/signalr');

const apiKey = 'YOUR_API_KEY_HERE';
const connection = new signalR.HubConnectionBuilder()
  .withUrl('https://publicapi.sandbox.hercle.financial/ExecutionLiveServer/v1', {
    accessTokenFactory: () => apiKey,
  })
  .build();

connection.start()
  .then(() => {
    console.log('Connected to WebSocket');
    
    // Invoke command
    connection.invoke('SubscribePairPriceChannel', "my-client-123", "BTCUSDT", 1)
      .then(() => {
        console.log('Command sent successfully');
      })
      .catch(err => {
        console.error('Command failed:', err);
      });
  })
  .catch(err => {
    console.error('Connection failed:', err);
  });

// Listen for events
connection.on('executionEvents', (data) => {
  console.log('Received event:', data);
});

SignalR API Tester

Test this command in the sandbox environment

Disconnected

Your API key is only used locally and never stored

Event Log

No events yet. Connect and invoke a command to see events.