I'm getting API error "ErrInsufficientFunds" even though I have funds in my Trading Wallet

  • Updated

Applies to: Luno Exchange API users placing orders with postorder.

Quick fix

Send your Trading (SPOT) wallet IDs with every order, using both base_account_id and counter_account_id. See Step 1 below for how to find them.

Why this happens

While markets are migrating to our new exchange platform, the API doesn’t automatically use your Trading wallet. 

If you don’t send base_account_id and counter_account_id, it uses the first wallet you created for each currency. For most customers, that is the Transactional wallet. If it holds too little, the order fails with ErrInsufficientFunds, even though your Trading wallet has enough. The Luno app and website always use your Trading wallet, so they behave differently. This is deliberate, so existing API trading scripts that haven’t moved to Trading wallets yet keep working until their market migrates.

Note

You’ll also see this error if you trade on a migrated market without a Trading wallet. We create an empty one for you and the order fails. In that case, create or fund a Trading wallet in the Luno app (version 8.118.1 or later) or on the website, then retry.

How to fix it

1. Find your Trading wallet IDs

curl -u KEY_ID:KEY_SECRET "https://api.luno.com/api/1/balance?account_type=SPOT"

Each wallet in the response shows an account_id, an asset and an account_type of SPOT. If you have several Trading wallets for a currency, choose the one holding the funds you want to use.

Example: For XBTZAR, the base currency is XBT and the counter currency is ZAR. So base_account_id is your XBT Trading wallet ID and counter_account_id is your ZAR Trading wallet ID.

Your response will look like this (trimmed):

{ "account_id": "123456789", "account_type": "SPOT", "asset": "XBT", "name": "Trading XBT" }

2. Send both IDs with each other

 curl -u KEY_ID:KEY_SECRET -X POST "https://api.luno.com/api/1/postorder" \
  -d pair=XBTZAR -d type=BID -d volume=0.001 -d price=1400000 \
  -d base_account_id=BASE_TRADING_WALLET_ID \
  -d counter_account_id=COUNTER_TRADING_WALLET_ID

Always pass both IDs together, and make sure both are Trading wallets.

Which wallet can I use?

Your market Wallet to use
Already migrated Trading wallet only. Send both IDs if you hold several Trading wallets.
Not yet migrated Either works, but we recommend a Trading wallet. If you don’t send IDs, the order uses your Transactional wallet.

Tip

Not sure whether your market has migrated? Check the dates in Upgrading the Luno Exchange: What you need to know.

Once your market migrates, orders without wallet IDs use your first Trading wallet, so they behave like the app and website. Sending the IDs becomes optional, though we still recommend it if you hold several Trading wallets for a currency.

Other errors you may see

Error What it means What to do
ErrCrossAccountTypeTradeNotAllowed One wallet is a Transactional wallet and the other is a Trading wallet. Use Trading wallets for both.
ErrInvalidAccount The wallet ID isn’t recognised on the new platform. Get the IDs again using the balance call in Step 1.
ErrInsufficientBalance or ErrInsufficientFunds The wallet used doesn’t hold enough funds. Check you’re sending Trading wallet IDs, and that the Trading wallet is funded.

Still stuck?

Contact Luno Support or your Account Manager with your API key name (never the secret), the market, the time of the failed request, and the wallet IDs you sent.

 

Share this article

Did this article help?

How can we improve this article?