ccxt 4.0.67 → 4.0.69

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 (46) hide show
  1. package/CHANGELOG.md +146 -0
  2. package/README.md +3 -3
  3. package/dist/ccxt.browser.js +193 -71
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/base/Exchange.js +1 -1
  7. package/dist/cjs/src/binance.js +1 -0
  8. package/dist/cjs/src/bitget.js +18 -1
  9. package/dist/cjs/src/bybit.js +10 -0
  10. package/dist/cjs/src/lykke.js +1 -1
  11. package/dist/cjs/src/phemex.js +2 -1
  12. package/dist/cjs/src/pro/binance.js +1 -1
  13. package/dist/cjs/src/pro/bitfinex2.js +7 -6
  14. package/dist/cjs/src/pro/bitget.js +10 -7
  15. package/dist/cjs/src/pro/bitmart.js +7 -6
  16. package/dist/cjs/src/pro/bittrex.js +2 -3
  17. package/dist/cjs/src/pro/coinbasepro.js +71 -9
  18. package/dist/cjs/src/pro/huobi.js +4 -2
  19. package/dist/cjs/src/pro/idex.js +1 -1
  20. package/dist/cjs/src/pro/okx.js +22 -16
  21. package/dist/cjs/src/wavesexchange.js +34 -15
  22. package/js/ccxt.d.ts +1 -1
  23. package/js/ccxt.js +1 -1
  24. package/js/src/base/Exchange.js +1 -1
  25. package/js/src/binance.js +1 -0
  26. package/js/src/bitget.js +18 -1
  27. package/js/src/bybit.js +10 -0
  28. package/js/src/lykke.js +1 -1
  29. package/js/src/phemex.js +2 -1
  30. package/js/src/pro/binance.js +1 -1
  31. package/js/src/pro/bitfinex2.d.ts +1 -1
  32. package/js/src/pro/bitfinex2.js +7 -6
  33. package/js/src/pro/bitget.d.ts +1 -1
  34. package/js/src/pro/bitget.js +10 -7
  35. package/js/src/pro/bitmart.d.ts +1 -1
  36. package/js/src/pro/bitmart.js +7 -6
  37. package/js/src/pro/bittrex.js +2 -3
  38. package/js/src/pro/coinbasepro.d.ts +3 -1
  39. package/js/src/pro/coinbasepro.js +71 -9
  40. package/js/src/pro/huobi.js +4 -2
  41. package/js/src/pro/idex.js +1 -1
  42. package/js/src/pro/okx.d.ts +1 -0
  43. package/js/src/pro/okx.js +22 -16
  44. package/js/src/wavesexchange.d.ts +2 -1
  45. package/js/src/wavesexchange.js +34 -15
  46. package/package.json +1 -1
@@ -617,19 +617,32 @@ export default class wavesexchange extends Exchange {
617
617
  }
618
618
  parseOrderBookSide(bookSide, market = undefined, limit = undefined) {
619
619
  const precision = market['precision'];
620
- const wavesPrecision = this.safeInteger(this.options, 'wavesPrecision', 8);
621
- const amountPrecision = Math.pow(10, precision['amount']);
622
- const difference = precision['amount'] - precision['price'];
623
- const pricePrecision = Math.pow(10, wavesPrecision - difference);
620
+ const wavesPrecision = this.safeString(this.options, 'wavesPrecision', '8');
621
+ const amountPrecision = '1e' + this.numberToString(precision['amount']);
622
+ const amountPrecisionString = this.numberToString(precision['amount']);
623
+ const pricePrecisionString = this.numberToString(precision['price']);
624
+ const difference = Precise.stringSub(amountPrecisionString, pricePrecisionString);
625
+ const pricePrecision = '1e' + Precise.stringSub(wavesPrecision, difference);
624
626
  const result = [];
625
627
  for (let i = 0; i < bookSide.length; i++) {
626
628
  const entry = bookSide[i];
627
- const price = this.safeInteger(entry, 'price', 0) / pricePrecision;
628
- const amount = this.safeInteger(entry, 'amount', 0) / amountPrecision;
629
+ const entryPrice = this.safeString(entry, 'price', '0');
630
+ const entryAmount = this.safeString(entry, 'amount', '0');
631
+ let price = undefined;
632
+ let amount = undefined;
633
+ if ((pricePrecision !== undefined) && (entryPrice !== undefined)) {
634
+ price = Precise.stringDiv(entryPrice, pricePrecision);
635
+ }
636
+ if ((amountPrecision !== undefined) && (entryAmount !== undefined)) {
637
+ amount = Precise.stringDiv(entryAmount, amountPrecision);
638
+ }
629
639
  if ((limit !== undefined) && (i > limit)) {
630
640
  break;
631
641
  }
632
- result.push([price, amount]);
642
+ result.push([
643
+ this.parseNumber(price),
644
+ this.parseNumber(amount),
645
+ ]);
633
646
  }
634
647
  return result;
635
648
  }
@@ -1209,15 +1222,21 @@ export default class wavesexchange extends Exchange {
1209
1222
  }
1210
1223
  customPriceToPrecision(symbol, price) {
1211
1224
  const market = this.markets[symbol];
1212
- const wavesPrecision = this.safeInteger(this.options, 'wavesPrecision', 8);
1213
- const difference = market['precision']['amount'] - market['precision']['price'];
1214
- return this.parseToInt(parseFloat(this.toPrecision(price, wavesPrecision - difference)));
1225
+ const wavesPrecision = this.safeString(this.options, 'wavesPrecision', '8');
1226
+ const amount = this.numberToString(market['precision']['amount']);
1227
+ const precisionPrice = this.numberToString(market['precision']['price']);
1228
+ const difference = Precise.stringSub(amount, precisionPrice);
1229
+ const precision = Precise.stringSub(wavesPrecision, difference);
1230
+ const pricePrecision = this.toPrecision(price, precision).toString();
1231
+ return this.parseToInt(parseFloat(pricePrecision));
1215
1232
  }
1216
1233
  customAmountToPrecision(symbol, amount) {
1217
- return this.parseToInt(parseFloat(this.toPrecision(amount, this.markets[symbol]['precision']['amount'])));
1234
+ const amountPrecision = this.numberToString(this.toPrecision(amount, this.numberToString(this.markets[symbol]['precision']['amount'])));
1235
+ return this.parseToInt(parseFloat(amountPrecision));
1218
1236
  }
1219
1237
  currencyToPrecision(code, amount, networkCode = undefined) {
1220
- return this.parseToInt(parseFloat(this.toPrecision(amount, this.currencies[code]['precision'])));
1238
+ const amountPrecision = this.numberToString(this.toPrecision(amount, this.currencies[code]['precision']));
1239
+ return this.parseToInt(parseFloat(amountPrecision));
1221
1240
  }
1222
1241
  fromPrecision(amount, scale) {
1223
1242
  if (amount === undefined) {
@@ -1229,11 +1248,11 @@ export default class wavesexchange extends Exchange {
1229
1248
  return precise.toString();
1230
1249
  }
1231
1250
  toPrecision(amount, scale) {
1232
- const amountString = amount.toString();
1251
+ const amountString = this.numberToString(amount);
1233
1252
  const precise = new Precise(amountString);
1234
- precise.decimals = precise.decimals - scale;
1253
+ precise.decimals = Precise.stringSub(precise.decimals, scale);
1235
1254
  precise.reduce();
1236
- return precise.toString();
1255
+ return precise;
1237
1256
  }
1238
1257
  currencyFromPrecision(currency, amount) {
1239
1258
  const scale = this.currencies[currency]['precision'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.0.67",
3
+ "version": "4.0.69",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",