Skip to main content

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, triggerMutations } =
await user.placeOrder({
marketId: 0,
side: Side.Bid,
fillMode: FillMode.Limit,
isReduceOnly: false,
size: 0.1,
price: 50000,
});
ParameterRequiredNotes
marketIdyesFrom nord.markets
sideyesSide.Bid or Side.Ask
fillModeyesSee below
isReduceOnlyyesRejects or trims anything that would increase the position
sizeone ofBase size, in decimals
priceone ofLimit price, in decimals
quoteSizeone ofBounds the order by quote amount instead of base size
accountIdnoDefaults to the wallet's first account
clientOrderIdnoYour own identifier, usable for cancels
selfTradePreventionno"expireMaker" cancels the resting side instead of self-matching
referrernoReferral identifier, see Referrals
triggersnoAttached take-profit, stop-loss, or OCO pair; not allowed on reduce-only orders. See Triggers

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​

FillModeBehavior
LimitRests on the book after taking any crossing liquidity
PostOnlyNever takes; rejected if it would cross
ImmediateOrCancelTakes what it can, cancels the remainder
FillOrKillFills entirely or is canceled

Semantics are documented in Order Types.

Reading the result​

  • orderId — present only if part of the order rests on the book. A fully filled ImmediateOrCancel or FillOrKill order 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 canceled size.
  • selfTradeCancels — your own orders canceled by self-trade prevention.
  • triggerMutations — attached triggers placed, activated, or canceled by the action.

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, triggerMutations }. Canceling a parent order can activate or cancel its attached triggers. 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.

user.atomic([...]) submits several subactions as one action, so they succeed or fail together — for example replacing a quote by canceling and re-placing in a single round trip. user.placeRfqOrder is built on it.

Liquidations​

user.takePositions({ targetAccountId }) moves each position of an eligible account to the backstop account of its market. It returns takers, with the positions each backstop account received in takenPositions. This is the integration point for liquidators; eligibility and pricing are described in Liquidations.

Next steps​

  • Triggers — stop-loss and take-profit.
  • RFQ — request-for-quote markets.
  • Fees — what a fill costs.

These materials are provided for informational purposes only and do not constitute financial, investment, legal, or tax advice, or an offer or solicitation to buy or sell any asset. Trading digital assets and derivatives involves substantial risk, including the possible loss of some or all capital. Products may not be available in all jurisdictions. Users are responsible for evaluating suitability and complying with applicable laws.