EOrder:Insufficient funds means Kraken looked at the balance an order needs (the quote currency on a buy, the base currency on a sell) and found less available than the order would use. Your key, signature and nonce are fine. The question is which number you compared against.
The usual trap is reading Balance, seeing enough USD, and sending a buy anyway. Balance shows what you hold, not what you can spend. Funds already reserved by open orders still count there.
Read the spendable balance, not the total
Kraken’s BalanceEx endpoint returns four fields per asset, and its documentation gives the formula: available balance = balance + credit - credit_used - hold_trade. hold_trade is the amount locked by your open orders. In @siebly/kraken-api that endpoint is getExtendedBalance():
import { SpotClient } from '@siebly/kraken-api';
const client = new SpotClient({
apiKey: process.env.KRAKEN_API_KEY,
apiSecret: process.env.KRAKEN_API_SECRET,
});
async function spendable(asset: string): Promise<number> {
const res = await client.getExtendedBalance();
const row = res.result[asset];
if (!row) return 0;
return (
Number(row.balance) +
Number(row.credit) -
Number(row.credit_used) -
Number(row.hold_trade)
);
}
Use a key with query permissions for this, and only add order permissions on the key that actually trades. Withdrawal permission is never needed.
Use the right balance key
Balance keys are Kraken asset codes, which are not always the names you type. USD is ZUSD and bitcoin is XXBT, while newer assets such as SOL have no prefix. Don’t hard-code them. getAssetPairs() tells you the base and quote codes for a pair, and they match the balance keys:
async function pairRules(pair: string) {
const res = await client.getAssetPairs({ pair });
const [key, info] = Object.entries(res.result)[0];
return {
key,
base: info.base,
quote: info.quote,
ordermin: Number(info.ordermin),
costmin: Number(info.costmin ?? 0),
lotDecimals: info.lot_decimals,
};
}
On 25 November 2026, XBTUSD came back as key XXBTZUSD with base XXBT, quote ZUSD, ordermin 0.00006 and costmin 0.5. ETHUSD was XETH / ZUSD with ordermin 0.002. Read them at startup rather than copying these values, as Kraken changes them.
You may also see suffixed keys such as USDT.F (balances earning in Kraken Rewards), .S, .M or .B. Kraken documents these as read-only views and says to transact through the base asset. Print the full getExtendedBalance() result once to see which keys your account actually uses.
Leave room for the fee
Kraken’s error guide says to account for fees, and a buy that uses exactly the spendable quote balance can fail once the fee is added. The per-pair fees arrays in AssetPairs are empty now, so read your own tier from getTradingVolume() with fee_schedule: true:
async function takerFeePct(pair: string): Promise<number> {
const res = await client.getTradingVolume({ pair, fee_schedule: true });
const fees = res.result.fees ?? {};
const first = Object.values(fees)[0];
// No fee row? Be deliberately conservative rather than guess your tier.
return first ? Number(first.fee) : 1;
}
The fee value is a percentage, so 0.25 means 0.25%.
Check, validate, then submit
Putting it together: check the pair minimums, check the spendable balance including the fee, ask Kraken to validate the order without placing it, and only then submit. Minimum failures have their own errors (EOrder:Order minimum not met and EOrder:Cost minimum not met), so checking them first keeps the funds error meaningful.
async function placeLimitBuy(pair: string, volume: string, price: string) {
const rules = await pairRules(pair);
const feePct = await takerFeePct(pair);
const cost = Number(volume) * Number(price);
const needed = cost * (1 + feePct / 100);
const have = await spendable(rules.quote);
if (Number(volume) < rules.ordermin) {
throw new Error(`Volume ${volume} is below ordermin ${rules.ordermin}`);
}
if (cost < rules.costmin) {
throw new Error(`Cost ${cost} is below costmin ${rules.costmin}`);
}
if (have < needed) {
throw new Error(`Need ${needed.toFixed(2)} ${rules.quote}, have ${have.toFixed(2)} spendable`);
}
const order = {
pair,
type: 'buy' as const,
ordertype: 'limit' as const,
volume,
price,
};
await client.submitOrder({ ...order, validate: true });
return client.submitOrder(order);
}
For a sell, swap rules.quote for rules.base and compare against the volume. Keep the volume within lot_decimals places.
The balance can still change between your check and the order arriving, for example when another order fills or a withdrawal is pending. Treat the pre-check as a way to catch your own mistakes, not as a guarantee.
Reading the error when it still happens
The SDK throws when Kraken’s error array is not empty, and the codes are on err.body.error. If it is the funds error, the most common culprit is an older open order still holding the balance:
try {
const res = await placeLimitBuy('XBTUSD', '0.001', '50000');
console.log('Order ids:', res.result.txid);
} catch (err: any) {
const codes: string[] = err?.body?.error ?? [];
if (codes.includes('EOrder:Insufficient funds')) {
const open = await client.getOpenOrders();
console.log('Open orders holding funds:', Object.keys(open.result.open).length);
}
console.error(codes.length ? codes : err);
}
Don’t retry the same order straight away. Kraken’s guidance for any EOrder:Insufficient* error is to check balances first, and a tight retry loop only adds to your rate-limit counter.
Quick checklist
- Compare against
balance + credit - credit_used - hold_tradefromgetExtendedBalance(), not the raw balance. - Look up the balance key from
getAssetPairs()(ZUSD,XXBTand so on). - Add your fee from
getTradingVolume({ fee_schedule: true }). - Check
orderminandcostminfirst, then send withvalidate: true. - If the error persists, list open orders and cancel the ones you no longer need.
If nonces are your problem instead, see Kraken API “EAPI:Invalid nonce” in Node.js. For the full client setup, REST and WebSocket examples, see the Kraken JavaScript tutorial and the Kraken SDK docs.
