Trading
Order entry requires a NordUser with a valid session — see
Accounts and sessions.
Place an order
import { FillMode, Side } from "@n1xyz/nord-ts";
const { actionId, orderId, fills, reducedOrders, selfTradeCancels } =
await user.placeOrder({
marketId: 0,
side: Side.Bid,
fillMode: FillMode.Limit,
isReduceOnly: false,
size: 0.1,
price: 50000,
});
| Parameter | Required | Notes |
|---|---|---|
marketId | yes | From nord.markets |
side | yes | Side.Bid or Side.Ask |
fillMode | yes | See below |
isReduceOnly | yes | Rejects or trims anything that would increase the position |
size | one of | Base size, in decimals |
price | one of | Limit price, in decimals |
quoteSize | one of | Bounds the order by quote amount instead of base size |
accountId | no | Defaults to the wallet's first account |
clientOrderId | no | Your own identifier, usable for cancels |
selfTradePrevention | no | "expireMaker" cancels the resting side instead of self-matching |
referrer | no | Referral identifier, see Referrals |
At least one of size, price, or quoteSize must be provided. Prices and
sizes are decimals; the SDK scales them to wire integers using the market's
priceDecimals and sizeDecimals.
Fill modes
FillMode | Behavior |
|---|---|
Limit | Rests on the book after taking any crossing liquidity |
PostOnly | Never takes; rejected if it would cross |
ImmediateOrCancel | Takes what it can, cancels the remainder |
FillOrKill | Fills entirely or is cancelled |
Semantics are documented in Order Types.
Reading the result
orderId— present only if part of the order rests on the book. A fully filledImmediateOrCancelorFillOrKillorder has none.fills— trades that executed immediately, with size, price, and trade ID.reducedOrders— resting orders trimmed by this action (for example under reduce-only), with remaining and cancelled size.selfTradeCancels— your own orders cancelled by self-trade prevention.
Treat orderId === undefined as "nothing to cancel later", not as a failure.
Cancel
await user.cancelOrder(orderId);
await user.cancelOrderByClientId(clientOrderId);
Both accept an optional accountId and return { actionId, orderId, accountId }.
Using clientOrderId lets you cancel without persisting exchange order IDs — the
common pattern for market makers restarting from their own state.
Read your orders and positions
await user.fetchInfo();
const accountId = user.accountIds![0];
user.orders[accountId]; // open orders
user.positions[accountId]; // positions
user.balances[accountId]; // balances
user.margins[accountId]; // margin state
For history and analytics, query through the client:
await nord.getAccountOrders(accountId, { pageSize: 100 });
await nord.getAccountPositionSummary(accountId);
await nord.getAccountPnlSummary(accountId);
await nord.getAccountPnl(accountId, { since, until, pageSize: 100 });
await nord.getAccountPositionHistory(accountId, { pageSize: 100 });
Live updates come from the account stream — see WebSockets.
Batching related actions
user.atomic([...]) submits several subactions as one action, so they succeed or
fail together — for example replacing a quote by cancelling and re-placing in a
single round trip. user.placeRfqOrder is built on it.
Liquidations
user.takePositions({ targetAccountId }) takes over the balances and positions
of an eligible account and returns the taken balances and positions per taker.
This is the integration point for liquidators; eligibility and pricing are
described in Liquidations.