Hercle
WebSocket

Place OTC Order

Places an order based on a Price Update ID received from price subscriptions.

This command executes a trade at the quoted price. You must have an active price subscription to receive Price Update IDs.

Auth:API Key
Tags:
Trading
Command Name
PlaceOtcOrder

Command Arguments

ClientId
Required
Type:
string
Description:

Custom client ID for tracking (max 36 characters)

Example: "my-order-123"
PriceId
Required
Type:
string
Description:

Price update ID received from price subscription

Example: "123e4567-e89b-12d3-a456-426614174000"
Side
Required
Type:
string
buysell
Description:

Order side - "buy" or "sell"

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

Maximum price slippage accepted in case of sudden price change (1.0 equals to 1%)

Example: 1

Command Invocation

Command Arguments Example:
[
  "my-order-123",
  "123e4567-e89b-12d3-a456-426614174000",
  "buy",
  1
]
Invocation Example:
connection.invoke('PlaceOtcOrder', 'my-order-123', '123e4567-e89b-12d3-a456-426614174000', 'buy', 1.0)

Response Event

Event Name
executionEvents
Subject
execution.order.executed
FieldTypeDescription
tradeIdstringUnique trade identifier
sidestringOrder side ("buy" or "sell")
pairstringTrading pair (e.g., "BTCUSDT")
pricenumberExecuted price
sizenumberTrade size in base currency
notionalnumberTrade notional value in quote currency
statusnumber
Order status
0Created
1Executed
2Cancelled
3Pending
baseCurrencystringBase currency symbol
quoteCurrencystringQuote currency symbol
timestampstringISO 8601 timestamp of execution
statusErrorstringError message if order was cancelled or rejected

Example Response

{
  "data": {
    "tradeId": "987e6543-e21b-12d3-a456-426614174001",
    "side": "buy",
    "pair": "BTCUSDT",
    "price": 26844.07,
    "size": 0.01,
    "notional": 268.4407,
    "status": 1,
    "baseCurrency": "BTC",
    "quoteCurrency": "USDT",
    "timestamp": "2023-10-11T23:00:57.93094Z",
    "statusError": ""
  }
}

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('PlaceOtcOrder', "my-order-123", "123e4567-e89b-12d3-a456-426614174000", "buy", 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.