DeviaVir / zenbot

Zenbot is a command-line cryptocurrency trading bot using Node.js and MongoDB.
MIT License
8.21k stars 2.04k forks source link

Kraken exchange broken on XXBT-ZUSD #2632

Closed zaventh closed 3 years ago

zaventh commented 3 years ago

System information

Describe the problem

All commands on selector kraken.XXBT-ZUSD fail with various errors.

Source code / Error logs

$ node zenbot balance kraken.XXBT-ZUSD
...
getQuote error:
TypeError: Cannot read property 'b' of undefined
    at [redacted]/zenbot/extensions/exchanges/kraken/exchange.js:224:34
    at [redacted]/zenbot/node_modules/kraken-api/kraken.js:125:23
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:30445) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'b' of undefined
    at [redacted]/zenbot/extensions/exchanges/kraken/exchange.js:226:34
    at [redacted]/zenbot/node_modules/kraken-api/kraken.js:125:23
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:30445) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:30445) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
^C

This is because

var pair = joinProductFormatted(opts.product_id)

Is returning XBTUSD after commit 574da603. However, Kraken API is returning:

{
  "XXBTZUSD": {
    "a": [
      "37844.70000",
      "1",
      "1.000"
    ],
    "b": [
      "37844.60000",
      "11",
      "11.000"
    ],
    "c": [
      "37844.70000",
      "0.00065207"
    ],
    "v": [
      "4593.65887495",
      "4807.10838099"
    ],
    "p": [
      "37647.70122",
      "37623.15773"
    ],
    "t": [
      39405,
      41211
    ],
    "l": [
      "36582.90000",
      "36582.90000"
    ],
    "h": [
      "38340.00000",
      "38340.00000"
    ],
    "o": "36975.80000"
  }
}

I'm not sure of the motivation behind #2629 but it appears the solution is more nuanced than remapping the symbols in every case. The unmodified concatenation XXBTZUSD is expected here.

xazes commented 3 years ago

As dirty workarround you can edit exchange.js from kraken and edit this part here: var fixMap = { 'XETH': 'ETH', 'XXBT': 'XBT', 'XLTC': 'LTC', 'XXDG': 'XDG', 'XETC': 'ETC', 'XMLN': 'MLN', 'XREP': 'REP', 'XXRP': 'XRP', 'XXLM': 'XLM', 'XXMR': 'XMR', 'XZEC': 'ZEC', 'ZAUD': 'AUD', 'ZEUR': 'EUR', 'ZGBP': 'GBP', 'ZUSD': 'USD', 'ZJPY': 'JPY', 'ZCAD': 'CAD',

change in your case 'XXBT': 'XBT' and 'ZUSD': 'USD', TO 'XXBT': 'XXBT' and 'ZUSD': 'ZUSD' until an update appears

ChairmenMeow100 commented 3 years ago

hey zaventh, the initial Problem is a inconsistency in the naming of the products on the kraken side this was the last solution https://github.com/DeviaVir/zenbot/commit/d5d1f917c7fd7acbc21ddcc27f64737e1084864c it reformatted the "small coins". The list on line 47 was incomplete so i figured out it needs to change into "var assetsToFix = ['AAVE', 'ADA', 'ALGO', 'ANT', 'ATOM', 'BAL', 'BAT', 'BCH', 'COMP', 'CRV', 'DAI', 'DOT', 'DASH', 'EOS', 'FIL', 'GNO', 'GRT', 'ICX', 'KAVA', 'KEEP', 'KNC', 'KSM', 'LINK', 'LSK', 'MANA', 'NANO', 'OMG', 'OXT', 'PAXG', 'QTUM', 'REPV2', 'SC', 'SNX', 'STORJ', 'TBTC', 'TRX', 'UNI', 'USDT', 'USDC', 'WAVES', 'XTZ', 'YFI']" to support all of this coins. I am completely new to al of this, so i made my pull request in the wrong directory - so it does not get a match. In the meantime the webpack components were updated and we saw a new approach to this problem. Now the "big coins" are reformatted, the small ones work great but the other coins no more. It seems to me this approach has not erase Problem, it just turns it upside down. I have no programming skills to fix this on my own and can´t merge my solution because the whole chunk was changed - as i mentioned i am new to this so i don´t know what to do.

best regards

ChairmenMeow100 commented 3 years ago

hey @zaventh , i have undone the last changes on the file ~/zenbot/extensions/exchanges/kraken/exchange.js and now XXBT works on my machine again - i will test it a bit and try to do a pull request tomorrow.

zaventh commented 3 years ago

@ChairmenMeow100 No worries. Can you describe what you were trying to fix initially? It looks like a problem with the DOT-XETH pair? If I get a chance I may be able to look at it sometime this week.

ChairmenMeow100 commented 3 years ago

hey @zaventh , thanks for the response. As far as i know all kraken names for currency starts with Z and asset start with X. The names consists of four letter, but at some point kraken has stopped to do so. Now we have products with three letters and products with four letters and i don´t know why but this causes trouble. So the solution is apparently to reformat one group, the earlier version was to change all of them into four letters (i guess) and it worked so i just added e few newer coins to get a fully support. The latest change just cut all products down to three letters but now you search for the "wrong product" at kraken and get an error cause they don´t have "ETH" they named it "XETH" examples: litecoin = XLTC polkadot = DOT unfortunately i can´t do a proper pull request - so please do it yourself. I had another problem with the changes in zenbot/extensions/exchanges/kraken/update-products.sh (the price had to much digits, they support only four decimals - so it gets rejected) ... I just downgraded my whole version a bit to undo all the latest kraken specific changes - now it seems to run.