Hercle
WebSocket

Get Pair Size by Amount

Retrieves the size of a trading pair based on a specified amount.

Auth:API Key
Tags:
General Methods
Command Name
GetPairSizeByAmount

Command Arguments

ClientId
Required
Type:
string
Description:

Custom client ID for tracking (max 36 characters)

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

The trading pair to retrieve size for

Example: "BTCUSDT"
Side
Required
Type:
string
Description:

The side of the trade (buy/sell)

Example: "buy"
Amount
Required
Type:
number
Description:

The amount to base the size calculation on

Example: 100

Command Invocation

Command Arguments Example:
[
  "my-client-123",
  "BTCUSDT",
  "buy",
  100
]
Invocation Example:
connection.invoke('GetPairSizeByAmount', ['my-client-123', 'BTCUSDT', 'buy', 100])

Response Event

Event Name
executionEvents
Subject
execution.pair.price
FieldTypeDescription
idstringUnique identifier for the size request
pairstringThe trading pair
pricenumberThe price of the trading pair
sizenumberThe calculated size based on the amount
timestampstringTimestamp of the response

Example Response

{
  "data": {
    "id": "size-request-123",
    "pair": "BTCUSDT",
    "price": 50000,
    "size": 0.002,
    "timestamp": "2024-01-01T12:00:00Z"
  }
}

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('GetPairSizeByAmount', "my-client-123", "BTCUSDT", "buy", 100)
      .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.