ccxt 4.2.73 → 4.2.75

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 (309) hide show
  1. package/CHANGELOG.md +206 -10
  2. package/README.md +10 -9
  3. package/build.sh +1 -1
  4. package/dist/ccxt.browser.js +1042 -297
  5. package/dist/ccxt.browser.min.js +3 -3
  6. package/dist/cjs/ccxt.js +4 -1
  7. package/dist/cjs/src/abstract/tradeogre.js +9 -0
  8. package/dist/cjs/src/ascendex.js +3 -2
  9. package/dist/cjs/src/base/Exchange.js +1 -1
  10. package/dist/cjs/src/bitget.js +62 -50
  11. package/dist/cjs/src/bitmart.js +1 -0
  12. package/dist/cjs/src/bybit.js +90 -30
  13. package/dist/cjs/src/coinbaseinternational.js +1 -1
  14. package/dist/cjs/src/coinex.js +4 -3
  15. package/dist/cjs/src/gate.js +1 -0
  16. package/dist/cjs/src/htx.js +16 -9
  17. package/dist/cjs/src/hyperliquid.js +2 -1
  18. package/dist/cjs/src/kraken.js +3 -3
  19. package/dist/cjs/src/kucoin.js +1 -1
  20. package/dist/cjs/src/pro/krakenfutures.js +8 -7
  21. package/dist/cjs/src/tradeogre.js +632 -0
  22. package/examples/README.md +308 -0
  23. package/examples/ccxt.pro/html/watchTicker.html +51 -0
  24. package/examples/ccxt.pro/js/binance-fetch-balance-snapshot-watch-balance-updates.js +55 -0
  25. package/examples/ccxt.pro/js/binance-https-proxy.js +48 -0
  26. package/examples/ccxt.pro/js/binance-watch-ohlcv-many-symbols-continuously.js +38 -0
  27. package/examples/ccxt.pro/js/binance-watch-ohlcv-many-symbols.js +64 -0
  28. package/examples/ccxt.pro/js/binance-watch-ticker-many-symbols.js +62 -0
  29. package/examples/ccxt.pro/js/build-ohlcv-many-symbols.js +68 -0
  30. package/examples/ccxt.pro/js/calculate-ohlcvs-from-trades-warmup.js +82 -0
  31. package/examples/ccxt.pro/js/calculate-ohlcvs-from-trades.js +59 -0
  32. package/examples/ccxt.pro/js/exchange-capabitities.js +72 -0
  33. package/examples/ccxt.pro/js/exchange-close.js +46 -0
  34. package/examples/ccxt.pro/js/gateio-swap-watch-many-orderbooks.js +30 -0
  35. package/examples/ccxt.pro/js/gateio-watch-balance.js +23 -0
  36. package/examples/ccxt.pro/js/gateio-watch-order-book.js +71 -0
  37. package/examples/ccxt.pro/js/graceful-shutdown.js +43 -0
  38. package/examples/ccxt.pro/js/many-exchanges-many-streams.js +37 -0
  39. package/examples/ccxt.pro/js/okex-create-futures-order.js +48 -0
  40. package/examples/ccxt.pro/js/okex-watch-balance-and-create-order.js +54 -0
  41. package/examples/ccxt.pro/js/okx-watch-tickers.js +31 -0
  42. package/examples/ccxt.pro/js/one-exchange-many-different-streams.js +46 -0
  43. package/examples/ccxt.pro/js/one-exchange-many-streams-2.js +26 -0
  44. package/examples/ccxt.pro/js/one-exchange-many-streams.js +28 -0
  45. package/examples/ccxt.pro/js/socks-binance-watch-orderbook.js +30 -0
  46. package/examples/ccxt.pro/js/watch-fetch-many-exchanges-many-ordersbooks.js +40 -0
  47. package/examples/ccxt.pro/js/watch-many-exchanges-many-ordersbooks.js +38 -0
  48. package/examples/ccxt.pro/js/watch-many-exchanges-many-symbols.js +40 -0
  49. package/examples/ccxt.pro/js/watch-many-orderbooks.js +27 -0
  50. package/examples/ccxt.pro/js/watch-new-trades-only.js +43 -0
  51. package/examples/ccxt.pro/js/watch-new-trades.js +42 -0
  52. package/examples/ccxt.pro/js/watch-trades-many-symbols.js +29 -0
  53. package/examples/ccxt.pro/js/watch-vs-fetch.js +29 -0
  54. package/examples/cs/Examples.sln +22 -0
  55. package/examples/cs/c#.csproj +19 -0
  56. package/examples/html/basic-cors-proxy.html +46 -0
  57. package/examples/html/basic-inheritance.html +47 -0
  58. package/examples/html/basic-poller.html +52 -0
  59. package/examples/html/basic-rate-limiting.html +49 -0
  60. package/examples/html/basic.html +43 -0
  61. package/examples/html/binance-cors-proxy.html +28 -0
  62. package/examples/html/bitmex-browser-cors-proxy.js +7 -0
  63. package/examples/html/bitmex-cors.html +46 -0
  64. package/examples/html/tradingview-charts.html +61 -0
  65. package/examples/html/webworker/index.html +97 -0
  66. package/examples/html/webworker/worker.js +43 -0
  67. package/examples/js/README.md +15 -0
  68. package/examples/js/advanced-error-handling.js +39 -0
  69. package/examples/js/aggregate-orderbook.js +54 -0
  70. package/examples/js/arbitrage-pairs.js +130 -0
  71. package/examples/js/basic-chart.js +29 -0
  72. package/examples/js/basic-orderbook-polling.js +13 -0
  73. package/examples/js/bcc-vs-bch.js +115 -0
  74. package/examples/js/binance-fetch-all-deposits.js +45 -0
  75. package/examples/js/binance-fetch-ohlcv-many-symbols-async-await.js +34 -0
  76. package/examples/js/binance-fetch-ohlcv-many-symbols-promise-then-callbacks.js +33 -0
  77. package/examples/js/binance-fetchTicker-delivery-vs-future.js +31 -0
  78. package/examples/js/binance-futures-transfer-from-sub-account-to-master.js +41 -0
  79. package/examples/js/binance-margin-stop-order.js +39 -0
  80. package/examples/js/binance-server-time.js +34 -0
  81. package/examples/js/binance-universal-transfer.js +16 -0
  82. package/examples/js/bitfinex-fetch-trades.js +35 -0
  83. package/examples/js/bitfinex2-fetch-trades.js +35 -0
  84. package/examples/js/bitmex-browser-cors-proxy.js +7 -0
  85. package/examples/js/bitpanda-fetchMyTrades-reduce.js +36 -0
  86. package/examples/js/bitrue-fetch-balance.js +28 -0
  87. package/examples/js/bitstamp-private-api.js +115 -0
  88. package/examples/js/bitstamp-public-api.js +39 -0
  89. package/examples/js/bittrex-balance.js +50 -0
  90. package/examples/js/bittrex-fetch-closed-orders-history.js +69 -0
  91. package/examples/js/blockchaincom-withdrawal.js +59 -0
  92. package/examples/js/build-ohlcv-bars.js +48 -0
  93. package/examples/js/builtin-rate-limiting-rest-poller.js +25 -0
  94. package/examples/js/bybit-trailing.js +62 -0
  95. package/examples/js/bybit-updated.cjs +154 -0
  96. package/examples/js/cli.js +405 -0
  97. package/examples/js/coinbase-fetch-all-balances.js +36 -0
  98. package/examples/js/coinex-fetch-all-deposit-addresses-using-fetchDepositAddress.js +47 -0
  99. package/examples/js/coinex-futures.js +75 -0
  100. package/examples/js/coinone-fetch-tickers.js +54 -0
  101. package/examples/js/coinone-markets.js +16 -0
  102. package/examples/js/compare-two-exchanges-capabilities.js +36 -0
  103. package/examples/js/cors-proxy.js +5 -0
  104. package/examples/js/create-order-handle-errors.js +55 -0
  105. package/examples/js/create-order-position-with-takeprofit-stoploss.js +71 -0
  106. package/examples/js/create-order-with-retry.js +65 -0
  107. package/examples/js/create-order-ws-example.js +25 -0
  108. package/examples/js/create-orders-example.js +17 -0
  109. package/examples/js/create-trailing-amount-order.js +36 -0
  110. package/examples/js/create-trailing-percent-order.js +36 -0
  111. package/examples/js/credentials.json +5 -0
  112. package/examples/js/custom-proxy-agent-for-js.js +10 -0
  113. package/examples/js/custom-proxy-url.js +23 -0
  114. package/examples/js/delta-maintenance-margin-rate-max-leverage.js +60 -0
  115. package/examples/js/env-variables.js +26 -0
  116. package/examples/js/error-handling.js +89 -0
  117. package/examples/js/exchange-capabilities.js +135 -0
  118. package/examples/js/exchanges-by-volume.js +60 -0
  119. package/examples/js/exchanges.js +40 -0
  120. package/examples/js/fetch-all-balances.js +219 -0
  121. package/examples/js/fetch-all-tickers-to-files-2.js +53 -0
  122. package/examples/js/fetch-all-tickers-to-files.js +77 -0
  123. package/examples/js/fetch-balance.js +28 -0
  124. package/examples/js/fetch-create-deposit-address.js +101 -0
  125. package/examples/js/fetch-from-many-exchanges-simultaneously.js +21 -0
  126. package/examples/js/fetch-funding-rate-history.js +25 -0
  127. package/examples/js/fetch-futures/prettier.config.js +5 -0
  128. package/examples/js/fetch-futures/src/index.js +25 -0
  129. package/examples/js/fetch-ohlcv-from-to-mark-index-premium.js +72 -0
  130. package/examples/js/fetch-ohlcv-many-exchanges-continuosly.js +39 -0
  131. package/examples/js/fetch-ohlcv.js +16 -0
  132. package/examples/js/fetch-okex-futures.js +22 -0
  133. package/examples/js/fetch-orders.js +27 -0
  134. package/examples/js/fetch-ticker-from-multiple-exchanges.js +35 -0
  135. package/examples/js/fetch-ticker-where-available.js +75 -0
  136. package/examples/js/fetch-tickers/build/index.js +19 -0
  137. package/examples/js/fetch-tickers/prettier.config.js +5 -0
  138. package/examples/js/fetch-tickers/src/index.js +17 -0
  139. package/examples/js/gateio-create-batch-order.js +43 -0
  140. package/examples/js/gateio-futures.js +49 -0
  141. package/examples/js/gateio-open-close-contract.js +49 -0
  142. package/examples/js/gateio-swaps.js +74 -0
  143. package/examples/js/gdax-fetch-trades-pagination.js +29 -0
  144. package/examples/js/hitbtc2-withdraw.js +61 -0
  145. package/examples/js/how-to-import-one-exchange-esm.js +10 -0
  146. package/examples/js/huobi-futures.js +71 -0
  147. package/examples/js/huobi-open-close-contract.js +63 -0
  148. package/examples/js/huobi-swaps.js +70 -0
  149. package/examples/js/huobipro-market-buy-sell-fetch-trading-limits.js +98 -0
  150. package/examples/js/hybridCJSExample.cjs +19 -0
  151. package/examples/js/hybridESMExample.js +19 -0
  152. package/examples/js/idex-fetch-balance.js +13 -0
  153. package/examples/js/instantiate-all-at-once.js +46 -0
  154. package/examples/js/instantiate-all-from-json.js +31 -0
  155. package/examples/js/kraken-create-and-close-position.js +54 -0
  156. package/examples/js/kraken-fetch-order-trades.js +33 -0
  157. package/examples/js/kraken-margin-trading.js +89 -0
  158. package/examples/js/kucoin-rate-limit.js +38 -0
  159. package/examples/js/latoken-example.js +108 -0
  160. package/examples/js/live-orderbook.js +106 -0
  161. package/examples/js/live-ticker.js +80 -0
  162. package/examples/js/live-tickers.js +74 -0
  163. package/examples/js/load-all-contracts.js +41 -0
  164. package/examples/js/load-all-symbols-at-once.js +69 -0
  165. package/examples/js/load-all-tickers-at-once.js +91 -0
  166. package/examples/js/load-markets-to-files.js +57 -0
  167. package/examples/js/looping-over-all-symbols-of-specific-exchanges.js +61 -0
  168. package/examples/js/looping-over-specific-symbols-of-all-exchanges.js +91 -0
  169. package/examples/js/margin-loan-borrow-buy-sell-repay.js +70 -0
  170. package/examples/js/market-status-and-currency-status.js +29 -0
  171. package/examples/js/ohlcv-console-chart.js +29 -0
  172. package/examples/js/okex-fetch-closed-orders-archive.js +31 -0
  173. package/examples/js/okex-transfer.js +51 -0
  174. package/examples/js/okx-poll-fetch-my-trades.js +37 -0
  175. package/examples/js/okx-poll-rate-limit.js +48 -0
  176. package/examples/js/order-book-extra-level-depth-param.js +20 -0
  177. package/examples/js/phemex-create-order-position-with-takeprofit-stoploss.js +49 -0
  178. package/examples/js/poll-ohlcv.js +43 -0
  179. package/examples/js/poloniex-fetch-order-books.js +35 -0
  180. package/examples/js/poloniex-limits-amount-min.js +62 -0
  181. package/examples/js/proxy-round-robin.js +98 -0
  182. package/examples/js/proxy-usage.js +32 -0
  183. package/examples/js/sample-local-proxy-server-with-cors.js +12 -0
  184. package/examples/js/search-all-exchanges.js +159 -0
  185. package/examples/js/shared-load-markets.js +80 -0
  186. package/examples/js/sort-swap-markets-by-hourly-price-change.js +55 -0
  187. package/examples/js/symbols.js +110 -0
  188. package/examples/js/theocean.js +41 -0
  189. package/examples/js/tickers.js +106 -0
  190. package/examples/js/validate-paginated-data.js +61 -0
  191. package/examples/js/watch-OHLCV-For-Symbols.js +15 -0
  192. package/examples/js/watch-OHLCV.js +12 -0
  193. package/examples/js/watch-OrderBook-For-Symbols.js +11 -0
  194. package/examples/js/watch-Trades-For-Symbols.js +11 -0
  195. package/examples/js/watch-tickers.js +11 -0
  196. package/examples/js/watchOHLCVForSymbols.js +15 -0
  197. package/examples/js/watchOrderBookForSymbols.js +11 -0
  198. package/examples/js/watchPositions-many-exchanges-continuosly.d.ts +2 -0
  199. package/examples/js/watchPositions-many-exchanges-continuosly.d.ts.map +1 -0
  200. package/examples/js/watchPositions-many-exchanges-continuosly.js +49 -0
  201. package/examples/js/watchPositions.d.ts +2 -0
  202. package/examples/js/watchPositions.d.ts.map +1 -0
  203. package/examples/js/watchPositions.js +13 -0
  204. package/examples/js/watchPositionsForSymbols.d.ts +2 -0
  205. package/examples/js/watchPositionsForSymbols.d.ts.map +1 -0
  206. package/examples/js/watchPositionsForSymbols.js +14 -0
  207. package/examples/js/watchTradesForSymbols.js +11 -0
  208. package/examples/js/withdraw-from-one-exchange-to-another.js +50 -0
  209. package/examples/php/README.md +7 -0
  210. package/examples/py/README.md +15 -0
  211. package/examples/py/playing_with_ccxt_example.ipynb +222 -0
  212. package/examples/ts/.eslintrc +111 -0
  213. package/examples/ts/build-ohlcv-bars.ts +53 -0
  214. package/examples/ts/cli.ts +397 -0
  215. package/examples/ts/compare-two-exchanges-capabilities.ts +36 -0
  216. package/examples/ts/create-order-position-with-takeprofit-stoploss.ts +89 -0
  217. package/examples/ts/create-order-ws-example.ts +33 -0
  218. package/examples/ts/create-orders-example.ts +21 -0
  219. package/examples/ts/create-trailing-amount-order.ts +37 -0
  220. package/examples/ts/create-trailing-percent-order.ts +37 -0
  221. package/examples/ts/custom-proxy-agent-for-js.ts +14 -0
  222. package/examples/ts/fetch-futures/package-lock.json +116 -0
  223. package/examples/ts/fetch-futures/package.json +34 -0
  224. package/examples/ts/fetch-futures/prettier.config.js +4 -0
  225. package/examples/ts/fetch-futures/src/index.ts +28 -0
  226. package/examples/ts/fetch-futures/tsconfig.json +28 -0
  227. package/examples/ts/fetch-ohlcv-many-exchanges-continuosly.ts +44 -0
  228. package/examples/ts/fetch-ohlcv.ts +17 -0
  229. package/examples/ts/fetch-tickers/package-lock.json +116 -0
  230. package/examples/ts/fetch-tickers/package.json +34 -0
  231. package/examples/ts/fetch-tickers/prettier.config.js +4 -0
  232. package/examples/ts/fetch-tickers/src/index.ts +21 -0
  233. package/examples/ts/fetch-tickers/tsconfig.json +28 -0
  234. package/examples/ts/how-to-import-one-exchange-esm.ts +11 -0
  235. package/examples/ts/kraken-create-and-close-position.ts +69 -0
  236. package/examples/ts/margin-loan-borrow-buy-sell-repay.ts +72 -0
  237. package/examples/ts/nextjs-page-router/.eslintrc.json +3 -0
  238. package/examples/ts/nextjs-page-router/README.md +43 -0
  239. package/examples/ts/nextjs-page-router/next.config.js +6 -0
  240. package/examples/ts/nextjs-page-router/package-lock.json +7425 -0
  241. package/examples/ts/nextjs-page-router/package.json +28 -0
  242. package/examples/ts/nextjs-page-router/postcss.config.js +6 -0
  243. package/examples/ts/nextjs-page-router/public/favicon.ico +0 -0
  244. package/examples/ts/nextjs-page-router/src/pages/_app.tsx +6 -0
  245. package/examples/ts/nextjs-page-router/src/pages/_document.tsx +13 -0
  246. package/examples/ts/nextjs-page-router/src/pages/balance.tsx +46 -0
  247. package/examples/ts/nextjs-page-router/src/pages/index.tsx +8 -0
  248. package/examples/ts/nextjs-page-router/src/pages/tickers.tsx +61 -0
  249. package/examples/ts/nextjs-page-router/src/styles/globals.css +27 -0
  250. package/examples/ts/nextjs-page-router/tailwind.config.ts +20 -0
  251. package/examples/ts/nextjs-page-router/tsconfig.json +22 -0
  252. package/examples/ts/phemex-create-order-position-with-takeprofit-stoploss.ts +62 -0
  253. package/examples/ts/proxy-usage.ts +41 -0
  254. package/examples/ts/sample-local-proxy-server-with-cors.ts +15 -0
  255. package/examples/ts/watch-OHLCV-For-Symbols.ts +17 -0
  256. package/examples/ts/watch-OHLCV.ts +14 -0
  257. package/examples/ts/watch-OrderBook-For-Symbols.ts +13 -0
  258. package/examples/ts/watch-Trades-For-Symbols.ts +13 -0
  259. package/examples/ts/watch-tickers.ts +13 -0
  260. package/examples/ts/watchPositions-many-exchanges-continuosly.ts +53 -0
  261. package/examples/ts/watchPositions.ts +15 -0
  262. package/examples/ts/watchPositionsForSymbols.ts +16 -0
  263. package/examples/tsconfig.json +27 -0
  264. package/js/ccxt.d.ts +5 -2
  265. package/js/ccxt.js +4 -2
  266. package/js/src/abstract/tradeogre.d.ts +19 -0
  267. package/js/src/abstract/tradeogre.js +11 -0
  268. package/js/src/ascendex.d.ts +2 -7
  269. package/js/src/ascendex.js +3 -2
  270. package/js/src/base/Exchange.d.ts +7 -7
  271. package/js/src/base/Exchange.js +1 -1
  272. package/js/src/base/types.d.ts +7 -1
  273. package/js/src/binance.d.ts +1 -1
  274. package/js/src/bitget.js +62 -50
  275. package/js/src/bitmart.d.ts +1 -1
  276. package/js/src/bitmart.js +2 -1
  277. package/js/src/bybit.d.ts +3 -1
  278. package/js/src/bybit.js +90 -30
  279. package/js/src/coinbase.d.ts +4 -4
  280. package/js/src/coinbaseinternational.d.ts +1 -1
  281. package/js/src/coinbaseinternational.js +1 -1
  282. package/js/src/coinbasepro.d.ts +2 -2
  283. package/js/src/coinex.js +4 -3
  284. package/js/src/coinlist.d.ts +2 -2
  285. package/js/src/cryptocom.d.ts +2 -2
  286. package/js/src/currencycom.d.ts +2 -2
  287. package/js/src/deribit.d.ts +2 -2
  288. package/js/src/gate.d.ts +1 -1
  289. package/js/src/gate.js +1 -0
  290. package/js/src/htx.d.ts +2 -2
  291. package/js/src/htx.js +16 -9
  292. package/js/src/huobijp.d.ts +2 -2
  293. package/js/src/hyperliquid.js +2 -1
  294. package/js/src/kraken.d.ts +1 -1
  295. package/js/src/kraken.js +3 -3
  296. package/js/src/kucoin.d.ts +3 -3
  297. package/js/src/kucoin.js +1 -1
  298. package/js/src/luno.d.ts +2 -2
  299. package/js/src/mexc.d.ts +3 -3
  300. package/js/src/ndax.d.ts +2 -2
  301. package/js/src/novadax.d.ts +2 -2
  302. package/js/src/okx.d.ts +2 -2
  303. package/js/src/pro/bitfinex2.d.ts +1 -1
  304. package/js/src/pro/krakenfutures.js +8 -7
  305. package/js/src/tradeogre.d.ts +32 -0
  306. package/js/src/tradeogre.js +633 -0
  307. package/js/src/woo.d.ts +2 -2
  308. package/package.json +4 -1
  309. package/skip-tests.json +219 -424
package/dist/cjs/ccxt.js CHANGED
@@ -106,6 +106,7 @@ var poloniexfutures = require('./src/poloniexfutures.js');
106
106
  var probit = require('./src/probit.js');
107
107
  var timex = require('./src/timex.js');
108
108
  var tokocrypto = require('./src/tokocrypto.js');
109
+ var tradeogre = require('./src/tradeogre.js');
109
110
  var upbit = require('./src/upbit.js');
110
111
  var wavesexchange = require('./src/wavesexchange.js');
111
112
  var wazirx = require('./src/wazirx.js');
@@ -180,7 +181,7 @@ var woo$1 = require('./src/pro/woo.js');
180
181
 
181
182
  //-----------------------------------------------------------------------------
182
183
  // this is updated by vss.js when building
183
- const version = '4.2.73';
184
+ const version = '4.2.75';
184
185
  Exchange["default"].ccxtVersion = version;
185
186
  const exchanges = {
186
187
  'ace': ace,
@@ -277,6 +278,7 @@ const exchanges = {
277
278
  'probit': probit,
278
279
  'timex': timex,
279
280
  'tokocrypto': tokocrypto,
281
+ 'tradeogre': tradeogre,
280
282
  'upbit': upbit,
281
283
  'wavesexchange': wavesexchange,
282
284
  'wazirx': wazirx,
@@ -486,6 +488,7 @@ exports.poloniexfutures = poloniexfutures;
486
488
  exports.probit = probit;
487
489
  exports.timex = timex;
488
490
  exports.tokocrypto = tokocrypto;
491
+ exports.tradeogre = tradeogre;
489
492
  exports.upbit = upbit;
490
493
  exports.wavesexchange = wavesexchange;
491
494
  exports.wazirx = wazirx;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var Exchange$1 = require('../base/Exchange.js');
4
+
5
+ // -------------------------------------------------------------------------------
6
+ class Exchange extends Exchange$1["default"] {
7
+ }
8
+
9
+ module.exports = Exchange;
@@ -750,7 +750,7 @@ class ascendex extends ascendex$1 {
750
750
  {
751
751
  'id': accountGroup,
752
752
  'type': undefined,
753
- 'currency': undefined,
753
+ 'code': undefined,
754
754
  'info': response,
755
755
  },
756
756
  ];
@@ -2730,7 +2730,8 @@ class ascendex extends ascendex$1 {
2730
2730
  if (Precise["default"].stringEq(notional, '0')) {
2731
2731
  notional = this.safeString(position, 'sellOpenOrderNotional');
2732
2732
  }
2733
- const marginMode = this.safeString(position, 'marginType');
2733
+ const marginType = this.safeString(position, 'marginType');
2734
+ const marginMode = (marginType === 'crossed') ? 'cross' : 'isolated';
2734
2735
  let collateral = undefined;
2735
2736
  if (marginMode === 'isolated') {
2736
2737
  collateral = this.safeString(position, 'isolatedMargin');
@@ -98,7 +98,7 @@ class Exchange {
98
98
  this.last_request_body = undefined;
99
99
  this.last_request_url = undefined;
100
100
  this.last_request_path = undefined;
101
- this.id = undefined;
101
+ this.id = 'Exchange';
102
102
  this.markets = undefined;
103
103
  this.status = undefined;
104
104
  this.rateLimit = undefined; // milliseconds
@@ -1340,10 +1340,10 @@ class bitget extends bitget$1 {
1340
1340
  },
1341
1341
  'fetchOHLCV': {
1342
1342
  'spot': {
1343
- 'method': 'publicSpotGetV2SpotMarketCandles', // or publicSpotGetV2SpotMarketHistoryCandles
1343
+ 'method': 'publicSpotGetV2SpotMarketCandles', // publicSpotGetV2SpotMarketCandles or publicSpotGetV2SpotMarketHistoryCandles
1344
1344
  },
1345
1345
  'swap': {
1346
- 'method': 'publicMixGetV2MixMarketCandles', // or publicMixGetV2MixMarketHistoryCandles or publicMixGetV2MixMarketHistoryIndexCandles or publicMixGetV2MixMarketHistoryMarkCandles
1346
+ 'method': 'publicMixGetV2MixMarketCandles', // publicMixGetV2MixMarketCandles or publicMixGetV2MixMarketHistoryCandles or publicMixGetV2MixMarketHistoryIndexCandles or publicMixGetV2MixMarketHistoryMarkCandles
1347
1347
  },
1348
1348
  'maxDaysPerTimeframe': {
1349
1349
  '1m': 30,
@@ -3313,11 +3313,13 @@ class bitget extends bitget$1 {
3313
3313
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
3314
3314
  */
3315
3315
  await this.loadMarkets();
3316
- const maxLimit = 1000; // max 1000
3316
+ const defaultLimit = 100; // default 100, max 1000
3317
+ const maxLimitForRecentEndpoint = 1000;
3318
+ const maxLimitForHistoryEndpoint = 200; // note, max 1000 bars are supported for "recent-candles" endpoint, but "historical-candles" support only max 200
3317
3319
  let paginate = false;
3318
3320
  [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
3319
3321
  if (paginate) {
3320
- return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxLimit);
3322
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxLimitForHistoryEndpoint);
3321
3323
  }
3322
3324
  const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
3323
3325
  let market = undefined;
@@ -3330,32 +3332,17 @@ class bitget extends bitget$1 {
3330
3332
  }
3331
3333
  const marketType = market['spot'] ? 'spot' : 'swap';
3332
3334
  const timeframes = this.options['timeframes'][marketType];
3333
- const selectedTimeframe = this.safeString(timeframes, timeframe, timeframe);
3335
+ const msInDay = 86400000;
3334
3336
  const duration = this.parseTimeframe(timeframe) * 1000;
3335
3337
  const request = {
3336
3338
  'symbol': market['id'],
3337
- 'granularity': selectedTimeframe,
3339
+ 'granularity': this.safeString(timeframes, timeframe, timeframe),
3338
3340
  };
3339
- const defaultLimit = 100; // by default, exchange returns 100 items
3340
- const msInDay = 1000 * 60 * 60 * 24;
3341
- if (limit !== undefined) {
3342
- limit = Math.min(limit, maxLimit);
3343
- request['limit'] = limit;
3344
- }
3345
3341
  const until = this.safeInteger2(params, 'until', 'till');
3342
+ const limitDefined = limit !== undefined;
3343
+ const sinceDefined = since !== undefined;
3344
+ const untilDefined = until !== undefined;
3346
3345
  params = this.omit(params, ['until', 'till']);
3347
- if (until !== undefined) {
3348
- request['endTime'] = until;
3349
- }
3350
- if (since !== undefined) {
3351
- request['startTime'] = since;
3352
- if (market['spot'] && (until === undefined)) {
3353
- // for spot we need to send "entTime" too
3354
- const limitForEnd = (limit !== undefined) ? limit : defaultLimit;
3355
- const calculatedEnd = this.sum(since, duration * limitForEnd);
3356
- request['endTime'] = calculatedEnd;
3357
- }
3358
- }
3359
3346
  let response = undefined;
3360
3347
  const now = this.milliseconds();
3361
3348
  // retrievable periods listed here:
@@ -3363,21 +3350,47 @@ class bitget extends bitget$1 {
3363
3350
  // - https://www.bitget.com/api-doc/contract/market/Get-Candle-Data#description
3364
3351
  const ohlcOptions = this.safeDict(this.options, 'fetchOHLCV', {});
3365
3352
  const retrievableDaysMap = this.safeDict(ohlcOptions, 'maxDaysPerTimeframe', {});
3366
- const maxRetrievableDaysForNonHistory = this.safeInteger(retrievableDaysMap, timeframe, 30); // default to safe minimum
3367
- const endpointTsBoundary = now - maxRetrievableDaysForNonHistory * msInDay;
3368
- // checks if we need history endpoint
3369
- let needsHistoryEndpoint = false;
3370
- const displaceByLimit = (limit === undefined) ? 0 : limit * duration;
3371
- if (since !== undefined && since < endpointTsBoundary) {
3372
- // if since it earlier than the allowed diapason
3373
- needsHistoryEndpoint = true;
3374
- }
3375
- else if (until !== undefined && until - displaceByLimit < endpointTsBoundary) {
3376
- // if until is earlier than the allowed diapason
3377
- needsHistoryEndpoint = true;
3353
+ const maxRetrievableDaysForRecent = this.safeInteger(retrievableDaysMap, timeframe, 30); // default to safe minimum
3354
+ const endpointTsBoundary = now - maxRetrievableDaysForRecent * msInDay;
3355
+ if (limitDefined) {
3356
+ limit = Math.min(limit, maxLimitForRecentEndpoint);
3357
+ request['limit'] = limit;
3378
3358
  }
3359
+ else {
3360
+ limit = defaultLimit;
3361
+ }
3362
+ const limitMultipliedDuration = limit * duration;
3363
+ // exchange aligns from endTime, so it's important, not startTime
3364
+ // startTime is supported only on "recent" endpoint, not on "historical" endpoint
3365
+ let calculatedStartTime = undefined;
3366
+ let calculatedEndTime = undefined;
3367
+ if (sinceDefined) {
3368
+ calculatedStartTime = since;
3369
+ request['startTime'] = since;
3370
+ if (!untilDefined) {
3371
+ calculatedEndTime = this.sum(calculatedStartTime, limitMultipliedDuration);
3372
+ request['endTime'] = calculatedEndTime;
3373
+ }
3374
+ }
3375
+ if (untilDefined) {
3376
+ calculatedEndTime = until;
3377
+ request['endTime'] = calculatedEndTime;
3378
+ if (!sinceDefined) {
3379
+ calculatedStartTime = calculatedEndTime - limitMultipliedDuration;
3380
+ // we do not need to set "startTime" here
3381
+ }
3382
+ }
3383
+ const historicalEndpointNeeded = (calculatedStartTime !== undefined) && (calculatedStartTime <= endpointTsBoundary);
3384
+ if (historicalEndpointNeeded) {
3385
+ // only for "historical-candles" - ensure we use correct max limit
3386
+ if (limitDefined) {
3387
+ request['limit'] = Math.min(limit, maxLimitForHistoryEndpoint);
3388
+ }
3389
+ }
3390
+ // make request
3379
3391
  if (market['spot']) {
3380
- if (needsHistoryEndpoint) {
3392
+ // checks if we need history endpoint
3393
+ if (historicalEndpointNeeded) {
3381
3394
  response = await this.publicSpotGetV2SpotMarketHistoryCandles(this.extend(request, params));
3382
3395
  }
3383
3396
  else {
@@ -3385,19 +3398,18 @@ class bitget extends bitget$1 {
3385
3398
  }
3386
3399
  }
3387
3400
  else {
3388
- const maxDistanceDaysForContracts = 90; // maximum 90 days allowed between start-end times
3389
- let distanceError = false;
3390
- if (limit !== undefined && limit * duration > maxDistanceDaysForContracts * msInDay) {
3391
- distanceError = true;
3392
- }
3393
- else if (since !== undefined && until !== undefined && until - since > maxDistanceDaysForContracts * msInDay) {
3394
- distanceError = true;
3395
- }
3396
- if (distanceError) {
3397
- throw new errors.BadRequest(this.id + ' fetchOHLCV() between start and end must be less than ' + maxDistanceDaysForContracts.toString() + ' days');
3401
+ const maxDistanceDaysForContracts = 90; // for contract, maximum 90 days allowed between start-end times
3402
+ // only correct the request to fix 90 days if until was auto-calculated
3403
+ if (sinceDefined) {
3404
+ if (!untilDefined) {
3405
+ request['endTime'] = Math.min(calculatedEndTime, this.sum(since, maxDistanceDaysForContracts * msInDay));
3406
+ }
3407
+ else if (calculatedEndTime - calculatedStartTime > maxDistanceDaysForContracts * msInDay) {
3408
+ throw new errors.BadRequest(this.id + ' fetchOHLCV() between start and end must be less than ' + maxDistanceDaysForContracts.toString() + ' days');
3409
+ }
3398
3410
  }
3399
- const priceType = this.safeString(params, 'price');
3400
- params = this.omit(params, ['price']);
3411
+ let priceType = undefined;
3412
+ [priceType, params] = this.handleParamString(params, 'price');
3401
3413
  let productType = undefined;
3402
3414
  [productType, params] = this.handleProductTypeAndParams(market, params);
3403
3415
  request['productType'] = productType;
@@ -3410,7 +3422,7 @@ class bitget extends bitget$1 {
3410
3422
  response = await this.publicMixGetV2MixMarketHistoryIndexCandles(extended);
3411
3423
  }
3412
3424
  else {
3413
- if (needsHistoryEndpoint) {
3425
+ if (historicalEndpointNeeded) {
3414
3426
  response = await this.publicMixGetV2MixMarketHistoryCandles(extended);
3415
3427
  }
3416
3428
  else {
@@ -347,6 +347,7 @@ class bitmart extends bitmart$1 {
347
347
  '70000': errors.ExchangeError,
348
348
  '70001': errors.BadRequest,
349
349
  '70002': errors.BadSymbol,
350
+ '70003': errors.NetworkError,
350
351
  '71001': errors.BadRequest,
351
352
  '71002': errors.BadRequest,
352
353
  '71003': errors.BadRequest,
@@ -79,6 +79,7 @@ class bybit extends bybit$1 {
79
79
  'fetchIsolatedBorrowRates': false,
80
80
  'fetchLedger': true,
81
81
  'fetchLeverage': true,
82
+ 'fetchLeverageTiers': true,
82
83
  'fetchMarketLeverageTiers': true,
83
84
  'fetchMarkets': true,
84
85
  'fetchMarkOHLCV': true,
@@ -7265,36 +7266,6 @@ class bybit extends bybit$1 {
7265
7266
  market['id'];
7266
7267
  return await this.fetchDerivativesMarketLeverageTiers(symbol, params);
7267
7268
  }
7268
- parseMarketLeverageTiers(info, market = undefined) {
7269
- //
7270
- // {
7271
- // "id": 1,
7272
- // "symbol": "BTCUSD",
7273
- // "riskLimitValue": "150",
7274
- // "maintenanceMargin": "0.5",
7275
- // "initialMargin": "1",
7276
- // "isLowestRisk": 1,
7277
- // "maxLeverage": "100.00"
7278
- // }
7279
- //
7280
- let minNotional = 0;
7281
- const tiers = [];
7282
- for (let i = 0; i < info.length; i++) {
7283
- const item = info[i];
7284
- const maxNotional = this.safeNumber(item, 'riskLimitValue');
7285
- tiers.push({
7286
- 'tier': this.sum(i, 1),
7287
- 'currency': market['base'],
7288
- 'minNotional': minNotional,
7289
- 'maxNotional': maxNotional,
7290
- 'maintenanceMarginRate': this.safeNumber(item, 'maintenanceMargin'),
7291
- 'maxLeverage': this.safeNumber(item, 'maxLeverage'),
7292
- 'info': item,
7293
- });
7294
- minNotional = maxNotional;
7295
- }
7296
- return tiers;
7297
- }
7298
7269
  parseTradingFee(fee, market = undefined) {
7299
7270
  //
7300
7271
  // {
@@ -7999,6 +7970,95 @@ class bybit extends bybit$1 {
7999
7970
  'datetime': this.iso8601(timestamp),
8000
7971
  });
8001
7972
  }
7973
+ async fetchLeverageTiers(symbols = undefined, params = {}) {
7974
+ /**
7975
+ * @method
7976
+ * @name bybit#fetchLeverageTiers
7977
+ * @see https://bybit-exchange.github.io/docs/v5/market/risk-limit
7978
+ * @description retrieve information on the maximum leverage, for different trade sizes
7979
+ * @param {string[]} [symbols] a list of unified market symbols
7980
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
7981
+ * @param {string} [params.subType] market subType, ['linear', 'inverse'], default is 'linear'
7982
+ * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
7983
+ */
7984
+ await this.loadMarkets();
7985
+ let market = undefined;
7986
+ if (symbols !== undefined) {
7987
+ market = this.market(symbols[0]);
7988
+ if (market['spot']) {
7989
+ throw new errors.NotSupported(this.id + ' fetchLeverageTiers() is not supported for spot market');
7990
+ }
7991
+ }
7992
+ let subType = undefined;
7993
+ [subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params, 'linear');
7994
+ const request = {
7995
+ 'category': subType,
7996
+ };
7997
+ const response = await this.publicGetV5MarketRiskLimit(this.extend(request, params));
7998
+ const result = this.safeDict(response, 'result', {});
7999
+ const data = this.safeList(result, 'list', []);
8000
+ symbols = this.marketSymbols(symbols);
8001
+ return this.parseLeverageTiers(data, symbols, 'symbol');
8002
+ }
8003
+ parseLeverageTiers(response, symbols = undefined, marketIdKey = undefined) {
8004
+ //
8005
+ // [
8006
+ // {
8007
+ // "id": 1,
8008
+ // "symbol": "BTCUSD",
8009
+ // "riskLimitValue": "150",
8010
+ // "maintenanceMargin": "0.5",
8011
+ // "initialMargin": "1",
8012
+ // "isLowestRisk": 1,
8013
+ // "maxLeverage": "100.00"
8014
+ // }
8015
+ // ]
8016
+ //
8017
+ const tiers = {};
8018
+ const marketIds = this.marketIds(symbols);
8019
+ const filteredResults = this.filterByArray(response, marketIdKey, marketIds, false);
8020
+ const grouped = this.groupBy(filteredResults, marketIdKey);
8021
+ const keys = Object.keys(grouped);
8022
+ for (let i = 0; i < keys.length; i++) {
8023
+ const marketId = keys[i];
8024
+ const entry = grouped[marketId];
8025
+ const market = this.safeMarket(marketId, undefined, undefined, 'contract');
8026
+ const symbol = market['symbol'];
8027
+ tiers[symbol] = this.parseMarketLeverageTiers(entry, market);
8028
+ }
8029
+ return tiers;
8030
+ }
8031
+ parseMarketLeverageTiers(info, market = undefined) {
8032
+ //
8033
+ // [
8034
+ // {
8035
+ // "id": 1,
8036
+ // "symbol": "BTCUSD",
8037
+ // "riskLimitValue": "150",
8038
+ // "maintenanceMargin": "0.5",
8039
+ // "initialMargin": "1",
8040
+ // "isLowestRisk": 1,
8041
+ // "maxLeverage": "100.00"
8042
+ // }
8043
+ // ]
8044
+ //
8045
+ const tiers = [];
8046
+ for (let i = 0; i < info.length; i++) {
8047
+ const tier = info[i];
8048
+ const marketId = this.safeString(info, 'symbol');
8049
+ market = this.safeMarket(marketId);
8050
+ tiers.push({
8051
+ 'tier': this.safeInteger(tier, 'id'),
8052
+ 'currency': market['settle'],
8053
+ 'minNotional': undefined,
8054
+ 'maxNotional': undefined,
8055
+ 'maintenanceMarginRate': this.safeNumber(tier, 'maintenanceMargin'),
8056
+ 'maxLeverage': this.safeNumber(tier, 'maxLeverage'),
8057
+ 'info': tier,
8058
+ });
8059
+ }
8060
+ return tiers;
8061
+ }
8002
8062
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
8003
8063
  let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
8004
8064
  if (api === 'public') {
@@ -115,7 +115,7 @@ class coinbaseinternational extends coinbaseinternational$1 {
115
115
  'test': {
116
116
  'rest': 'https://api-n5e1.coinbase.com/api',
117
117
  },
118
- 'www': 'https://www.coinbaseinternational.com/international-exchange',
118
+ 'www': 'https://international.coinbase.com',
119
119
  'doc': [
120
120
  'https://docs.cloud.coinbaseinternational.com/intx/docs',
121
121
  ],
@@ -134,7 +134,7 @@ class coinex extends coinex$1 {
134
134
  'perpetualPrivate': 'https://api.coinex.com/perpetual',
135
135
  },
136
136
  'www': 'https://www.coinex.com',
137
- 'doc': 'https://github.com/coinexcom/coinex_exchange_api/wiki',
137
+ 'doc': 'https://viabtc.github.io/coinex_api_en_doc',
138
138
  'fees': 'https://www.coinex.com/fees',
139
139
  'referral': 'https://www.coinex.com/register?refer_code=yw5fz',
140
140
  },
@@ -348,6 +348,7 @@ class coinex extends coinex$1 {
348
348
  },
349
349
  'broad': {
350
350
  'ip not allow visit': errors.PermissionDenied,
351
+ 'service too busy': errors.ExchangeNotAvailable,
351
352
  },
352
353
  },
353
354
  });
@@ -5154,7 +5155,7 @@ class coinex extends coinex$1 {
5154
5155
  * @method
5155
5156
  * @name coinex#borrowIsolatedMargin
5156
5157
  * @description create a loan to borrow margin
5157
- * @see https://github.com/coinexcom/coinex_exchange_api/wiki/086margin_loan
5158
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account017_margin_loan
5158
5159
  * @param {string} symbol unified market symbol, required for coinex
5159
5160
  * @param {string} code unified currency code of the currency to borrow
5160
5161
  * @param {float} amount the amount to borrow
@@ -5191,7 +5192,7 @@ class coinex extends coinex$1 {
5191
5192
  * @method
5192
5193
  * @name coinex#repayIsolatedMargin
5193
5194
  * @description repay borrowed margin and interest
5194
- * @see https://github.com/coinexcom/coinex_exchange_api/wiki/087margin_flat
5195
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account018_margin_flat
5195
5196
  * @param {string} symbol unified market symbol, required for coinex
5196
5197
  * @param {string} code unified currency code of the currency to repay
5197
5198
  * @param {float} amount the amount to repay
@@ -4286,6 +4286,7 @@ class gate extends gate$1 {
4286
4286
  'failed': 'canceled',
4287
4287
  'expired': 'canceled',
4288
4288
  'finished': 'closed',
4289
+ 'finish': 'closed',
4289
4290
  'succeeded': 'closed',
4290
4291
  };
4291
4292
  return this.safeString(statuses, status, status);
@@ -949,6 +949,9 @@ class htx extends htx$1 {
949
949
  },
950
950
  },
951
951
  },
952
+ 'fetchOHLCV': {
953
+ 'useHistoricalEndpointForSpot': true,
954
+ },
952
955
  'withdraw': {
953
956
  'includeFee': false,
954
957
  },
@@ -2956,6 +2959,7 @@ class htx extends htx$1 {
2956
2959
  * @param {int} [limit] the maximum amount of candles to fetch
2957
2960
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2958
2961
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2962
+ * @param {string} [params.useHistoricalEndpointForSpot] true/false - whether use the historical candles endpoint for spot markets or default klines endpoint
2959
2963
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
2960
2964
  */
2961
2965
  await this.loadMarkets();
@@ -3062,19 +3066,22 @@ class htx extends htx$1 {
3062
3066
  }
3063
3067
  }
3064
3068
  else {
3065
- if (since !== undefined) {
3066
- request['from'] = this.parseToInt(since / 1000);
3067
- }
3068
- if (limit !== undefined) {
3069
- request['size'] = limit; // max 2000
3070
- }
3071
3069
  request['symbol'] = market['id'];
3072
- if (timeframe === '1M' || timeframe === '1y') {
3073
- // for some reason 1M and 1Y does not work with the regular endpoint
3074
- // https://github.com/ccxt/ccxt/issues/18006
3070
+ let useHistorical = undefined;
3071
+ [useHistorical, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'useHistoricalEndpointForSpot', true);
3072
+ if (!useHistorical) {
3073
+ // `limit` only available for the this endpoint
3074
+ if (limit !== undefined) {
3075
+ request['size'] = limit; // max 2000
3076
+ }
3075
3077
  response = await this.spotPublicGetMarketHistoryKline(this.extend(request, params));
3076
3078
  }
3077
3079
  else {
3080
+ // `since` only available for the this endpoint
3081
+ if (since !== undefined) {
3082
+ // default 150 bars
3083
+ request['from'] = this.parseToInt(since / 1000);
3084
+ }
3078
3085
  response = await this.spotPublicGetMarketHistoryCandles(this.extend(request, params));
3079
3086
  }
3080
3087
  }
@@ -365,7 +365,7 @@ class hyperliquid extends hyperliquid$1 {
365
365
  'optionType': undefined,
366
366
  'precision': {
367
367
  'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'szDecimals'))),
368
- 'price': this.parseNumber('5'), // significant digits
368
+ 'price': 5, // significant digits
369
369
  },
370
370
  'limits': {
371
371
  'leverage': {
@@ -847,6 +847,7 @@ class hyperliquid extends hyperliquid$1 {
847
847
  throw new errors.ArgumentsRequired(this.id + ' market orders require price to calculate the max slippage price. Default slippage can be set in options (default is 5%).');
848
848
  }
849
849
  px = (isBuy) ? Precise["default"].stringMul(price, Precise["default"].stringAdd('1', slippage)) : Precise["default"].stringMul(price, Precise["default"].stringSub('1', slippage));
850
+ px = this.priceToPrecision(symbol, px); // round after adding slippage
850
851
  }
851
852
  else {
852
853
  px = this.priceToPrecision(symbol, price);
@@ -2761,7 +2761,7 @@ class kraken extends kraken$1 {
2761
2761
  // todo unify parsePosition/parsePositions
2762
2762
  return result;
2763
2763
  }
2764
- parseAccount(account) {
2764
+ parseAccountType(account) {
2765
2765
  const accountByType = {
2766
2766
  'spot': 'Spot Wallet',
2767
2767
  'swap': 'Futures Wallet',
@@ -2795,8 +2795,8 @@ class kraken extends kraken$1 {
2795
2795
  */
2796
2796
  await this.loadMarkets();
2797
2797
  const currency = this.currency(code);
2798
- fromAccount = this.parseAccount(fromAccount);
2799
- toAccount = this.parseAccount(toAccount);
2798
+ fromAccount = this.parseAccountType(fromAccount);
2799
+ toAccount = this.parseAccountType(toAccount);
2800
2800
  const request = {
2801
2801
  'amount': this.currencyToPrecision(code, amount),
2802
2802
  'from': fromAccount,
@@ -461,7 +461,7 @@ class kucoin extends kucoin$1 {
461
461
  '400006': errors.AuthenticationError,
462
462
  '400007': errors.AuthenticationError,
463
463
  '400008': errors.NotSupported,
464
- '400100': errors.BadRequest,
464
+ '400100': errors.InsufficientFunds,
465
465
  '400200': errors.InvalidOrder,
466
466
  '400350': errors.InvalidOrder,
467
467
  '400370': errors.InvalidOrder,
@@ -467,16 +467,17 @@ class krakenfutures extends krakenfutures$1 {
467
467
  const market = this.market(marketId);
468
468
  const symbol = market['symbol'];
469
469
  const messageHash = 'trade:' + symbol;
470
- let tradesArray = this.safeValue(this.trades, symbol);
471
- if (tradesArray === undefined) {
470
+ if (this.safeList(this.trades, symbol) === undefined) {
472
471
  const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
473
- tradesArray = new Cache.ArrayCache(tradesLimit);
474
- this.trades[symbol] = tradesArray;
472
+ this.trades[symbol] = new Cache.ArrayCache(tradesLimit);
475
473
  }
474
+ const tradesArray = this.trades[symbol];
476
475
  if (channel === 'trade_snapshot') {
477
- const trades = this.safeValue(message, 'trades', []);
478
- for (let i = 0; i < trades.length; i++) {
479
- const item = trades[i];
476
+ const trades = this.safeList(message, 'trades', []);
477
+ const length = trades.length;
478
+ for (let i = 0; i < length; i++) {
479
+ const index = length - 1 - i; // need reverse to correct chronology
480
+ const item = trades[index];
480
481
  const trade = this.parseWsTrade(item);
481
482
  tradesArray.append(trade);
482
483
  }