Help debugging typescript program to place limit order on the Nash DEX

I’m not sure if this is where to get help for a programming issue. If this is not the correct place, let me know.

I am trying to write a typescript trading program for the Nash DEX, but am having problems with placing a limit order. The program is able to use the API key to log into the trading account and to retrieve account balances. However, the program has a problem trying to place a limit order.

The offending line is as follows:

const order = await nashClient.placeLimitOrder(
  false,
  createCurrencyAmount('0.020001', CryptoCurrency.ETH),
  OrderBuyOrSell.BUY,
  OrderCancellationPolicy.GOOD_TIL_CANCELLED,
  createCurrencyPrice('0.01', CryptoCurrency.BTC, CryptoCurrency.ETH),
  'eth_btc'
)

I get the following error message:

Could not get nonce set: TypeError: Cannot read property ‘eth’ of undefined
2020-10-26T21:57:02.920Z
Caught error
TypeError: Cannot read property ‘eth_btc’ of undefined
at Client.placeLimitOrder (/home/pi/node_modules/@neon-exchange/api-client-typescript/build/main/client/client.js:1540:92)
at /home/pi/typescript_programs/trade.js:58:49
at step (/home/pi/typescript_programs/trade.js:33:23)
at Object.next (/home/pi/typescript_programs/trade.js:14:53)
at /home/pi/typescript_programs/trade.js:8:71
at new Promise ()
at __awaiter (/home/pi/typescript_programs/trade.js:4:12)
at run (/home/pi/typescript_programs/trade.js:51:32)
at Object. (/home/pi/typescript_programs/trade.js:74:1)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)

Any help or suggestions would be greatly appreciated.

Thanks,
Eugene Tsai

3 Likes

Hey,

Did you import CryptoCurrency as well? I ask because in the documentation example, it’s not added:

Also, could you try placing a sell order instead of a buy order? i.e using OrderBuyOrSell.SELL instead of OrderBuyOrSell.BUY (you need to switch the pair accordingly ofc).

If none of this works, I’ve sent you a link to a Telegram group with other Nash developers who might be able to help.

2 Likes

Thanks so much for your response and your suggestions. Unfortunately, neither suggestion worked. I had already imported CryptoCurrency and switching to a limit sell order was not successful. I have a feeling I may have set up the raspberry pi incorrectly which is running the typescript program. Thanks for the link to the Telegram group.

Could be caused by the Raspberry. I don’t know if it’s changed, but the API did not support 32bit OS, which is default for Raspbian.

I just tried running the same code on a Windows machine and still get the same error. It might not be Raspberry pi related.

could you use a gist ? gist.github.com

I created a gist…

Hi @ectsaimd, I tried your code and was able to fix by adding await for login function. image

5 Likes

Hi @Dline1,
Thank you so much!! With your fix, I was able to get the code working on my Windows machine, though a different error popped up on the Raspberry pi (wrong ELF class: ELFCLASS64), which may be related to @vt0 's comment about the API no supporting a 32bi OS.

1 Like