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
package/dist/cjs/ccxt.js CHANGED
@@ -176,7 +176,7 @@ var woo$1 = require('./src/pro/woo.js');
176
176
 
177
177
  //-----------------------------------------------------------------------------
178
178
  // this is updated by vss.js when building
179
- const version = '4.2.31';
179
+ const version = '4.2.35';
180
180
  Exchange["default"].ccxtVersion = version;
181
181
  const exchanges = {
182
182
  'ace': ace,
@@ -1048,8 +1048,9 @@ class ace extends ace$1 {
1048
1048
  const feedback = this.id + ' ' + body;
1049
1049
  const status = this.safeNumber(response, 'status', 200);
1050
1050
  if (status > 200) {
1051
- this.throwExactlyMatchedException(this.exceptions['exact'], status, feedback);
1052
- this.throwBroadlyMatchedException(this.exceptions['broad'], status, feedback);
1051
+ const statusStr = status.toString();
1052
+ this.throwExactlyMatchedException(this.exceptions['exact'], statusStr, feedback);
1053
+ this.throwBroadlyMatchedException(this.exceptions['broad'], statusStr, feedback);
1053
1054
  }
1054
1055
  return undefined;
1055
1056
  }
@@ -3130,7 +3130,7 @@ class ascendex extends ascendex$1 {
3130
3130
  * @method
3131
3131
  * @name ascendex#transfer
3132
3132
  * @description transfer currency internally between wallets on the same account
3133
- * @param {string} code unified currency code
3133
+ * @param {string} code unified currency codeåå
3134
3134
  * @param {float} amount amount to transfer
3135
3135
  * @param {string} fromAccount account to transfer from
3136
3136
  * @param {string} toAccount account to transfer to
@@ -39,6 +39,7 @@ const { isNode, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sor
39
39
  */
40
40
  class Exchange {
41
41
  constructor(userConfig = {}) {
42
+ this.throttleProp = undefined;
42
43
  this.api = undefined;
43
44
  this.userAgent = undefined;
44
45
  this.user_agent = undefined;
@@ -120,6 +121,7 @@ class Exchange {
120
121
  this.clients = {};
121
122
  this.newUpdates = true;
122
123
  this.streaming = {};
124
+ this.alias = false;
123
125
  this.deepExtend = deepExtend;
124
126
  this.isNode = isNode;
125
127
  this.keys = generic.keys;
@@ -695,7 +697,7 @@ class Exchange {
695
697
  // @ts-ignore
696
698
  this.httpProxyAgentModule = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ 'https-proxy-agent')); });
697
699
  }
698
- catch { }
700
+ catch (e) { }
699
701
  }
700
702
  if (this.socksProxyAgentModuleChecked === false) {
701
703
  this.socksProxyAgentModuleChecked = true;
@@ -957,7 +959,7 @@ class Exchange {
957
959
  const markets = await this.fetchMarkets(params);
958
960
  return this.setMarkets(markets, currencies);
959
961
  }
960
- loadMarkets(reload = false, params = {}) {
962
+ async loadMarkets(reload = false, params = {}) {
961
963
  // this method is async, it returns a promise
962
964
  if ((reload && !this.reloadingMarkets) || !this.marketsLoading) {
963
965
  this.reloadingMarkets = true;
@@ -971,28 +973,28 @@ class Exchange {
971
973
  }
972
974
  return this.marketsLoading;
973
975
  }
974
- fetchCurrencies(params = {}) {
976
+ async fetchCurrencies(params = {}) {
975
977
  // markets are returned as a list
976
978
  // currencies are returned as a dict
977
979
  // this is for historical reasons
978
980
  // and may be changed for consistency later
979
981
  return new Promise((resolve, reject) => resolve(this.currencies));
980
982
  }
981
- fetchCurrenciesWs(params = {}) {
983
+ async fetchCurrenciesWs(params = {}) {
982
984
  // markets are returned as a list
983
985
  // currencies are returned as a dict
984
986
  // this is for historical reasons
985
987
  // and may be changed for consistency later
986
988
  return new Promise((resolve, reject) => resolve(this.currencies));
987
989
  }
988
- fetchMarkets(params = {}) {
990
+ async fetchMarkets(params = {}) {
989
991
  // markets are returned as a list
990
992
  // currencies are returned as a dict
991
993
  // this is for historical reasons
992
994
  // and may be changed for consistency later
993
995
  return new Promise((resolve, reject) => resolve(Object.values(this.markets)));
994
996
  }
995
- fetchMarketsWs(params = {}) {
997
+ async fetchMarketsWs(params = {}) {
996
998
  // markets are returned as a list
997
999
  // currencies are returned as a dict
998
1000
  // this is for historical reasons
@@ -1067,6 +1069,9 @@ class Exchange {
1067
1069
  }
1068
1070
  handleMessage(client, message) { } // stub to override
1069
1071
  // ping (client) {} // stub to override
1072
+ // ping (client) {
1073
+ // return undefined;
1074
+ // }
1070
1075
  client(url) {
1071
1076
  this.clients = this.clients || {};
1072
1077
  if (!this.clients[url]) {
@@ -1446,6 +1451,9 @@ class Exchange {
1446
1451
  * @returns {object | undefined}
1447
1452
  */
1448
1453
  const value = this.safeValueN(dictionaryOrList, keys, defaultValue);
1454
+ if (value === undefined) {
1455
+ return defaultValue;
1456
+ }
1449
1457
  if (typeof value === 'object') {
1450
1458
  return value;
1451
1459
  }
@@ -1477,6 +1485,9 @@ class Exchange {
1477
1485
  * @returns {Array | undefined}
1478
1486
  */
1479
1487
  const value = this.safeValueN(dictionaryOrList, keys, defaultValue);
1488
+ if (value === undefined) {
1489
+ return defaultValue;
1490
+ }
1480
1491
  if (Array.isArray(value)) {
1481
1492
  return value;
1482
1493
  }
@@ -1694,6 +1705,9 @@ class Exchange {
1694
1705
  }
1695
1706
  }
1696
1707
  if (fromStart) {
1708
+ if (limit > arrayLength) {
1709
+ limit = arrayLength;
1710
+ }
1697
1711
  array = ascending ? this.arraySlice(array, 0, limit) : this.arraySlice(array, -limit);
1698
1712
  }
1699
1713
  else {
@@ -1922,6 +1936,18 @@ class Exchange {
1922
1936
  async setLeverage(leverage, symbol = undefined, params = {}) {
1923
1937
  throw new errors.NotSupported(this.id + ' setLeverage() is not supported yet');
1924
1938
  }
1939
+ async fetchOpenInterestHistory(symbol, timeframe = '1h', since = undefined, limit = undefined, params = {}) {
1940
+ throw new errors.NotSupported(this.id + ' fetchOpenInterestHistory() is not supported yet');
1941
+ }
1942
+ async fetchOpenInterest(symbol, params = {}) {
1943
+ throw new errors.NotSupported(this.id + ' fetchOpenInterest() is not supported yet');
1944
+ }
1945
+ async signIn(params = {}) {
1946
+ throw new errors.NotSupported(this.id + ' signIn() is not supported yet');
1947
+ }
1948
+ async fetchPaymentMethods(params = {}) {
1949
+ throw new errors.NotSupported(this.id + ' fetchPaymentMethods() is not supported yet');
1950
+ }
1925
1951
  parseToInt(number) {
1926
1952
  // Solve Common parseInt misuse ex: parseInt ((since / 1000).toString ())
1927
1953
  // using a number as parameter which is not valid in ts
@@ -3532,6 +3558,15 @@ class Exchange {
3532
3558
  async fetchBidsAsks(symbols = undefined, params = {}) {
3533
3559
  throw new errors.NotSupported(this.id + ' fetchBidsAsks() is not supported yet');
3534
3560
  }
3561
+ async fetchBorrowInterest(code = undefined, symbol = undefined, since = undefined, limit = undefined, params = {}) {
3562
+ throw new errors.NotSupported(this.id + ' fetchBorrowInterest() is not supported yet');
3563
+ }
3564
+ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
3565
+ throw new errors.NotSupported(this.id + ' fetchLedger() is not supported yet');
3566
+ }
3567
+ async fetchLedgerEntry(id, code = undefined, params = {}) {
3568
+ throw new errors.NotSupported(this.id + ' fetchLedgerEntry() is not supported yet');
3569
+ }
3535
3570
  parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
3536
3571
  const price = this.safeNumber(bidask, priceKey);
3537
3572
  const amount = this.safeNumber(bidask, amountKey);
@@ -3832,6 +3867,9 @@ class Exchange {
3832
3867
  return this.handleOptionAndParams(params, methodName, 'marginMode', defaultValue);
3833
3868
  }
3834
3869
  throwExactlyMatchedException(exact, string, message) {
3870
+ if (string === undefined) {
3871
+ return;
3872
+ }
3835
3873
  if (string in exact) {
3836
3874
  throw new exact[string](message);
3837
3875
  }
@@ -4255,21 +4293,18 @@ class Exchange {
4255
4293
  */
4256
4294
  throw new errors.NotSupported(this.id + ' fetchDepositsWithdrawals() is not supported yet');
4257
4295
  }
4258
- async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
4296
+ async fetchDeposits(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4259
4297
  throw new errors.NotSupported(this.id + ' fetchDeposits() is not supported yet');
4260
4298
  }
4299
+ async fetchWithdrawals(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4300
+ throw new errors.NotSupported(this.id + ' fetchWithdrawals() is not supported yet');
4301
+ }
4261
4302
  async fetchDepositsWs(code = undefined, since = undefined, limit = undefined, params = {}) {
4262
4303
  throw new errors.NotSupported(this.id + ' fetchDepositsWs() is not supported yet');
4263
4304
  }
4264
- async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
4265
- throw new errors.NotSupported(this.id + ' fetchWithdrawals() is not supported yet');
4266
- }
4267
4305
  async fetchWithdrawalsWs(code = undefined, since = undefined, limit = undefined, params = {}) {
4268
4306
  throw new errors.NotSupported(this.id + ' fetchWithdrawalsWs() is not supported yet');
4269
4307
  }
4270
- async fetchOpenInterest(symbol, params = {}) {
4271
- throw new errors.NotSupported(this.id + ' fetchOpenInterest() is not supported yet');
4272
- }
4273
4308
  async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4274
4309
  throw new errors.NotSupported(this.id + ' fetchFundingRateHistory() is not supported yet');
4275
4310
  }
@@ -4357,7 +4392,7 @@ class Exchange {
4357
4392
  throw new errors.NotSupported(this.id + ' createExpiredOptionMarket () is not supported yet');
4358
4393
  }
4359
4394
  handleWithdrawTagAndParams(tag, params) {
4360
- if (typeof tag === 'object') {
4395
+ if ((tag !== undefined) && (typeof tag === 'object')) {
4361
4396
  params = this.extend(tag, params);
4362
4397
  tag = undefined;
4363
4398
  }
@@ -4491,14 +4526,14 @@ class Exchange {
4491
4526
  throw new errors.NotSupported(this.id + ' fetchMarketLeverageTiers() is not supported yet');
4492
4527
  }
4493
4528
  }
4494
- async createPostOnlyOrder(symbol, type, side, amount, price, params = {}) {
4529
+ async createPostOnlyOrder(symbol, type, side, amount, price = undefined, params = {}) {
4495
4530
  if (!this.has['createPostOnlyOrder']) {
4496
4531
  throw new errors.NotSupported(this.id + 'createPostOnlyOrder() is not supported yet');
4497
4532
  }
4498
4533
  const query = this.extend(params, { 'postOnly': true });
4499
4534
  return await this.createOrder(symbol, type, side, amount, price, query);
4500
4535
  }
4501
- async createReduceOnlyOrder(symbol, type, side, amount, price, params = {}) {
4536
+ async createReduceOnlyOrder(symbol, type, side, amount, price = undefined, params = {}) {
4502
4537
  if (!this.has['createReduceOnlyOrder']) {
4503
4538
  throw new errors.NotSupported(this.id + 'createReduceOnlyOrder() is not supported yet');
4504
4539
  }
@@ -5121,7 +5156,8 @@ class Exchange {
5121
5156
  const response = await this[method](symbol, undefined, maxEntriesPerRequest, params);
5122
5157
  const responseLength = response.length;
5123
5158
  if (this.verbose) {
5124
- this.log('Dynamic pagination call', calls, 'method', method, 'response length', responseLength, 'timestamp', paginationTimestamp);
5159
+ const backwardMessage = 'Dynamic pagination call ' + calls + ' method ' + method + ' response length ' + responseLength + ' timestamp ' + paginationTimestamp;
5160
+ this.log(backwardMessage);
5125
5161
  }
5126
5162
  if (responseLength === 0) {
5127
5163
  break;
@@ -5139,7 +5175,8 @@ class Exchange {
5139
5175
  const response = await this[method](symbol, paginationTimestamp, maxEntriesPerRequest, params);
5140
5176
  const responseLength = response.length;
5141
5177
  if (this.verbose) {
5142
- this.log('Dynamic pagination call', calls, 'method', method, 'response length', responseLength, 'timestamp', paginationTimestamp);
5178
+ const forwardMessage = 'Dynamic pagination call ' + calls + ' method ' + method + ' response length ' + responseLength + ' timestamp ' + paginationTimestamp;
5179
+ this.log(forwardMessage);
5143
5180
  }
5144
5181
  if (responseLength === 0) {
5145
5182
  break;
@@ -5185,6 +5222,7 @@ class Exchange {
5185
5222
  throw e;
5186
5223
  }
5187
5224
  }
5225
+ return undefined;
5188
5226
  }
5189
5227
  async fetchPaginatedCallDeterministic(method, symbol = undefined, since = undefined, limit = undefined, timeframe = undefined, params = {}, maxEntriesPerRequest = undefined) {
5190
5228
  let maxCalls = undefined;
@@ -5249,7 +5287,9 @@ class Exchange {
5249
5287
  errors = 0;
5250
5288
  const responseLength = response.length;
5251
5289
  if (this.verbose) {
5252
- this.log('Cursor pagination call', i + 1, 'method', method, 'response length', responseLength, 'cursor', cursorValue);
5290
+ const iteration = (i + 1).toString();
5291
+ const cursorMessage = 'Cursor pagination call ' + iteration + ' method ' + method + ' response length ' + responseLength.toString() + ' cursor ' + cursorValue;
5292
+ this.log(cursorMessage);
5253
5293
  }
5254
5294
  if (responseLength === 0) {
5255
5295
  break;
@@ -5293,7 +5333,9 @@ class Exchange {
5293
5333
  errors = 0;
5294
5334
  const responseLength = response.length;
5295
5335
  if (this.verbose) {
5296
- this.log('Incremental pagination call', i + 1, 'method', method, 'response length', responseLength);
5336
+ const iteration = (i + 1).toString();
5337
+ const incrementalMessage = 'Incremental pagination call ' + iteration + ' method ' + method + ' response length ' + responseLength.toString();
5338
+ this.log(incrementalMessage);
5297
5339
  }
5298
5340
  if (responseLength === 0) {
5299
5341
  break;
@@ -518,6 +518,7 @@ class bigone extends bigone$1 {
518
518
  * @method
519
519
  * @name bigone#fetchMarkets
520
520
  * @description retrieves data on all markets for bigone
521
+ * @see https://open.big.one/docs/spot_asset_pair.html
521
522
  * @param {object} [params] extra parameters specific to the exchange API endpoint
522
523
  * @returns {object[]} an array of objects representing market data
523
524
  */
@@ -780,6 +781,7 @@ class bigone extends bigone$1 {
780
781
  * @method
781
782
  * @name bigone#fetchTicker
782
783
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
784
+ * @see https://open.big.one/docs/spot_tickers.html
783
785
  * @param {string} symbol unified symbol of the market to fetch the ticker for
784
786
  * @param {object} [params] extra parameters specific to the exchange API endpoint
785
787
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -822,6 +824,7 @@ class bigone extends bigone$1 {
822
824
  * @method
823
825
  * @name bigone#fetchTickers
824
826
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
827
+ * @see https://open.big.one/docs/spot_tickers.html
825
828
  * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
826
829
  * @param {object} [params] extra parameters specific to the exchange API endpoint
827
830
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -909,6 +912,7 @@ class bigone extends bigone$1 {
909
912
  * @method
910
913
  * @name bigone#fetchTime
911
914
  * @description fetches the current integer timestamp in milliseconds from the exchange server
915
+ * @see https://open.big.one/docs/spot_ping.html
912
916
  * @param {object} [params] extra parameters specific to the exchange API endpoint
913
917
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
914
918
  */
@@ -929,6 +933,7 @@ class bigone extends bigone$1 {
929
933
  * @method
930
934
  * @name bigone#fetchOrderBook
931
935
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
936
+ * @see https://open.big.one/docs/contract_misc.html#get-orderbook-snapshot
932
937
  * @param {string} symbol unified symbol of the market to fetch the order book for
933
938
  * @param {int} [limit] the maximum amount of order book entries to return
934
939
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1171,6 +1176,7 @@ class bigone extends bigone$1 {
1171
1176
  * @method
1172
1177
  * @name bigone#fetchTrades
1173
1178
  * @description get the list of most recent trades for a particular symbol
1179
+ * @see https://open.big.one/docs/spot_asset_pair_trade.html
1174
1180
  * @param {string} symbol unified symbol of the market to fetch trades for
1175
1181
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
1176
1182
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -1235,6 +1241,7 @@ class bigone extends bigone$1 {
1235
1241
  * @method
1236
1242
  * @name bigone#fetchOHLCV
1237
1243
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1244
+ * @see https://open.big.one/docs/spot_asset_pair_candle.html
1238
1245
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1239
1246
  * @param {string} timeframe the length of time each candle represents
1240
1247
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -1311,6 +1318,8 @@ class bigone extends bigone$1 {
1311
1318
  * @method
1312
1319
  * @name bigone#fetchBalance
1313
1320
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
1321
+ * @see https://open.big.one/docs/fund_accounts.html
1322
+ * @see https://open.big.one/docs/spot_accounts.html
1314
1323
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1315
1324
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1316
1325
  */
@@ -1556,6 +1565,7 @@ class bigone extends bigone$1 {
1556
1565
  * @method
1557
1566
  * @name bigone#cancelOrder
1558
1567
  * @description cancels an open order
1568
+ * @see https://open.big.one/docs/spot_orders.html#cancel-order
1559
1569
  * @param {string} id order id
1560
1570
  * @param {string} symbol Not used by bigone cancelOrder ()
1561
1571
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1584,6 +1594,7 @@ class bigone extends bigone$1 {
1584
1594
  * @method
1585
1595
  * @name bigone#cancelAllOrders
1586
1596
  * @description cancel all open orders
1597
+ * @see https://open.big.one/docs/spot_orders.html#cancel-all-orders
1587
1598
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
1588
1599
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1589
1600
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -1613,6 +1624,7 @@ class bigone extends bigone$1 {
1613
1624
  * @method
1614
1625
  * @name bigone#fetchOrder
1615
1626
  * @description fetches information on an order made by the user
1627
+ * @see https://open.big.one/docs/spot_orders.html#get-one-order
1616
1628
  * @param {string} symbol not used by bigone fetchOrder
1617
1629
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1618
1630
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -1628,6 +1640,7 @@ class bigone extends bigone$1 {
1628
1640
  * @method
1629
1641
  * @name bigone#fetchOrders
1630
1642
  * @description fetches information on multiple orders made by the user
1643
+ * @see https://open.big.one/docs/spot_orders.html#get-user-orders-in-one-asset-pair
1631
1644
  * @param {string} symbol unified market symbol of the market orders were made in
1632
1645
  * @param {int} [since] the earliest time in ms to fetch orders for
1633
1646
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -1678,6 +1691,7 @@ class bigone extends bigone$1 {
1678
1691
  * @method
1679
1692
  * @name bigone#fetchMyTrades
1680
1693
  * @description fetch all trades made by the user
1694
+ * @see https://open.big.one/docs/spot_trade.html#trades-of-user
1681
1695
  * @param {string} symbol unified market symbol
1682
1696
  * @param {int} [since] the earliest time in ms to fetch trades for
1683
1697
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -1747,6 +1761,7 @@ class bigone extends bigone$1 {
1747
1761
  * @method
1748
1762
  * @name bigone#fetchOpenOrders
1749
1763
  * @description fetch all unfilled currently open orders
1764
+ * @see https://open.big.one/docs/spot_orders.html#get-user-orders-in-one-asset-pair
1750
1765
  * @param {string} symbol unified market symbol
1751
1766
  * @param {int} [since] the earliest time in ms to fetch open orders for
1752
1767
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -1763,6 +1778,7 @@ class bigone extends bigone$1 {
1763
1778
  * @method
1764
1779
  * @name bigone#fetchClosedOrders
1765
1780
  * @description fetches information on multiple closed orders made by the user
1781
+ * @see https://open.big.one/docs/spot_orders.html#get-user-orders-in-one-asset-pair
1766
1782
  * @param {string} symbol unified market symbol of the market orders were made in
1767
1783
  * @param {int} [since] the earliest time in ms to fetch orders for
1768
1784
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -1817,6 +1833,7 @@ class bigone extends bigone$1 {
1817
1833
  * @method
1818
1834
  * @name bigone#fetchDepositAddress
1819
1835
  * @description fetch the deposit address for a currency associated with this account
1836
+ * @see https://open.big.one/docs/spot_deposit.html#get-deposite-address-of-one-asset-of-user
1820
1837
  * @param {string} code unified currency code
1821
1838
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1822
1839
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
@@ -1967,6 +1984,7 @@ class bigone extends bigone$1 {
1967
1984
  * @method
1968
1985
  * @name bigone#fetchDeposits
1969
1986
  * @description fetch all deposits made to an account
1987
+ * @see https://open.big.one/docs/spot_deposit.html#deposit-of-user
1970
1988
  * @param {string} code unified currency code
1971
1989
  * @param {int} [since] the earliest time in ms to fetch deposits for
1972
1990
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -2018,6 +2036,7 @@ class bigone extends bigone$1 {
2018
2036
  * @method
2019
2037
  * @name bigone#fetchWithdrawals
2020
2038
  * @description fetch all withdrawals made from an account
2039
+ * @see https://open.big.one/docs/spot_withdrawal.html#get-withdrawals-of-user
2021
2040
  * @param {string} code unified currency code
2022
2041
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
2023
2042
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -2123,7 +2142,7 @@ class bigone extends bigone$1 {
2123
2142
  'id': undefined,
2124
2143
  'timestamp': undefined,
2125
2144
  'datetime': undefined,
2126
- 'currency': code,
2145
+ 'currency': undefined,
2127
2146
  'amount': undefined,
2128
2147
  'fromAccount': undefined,
2129
2148
  'toAccount': undefined,
@@ -2141,6 +2160,7 @@ class bigone extends bigone$1 {
2141
2160
  * @method
2142
2161
  * @name bigone#withdraw
2143
2162
  * @description make a withdrawal
2163
+ * @see https://open.big.one/docs/spot_withdrawal.html#create-withdrawal-of-user
2144
2164
  * @param {string} code unified currency code
2145
2165
  * @param {float} amount the amount to withdraw
2146
2166
  * @param {string} address the address to withdraw to
@@ -3136,16 +3136,31 @@ class binance extends binance$1 {
3136
3136
  account['debt'] = Precise["default"].stringAdd(debt, interest);
3137
3137
  return account;
3138
3138
  }
3139
- parseBalance(response, type = undefined, marginMode = undefined) {
3139
+ parseBalanceCustom(response, type = undefined, marginMode = undefined) {
3140
3140
  const result = {
3141
3141
  'info': response,
3142
3142
  };
3143
3143
  let timestamp = undefined;
3144
3144
  const isolated = marginMode === 'isolated';
3145
3145
  const cross = (type === 'margin') || (marginMode === 'cross');
3146
- if (!isolated && ((type === 'spot') || cross)) {
3146
+ if (type === 'papi') {
3147
+ for (let i = 0; i < response.length; i++) {
3148
+ const entry = response[i];
3149
+ const account = this.account();
3150
+ const currencyId = this.safeString(entry, 'asset');
3151
+ const code = this.safeCurrencyCode(currencyId);
3152
+ const borrowed = this.safeString(entry, 'crossMarginBorrowed');
3153
+ const interest = this.safeString(entry, 'crossMarginInterest');
3154
+ account['free'] = this.safeString(entry, 'crossMarginFree');
3155
+ account['used'] = this.safeString(entry, 'crossMarginLocked');
3156
+ account['total'] = this.safeString(entry, 'crossMarginAsset');
3157
+ account['debt'] = Precise["default"].stringAdd(borrowed, interest);
3158
+ result[code] = account;
3159
+ }
3160
+ }
3161
+ else if (!isolated && ((type === 'spot') || cross)) {
3147
3162
  timestamp = this.safeInteger(response, 'updateTime');
3148
- const balances = this.safeValue2(response, 'balances', 'userAssets', []);
3163
+ const balances = this.safeList2(response, 'balances', 'userAssets', []);
3149
3164
  for (let i = 0; i < balances.length; i++) {
3150
3165
  const balance = balances[i];
3151
3166
  const currencyId = this.safeString(balance, 'asset');
@@ -3162,13 +3177,13 @@ class binance extends binance$1 {
3162
3177
  }
3163
3178
  }
3164
3179
  else if (isolated) {
3165
- const assets = this.safeValue(response, 'assets');
3180
+ const assets = this.safeList(response, 'assets');
3166
3181
  for (let i = 0; i < assets.length; i++) {
3167
3182
  const asset = assets[i];
3168
- const marketId = this.safeValue(asset, 'symbol');
3183
+ const marketId = this.safeString(asset, 'symbol');
3169
3184
  const symbol = this.safeSymbol(marketId, undefined, undefined, 'spot');
3170
- const base = this.safeValue(asset, 'baseAsset', {});
3171
- const quote = this.safeValue(asset, 'quoteAsset', {});
3185
+ const base = this.safeDict(asset, 'baseAsset', {});
3186
+ const quote = this.safeDict(asset, 'quoteAsset', {});
3172
3187
  const baseCode = this.safeCurrencyCode(this.safeString(base, 'asset'));
3173
3188
  const quoteCode = this.safeCurrencyCode(this.safeString(quote, 'asset'));
3174
3189
  const subResult = {};
@@ -3178,7 +3193,7 @@ class binance extends binance$1 {
3178
3193
  }
3179
3194
  }
3180
3195
  else if (type === 'savings') {
3181
- const positionAmountVos = this.safeValue(response, 'positionAmountVos', []);
3196
+ const positionAmountVos = this.safeList(response, 'positionAmountVos', []);
3182
3197
  for (let i = 0; i < positionAmountVos.length; i++) {
3183
3198
  const entry = positionAmountVos[i];
3184
3199
  const currencyId = this.safeString(entry, 'asset');
@@ -3207,7 +3222,7 @@ class binance extends binance$1 {
3207
3222
  else {
3208
3223
  let balances = response;
3209
3224
  if (!Array.isArray(response)) {
3210
- balances = this.safeValue(response, 'assets', []);
3225
+ balances = this.safeList(response, 'assets', []);
3211
3226
  }
3212
3227
  for (let i = 0; i < balances.length; i++) {
3213
3228
  const balance = balances[i];
@@ -3237,10 +3252,12 @@ class binance extends binance$1 {
3237
3252
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data // swap
3238
3253
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data // future
3239
3254
  * @see https://binance-docs.github.io/apidocs/voptions/en/#option-account-information-trade // option
3255
+ * @see https://binance-docs.github.io/apidocs/pm/en/#account-balance-user_data // portfolio margin
3240
3256
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3241
- * @param {string} [params.type] 'future', 'delivery', 'savings', 'funding', or 'spot'
3257
+ * @param {string} [params.type] 'future', 'delivery', 'savings', 'funding', or 'spot' or 'papi'
3242
3258
  * @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
3243
3259
  * @param {string[]|undefined} [params.symbols] unified market symbols, only used in isolated margin mode
3260
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the balance for a portfolio margin account
3244
3261
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
3245
3262
  */
3246
3263
  await this.loadMarkets();
@@ -3248,13 +3265,19 @@ class binance extends binance$1 {
3248
3265
  let type = this.safeString(params, 'type', defaultType);
3249
3266
  let subType = undefined;
3250
3267
  [subType, params] = this.handleSubTypeAndParams('fetchBalance', undefined, params);
3268
+ let isPortfolioMargin = undefined;
3269
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchBalance', 'papi', 'portfolioMargin', false);
3251
3270
  let marginMode = undefined;
3252
3271
  let query = undefined;
3253
3272
  [marginMode, query] = this.handleMarginModeAndParams('fetchBalance', params);
3254
3273
  query = this.omit(query, 'type');
3255
3274
  let response = undefined;
3256
3275
  const request = {};
3257
- if (this.isLinear(type, subType)) {
3276
+ if (isPortfolioMargin || (type === 'papi')) {
3277
+ type = 'papi';
3278
+ response = await this.papiGetBalance(this.extend(request, query));
3279
+ }
3280
+ else if (this.isLinear(type, subType)) {
3258
3281
  type = 'linear';
3259
3282
  response = await this.fapiPrivateV2GetAccount(this.extend(request, query));
3260
3283
  }
@@ -3263,7 +3286,7 @@ class binance extends binance$1 {
3263
3286
  response = await this.dapiPrivateGetAccount(this.extend(request, query));
3264
3287
  }
3265
3288
  else if (marginMode === 'isolated') {
3266
- const paramSymbols = this.safeValue(params, 'symbols');
3289
+ const paramSymbols = this.safeList(params, 'symbols');
3267
3290
  query = this.omit(query, 'symbols');
3268
3291
  if (paramSymbols !== undefined) {
3269
3292
  let symbols = '';
@@ -3479,7 +3502,27 @@ class binance extends binance$1 {
3479
3502
  // }
3480
3503
  // ]
3481
3504
  //
3482
- return this.parseBalance(response, type, marginMode);
3505
+ // portfolio margin
3506
+ //
3507
+ // [
3508
+ // {
3509
+ // "asset": "USDT",
3510
+ // "totalWalletBalance": "66.9923261",
3511
+ // "crossMarginAsset": "35.9697141",
3512
+ // "crossMarginBorrowed": "0.0",
3513
+ // "crossMarginFree": "35.9697141",
3514
+ // "crossMarginInterest": "0.0",
3515
+ // "crossMarginLocked": "0.0",
3516
+ // "umWalletBalance": "31.022612",
3517
+ // "umUnrealizedPNL": "0.0",
3518
+ // "cmWalletBalance": "0.0",
3519
+ // "cmUnrealizedPNL": "0.0",
3520
+ // "updateTime": 0,
3521
+ // "negativeBalance": "0.0"
3522
+ // },
3523
+ // ]
3524
+ //
3525
+ return this.parseBalanceCustom(response, type, marginMode);
3483
3526
  }
3484
3527
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
3485
3528
  /**
@@ -5251,7 +5294,7 @@ class binance extends binance$1 {
5251
5294
  const stopLossPrice = this.safeValue(params, 'stopLossPrice', triggerPrice); // fallback to stopLoss
5252
5295
  const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
5253
5296
  const trailingDelta = this.safeValue(params, 'trailingDelta');
5254
- const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activationPrice', price);
5297
+ const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activationPrice', this.numberToString(price));
5255
5298
  const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
5256
5299
  const isTrailingPercentOrder = trailingPercent !== undefined;
5257
5300
  const isStopLoss = stopLossPrice !== undefined || trailingDelta !== undefined;
@@ -9584,7 +9627,7 @@ class binance extends binance$1 {
9584
9627
  }
9585
9628
  return this.safeValue(config, 'cost', 1);
9586
9629
  }
9587
- async request(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined, config = {}, context = {}) {
9630
+ async request(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined, config = {}) {
9588
9631
  const response = await this.fetch2(path, api, method, params, headers, body, config);
9589
9632
  // a workaround for {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
9590
9633
  if (api === 'private') {
@@ -10217,6 +10260,7 @@ class binance extends binance$1 {
10217
10260
  else {
10218
10261
  return this.parseOpenInterest(response, market);
10219
10262
  }
10263
+ return undefined;
10220
10264
  }
10221
10265
  parseOpenInterest(interest, market = undefined) {
10222
10266
  const timestamp = this.safeInteger2(interest, 'timestamp', 'time');
@@ -1885,6 +1885,7 @@ class bingx extends bingx$1 {
1885
1885
  }
1886
1886
  }
1887
1887
  if (isStopLoss || isTakeProfit) {
1888
+ const stringifiedAmount = this.numberToString(amount);
1888
1889
  if (isStopLoss) {
1889
1890
  const slTriggerPrice = this.safeString2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
1890
1891
  const slWorkingType = this.safeString(stopLoss, 'workingType', 'MARK_PRICE');
@@ -1898,7 +1899,7 @@ class bingx extends bingx$1 {
1898
1899
  if (slPrice !== undefined) {
1899
1900
  slRequest['price'] = this.parseToNumeric(this.priceToPrecision(symbol, slPrice));
1900
1901
  }
1901
- const slQuantity = this.safeString(stopLoss, 'quantity', amount);
1902
+ const slQuantity = this.safeString(stopLoss, 'quantity', stringifiedAmount);
1902
1903
  slRequest['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, slQuantity));
1903
1904
  request['stopLoss'] = this.json(slRequest);
1904
1905
  }
@@ -1915,7 +1916,7 @@ class bingx extends bingx$1 {
1915
1916
  if (slPrice !== undefined) {
1916
1917
  tpRequest['price'] = this.parseToNumeric(this.priceToPrecision(symbol, slPrice));
1917
1918
  }
1918
- const tkQuantity = this.safeString(takeProfit, 'quantity', amount);
1919
+ const tkQuantity = this.safeString(takeProfit, 'quantity', stringifiedAmount);
1919
1920
  tpRequest['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, tkQuantity));
1920
1921
  request['takeProfit'] = this.json(tpRequest);
1921
1922
  }
@@ -3601,7 +3602,7 @@ class bingx extends bingx$1 {
3601
3602
  // "id":"1197073063359000577"
3602
3603
  // }
3603
3604
  // }
3604
- this.parseTransaction(data);
3605
+ return this.parseTransaction(data);
3605
3606
  }
3606
3607
  parseParams(params) {
3607
3608
  const sortedParams = this.keysort(params);