ccxt 4.2.31 → 4.2.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/.gitattributes +1 -0
  2. package/CONTRIBUTING.md +20 -1
  3. package/README.md +8 -7
  4. package/build.sh +9 -2
  5. package/cleanup.sh +3 -0
  6. package/dist/ccxt.browser.js +741 -501
  7. package/dist/ccxt.browser.min.js +3 -3
  8. package/dist/cjs/ccxt.js +1 -1
  9. package/dist/cjs/src/ace.js +3 -2
  10. package/dist/cjs/src/ascendex.js +1 -1
  11. package/dist/cjs/src/base/Exchange.js +62 -20
  12. package/dist/cjs/src/bigone.js +21 -1
  13. package/dist/cjs/src/binance.js +59 -15
  14. package/dist/cjs/src/bingx.js +4 -3
  15. package/dist/cjs/src/bit2c.js +12 -0
  16. package/dist/cjs/src/bitfinex2.js +12 -1
  17. package/dist/cjs/src/bitget.js +3 -3
  18. package/dist/cjs/src/bitmart.js +1 -1
  19. package/dist/cjs/src/bitrue.js +3 -3
  20. package/dist/cjs/src/blockchaincom.js +1 -1
  21. package/dist/cjs/src/bybit.js +1 -1
  22. package/dist/cjs/src/coinbase.js +2 -2
  23. package/dist/cjs/src/coinex.js +1 -1
  24. package/dist/cjs/src/cryptocom.js +10 -10
  25. package/dist/cjs/src/gate.js +34 -29
  26. package/dist/cjs/src/kraken.js +39 -0
  27. package/dist/cjs/src/krakenfutures.js +25 -3
  28. package/dist/cjs/src/kucoin.js +1 -1
  29. package/dist/cjs/src/mexc.js +2 -1
  30. package/dist/cjs/src/okx.js +4 -3
  31. package/dist/cjs/src/phemex.js +8 -8
  32. package/dist/cjs/src/pro/alpaca.js +8 -4
  33. package/dist/cjs/src/pro/ascendex.js +1 -2
  34. package/dist/cjs/src/pro/binance.js +17 -13
  35. package/dist/cjs/src/pro/bingx.js +1 -1
  36. package/dist/cjs/src/pro/bitfinex.js +21 -24
  37. package/dist/cjs/src/pro/bitfinex2.js +13 -17
  38. package/dist/cjs/src/pro/bitget.js +3 -1
  39. package/dist/cjs/src/pro/bitmart.js +3 -8
  40. package/dist/cjs/src/pro/bitmex.js +4 -7
  41. package/dist/cjs/src/pro/bitopro.js +2 -5
  42. package/dist/cjs/src/pro/bitrue.js +1 -1
  43. package/dist/cjs/src/pro/bitstamp.js +2 -3
  44. package/dist/cjs/src/pro/bitvavo.js +12 -5
  45. package/dist/cjs/src/pro/blockchaincom.js +22 -23
  46. package/dist/cjs/src/pro/bybit.js +5 -5
  47. package/dist/cjs/src/pro/cex.js +7 -7
  48. package/dist/cjs/src/pro/coinbase.js +3 -2
  49. package/dist/cjs/src/pro/coinbasepro.js +1 -1
  50. package/dist/cjs/src/pro/coinex.js +15 -13
  51. package/dist/cjs/src/pro/currencycom.js +5 -7
  52. package/dist/cjs/src/pro/deribit.js +4 -4
  53. package/dist/cjs/src/pro/exmo.js +15 -13
  54. package/dist/cjs/src/pro/gate.js +1 -1
  55. package/dist/cjs/src/pro/gemini.js +4 -2
  56. package/dist/cjs/src/pro/hitbtc.js +9 -8
  57. package/dist/cjs/src/pro/hollaex.js +2 -2
  58. package/dist/cjs/src/pro/htx.js +6 -7
  59. package/dist/cjs/src/pro/huobijp.js +3 -5
  60. package/dist/cjs/src/pro/idex.js +1 -1
  61. package/dist/cjs/src/pro/independentreserve.js +14 -13
  62. package/dist/cjs/src/pro/kraken.js +10 -16
  63. package/dist/cjs/src/pro/krakenfutures.js +10 -6
  64. package/dist/cjs/src/pro/kucoin.js +10 -11
  65. package/dist/cjs/src/pro/kucoinfutures.js +12 -11
  66. package/dist/cjs/src/pro/lbank.js +10 -10
  67. package/dist/cjs/src/pro/luno.js +12 -14
  68. package/dist/cjs/src/pro/mexc.js +3 -2
  69. package/dist/cjs/src/pro/ndax.js +7 -13
  70. package/dist/cjs/src/pro/okcoin.js +7 -12
  71. package/dist/cjs/src/pro/okx.js +6 -11
  72. package/dist/cjs/src/pro/onetrading.js +16 -15
  73. package/dist/cjs/src/pro/p2b.js +5 -3
  74. package/dist/cjs/src/pro/phemex.js +16 -11
  75. package/dist/cjs/src/pro/poloniex.js +6 -4
  76. package/dist/cjs/src/pro/poloniexfutures.js +14 -9
  77. package/dist/cjs/src/pro/probit.js +15 -11
  78. package/dist/cjs/src/pro/upbit.js +8 -8
  79. package/dist/cjs/src/pro/wazirx.js +6 -3
  80. package/dist/cjs/src/pro/woo.js +8 -6
  81. package/dist/cjs/src/probit.js +3 -3
  82. package/dist/cjs/src/tokocrypto.js +2 -2
  83. package/dist/cjs/src/wavesexchange.js +2 -1
  84. package/dist/cjs/src/woo.js +1 -1
  85. package/dist/cjs/src/yobit.js +39 -0
  86. package/js/ccxt.d.ts +1 -1
  87. package/js/ccxt.js +1 -1
  88. package/js/src/ace.d.ts +1 -1
  89. package/js/src/ace.js +3 -2
  90. package/js/src/alpaca.d.ts +1 -1
  91. package/js/src/ascendex.d.ts +5 -15
  92. package/js/src/ascendex.js +1 -1
  93. package/js/src/base/Exchange.d.ts +86 -78
  94. package/js/src/base/Exchange.js +62 -20
  95. package/js/src/base/types.d.ts +90 -6
  96. package/js/src/bigone.d.ts +5 -15
  97. package/js/src/bigone.js +21 -1
  98. package/js/src/binance.d.ts +13 -23
  99. package/js/src/binance.js +59 -15
  100. package/js/src/bingx.d.ts +6 -16
  101. package/js/src/bingx.js +4 -3
  102. package/js/src/bit2c.d.ts +1 -1
  103. package/js/src/bit2c.js +12 -0
  104. package/js/src/bitbank.d.ts +2 -2
  105. package/js/src/bitbns.d.ts +1 -1
  106. package/js/src/bitfinex.d.ts +5 -5
  107. package/js/src/bitfinex2.d.ts +7 -17
  108. package/js/src/bitfinex2.js +12 -1
  109. package/js/src/bitflyer.d.ts +5 -5
  110. package/js/src/bitforex.d.ts +1 -1
  111. package/js/src/bitget.d.ts +8 -38
  112. package/js/src/bitget.js +3 -3
  113. package/js/src/bithumb.d.ts +2 -2
  114. package/js/src/bitmart.d.ts +10 -21
  115. package/js/src/bitmart.js +1 -1
  116. package/js/src/bitmex.d.ts +3 -3
  117. package/js/src/bitopro.d.ts +2 -2
  118. package/js/src/bitrue.d.ts +5 -15
  119. package/js/src/bitrue.js +3 -3
  120. package/js/src/bitso.d.ts +4 -4
  121. package/js/src/bitstamp.d.ts +2 -2
  122. package/js/src/bitteam.d.ts +1 -1
  123. package/js/src/bitvavo.d.ts +3 -3
  124. package/js/src/bl3p.d.ts +1 -1
  125. package/js/src/blockchaincom.d.ts +2 -2
  126. package/js/src/blockchaincom.js +1 -1
  127. package/js/src/btcalpha.d.ts +1 -1
  128. package/js/src/btcbox.d.ts +1 -1
  129. package/js/src/btcmarkets.d.ts +3 -3
  130. package/js/src/btcturk.d.ts +1 -1
  131. package/js/src/bybit.d.ts +8 -8
  132. package/js/src/bybit.js +1 -1
  133. package/js/src/cex.d.ts +1 -1
  134. package/js/src/coinbase.d.ts +6 -50
  135. package/js/src/coinbase.js +2 -2
  136. package/js/src/coinbasepro.d.ts +2 -2
  137. package/js/src/coincheck.d.ts +1 -1
  138. package/js/src/coinex.d.ts +8 -8
  139. package/js/src/coinex.js +1 -1
  140. package/js/src/coinlist.d.ts +4 -14
  141. package/js/src/coinmate.d.ts +2 -2
  142. package/js/src/coinmetro.d.ts +2 -2
  143. package/js/src/coinone.d.ts +1 -1
  144. package/js/src/coinsph.d.ts +2 -2
  145. package/js/src/coinspot.d.ts +1 -1
  146. package/js/src/cryptocom.d.ts +4 -4
  147. package/js/src/cryptocom.js +10 -10
  148. package/js/src/currencycom.d.ts +2 -2
  149. package/js/src/delta.d.ts +2 -2
  150. package/js/src/deribit.d.ts +4 -14
  151. package/js/src/digifinex.d.ts +10 -38
  152. package/js/src/exmo.d.ts +2 -2
  153. package/js/src/gate.d.ts +8 -18
  154. package/js/src/gate.js +34 -29
  155. package/js/src/gemini.d.ts +2 -2
  156. package/js/src/hitbtc.d.ts +6 -16
  157. package/js/src/hollaex.d.ts +2 -2
  158. package/js/src/htx.d.ts +11 -21
  159. package/js/src/huobijp.d.ts +4 -4
  160. package/js/src/idex.d.ts +3 -3
  161. package/js/src/independentreserve.d.ts +2 -2
  162. package/js/src/indodax.d.ts +2 -2
  163. package/js/src/kraken.d.ts +5 -5
  164. package/js/src/kraken.js +39 -0
  165. package/js/src/krakenfutures.d.ts +7 -7
  166. package/js/src/krakenfutures.js +25 -3
  167. package/js/src/kucoin.d.ts +8 -29
  168. package/js/src/kucoin.js +1 -1
  169. package/js/src/kucoinfutures.d.ts +4 -4
  170. package/js/src/kuna.d.ts +2 -2
  171. package/js/src/latoken.d.ts +4 -14
  172. package/js/src/lbank.d.ts +2 -5
  173. package/js/src/luno.d.ts +1 -1
  174. package/js/src/lykke.d.ts +2 -2
  175. package/js/src/mercado.d.ts +2 -2
  176. package/js/src/mexc.d.ts +6 -6
  177. package/js/src/mexc.js +2 -1
  178. package/js/src/ndax.d.ts +2 -2
  179. package/js/src/novadax.d.ts +4 -15
  180. package/js/src/oceanex.d.ts +1 -1
  181. package/js/src/okcoin.d.ts +5 -15
  182. package/js/src/okx.d.ts +8 -18
  183. package/js/src/okx.js +4 -3
  184. package/js/src/onetrading.d.ts +2 -2
  185. package/js/src/p2b.d.ts +1 -1
  186. package/js/src/paymium.d.ts +3 -13
  187. package/js/src/phemex.d.ts +5 -5
  188. package/js/src/phemex.js +8 -8
  189. package/js/src/poloniex.d.ts +4 -14
  190. package/js/src/poloniexfutures.d.ts +1 -1
  191. package/js/src/pro/alpaca.d.ts +2 -2
  192. package/js/src/pro/alpaca.js +8 -4
  193. package/js/src/pro/ascendex.d.ts +2 -2
  194. package/js/src/pro/ascendex.js +1 -2
  195. package/js/src/pro/binance.d.ts +3 -3
  196. package/js/src/pro/binance.js +17 -13
  197. package/js/src/pro/bingx.d.ts +1 -1
  198. package/js/src/pro/bingx.js +1 -1
  199. package/js/src/pro/bitfinex.d.ts +2 -2
  200. package/js/src/pro/bitfinex.js +21 -24
  201. package/js/src/pro/bitfinex2.d.ts +2 -2
  202. package/js/src/pro/bitfinex2.js +13 -17
  203. package/js/src/pro/bitget.js +3 -1
  204. package/js/src/pro/bitmart.d.ts +3 -3
  205. package/js/src/pro/bitmart.js +3 -8
  206. package/js/src/pro/bitmex.d.ts +1 -1
  207. package/js/src/pro/bitmex.js +4 -7
  208. package/js/src/pro/bitopro.d.ts +1 -1
  209. package/js/src/pro/bitopro.js +2 -5
  210. package/js/src/pro/bitrue.js +1 -1
  211. package/js/src/pro/bitstamp.d.ts +1 -1
  212. package/js/src/pro/bitstamp.js +2 -3
  213. package/js/src/pro/bitvavo.d.ts +3 -3
  214. package/js/src/pro/bitvavo.js +12 -5
  215. package/js/src/pro/blockchaincom.d.ts +8 -8
  216. package/js/src/pro/blockchaincom.js +22 -23
  217. package/js/src/pro/bybit.d.ts +2 -2
  218. package/js/src/pro/bybit.js +5 -5
  219. package/js/src/pro/cex.d.ts +1 -1
  220. package/js/src/pro/cex.js +7 -7
  221. package/js/src/pro/coinbase.d.ts +1 -1
  222. package/js/src/pro/coinbase.js +3 -2
  223. package/js/src/pro/coinbasepro.d.ts +1 -1
  224. package/js/src/pro/coinbasepro.js +1 -1
  225. package/js/src/pro/coinex.d.ts +2 -2
  226. package/js/src/pro/coinex.js +15 -13
  227. package/js/src/pro/currencycom.d.ts +1 -1
  228. package/js/src/pro/currencycom.js +5 -7
  229. package/js/src/pro/deribit.d.ts +2 -2
  230. package/js/src/pro/deribit.js +4 -4
  231. package/js/src/pro/exmo.d.ts +2 -2
  232. package/js/src/pro/exmo.js +15 -13
  233. package/js/src/pro/gate.js +1 -1
  234. package/js/src/pro/gemini.d.ts +1 -1
  235. package/js/src/pro/gemini.js +4 -2
  236. package/js/src/pro/hitbtc.d.ts +2 -2
  237. package/js/src/pro/hitbtc.js +9 -8
  238. package/js/src/pro/hollaex.d.ts +2 -2
  239. package/js/src/pro/hollaex.js +2 -2
  240. package/js/src/pro/htx.d.ts +2 -2
  241. package/js/src/pro/htx.js +6 -7
  242. package/js/src/pro/huobijp.d.ts +1 -1
  243. package/js/src/pro/huobijp.js +3 -5
  244. package/js/src/pro/idex.js +1 -1
  245. package/js/src/pro/independentreserve.d.ts +1 -1
  246. package/js/src/pro/independentreserve.js +14 -13
  247. package/js/src/pro/kraken.d.ts +2 -2
  248. package/js/src/pro/kraken.js +10 -16
  249. package/js/src/pro/krakenfutures.d.ts +1 -1
  250. package/js/src/pro/krakenfutures.js +10 -6
  251. package/js/src/pro/kucoin.d.ts +3 -3
  252. package/js/src/pro/kucoin.js +10 -11
  253. package/js/src/pro/kucoinfutures.d.ts +3 -3
  254. package/js/src/pro/kucoinfutures.js +12 -11
  255. package/js/src/pro/lbank.d.ts +1 -1
  256. package/js/src/pro/lbank.js +10 -10
  257. package/js/src/pro/luno.d.ts +2 -2
  258. package/js/src/pro/luno.js +12 -14
  259. package/js/src/pro/mexc.d.ts +2 -2
  260. package/js/src/pro/mexc.js +3 -2
  261. package/js/src/pro/ndax.d.ts +3 -3
  262. package/js/src/pro/ndax.js +7 -13
  263. package/js/src/pro/okcoin.d.ts +1 -1
  264. package/js/src/pro/okcoin.js +7 -12
  265. package/js/src/pro/okx.d.ts +1 -1
  266. package/js/src/pro/okx.js +6 -11
  267. package/js/src/pro/onetrading.d.ts +1 -1
  268. package/js/src/pro/onetrading.js +16 -15
  269. package/js/src/pro/p2b.d.ts +1 -1
  270. package/js/src/pro/p2b.js +5 -3
  271. package/js/src/pro/phemex.d.ts +3 -3
  272. package/js/src/pro/phemex.js +16 -11
  273. package/js/src/pro/poloniex.d.ts +1 -1
  274. package/js/src/pro/poloniex.js +6 -4
  275. package/js/src/pro/poloniexfutures.d.ts +4 -4
  276. package/js/src/pro/poloniexfutures.js +13 -10
  277. package/js/src/pro/probit.d.ts +1 -1
  278. package/js/src/pro/probit.js +14 -12
  279. package/js/src/pro/upbit.js +8 -8
  280. package/js/src/pro/wazirx.d.ts +1 -1
  281. package/js/src/pro/wazirx.js +6 -3
  282. package/js/src/pro/woo.d.ts +3 -3
  283. package/js/src/pro/woo.js +8 -6
  284. package/js/src/probit.d.ts +3 -3
  285. package/js/src/probit.js +3 -3
  286. package/js/src/timex.d.ts +1 -1
  287. package/js/src/tokocrypto.d.ts +3 -3
  288. package/js/src/tokocrypto.js +2 -2
  289. package/js/src/upbit.d.ts +2 -2
  290. package/js/src/wavesexchange.d.ts +3 -4
  291. package/js/src/wavesexchange.js +2 -1
  292. package/js/src/wazirx.d.ts +1 -1
  293. package/js/src/whitebit.d.ts +5 -15
  294. package/js/src/woo.d.ts +5 -15
  295. package/js/src/woo.js +1 -1
  296. package/js/src/yobit.d.ts +21 -6
  297. package/js/src/yobit.js +39 -0
  298. package/js/src/zaif.d.ts +2 -2
  299. package/js/src/zonda.d.ts +4 -14
  300. package/package.json +22 -8
  301. package/skip-tests.json +9 -1
  302. package/tests-manager.sh +1 -2
@@ -47,19 +47,20 @@ class kucoin extends kucoin$1 {
47
47
  },
48
48
  });
49
49
  }
50
- negotiate(privateChannel, params = {}) {
50
+ async negotiate(privateChannel, params = {}) {
51
51
  const connectId = privateChannel ? 'private' : 'public';
52
52
  const urls = this.safeValue(this.options, 'urls', {});
53
53
  const spawaned = this.safeValue(urls, connectId);
54
54
  if (spawaned !== undefined) {
55
- return spawaned;
55
+ return await spawaned;
56
56
  }
57
57
  // we store an awaitable to the url
58
58
  // so that multiple calls don't asynchronously
59
59
  // fetch different urls and overwrite each other
60
60
  urls[connectId] = this.spawn(this.negotiateHelper, privateChannel, params);
61
61
  this.options['urls'] = urls;
62
- return urls[connectId];
62
+ const future = urls[connectId];
63
+ return await future;
63
64
  }
64
65
  async negotiateHelper(privateChannel, params = {}) {
65
66
  let response = undefined;
@@ -545,7 +546,7 @@ class kucoin extends kucoin$1 {
545
546
  const limit = this.safeInteger(subscription, 'limit');
546
547
  const snapshotDelay = this.handleOption('watchOrderBook', 'snapshotDelay', 5);
547
548
  if (cacheLength === snapshotDelay) {
548
- this.spawn(this.loadOrderBook, client, messageHash, symbol, limit);
549
+ this.spawn(this.loadOrderBook, client, messageHash, symbol, limit, {});
549
550
  }
550
551
  storedOrderBook.cache.push(data);
551
552
  return;
@@ -987,7 +988,8 @@ class kucoin extends kucoin$1 {
987
988
  //
988
989
  const topic = this.safeString(message, 'topic');
989
990
  if (topic === '/market/ticker:all') {
990
- return this.handleTicker(client, message);
991
+ this.handleTicker(client, message);
992
+ return;
991
993
  }
992
994
  const subject = this.safeString(message, 'subject');
993
995
  const methods = {
@@ -1002,11 +1004,8 @@ class kucoin extends kucoin$1 {
1002
1004
  'stopOrder': this.handleOrder,
1003
1005
  };
1004
1006
  const method = this.safeValue(methods, subject);
1005
- if (method === undefined) {
1006
- return message;
1007
- }
1008
- else {
1009
- return method.call(this, client, message);
1007
+ if (method !== undefined) {
1008
+ method.call(this, client, message);
1010
1009
  }
1011
1010
  }
1012
1011
  ping(client) {
@@ -1054,7 +1053,7 @@ class kucoin extends kucoin$1 {
1054
1053
  };
1055
1054
  const method = this.safeValue(methods, type);
1056
1055
  if (method !== undefined) {
1057
- return method.call(this, client, message);
1056
+ method.call(this, client, message);
1058
1057
  }
1059
1058
  }
1060
1059
  }
@@ -57,19 +57,20 @@ class kucoinfutures extends kucoinfutures$1 {
57
57
  },
58
58
  });
59
59
  }
60
- negotiate(privateChannel, params = {}) {
60
+ async negotiate(privateChannel, params = {}) {
61
61
  const connectId = privateChannel ? 'private' : 'public';
62
62
  const urls = this.safeValue(this.options, 'urls', {});
63
63
  const spawaned = this.safeValue(urls, connectId);
64
64
  if (spawaned !== undefined) {
65
- return spawaned;
65
+ return await spawaned;
66
66
  }
67
67
  // we store an awaitable to the url
68
68
  // so that multiple calls don't asynchronously
69
69
  // fetch different urls and overwrite each other
70
- urls[connectId] = this.spawn(this.negotiateHelper, privateChannel, params);
70
+ urls[connectId] = this.spawn(this.negotiateHelper, privateChannel, params); // we have to wait here otherwsie in c# will not work
71
71
  this.options['urls'] = urls;
72
- return urls[connectId];
72
+ const future = urls[connectId];
73
+ return await future;
73
74
  }
74
75
  async negotiateHelper(privateChannel, params = {}) {
75
76
  let response = undefined;
@@ -582,6 +583,9 @@ class kucoinfutures extends kucoinfutures$1 {
582
583
  const messageHash = 'orderbook:' + symbol;
583
584
  const storedOrderBook = this.safeValue(this.orderbooks, symbol);
584
585
  const nonce = this.safeInteger(storedOrderBook, 'nonce');
586
+ if (storedOrderBook === undefined) {
587
+ return; // this shouldn't be needed, but for some reason sometimes this runs before handleOrderBookSubscription in c#
588
+ }
585
589
  const deltaEnd = this.safeInteger(data, 'sequence');
586
590
  if (nonce === undefined) {
587
591
  const cacheLength = storedOrderBook.cache.length;
@@ -600,7 +604,7 @@ class kucoinfutures extends kucoinfutures$1 {
600
604
  const limit = this.safeInteger(subscription, 'limit');
601
605
  const snapshotDelay = this.handleOption('watchOrderBook', 'snapshotDelay', 5);
602
606
  if (cacheLength === snapshotDelay) {
603
- this.spawn(this.loadOrderBook, client, messageHash, symbol, limit);
607
+ this.spawn(this.loadOrderBook, client, messageHash, symbol, limit, {});
604
608
  }
605
609
  storedOrderBook.cache.push(data);
606
610
  return;
@@ -928,11 +932,8 @@ class kucoinfutures extends kucoinfutures$1 {
928
932
  'position.adjustRiskLimit': this.handlePosition,
929
933
  };
930
934
  const method = this.safeValue(methods, subject);
931
- if (method === undefined) {
932
- return message;
933
- }
934
- else {
935
- return method.call(this, client, message);
935
+ if (method !== undefined) {
936
+ method.call(this, client, message);
936
937
  }
937
938
  }
938
939
  ping(client) {
@@ -981,7 +982,7 @@ class kucoinfutures extends kucoinfutures$1 {
981
982
  };
982
983
  const method = this.safeValue(methods, type);
983
984
  if (method !== undefined) {
984
- return method.call(this, client, message);
985
+ method.call(this, client, message);
985
986
  }
986
987
  }
987
988
  }
@@ -776,17 +776,17 @@ class lbank extends lbank$1 {
776
776
  const orderBook = this.safeValue(message, 'depth', message);
777
777
  const datetime = this.safeString(message, 'TS');
778
778
  const timestamp = this.parse8601(datetime);
779
- let storedOrderBook = this.safeValue(this.orderbooks, symbol);
780
- if (storedOrderBook === undefined) {
781
- storedOrderBook = this.orderBook({});
782
- this.orderbooks[symbol] = storedOrderBook;
779
+ let orderbook = this.safeValue(this.orderbooks, symbol);
780
+ if (orderbook === undefined) {
781
+ orderbook = this.orderBook({});
782
+ this.orderbooks[symbol] = orderbook;
783
783
  }
784
784
  const snapshot = this.parseOrderBook(orderBook, symbol, timestamp, 'bids', 'asks');
785
- storedOrderBook.reset(snapshot);
785
+ orderbook.reset(snapshot);
786
786
  let messageHash = 'orderbook:' + symbol;
787
- client.resolve(storedOrderBook, messageHash);
787
+ client.resolve(orderbook, messageHash);
788
788
  messageHash = 'fetchOrderbook:' + symbol;
789
- client.resolve(storedOrderBook, messageHash);
789
+ client.resolve(orderbook, messageHash);
790
790
  }
791
791
  handleErrorMessage(client, message) {
792
792
  //
@@ -814,7 +814,8 @@ class lbank extends lbank$1 {
814
814
  handleMessage(client, message) {
815
815
  const status = this.safeString(message, 'status');
816
816
  if (status === 'error') {
817
- return this.handleErrorMessage(client, message);
817
+ this.handleErrorMessage(client, message);
818
+ return;
818
819
  }
819
820
  const type = this.safeString2(message, 'type', 'action');
820
821
  if (type === 'ping') {
@@ -830,9 +831,8 @@ class lbank extends lbank$1 {
830
831
  };
831
832
  const handler = this.safeValue(handlers, type);
832
833
  if (handler !== undefined) {
833
- return handler.call(this, client, message);
834
+ handler.call(this, client, message);
834
835
  }
835
- return message;
836
836
  }
837
837
  async authenticate(params = {}) {
838
838
  // when we implement more private streams, we need to refactor the authentication
@@ -191,24 +191,24 @@ class luno extends luno$1 {
191
191
  const symbol = subscription['symbol'];
192
192
  const messageHash = 'orderbook:' + symbol;
193
193
  const timestamp = this.safeString(message, 'timestamp');
194
- let storedOrderBook = this.safeValue(this.orderbooks, symbol);
195
- if (storedOrderBook === undefined) {
196
- storedOrderBook = this.indexedOrderBook({});
197
- this.orderbooks[symbol] = storedOrderBook;
194
+ let orderbook = this.safeValue(this.orderbooks, symbol);
195
+ if (orderbook === undefined) {
196
+ orderbook = this.indexedOrderBook({});
197
+ this.orderbooks[symbol] = orderbook;
198
198
  }
199
199
  const asks = this.safeValue(message, 'asks');
200
200
  if (asks !== undefined) {
201
201
  const snapshot = this.customParseOrderBook(message, symbol, timestamp, 'bids', 'asks', 'price', 'volume', 'id');
202
- storedOrderBook.reset(snapshot);
202
+ orderbook.reset(snapshot);
203
203
  }
204
204
  else {
205
- this.handleDelta(storedOrderBook, message);
206
- storedOrderBook['timestamp'] = timestamp;
207
- storedOrderBook['datetime'] = this.iso8601(timestamp);
205
+ this.handleDelta(orderbook, message);
206
+ orderbook['timestamp'] = timestamp;
207
+ orderbook['datetime'] = this.iso8601(timestamp);
208
208
  }
209
209
  const nonce = this.safeInteger(message, 'sequence');
210
- storedOrderBook['nonce'] = nonce;
211
- client.resolve(storedOrderBook, messageHash);
210
+ orderbook['nonce'] = nonce;
211
+ client.resolve(orderbook, messageHash);
212
212
  }
213
213
  customParseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 'price', amountKey = 'volume', countOrIdKey = 2) {
214
214
  const bids = this.parseBidsAsks(this.safeValue(orderbook, bidsKey, []), priceKey, amountKey, countOrIdKey);
@@ -300,10 +300,9 @@ class luno extends luno$1 {
300
300
  const deleteUpdate = this.safeValue(message, 'delete_update');
301
301
  if (deleteUpdate !== undefined) {
302
302
  const orderId = this.safeString(deleteUpdate, 'order_id');
303
- asksOrderSide.storeArray(0, 0, orderId);
304
- bidsOrderSide.storeArray(0, 0, orderId);
303
+ asksOrderSide.storeArray([0, 0, orderId]);
304
+ bidsOrderSide.storeArray([0, 0, orderId]);
305
305
  }
306
- return message;
307
306
  }
308
307
  handleMessage(client, message) {
309
308
  if (message === '') {
@@ -315,7 +314,6 @@ class luno extends luno$1 {
315
314
  const handler = handlers[j];
316
315
  handler.call(this, client, message, subscriptions[0]);
317
316
  }
318
- return message;
319
317
  }
320
318
  }
321
319
 
@@ -1106,7 +1106,7 @@ class mexc extends mexc$1 {
1106
1106
  //
1107
1107
  const msg = this.safeString(message, 'msg');
1108
1108
  if (msg === 'PONG') {
1109
- return this.handlePong(client, message);
1109
+ this.handlePong(client, message);
1110
1110
  }
1111
1111
  else if (msg.indexOf('@') > -1) {
1112
1112
  const parts = msg.split('@');
@@ -1129,7 +1129,8 @@ class mexc extends mexc$1 {
1129
1129
  return;
1130
1130
  }
1131
1131
  if ('msg' in message) {
1132
- return this.handleSubscriptionStatus(client, message);
1132
+ this.handleSubscriptionStatus(client, message);
1133
+ return;
1133
1134
  }
1134
1135
  const c = this.safeString(message, 'c');
1135
1136
  let channel = undefined;
@@ -385,13 +385,13 @@ class ndax extends ndax$1 {
385
385
  const firstBidAsk = this.safeValue(payload, 0, []);
386
386
  const marketId = this.safeString(firstBidAsk, 7);
387
387
  if (marketId === undefined) {
388
- return message;
388
+ return;
389
389
  }
390
390
  const market = this.safeMarket(marketId);
391
391
  const symbol = market['symbol'];
392
392
  const orderbook = this.safeValue(this.orderbooks, symbol);
393
393
  if (orderbook === undefined) {
394
- return message;
394
+ return;
395
395
  }
396
396
  let timestamp = undefined;
397
397
  let nonce = undefined;
@@ -485,11 +485,8 @@ class ndax extends ndax$1 {
485
485
  const subscription = this.safeValue(subscriptionsById, id);
486
486
  if (subscription !== undefined) {
487
487
  const method = this.safeValue(subscription, 'method');
488
- if (method === undefined) {
489
- return message;
490
- }
491
- else {
492
- return method.call(this, client, message, subscription);
488
+ if (method !== undefined) {
489
+ method.call(this, client, message, subscription);
493
490
  }
494
491
  }
495
492
  }
@@ -518,7 +515,7 @@ class ndax extends ndax$1 {
518
515
  //
519
516
  const payload = this.safeString(message, 'o');
520
517
  if (payload === undefined) {
521
- return message;
518
+ return;
522
519
  }
523
520
  message['o'] = JSON.parse(payload);
524
521
  const methods = {
@@ -533,11 +530,8 @@ class ndax extends ndax$1 {
533
530
  };
534
531
  const event = this.safeString(message, 'n');
535
532
  const method = this.safeValue(methods, event);
536
- if (method === undefined) {
537
- return message;
538
- }
539
- else {
540
- return method.call(this, client, message);
533
+ if (method !== undefined) {
534
+ method.call(this, client, message);
541
535
  }
542
536
  }
543
537
  }
@@ -475,7 +475,7 @@ class okcoin extends okcoin$1 {
475
475
  };
476
476
  this.spawn(this.watch, url, messageHash, request, messageHash, future);
477
477
  }
478
- return await future;
478
+ return future;
479
479
  }
480
480
  async watchBalance(params = {}) {
481
481
  /**
@@ -708,7 +708,8 @@ class okcoin extends okcoin$1 {
708
708
  // }
709
709
  //
710
710
  if (message === 'pong') {
711
- return this.handlePong(client, message);
711
+ this.handlePong(client, message);
712
+ return;
712
713
  }
713
714
  const table = this.safeString(message, 'table');
714
715
  if (table === undefined) {
@@ -721,11 +722,8 @@ class okcoin extends okcoin$1 {
721
722
  'subscribe': this.handleSubscriptionStatus,
722
723
  };
723
724
  const method = this.safeValue(methods, event);
724
- if (method === undefined) {
725
- return message;
726
- }
727
- else {
728
- return method.call(this, client, message);
725
+ if (method !== undefined) {
726
+ method.call(this, client, message);
729
727
  }
730
728
  }
731
729
  }
@@ -747,11 +745,8 @@ class okcoin extends okcoin$1 {
747
745
  if (name.indexOf('candle') >= 0) {
748
746
  method = this.handleOHLCV;
749
747
  }
750
- if (method === undefined) {
751
- return message;
752
- }
753
- else {
754
- return method.call(this, client, message);
748
+ if (method !== undefined) {
749
+ method.call(this, client, message);
755
750
  }
756
751
  }
757
752
  }
@@ -755,7 +755,7 @@ class okx extends okx$1 {
755
755
  const message = this.extend(request, params);
756
756
  this.watch(url, messageHash, message, messageHash);
757
757
  }
758
- return future;
758
+ return await future;
759
759
  }
760
760
  async watchBalance(params = {}) {
761
761
  /**
@@ -1561,7 +1561,8 @@ class okx extends okx$1 {
1561
1561
  //
1562
1562
  //
1563
1563
  if (message === 'pong') {
1564
- return this.handlePong(client, message);
1564
+ this.handlePong(client, message);
1565
+ return;
1565
1566
  }
1566
1567
  // const table = this.safeString (message, 'table');
1567
1568
  // if (table === undefined) {
@@ -1580,11 +1581,8 @@ class okx extends okx$1 {
1580
1581
  'mass-cancel': this.handleCancelAllOrders,
1581
1582
  };
1582
1583
  const method = this.safeValue(methods, event);
1583
- if (method === undefined) {
1584
- return message;
1585
- }
1586
- else {
1587
- return method.call(this, client, message);
1584
+ if (method !== undefined) {
1585
+ method.call(this, client, message);
1588
1586
  }
1589
1587
  }
1590
1588
  else {
@@ -1612,12 +1610,9 @@ class okx extends okx$1 {
1612
1610
  if (channel.indexOf('candle') === 0) {
1613
1611
  this.handleOHLCV(client, message);
1614
1612
  }
1615
- else {
1616
- return message;
1617
- }
1618
1613
  }
1619
1614
  else {
1620
- return method.call(this, client, message);
1615
+ method.call(this, client, message);
1621
1616
  }
1622
1617
  }
1623
1618
  }
@@ -362,26 +362,26 @@ class onetrading extends onetrading$1 {
362
362
  const dateTime = this.safeString(message, 'time');
363
363
  const timestamp = this.parse8601(dateTime);
364
364
  const channel = 'book:' + symbol;
365
- let storedOrderBook = this.safeValue(this.orderbooks, symbol);
366
- if (storedOrderBook === undefined) {
367
- storedOrderBook = this.orderBook({});
365
+ let orderbook = this.safeValue(this.orderbooks, symbol);
366
+ if (orderbook === undefined) {
367
+ orderbook = this.orderBook({});
368
368
  }
369
369
  if (type === 'ORDER_BOOK_SNAPSHOT') {
370
370
  const snapshot = this.parseOrderBook(message, symbol, timestamp, 'bids', 'asks');
371
- storedOrderBook.reset(snapshot);
371
+ orderbook.reset(snapshot);
372
372
  }
373
373
  else if (type === 'ORDER_BOOK_UPDATE') {
374
374
  const changes = this.safeValue(message, 'changes', []);
375
- this.handleDeltas(storedOrderBook, changes);
375
+ this.handleDeltas(orderbook, changes);
376
376
  }
377
377
  else {
378
378
  throw new errors.NotSupported(this.id + ' watchOrderBook() did not recognize message type ' + type);
379
379
  }
380
- storedOrderBook['nonce'] = timestamp;
381
- storedOrderBook['timestamp'] = timestamp;
382
- storedOrderBook['datetime'] = this.iso8601(timestamp);
383
- this.orderbooks[symbol] = storedOrderBook;
384
- client.resolve(storedOrderBook, channel);
380
+ orderbook['nonce'] = timestamp;
381
+ orderbook['timestamp'] = timestamp;
382
+ orderbook['datetime'] = this.iso8601(timestamp);
383
+ this.orderbooks[symbol] = orderbook;
384
+ client.resolve(orderbook, channel);
385
385
  }
386
386
  handleDelta(orderbook, delta) {
387
387
  //
@@ -967,13 +967,14 @@ class onetrading extends onetrading$1 {
967
967
  if (updateType === 'ORDER_CLOSED' && filled === 0) {
968
968
  status = 'canceled';
969
969
  }
970
- orders.append({
970
+ const orderObject = {
971
971
  'id': orderId,
972
972
  'symbol': symbol,
973
973
  'status': status,
974
974
  'timestamp': this.parse8601(datetime),
975
975
  'datetime': datetime,
976
- });
976
+ };
977
+ orders.append(orderObject);
977
978
  }
978
979
  else {
979
980
  const parsed = this.parseOrder(update);
@@ -1210,7 +1211,8 @@ class onetrading extends onetrading$1 {
1210
1211
  handleMessage(client, message) {
1211
1212
  const error = this.safeValue(message, 'error');
1212
1213
  if (error !== undefined) {
1213
- return this.handleErrorMessage(client, message);
1214
+ this.handleErrorMessage(client, message);
1215
+ return;
1214
1216
  }
1215
1217
  const type = this.safeValue(message, 'type');
1216
1218
  const handlers = {
@@ -1241,9 +1243,8 @@ class onetrading extends onetrading$1 {
1241
1243
  };
1242
1244
  const handler = this.safeValue(handlers, type);
1243
1245
  if (handler !== undefined) {
1244
- return handler.call(this, client, message);
1246
+ handler.call(this, client, message);
1245
1247
  }
1246
- throw new errors.NotSupported(this.id + ' no handler found for this message ' + this.json(message));
1247
1248
  }
1248
1249
  handlePricePointUpdates(client, message) {
1249
1250
  //
@@ -362,7 +362,8 @@ class p2b extends p2b$1 {
362
362
  const bid = this.safeValue(bids, i);
363
363
  const price = this.safeNumber(bid, 0);
364
364
  const amount = this.safeNumber(bid, 1);
365
- orderbook['bids'].store(price, amount);
365
+ const bookSide = orderbook['bids'];
366
+ bookSide.store(price, amount);
366
367
  }
367
368
  }
368
369
  if (asks !== undefined) {
@@ -370,7 +371,8 @@ class p2b extends p2b$1 {
370
371
  const ask = this.safeValue(asks, i);
371
372
  const price = this.safeNumber(ask, 0);
372
373
  const amount = this.safeNumber(ask, 1);
373
- orderbook['asks'].store(price, amount);
374
+ const bookside = orderbook['asks'];
375
+ bookside.store(price, amount);
374
376
  }
375
377
  }
376
378
  orderbook['symbol'] = symbol;
@@ -395,7 +397,7 @@ class p2b extends p2b$1 {
395
397
  };
396
398
  const endpoint = this.safeValue(methods, method);
397
399
  if (endpoint !== undefined) {
398
- return endpoint.call(this, client, message);
400
+ endpoint.call(this, client, message);
399
401
  }
400
402
  }
401
403
  handleErrorMessage(client, message) {
@@ -630,13 +630,13 @@ class phemex extends phemex$1 {
630
630
  }
631
631
  return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
632
632
  }
633
- handleDelta(bookside, delta, market = undefined) {
633
+ customHandleDelta(bookside, delta, market = undefined) {
634
634
  const bidAsk = this.customParseBidAsk(delta, 0, 1, market);
635
635
  bookside.storeArray(bidAsk);
636
636
  }
637
- handleDeltas(bookside, deltas, market = undefined) {
637
+ customHandleDeltas(bookside, deltas, market = undefined) {
638
638
  for (let i = 0; i < deltas.length; i++) {
639
- this.handleDelta(bookside, deltas[i], market);
639
+ this.customHandleDelta(bookside, deltas[i], market);
640
640
  }
641
641
  }
642
642
  handleOrderBook(client, message) {
@@ -706,8 +706,8 @@ class phemex extends phemex$1 {
706
706
  const changes = this.safeValue2(message, 'book', 'orderbook_p', {});
707
707
  const asks = this.safeValue(changes, 'asks', []);
708
708
  const bids = this.safeValue(changes, 'bids', []);
709
- this.handleDeltas(orderbook['asks'], asks, market);
710
- this.handleDeltas(orderbook['bids'], bids, market);
709
+ this.customHandleDeltas(orderbook['asks'], asks, market);
710
+ this.customHandleDeltas(orderbook['bids'], bids, market);
711
711
  orderbook['nonce'] = nonce;
712
712
  orderbook['timestamp'] = timestamp;
713
713
  orderbook['datetime'] = this.iso8601(timestamp);
@@ -1403,21 +1403,26 @@ class phemex extends phemex$1 {
1403
1403
  const method = client.subscriptions[id];
1404
1404
  delete client.subscriptions[id];
1405
1405
  if (method !== true) {
1406
- return method.call(this, client, message);
1406
+ method.call(this, client, message);
1407
+ return;
1407
1408
  }
1408
1409
  }
1409
1410
  const methodName = this.safeString(message, 'method', '');
1410
1411
  if (('market24h' in message) || ('spot_market24h' in message) || (methodName.indexOf('perp_market24h_pack_p') >= 0)) {
1411
- return this.handleTicker(client, message);
1412
+ this.handleTicker(client, message);
1413
+ return;
1412
1414
  }
1413
1415
  else if (('trades' in message) || ('trades_p' in message)) {
1414
- return this.handleTrades(client, message);
1416
+ this.handleTrades(client, message);
1417
+ return;
1415
1418
  }
1416
1419
  else if (('kline' in message) || ('kline_p' in message)) {
1417
- return this.handleOHLCV(client, message);
1420
+ this.handleOHLCV(client, message);
1421
+ return;
1418
1422
  }
1419
1423
  else if (('book' in message) || ('orderbook_p' in message)) {
1420
- return this.handleOrderBook(client, message);
1424
+ this.handleOrderBook(client, message);
1425
+ return;
1421
1426
  }
1422
1427
  if (('orders' in message) || ('orders_p' in message)) {
1423
1428
  const orders = this.safeValue2(message, 'orders', 'orders_p', {});
@@ -1504,7 +1509,7 @@ class phemex extends phemex$1 {
1504
1509
  future = this.watch(url, messageHash, message);
1505
1510
  client.subscriptions[messageHash] = future;
1506
1511
  }
1507
- return await future;
1512
+ return future;
1508
1513
  }
1509
1514
  }
1510
1515
 
@@ -1039,7 +1039,8 @@ class poloniex extends poloniex$1 {
1039
1039
  const bid = this.safeValue(bids, j);
1040
1040
  const price = this.safeNumber(bid, 0);
1041
1041
  const amount = this.safeNumber(bid, 1);
1042
- orderbook['bids'].store(price, amount);
1042
+ const bidsSide = orderbook['bids'];
1043
+ bidsSide.store(price, amount);
1043
1044
  }
1044
1045
  }
1045
1046
  if (asks !== undefined) {
@@ -1047,7 +1048,8 @@ class poloniex extends poloniex$1 {
1047
1048
  const ask = this.safeValue(asks, j);
1048
1049
  const price = this.safeNumber(ask, 0);
1049
1050
  const amount = this.safeNumber(ask, 1);
1050
- orderbook['asks'].store(price, amount);
1051
+ const asksSide = orderbook['asks'];
1052
+ asksSide.store(price, amount);
1051
1053
  }
1052
1054
  }
1053
1055
  orderbook['symbol'] = symbol;
@@ -1181,14 +1183,14 @@ class poloniex extends poloniex$1 {
1181
1183
  this.handleErrorMessage(client, item);
1182
1184
  }
1183
1185
  else {
1184
- return this.handleOrderRequest(client, message);
1186
+ this.handleOrderRequest(client, message);
1185
1187
  }
1186
1188
  }
1187
1189
  else {
1188
1190
  const data = this.safeValue(message, 'data', []);
1189
1191
  const dataLength = data.length;
1190
1192
  if (dataLength > 0) {
1191
- return method.call(this, client, message);
1193
+ method.call(this, client, message);
1192
1194
  }
1193
1195
  }
1194
1196
  }