Unexpected token error on Gunbot – How to fix

Are you getting an error msg something like “Unexpected token” when running Gunbot on Bitmex?  Don’t worry, we are going to tell you how to fix it.

SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at Request.__dirname.makeRequest.request [as _callback] (C:\snapshot\gunbotv12_alfa\ctx\helper\bitmex\index.js:44:28)
at Request.init.self.callback (C:\snapshot\gunbotv12_alfa\node_modules\request\request.js:185:22)
at Request.emit (events.js:159:13)
at Request.<anonymous> (C:\snapshot\gunbotv12_alfa\node_modules\request\request.js:1161:10)
at Request.emit (events.js:159:13)
at IncomingMessage.<anonymous> (C:\snapshot\gunbotv12_alfa\node_modules\request\request.js:1083:12)
at Object.onceWrapper (events.js:254:19)
at IncomingMessage.emit (events.js:164:20)
at endReadableNT (_stream_readable.js:1054:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9) ‘Uncaught Exception thrown’

Ok, let’s see the most common ways to fix “Unexpected token” error:

1- Set a delay higher than 10 for each Gunbot instance you run. If your delay is lower than that, most likely your api has been temporary banned from Bitmex. In this case, wait 1 hour and try to run the bot again with a higher delay.

2- Maybe you added incorrect / non existing pairs. Note that some contracts has “weird” names, different from other exchanges. For example, LTC-BTC is called LTC-H19. Note you can check the pair names at the right of “Contract details“, below “Leverage”:

3- Be sure you trading volume is above the minimum allowed. It’s a common error to set trading_limit to something like 0.2 when trading the contract ETH-USD. Note that the number of contracts is stated in USD and not in ETH, and the minimum volume in this case is 2.

Submit Your Comment