ccxt 4.1.84 → 4.1.86

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 (301) hide show
  1. package/README.md +5 -4
  2. package/dist/ccxt.browser.js +1939 -806
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/ace.js +1 -1
  6. package/dist/cjs/src/alpaca.js +2 -2
  7. package/dist/cjs/src/ascendex.js +2 -2
  8. package/dist/cjs/src/base/Exchange.js +53 -20
  9. package/dist/cjs/src/bigone.js +1 -1
  10. package/dist/cjs/src/binance.js +2 -2
  11. package/dist/cjs/src/bingx.js +11 -9
  12. package/dist/cjs/src/bit2c.js +1 -1
  13. package/dist/cjs/src/bitbank.js +1 -1
  14. package/dist/cjs/src/bitbns.js +1 -1
  15. package/dist/cjs/src/bitfinex.js +1 -1
  16. package/dist/cjs/src/bitfinex2.js +1 -1
  17. package/dist/cjs/src/bitflyer.js +1 -1
  18. package/dist/cjs/src/bitforex.js +1 -1
  19. package/dist/cjs/src/bitget.js +2 -3
  20. package/dist/cjs/src/bithumb.js +3 -3
  21. package/dist/cjs/src/bitmart.js +91 -74
  22. package/dist/cjs/src/bitmex.js +2 -2
  23. package/dist/cjs/src/bitopro.js +3 -3
  24. package/dist/cjs/src/bitpanda.js +1 -1
  25. package/dist/cjs/src/bitrue.js +1 -1
  26. package/dist/cjs/src/bitso.js +1 -1
  27. package/dist/cjs/src/bitstamp.js +1 -1
  28. package/dist/cjs/src/bittrex.js +1 -1
  29. package/dist/cjs/src/bitvavo.js +1 -1
  30. package/dist/cjs/src/bl3p.js +1 -1
  31. package/dist/cjs/src/blockchaincom.js +1 -1
  32. package/dist/cjs/src/btcalpha.js +1 -1
  33. package/dist/cjs/src/btcbox.js +1 -1
  34. package/dist/cjs/src/btcmarkets.js +1 -1
  35. package/dist/cjs/src/btcturk.js +1 -1
  36. package/dist/cjs/src/bybit.js +3 -5
  37. package/dist/cjs/src/cex.js +1 -1
  38. package/dist/cjs/src/coinbase.js +1 -1
  39. package/dist/cjs/src/coinbasepro.js +1 -1
  40. package/dist/cjs/src/coincheck.js +1 -1
  41. package/dist/cjs/src/coinex.js +3 -2
  42. package/dist/cjs/src/coinlist.js +1 -1
  43. package/dist/cjs/src/coinmate.js +1 -1
  44. package/dist/cjs/src/coinone.js +1 -1
  45. package/dist/cjs/src/coinsph.js +1 -1
  46. package/dist/cjs/src/coinspot.js +1 -1
  47. package/dist/cjs/src/cryptocom.js +3 -3
  48. package/dist/cjs/src/currencycom.js +1 -1
  49. package/dist/cjs/src/delta.js +1 -1
  50. package/dist/cjs/src/deribit.js +1 -1
  51. package/dist/cjs/src/digifinex.js +160 -112
  52. package/dist/cjs/src/exmo.js +1 -1
  53. package/dist/cjs/src/gate.js +1 -1
  54. package/dist/cjs/src/gemini.js +1 -1
  55. package/dist/cjs/src/hitbtc.js +2 -2
  56. package/dist/cjs/src/hitbtc3.js +1 -1
  57. package/dist/cjs/src/hollaex.js +1 -1
  58. package/dist/cjs/src/htx.js +2 -2
  59. package/dist/cjs/src/huobijp.js +1 -1
  60. package/dist/cjs/src/idex.js +1 -1
  61. package/dist/cjs/src/independentreserve.js +1 -1
  62. package/dist/cjs/src/indodax.js +1 -1
  63. package/dist/cjs/src/kraken.js +2 -2
  64. package/dist/cjs/src/krakenfutures.js +3 -3
  65. package/dist/cjs/src/kucoin.js +2 -6
  66. package/dist/cjs/src/kucoinfutures.js +0 -3
  67. package/dist/cjs/src/kuna.js +1 -1
  68. package/dist/cjs/src/latoken.js +2 -2
  69. package/dist/cjs/src/lbank.js +1 -1
  70. package/dist/cjs/src/luno.js +1 -1
  71. package/dist/cjs/src/lykke.js +1 -1
  72. package/dist/cjs/src/mercado.js +1 -1
  73. package/dist/cjs/src/mexc.js +102 -53
  74. package/dist/cjs/src/ndax.js +1 -1
  75. package/dist/cjs/src/novadax.js +1 -1
  76. package/dist/cjs/src/oceanex.js +1 -1
  77. package/dist/cjs/src/okcoin.js +1 -1
  78. package/dist/cjs/src/okx.js +4 -4
  79. package/dist/cjs/src/p2b.js +1 -3
  80. package/dist/cjs/src/paymium.js +1 -1
  81. package/dist/cjs/src/phemex.js +1 -1
  82. package/dist/cjs/src/poloniex.js +51 -51
  83. package/dist/cjs/src/poloniexfutures.js +1 -1
  84. package/dist/cjs/src/pro/bitget.js +1 -1
  85. package/dist/cjs/src/pro/bitmart.js +1026 -250
  86. package/dist/cjs/src/pro/bitmex.js +206 -0
  87. package/dist/cjs/src/pro/krakenfutures.js +6 -6
  88. package/dist/cjs/src/pro/mexc.js +1 -1
  89. package/dist/cjs/src/pro/poloniex.js +1 -1
  90. package/dist/cjs/src/pro/poloniexfutures.js +3 -3
  91. package/dist/cjs/src/probit.js +27 -19
  92. package/dist/cjs/src/static_dependencies/jsencrypt/JSEncrypt.js +1 -1
  93. package/dist/cjs/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +3 -3
  94. package/dist/cjs/src/timex.js +1 -1
  95. package/dist/cjs/src/tokocrypto.js +8 -4
  96. package/dist/cjs/src/upbit.js +1 -1
  97. package/dist/cjs/src/wavesexchange.js +1 -1
  98. package/dist/cjs/src/wazirx.js +1 -1
  99. package/dist/cjs/src/whitebit.js +1 -1
  100. package/dist/cjs/src/woo.js +1 -1
  101. package/dist/cjs/src/yobit.js +1 -1
  102. package/dist/cjs/src/zaif.js +1 -1
  103. package/dist/cjs/src/zonda.js +1 -1
  104. package/js/ccxt.d.ts +1 -1
  105. package/js/ccxt.js +1 -1
  106. package/js/src/ace.d.ts +1 -1
  107. package/js/src/ace.js +1 -1
  108. package/js/src/alpaca.d.ts +1 -1
  109. package/js/src/alpaca.js +2 -2
  110. package/js/src/ascendex.d.ts +1 -1
  111. package/js/src/ascendex.js +2 -2
  112. package/js/src/base/Exchange.d.ts +5 -0
  113. package/js/src/base/Exchange.js +53 -20
  114. package/js/src/base/types.d.ts +1 -0
  115. package/js/src/bigone.d.ts +1 -1
  116. package/js/src/bigone.js +1 -1
  117. package/js/src/binance.d.ts +1 -1
  118. package/js/src/binance.js +2 -2
  119. package/js/src/bingx.js +11 -9
  120. package/js/src/bit2c.d.ts +1 -1
  121. package/js/src/bit2c.js +1 -1
  122. package/js/src/bitbank.d.ts +1 -1
  123. package/js/src/bitbank.js +1 -1
  124. package/js/src/bitbns.d.ts +1 -1
  125. package/js/src/bitbns.js +1 -1
  126. package/js/src/bitfinex.d.ts +1 -1
  127. package/js/src/bitfinex.js +1 -1
  128. package/js/src/bitfinex2.d.ts +1 -1
  129. package/js/src/bitfinex2.js +1 -1
  130. package/js/src/bitflyer.d.ts +1 -1
  131. package/js/src/bitflyer.js +1 -1
  132. package/js/src/bitforex.d.ts +1 -1
  133. package/js/src/bitforex.js +1 -1
  134. package/js/src/bitget.d.ts +1 -1
  135. package/js/src/bitget.js +2 -3
  136. package/js/src/bithumb.d.ts +1 -1
  137. package/js/src/bithumb.js +3 -3
  138. package/js/src/bitmart.d.ts +1 -1
  139. package/js/src/bitmart.js +91 -74
  140. package/js/src/bitmex.d.ts +1 -1
  141. package/js/src/bitmex.js +2 -2
  142. package/js/src/bitopro.d.ts +1 -1
  143. package/js/src/bitopro.js +3 -3
  144. package/js/src/bitpanda.d.ts +1 -1
  145. package/js/src/bitpanda.js +1 -1
  146. package/js/src/bitrue.d.ts +1 -1
  147. package/js/src/bitrue.js +1 -1
  148. package/js/src/bitso.d.ts +1 -1
  149. package/js/src/bitso.js +1 -1
  150. package/js/src/bitstamp.d.ts +1 -1
  151. package/js/src/bitstamp.js +1 -1
  152. package/js/src/bittrex.d.ts +1 -1
  153. package/js/src/bittrex.js +1 -1
  154. package/js/src/bitvavo.d.ts +1 -1
  155. package/js/src/bitvavo.js +1 -1
  156. package/js/src/bl3p.d.ts +1 -1
  157. package/js/src/bl3p.js +1 -1
  158. package/js/src/blockchaincom.d.ts +1 -1
  159. package/js/src/blockchaincom.js +1 -1
  160. package/js/src/btcalpha.d.ts +1 -1
  161. package/js/src/btcalpha.js +1 -1
  162. package/js/src/btcbox.d.ts +1 -1
  163. package/js/src/btcbox.js +1 -1
  164. package/js/src/btcmarkets.d.ts +1 -1
  165. package/js/src/btcmarkets.js +1 -1
  166. package/js/src/btcturk.d.ts +1 -1
  167. package/js/src/btcturk.js +1 -1
  168. package/js/src/bybit.d.ts +1 -1
  169. package/js/src/bybit.js +3 -5
  170. package/js/src/cex.d.ts +1 -1
  171. package/js/src/cex.js +1 -1
  172. package/js/src/coinbase.d.ts +1 -1
  173. package/js/src/coinbase.js +1 -1
  174. package/js/src/coinbasepro.d.ts +1 -1
  175. package/js/src/coinbasepro.js +1 -1
  176. package/js/src/coincheck.d.ts +1 -1
  177. package/js/src/coincheck.js +1 -1
  178. package/js/src/coinex.d.ts +1 -1
  179. package/js/src/coinex.js +3 -2
  180. package/js/src/coinlist.d.ts +1 -1
  181. package/js/src/coinlist.js +1 -1
  182. package/js/src/coinmate.d.ts +1 -1
  183. package/js/src/coinmate.js +1 -1
  184. package/js/src/coinone.d.ts +1 -1
  185. package/js/src/coinone.js +1 -1
  186. package/js/src/coinsph.d.ts +1 -1
  187. package/js/src/coinsph.js +1 -1
  188. package/js/src/coinspot.d.ts +1 -1
  189. package/js/src/coinspot.js +1 -1
  190. package/js/src/cryptocom.d.ts +1 -1
  191. package/js/src/cryptocom.js +3 -3
  192. package/js/src/currencycom.d.ts +1 -1
  193. package/js/src/currencycom.js +1 -1
  194. package/js/src/delta.d.ts +1 -1
  195. package/js/src/delta.js +1 -1
  196. package/js/src/deribit.d.ts +1 -1
  197. package/js/src/deribit.js +1 -1
  198. package/js/src/digifinex.d.ts +1 -1
  199. package/js/src/digifinex.js +160 -112
  200. package/js/src/exmo.d.ts +1 -1
  201. package/js/src/exmo.js +1 -1
  202. package/js/src/gate.d.ts +1 -1
  203. package/js/src/gate.js +1 -1
  204. package/js/src/gemini.d.ts +1 -1
  205. package/js/src/gemini.js +1 -1
  206. package/js/src/hitbtc.d.ts +1 -1
  207. package/js/src/hitbtc.js +2 -2
  208. package/js/src/hitbtc3.d.ts +1 -1
  209. package/js/src/hitbtc3.js +1 -1
  210. package/js/src/hollaex.d.ts +1 -1
  211. package/js/src/hollaex.js +1 -1
  212. package/js/src/htx.d.ts +1 -1
  213. package/js/src/htx.js +2 -2
  214. package/js/src/huobijp.d.ts +1 -1
  215. package/js/src/huobijp.js +1 -1
  216. package/js/src/idex.d.ts +1 -1
  217. package/js/src/idex.js +1 -1
  218. package/js/src/independentreserve.d.ts +1 -1
  219. package/js/src/independentreserve.js +1 -1
  220. package/js/src/indodax.d.ts +1 -1
  221. package/js/src/indodax.js +1 -1
  222. package/js/src/kraken.d.ts +1 -1
  223. package/js/src/kraken.js +2 -2
  224. package/js/src/krakenfutures.d.ts +1 -1
  225. package/js/src/krakenfutures.js +3 -3
  226. package/js/src/kucoin.d.ts +1 -1
  227. package/js/src/kucoin.js +2 -6
  228. package/js/src/kucoinfutures.d.ts +0 -1
  229. package/js/src/kucoinfutures.js +0 -3
  230. package/js/src/kuna.d.ts +1 -1
  231. package/js/src/kuna.js +1 -1
  232. package/js/src/latoken.d.ts +1 -1
  233. package/js/src/latoken.js +2 -2
  234. package/js/src/lbank.d.ts +1 -1
  235. package/js/src/lbank.js +1 -1
  236. package/js/src/luno.d.ts +1 -1
  237. package/js/src/luno.js +1 -1
  238. package/js/src/lykke.d.ts +1 -1
  239. package/js/src/lykke.js +1 -1
  240. package/js/src/mercado.d.ts +1 -1
  241. package/js/src/mercado.js +1 -1
  242. package/js/src/mexc.d.ts +1 -1
  243. package/js/src/mexc.js +102 -53
  244. package/js/src/ndax.d.ts +1 -1
  245. package/js/src/ndax.js +1 -1
  246. package/js/src/novadax.d.ts +1 -1
  247. package/js/src/novadax.js +1 -1
  248. package/js/src/oceanex.d.ts +1 -1
  249. package/js/src/oceanex.js +1 -1
  250. package/js/src/okcoin.d.ts +1 -1
  251. package/js/src/okcoin.js +1 -1
  252. package/js/src/okx.d.ts +1 -1
  253. package/js/src/okx.js +4 -4
  254. package/js/src/p2b.d.ts +1 -1
  255. package/js/src/p2b.js +1 -3
  256. package/js/src/paymium.d.ts +1 -1
  257. package/js/src/paymium.js +1 -1
  258. package/js/src/phemex.d.ts +1 -1
  259. package/js/src/phemex.js +1 -1
  260. package/js/src/poloniex.d.ts +1 -1
  261. package/js/src/poloniex.js +51 -51
  262. package/js/src/poloniexfutures.d.ts +1 -1
  263. package/js/src/poloniexfutures.js +1 -1
  264. package/js/src/pro/bitget.d.ts +1 -1
  265. package/js/src/pro/bitget.js +1 -1
  266. package/js/src/pro/bitmart.d.ts +17 -6
  267. package/js/src/pro/bitmart.js +1028 -252
  268. package/js/src/pro/bitmex.d.ts +3 -1
  269. package/js/src/pro/bitmex.js +207 -1
  270. package/js/src/pro/krakenfutures.js +6 -6
  271. package/js/src/pro/mexc.js +1 -1
  272. package/js/src/pro/poloniex.js +1 -1
  273. package/js/src/pro/poloniexfutures.js +3 -3
  274. package/js/src/probit.d.ts +1 -1
  275. package/js/src/probit.js +27 -19
  276. package/js/src/static_dependencies/jsencrypt/JSEncrypt.d.ts +1 -1
  277. package/js/src/static_dependencies/jsencrypt/JSEncrypt.js +1 -1
  278. package/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.d.ts +3 -3
  279. package/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +3 -3
  280. package/js/src/timex.d.ts +1 -1
  281. package/js/src/timex.js +1 -1
  282. package/js/src/tokocrypto.d.ts +1 -1
  283. package/js/src/tokocrypto.js +8 -4
  284. package/js/src/upbit.d.ts +1 -1
  285. package/js/src/upbit.js +1 -1
  286. package/js/src/wavesexchange.d.ts +1 -1
  287. package/js/src/wavesexchange.js +1 -1
  288. package/js/src/wazirx.d.ts +1 -1
  289. package/js/src/wazirx.js +1 -1
  290. package/js/src/whitebit.d.ts +1 -1
  291. package/js/src/whitebit.js +1 -1
  292. package/js/src/woo.d.ts +1 -1
  293. package/js/src/woo.js +1 -1
  294. package/js/src/yobit.d.ts +1 -1
  295. package/js/src/yobit.js +1 -1
  296. package/js/src/zaif.d.ts +1 -1
  297. package/js/src/zaif.js +1 -1
  298. package/js/src/zonda.d.ts +1 -1
  299. package/js/src/zonda.js +1 -1
  300. package/package.json +4 -3
  301. package/skip-tests.json +4 -0
@@ -1,5 +1,5 @@
1
1
  import bitmexRest from '../bitmex.js';
2
- import { Int, Str } from '../base/types.js';
2
+ import { Int, Str, Strings } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class bitmex extends bitmexRest {
5
5
  describe(): any;
@@ -11,6 +11,8 @@ export default class bitmex extends bitmexRest {
11
11
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
12
12
  authenticate(params?: {}): Promise<any>;
13
13
  handleAuthenticationMessage(client: Client, message: any): void;
14
+ watchPositions(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<any>;
15
+ handlePositions(client: any, message: any): void;
14
16
  watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
15
17
  handleOrders(client: Client, message: any): void;
16
18
  watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
@@ -7,7 +7,7 @@
7
7
  // ---------------------------------------------------------------------------
8
8
  import bitmexRest from '../bitmex.js';
9
9
  import { AuthenticationError, ExchangeError, RateLimitExceeded } from '../base/errors.js';
10
- import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
10
+ import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
11
11
  import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
12
12
  // ---------------------------------------------------------------------------
13
13
  export default class bitmex extends bitmexRest {
@@ -21,6 +21,7 @@ export default class bitmex extends bitmexRest {
21
21
  'watchOrderBook': true,
22
22
  'watchOrderBookForSymbols': true,
23
23
  'watchOrders': true,
24
+ 'watchPostions': true,
24
25
  'watchTicker': true,
25
26
  'watchTickers': false,
26
27
  'watchTrades': true,
@@ -594,6 +595,210 @@ export default class bitmex extends bitmexRest {
594
595
  }
595
596
  }
596
597
  }
598
+ async watchPositions(symbols = undefined, since = undefined, limit = undefined, params = {}) {
599
+ /**
600
+ * @method
601
+ * @name bitmex#watchPositions
602
+ * @see https://www.bitmex.com/app/wsAPI
603
+ * @description watch all open positions
604
+ * @param {string[]|undefined} symbols list of unified market symbols
605
+ * @param {object} params extra parameters specific to the exchange API endpoint
606
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
607
+ */
608
+ await this.loadMarkets();
609
+ await this.authenticate();
610
+ const subscriptionHash = 'position';
611
+ let messageHash = 'positions';
612
+ if (!this.isEmpty(symbols)) {
613
+ messageHash = '::' + symbols.join(',');
614
+ }
615
+ const url = this.urls['api']['ws'];
616
+ const request = {
617
+ 'op': 'subscribe',
618
+ 'args': [
619
+ subscriptionHash,
620
+ ],
621
+ };
622
+ const newPositions = await this.watch(url, messageHash, request, subscriptionHash);
623
+ if (this.newUpdates) {
624
+ return newPositions;
625
+ }
626
+ return this.filterBySymbolsSinceLimit(this.positions, symbols, since, limit, true);
627
+ }
628
+ handlePositions(client, message) {
629
+ //
630
+ // partial
631
+ // {
632
+ // table: 'position',
633
+ // action: 'partial',
634
+ // keys: [ 'account', 'symbol' ],
635
+ // types: {
636
+ // account: 'long',
637
+ // symbol: 'symbol',
638
+ // currency: 'symbol',
639
+ // underlying: 'symbol',
640
+ // quoteCurrency: 'symbol',
641
+ // commission: 'float',
642
+ // initMarginReq: 'float',
643
+ // maintMarginReq: 'float',
644
+ // riskLimit: 'long',
645
+ // leverage: 'float',
646
+ // crossMargin: 'boolean',
647
+ // deleveragePercentile: 'float',
648
+ // rebalancedPnl: 'long',
649
+ // prevRealisedPnl: 'long',
650
+ // prevUnrealisedPnl: 'long',
651
+ // openingQty: 'long',
652
+ // openOrderBuyQty: 'long',
653
+ // openOrderBuyCost: 'long',
654
+ // openOrderBuyPremium: 'long',
655
+ // openOrderSellQty: 'long',
656
+ // openOrderSellCost: 'long',
657
+ // openOrderSellPremium: 'long',
658
+ // currentQty: 'long',
659
+ // currentCost: 'long',
660
+ // currentComm: 'long',
661
+ // realisedCost: 'long',
662
+ // unrealisedCost: 'long',
663
+ // grossOpenPremium: 'long',
664
+ // isOpen: 'boolean',
665
+ // markPrice: 'float',
666
+ // markValue: 'long',
667
+ // riskValue: 'long',
668
+ // homeNotional: 'float',
669
+ // foreignNotional: 'float',
670
+ // posState: 'symbol',
671
+ // posCost: 'long',
672
+ // posCross: 'long',
673
+ // posComm: 'long',
674
+ // posLoss: 'long',
675
+ // posMargin: 'long',
676
+ // posMaint: 'long',
677
+ // initMargin: 'long',
678
+ // maintMargin: 'long',
679
+ // realisedPnl: 'long',
680
+ // unrealisedPnl: 'long',
681
+ // unrealisedPnlPcnt: 'float',
682
+ // unrealisedRoePcnt: 'float',
683
+ // avgCostPrice: 'float',
684
+ // avgEntryPrice: 'float',
685
+ // breakEvenPrice: 'float',
686
+ // marginCallPrice: 'float',
687
+ // liquidationPrice: 'float',
688
+ // bankruptPrice: 'float',
689
+ // timestamp: 'timestamp'
690
+ // },
691
+ // filter: { account: 412475 },
692
+ // data: [
693
+ // {
694
+ // account: 412475,
695
+ // symbol: 'XBTUSD',
696
+ // currency: 'XBt',
697
+ // underlying: 'XBT',
698
+ // quoteCurrency: 'USD',
699
+ // commission: 0.00075,
700
+ // initMarginReq: 0.01,
701
+ // maintMarginReq: 0.0035,
702
+ // riskLimit: 20000000000,
703
+ // leverage: 100,
704
+ // crossMargin: true,
705
+ // deleveragePercentile: 1,
706
+ // rebalancedPnl: 0,
707
+ // prevRealisedPnl: 0,
708
+ // prevUnrealisedPnl: 0,
709
+ // openingQty: 400,
710
+ // openOrderBuyQty: 0,
711
+ // openOrderBuyCost: 0,
712
+ // openOrderBuyPremium: 0,
713
+ // openOrderSellQty: 0,
714
+ // openOrderSellCost: 0,
715
+ // openOrderSellPremium: 0,
716
+ // currentQty: 400,
717
+ // currentCost: -912269,
718
+ // currentComm: 684,
719
+ // realisedCost: 0,
720
+ // unrealisedCost: -912269,
721
+ // grossOpenPremium: 0,
722
+ // isOpen: true,
723
+ // markPrice: 43772,
724
+ // markValue: -913828,
725
+ // riskValue: 913828,
726
+ // homeNotional: 0.00913828,
727
+ // foreignNotional: -400,
728
+ // posCost: -912269,
729
+ // posCross: 1559,
730
+ // posComm: 694,
731
+ // posLoss: 0,
732
+ // posMargin: 11376,
733
+ // posMaint: 3887,
734
+ // initMargin: 0,
735
+ // maintMargin: 9817,
736
+ // realisedPnl: -684,
737
+ // unrealisedPnl: -1559,
738
+ // unrealisedPnlPcnt: -0.0017,
739
+ // unrealisedRoePcnt: -0.1709,
740
+ // avgCostPrice: 43846.7643,
741
+ // avgEntryPrice: 43846.7643,
742
+ // breakEvenPrice: 43880,
743
+ // marginCallPrice: 20976,
744
+ // liquidationPrice: 20976,
745
+ // bankruptPrice: 20941,
746
+ // timestamp: '2023-12-07T00:09:00.709Z'
747
+ // }
748
+ // ]
749
+ // }
750
+ // update
751
+ // {
752
+ // table: 'position',
753
+ // action: 'update',
754
+ // data: [
755
+ // {
756
+ // account: 412475,
757
+ // symbol: 'XBTUSD',
758
+ // currency: 'XBt',
759
+ // currentQty: 400,
760
+ // markPrice: 43772.75,
761
+ // markValue: -913812,
762
+ // riskValue: 913812,
763
+ // homeNotional: 0.00913812,
764
+ // posCross: 1543,
765
+ // posComm: 693,
766
+ // posMargin: 11359,
767
+ // posMaint: 3886,
768
+ // maintMargin: 9816,
769
+ // unrealisedPnl: -1543,
770
+ // unrealisedRoePcnt: -0.1691,
771
+ // liquidationPrice: 20976,
772
+ // timestamp: '2023-12-07T00:09:10.760Z'
773
+ // }
774
+ // ]
775
+ // }
776
+ //
777
+ if (this.positions === undefined) {
778
+ this.positions = new ArrayCacheBySymbolBySide();
779
+ }
780
+ const cache = this.positions;
781
+ const rawPositions = this.safeValue(message, 'data', []);
782
+ const newPositions = [];
783
+ for (let i = 0; i < rawPositions.length; i++) {
784
+ const rawPosition = rawPositions[i];
785
+ const position = this.parsePosition(rawPosition);
786
+ newPositions.push(position);
787
+ cache.append(position);
788
+ }
789
+ const messageHashes = this.findMessageHashes(client, 'positions::');
790
+ for (let i = 0; i < messageHashes.length; i++) {
791
+ const messageHash = messageHashes[i];
792
+ const parts = messageHash.split('::');
793
+ const symbolsString = parts[1];
794
+ const symbols = symbolsString.split(',');
795
+ const positions = this.filterByArray(newPositions, 'symbol', symbols, false);
796
+ if (!this.isEmpty(positions)) {
797
+ client.resolve(positions, messageHash);
798
+ }
799
+ }
800
+ client.resolve(newPositions, 'positions');
801
+ }
597
802
  async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
598
803
  /**
599
804
  * @method
@@ -1376,6 +1581,7 @@ export default class bitmex extends bitmexRest {
1376
1581
  'order': this.handleOrders,
1377
1582
  'execution': this.handleMyTrades,
1378
1583
  'margin': this.handleBalance,
1584
+ 'position': this.handlePositions,
1379
1585
  };
1380
1586
  const method = this.safeValue(methods, table);
1381
1587
  if (method === undefined) {
@@ -99,10 +99,10 @@ export default class krakenfutures extends krakenfuturesRest {
99
99
  * @ignore
100
100
  * @method
101
101
  * @description Connects to a websocket channel
102
- * @param {String} name name of the channel
102
+ * @param {string} name name of the channel
103
103
  * @param {string[]} symbols CCXT market symbols
104
- * @param {Object} [params] extra parameters specific to the krakenfutures api
105
- * @returns {Object} data from the websocket stream
104
+ * @param {object} [params] extra parameters specific to the krakenfutures api
105
+ * @returns {object} data from the websocket stream
106
106
  */
107
107
  await this.loadMarkets();
108
108
  const url = this.urls['api']['ws'];
@@ -133,10 +133,10 @@ export default class krakenfutures extends krakenfuturesRest {
133
133
  * @ignore
134
134
  * @method
135
135
  * @description Connects to a websocket channel
136
- * @param {String} name name of the channel
136
+ * @param {string} name name of the channel
137
137
  * @param {string[]} symbols CCXT market symbols
138
- * @param {Object} [params] extra parameters specific to the krakenfutures api
139
- * @returns {Object} data from the websocket stream
138
+ * @param {object} [params] extra parameters specific to the krakenfutures api
139
+ * @returns {object} data from the websocket stream
140
140
  */
141
141
  await this.loadMarkets();
142
142
  await this.authenticate();
@@ -742,7 +742,7 @@ export default class mexc extends mexcRest {
742
742
  * @param {int} [since] the earliest time in ms to fetch orders for
743
743
  * @param {int} [limit] the maximum number of orde structures to retrieve
744
744
  * @param {object} [params] extra parameters specific to the exchange API endpoint
745
- * @params {string|undefined} params.type the type of orders to retrieve, can be 'spot' or 'margin'
745
+ * @param {string|undefined} params.type the type of orders to retrieve, can be 'spot' or 'margin'
746
746
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
747
747
  */
748
748
  await this.loadMarkets();
@@ -204,7 +204,7 @@ export default class poloniex extends poloniexRest {
204
204
  * @param {string} [params.stpMode] self-trade prevention, defaults to expire_taker, none: enable self-trade; expire_taker: taker order will be canceled when self-trade happens
205
205
  * @param {string} [params.slippageTolerance] used to control the maximum slippage ratio, the value range is greater than 0 and less than 1
206
206
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
207
- */
207
+ */
208
208
  await this.loadMarkets();
209
209
  await this.authenticate();
210
210
  const market = this.market(symbol);
@@ -131,9 +131,9 @@ export default class poloniexfutures extends poloniexfuturesRest {
131
131
  * @param {string} name name of the channel and suscriptionHash
132
132
  * @param {bool} isPrivate true for the authenticated url, false for the public url
133
133
  * @param {string} symbol is required for all public channels, not required for private channels (except position)
134
- * @param {Object} subscription subscription parameters
135
- * @param {Object} [params] extra parameters specific to the poloniex api
136
- * @returns {Object} data from the websocket stream
134
+ * @param {object} subscription subscription parameters
135
+ * @param {object} [params] extra parameters specific to the poloniex api
136
+ * @returns {object} data from the websocket stream
137
137
  */
138
138
  const url = await this.negotiate(isPrivate);
139
139
  if (symbol !== undefined) {
@@ -2,7 +2,7 @@ import Exchange from './abstract/probit.js';
2
2
  import { Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction } from './base/types.js';
3
3
  /**
4
4
  * @class probit
5
- * @extends Exchange
5
+ * @augments Exchange
6
6
  */
7
7
  export default class probit extends Exchange {
8
8
  describe(): any;
package/js/src/probit.js CHANGED
@@ -12,7 +12,7 @@ import { TRUNCATE, TICK_SIZE } from './base/functions/number.js';
12
12
  // ---------------------------------------------------------------------------
13
13
  /**
14
14
  * @class probit
15
- * @extends Exchange
15
+ * @augments Exchange
16
16
  */
17
17
  export default class probit extends Exchange {
18
18
  describe() {
@@ -31,7 +31,10 @@ export default class probit extends Exchange {
31
31
  'option': false,
32
32
  'addMargin': false,
33
33
  'cancelOrder': true,
34
+ 'createMarketBuyOrderWithCost': true,
34
35
  'createMarketOrder': true,
36
+ 'createMarketOrderWithCost': false,
37
+ 'createMarketSellOrderWithCost': false,
35
38
  'createOrder': true,
36
39
  'createReduceOnlyOrder': false,
37
40
  'createStopLimitOrder': false,
@@ -318,6 +321,7 @@ export default class probit extends Exchange {
318
321
  'precision': {
319
322
  'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'quantity_precision'))),
320
323
  'price': this.safeNumber(market, 'price_increment'),
324
+ 'cost': this.parseNumber(this.parsePrecision(this.safeString(market, 'cost_precision'))),
321
325
  },
322
326
  'limits': {
323
327
  'leverage': {
@@ -1190,14 +1194,15 @@ export default class probit extends Exchange {
1190
1194
  /**
1191
1195
  * @method
1192
1196
  * @name probit#createOrder
1193
- * @see https://docs-en.probit.com/reference/order-1
1194
1197
  * @description create a trade order
1198
+ * @see https://docs-en.probit.com/reference/order-1
1195
1199
  * @param {string} symbol unified symbol of the market to create an order in
1196
1200
  * @param {string} type 'market' or 'limit'
1197
1201
  * @param {string} side 'buy' or 'sell'
1198
- * @param {float} amount how much of currency you want to trade in units of base currency
1202
+ * @param {float} amount how much you want to trade in units of the base currency
1199
1203
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1200
1204
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1205
+ * @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount for market buy orders
1201
1206
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1202
1207
  */
1203
1208
  await this.loadMarkets();
@@ -1215,7 +1220,7 @@ export default class probit extends Exchange {
1215
1220
  if (clientOrderId !== undefined) {
1216
1221
  request['client_order_id'] = clientOrderId;
1217
1222
  }
1218
- let costToPrecision = undefined;
1223
+ let quoteAmount = undefined;
1219
1224
  if (type === 'limit') {
1220
1225
  request['limit_price'] = this.priceToPrecision(symbol, price);
1221
1226
  request['quantity'] = this.amountToPrecision(symbol, amount);
@@ -1223,25 +1228,28 @@ export default class probit extends Exchange {
1223
1228
  else if (type === 'market') {
1224
1229
  // for market buy it requires the amount of quote currency to spend
1225
1230
  if (side === 'buy') {
1226
- let cost = this.safeNumber(params, 'cost');
1227
- const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice', true);
1228
- if (createMarketBuyOrderRequiresPrice) {
1229
- if (price !== undefined) {
1230
- if (cost === undefined) {
1231
- const amountString = this.numberToString(amount);
1232
- const priceString = this.numberToString(price);
1233
- cost = this.parseNumber(Precise.stringMul(amountString, priceString));
1234
- }
1231
+ let createMarketBuyOrderRequiresPrice = true;
1232
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
1233
+ const cost = this.safeString(params, 'cost');
1234
+ params = this.omit(params, 'cost');
1235
+ if (cost !== undefined) {
1236
+ quoteAmount = this.costToPrecision(symbol, cost);
1237
+ }
1238
+ else if (createMarketBuyOrderRequiresPrice) {
1239
+ if (price === undefined) {
1240
+ throw new InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument');
1235
1241
  }
1236
- else if (cost === undefined) {
1237
- throw new InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options["createMarketBuyOrderRequiresPrice"] = false and supply the total cost value in the "amount" argument or in the "cost" extra parameter (the exchange-specific behaviour)');
1242
+ else {
1243
+ const amountString = this.numberToString(amount);
1244
+ const priceString = this.numberToString(price);
1245
+ const costRequest = Precise.stringMul(amountString, priceString);
1246
+ quoteAmount = this.costToPrecision(symbol, costRequest);
1238
1247
  }
1239
1248
  }
1240
1249
  else {
1241
- cost = (cost === undefined) ? amount : cost;
1250
+ quoteAmount = this.costToPrecision(symbol, amount);
1242
1251
  }
1243
- costToPrecision = this.costToPrecision(symbol, cost);
1244
- request['cost'] = costToPrecision;
1252
+ request['cost'] = quoteAmount;
1245
1253
  }
1246
1254
  else {
1247
1255
  request['quantity'] = this.amountToPrecision(symbol, amount);
@@ -1276,7 +1284,7 @@ export default class probit extends Exchange {
1276
1284
  // returned by the exchange on market buys
1277
1285
  if ((type === 'market') && (side === 'buy')) {
1278
1286
  order['amount'] = undefined;
1279
- order['cost'] = this.parseNumber(costToPrecision);
1287
+ order['cost'] = this.parseNumber(quoteAmount);
1280
1288
  order['remaining'] = undefined;
1281
1289
  }
1282
1290
  return order;
@@ -6,7 +6,7 @@ export interface IJSEncryptOptions {
6
6
  }
7
7
  /**
8
8
  *
9
- * @param {Object} [options = {}] - An object to customize JSEncrypt behaviour
9
+ * @param {object} [options = {}] - An object to customize JSEncrypt behaviour
10
10
  * possible parameters are:
11
11
  * - default_key_size {number} default: 1024 the key size in bit
12
12
  * - default_public_exponent {string} default: '010001' the hexadecimal representation of the public exponent
@@ -11,7 +11,7 @@ const version = typeof process !== 'undefined'
11
11
  : undefined;
12
12
  /**
13
13
  *
14
- * @param {Object} [options = {}] - An object to customize JSEncrypt behaviour
14
+ * @param {object} [options = {}] - An object to customize JSEncrypt behaviour
15
15
  * possible parameters are:
16
16
  * - default_key_size {number} default: 1024 the key size in bit
17
17
  * - default_public_exponent {string} default: '010001' the hexadecimal representation of the public exponent
@@ -113,7 +113,7 @@ export declare class JSEncryptRSAKey extends RSAKey {
113
113
  /**
114
114
  * Check if the object contains the necessary parameters to populate the rsa modulus
115
115
  * and public exponent parameters.
116
- * @param {Object} [obj={}] - An object that may contain the two public key
116
+ * @param {object} [obj={}] - An object that may contain the two public key
117
117
  * parameters
118
118
  * @returns {boolean} true if the object contains both the modulus and the public exponent
119
119
  * properties (n and e)
@@ -124,7 +124,7 @@ export declare class JSEncryptRSAKey extends RSAKey {
124
124
  static hasPublicKeyProperty(obj: object): boolean;
125
125
  /**
126
126
  * Check if the object contains ALL the parameters of an RSA key.
127
- * @param {Object} [obj={}] - An object that may contain nine rsa key
127
+ * @param {object} [obj={}] - An object that may contain nine rsa key
128
128
  * parameters
129
129
  * @returns {boolean} true if the object contains all the parameters needed
130
130
  * @todo check for types of the parameters all the parameters but the public exponent
@@ -135,7 +135,7 @@ export declare class JSEncryptRSAKey extends RSAKey {
135
135
  /**
136
136
  * Parse the properties of obj in the current rsa object. Obj should AT LEAST
137
137
  * include the modulus and public exponent (n, e) parameters.
138
- * @param {Object} obj - the object containing rsa parameters
138
+ * @param {object} obj - the object containing rsa parameters
139
139
  * @private
140
140
  */
141
141
  parsePropertiesFrom(obj: any): void;
@@ -254,7 +254,7 @@ export class JSEncryptRSAKey extends RSAKey {
254
254
  /**
255
255
  * Check if the object contains the necessary parameters to populate the rsa modulus
256
256
  * and public exponent parameters.
257
- * @param {Object} [obj={}] - An object that may contain the two public key
257
+ * @param {object} [obj={}] - An object that may contain the two public key
258
258
  * parameters
259
259
  * @returns {boolean} true if the object contains both the modulus and the public exponent
260
260
  * properties (n and e)
@@ -268,7 +268,7 @@ export class JSEncryptRSAKey extends RSAKey {
268
268
  }
269
269
  /**
270
270
  * Check if the object contains ALL the parameters of an RSA key.
271
- * @param {Object} [obj={}] - An object that may contain nine rsa key
271
+ * @param {object} [obj={}] - An object that may contain nine rsa key
272
272
  * parameters
273
273
  * @returns {boolean} true if the object contains all the parameters needed
274
274
  * @todo check for types of the parameters all the parameters but the public exponent
@@ -289,7 +289,7 @@ export class JSEncryptRSAKey extends RSAKey {
289
289
  /**
290
290
  * Parse the properties of obj in the current rsa object. Obj should AT LEAST
291
291
  * include the modulus and public exponent (n, e) parameters.
292
- * @param {Object} obj - the object containing rsa parameters
292
+ * @param {object} obj - the object containing rsa parameters
293
293
  * @private
294
294
  */
295
295
  parsePropertiesFrom(obj) {
package/js/src/timex.d.ts CHANGED
@@ -2,7 +2,7 @@ import Exchange from './abstract/timex.js';
2
2
  import { Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction } from './base/types.js';
3
3
  /**
4
4
  * @class timex
5
- * @extends Exchange
5
+ * @augments Exchange
6
6
  */
7
7
  export default class timex extends Exchange {
8
8
  describe(): any;
package/js/src/timex.js CHANGED
@@ -10,7 +10,7 @@ import { Precise } from './base/Precise.js';
10
10
  import { TICK_SIZE } from './base/functions/number.js';
11
11
  /**
12
12
  * @class timex
13
- * @extends Exchange
13
+ * @augments Exchange
14
14
  */
15
15
  export default class timex extends Exchange {
16
16
  describe() {
@@ -2,7 +2,7 @@ import Exchange from './abstract/tokocrypto.js';
2
2
  import { Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction } from './base/types.js';
3
3
  /**
4
4
  * @class tokocrypto
5
- * @extends Exchange
5
+ * @augments Exchange
6
6
  */
7
7
  export default class tokocrypto extends Exchange {
8
8
  describe(): any;
@@ -13,7 +13,7 @@ import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
13
13
  // ---------------------------------------------------------------------------
14
14
  /**
15
15
  * @class tokocrypto
16
- * @extends Exchange
16
+ * @augments Exchange
17
17
  */
18
18
  export default class tokocrypto extends Exchange {
19
19
  describe() {
@@ -1018,16 +1018,21 @@ export default class tokocrypto extends Exchange {
1018
1018
  const data = this.safeValue(responseInner, 'data', {});
1019
1019
  return this.parseTrades(data, market, since, limit);
1020
1020
  }
1021
+ if (limit !== undefined) {
1022
+ request['limit'] = limit; // default = 500, maximum = 1000
1023
+ }
1021
1024
  const defaultMethod = 'binanceGetTrades';
1022
1025
  const method = this.safeString(this.options, 'fetchTradesMethod', defaultMethod);
1026
+ let response = undefined;
1023
1027
  if ((method === 'binanceGetAggTrades') && (since !== undefined)) {
1024
1028
  request['startTime'] = since;
1025
1029
  // https://github.com/ccxt/ccxt/issues/6400
1026
1030
  // https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#compressedaggregate-trades-list
1027
1031
  request['endTime'] = this.sum(since, 3600000);
1032
+ response = await this.binanceGetAggTrades(this.extend(request, params));
1028
1033
  }
1029
- if (limit !== undefined) {
1030
- request['limit'] = limit; // default = 500, maximum = 1000
1034
+ else {
1035
+ response = await this.binanceGetTrades(this.extend(request, params));
1031
1036
  }
1032
1037
  //
1033
1038
  // Caveats:
@@ -1038,7 +1043,6 @@ export default class tokocrypto extends Exchange {
1038
1043
  // - 'tradeId' accepted and returned by this method is "aggregate" trade id
1039
1044
  // which is different from actual trade id
1040
1045
  // - setting both fromId and time window results in error
1041
- const response = await this[method](this.extend(request, params));
1042
1046
  //
1043
1047
  // aggregate trades
1044
1048
  //
package/js/src/upbit.d.ts CHANGED
@@ -2,7 +2,7 @@ import Exchange from './abstract/upbit.js';
2
2
  import { Balances, Currency, Dictionary, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction } from './base/types.js';
3
3
  /**
4
4
  * @class upbit
5
- * @extends Exchange
5
+ * @augments Exchange
6
6
  */
7
7
  export default class upbit extends Exchange {
8
8
  describe(): any;
package/js/src/upbit.js CHANGED
@@ -15,7 +15,7 @@ import { jwt } from './base/functions/rsa.js';
15
15
  // ---------------------------------------------------------------------------
16
16
  /**
17
17
  * @class upbit
18
- * @extends Exchange
18
+ * @augments Exchange
19
19
  */
20
20
  export default class upbit extends Exchange {
21
21
  describe() {
@@ -3,7 +3,7 @@ import { Precise } from './base/Precise.js';
3
3
  import { Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction } from './base/types.js';
4
4
  /**
5
5
  * @class wavesexchange
6
- * @extends Exchange
6
+ * @augments Exchange
7
7
  */
8
8
  export default class wavesexchange extends Exchange {
9
9
  describe(): any;
@@ -13,7 +13,7 @@ import { DECIMAL_PLACES } from './base/functions/number.js';
13
13
  // ---------------------------------------------------------------------------
14
14
  /**
15
15
  * @class wavesexchange
16
- * @extends Exchange
16
+ * @augments Exchange
17
17
  */
18
18
  export default class wavesexchange extends Exchange {
19
19
  describe() {
@@ -2,7 +2,7 @@ import Exchange from './abstract/wazirx.js';
2
2
  import { Balances, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade } from './base/types.js';
3
3
  /**
4
4
  * @class wazirx
5
- * @extends Exchange
5
+ * @augments Exchange
6
6
  */
7
7
  export default class wazirx extends Exchange {
8
8
  describe(): any;
package/js/src/wazirx.js CHANGED
@@ -11,7 +11,7 @@ import { TICK_SIZE } from './base/functions/number.js';
11
11
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
12
12
  /**
13
13
  * @class wazirx
14
- * @extends Exchange
14
+ * @augments Exchange
15
15
  */
16
16
  export default class wazirx extends Exchange {
17
17
  describe() {