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
PlaceOtcOrderCommand Arguments
| Field | Type | Required | Description |
|---|---|---|---|
ClientId | string | Required | Custom client ID for tracking (max 36 characters) Example: "my-order-123" |
PriceId | string | Required | Price update ID received from price subscription Example: "123e4567-e89b-12d3-a456-426614174000" |
Side | stringbuysell | Required | Order side - "buy" or "sell" Example: "buy" |
Slippage | number | Required | Maximum price slippage accepted in case of sudden price change (1.0 equals to 1%) Example: 1 |
ClientIdRequired
Type:
string
Description:
Custom client ID for tracking (max 36 characters)
Example:
"my-order-123"PriceIdRequired
Type:
string
Description:
Price update ID received from price subscription
Example:
"123e4567-e89b-12d3-a456-426614174000"SideRequired
Type:
string
buysellDescription:
Order side - "buy" or "sell"
Example:
"buy"SlippageRequired
Type:
number
Description:
Maximum price slippage accepted in case of sudden price change (1.0 equals to 1%)
Example:
1Command 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
executionEventsSubject
execution.order.executedEvent sent when the order is executed. If the order is cancelled (for example the price expired or the slippage was exceeded), the reply has subject execution.order.cancelled instead, with the same fields, status 2 and the reason in statusError.
| Field | Type | Description |
|---|---|---|
tradeId | string | Unique trade identifier |
side | string | Order side ("buy" or "sell") |
pair | string | Trading pair (e.g., "BTCUSDT") |
price | number | Executed price |
size | number | Trade size in base currency |
notional | number | Trade notional value in quote currency |
status | number | Order status 0→ Created1→ Executed2→ Cancelled3→ Pending |
baseCurrency | string | Base currency symbol |
quoteCurrency | string | Quote currency symbol |
timestamp | string | ISO 8601 timestamp of execution |
statusError | string | Error 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