Orderly Trading Orders
by @tarnadas
Place, manage, and cancel orders using REST API or SDK hooks. Covers market, limit, IOC, FOK, POST_ONLY order types and batch operations
import { signAsync } from '@noble/ed25519';async function placeOrder(order: OrderRequest) {
const timestamp = Date.now();
const body = JSON.stringify(order);
const message = ${timestamp}POST/v1/order${body};
const signature = await signAsync(new TextEncoder().encode(message), privateKey);
// Encode as base64url (browser & Node.js compatible)
const base64 = btoa(String.fromCharCode(...signature));
const base64url = base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
const response = await fetch('https://api.orderly.org/v1/order', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'orderly-timestamp': String(timestamp),
'orderly-account-id': accountId,
'orderly-key': ed25519:${publicKeyBase58},
'orderly-signature': base64url,
},
body,
});
return response.json();
}
// Place a limit buy order
const order = await placeOrder({
symbol: 'PERP_ETH_USDC',
side: 'BUY',
order_type: 'LIMIT',
order_price: 3000,
order_quantity: 0.1,
});
trading scopeclawhub install orderly-trading-orders