ccxt 4.2.47 → 4.2.49

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 (59) hide show
  1. package/README.md +3 -3
  2. package/build.sh +7 -0
  3. package/dist/ccxt.browser.js +681 -84
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/binance.js +10 -4
  7. package/dist/cjs/src/bitmart.js +30 -4
  8. package/dist/cjs/src/bitstamp.js +8 -0
  9. package/dist/cjs/src/btcalpha.js +4 -0
  10. package/dist/cjs/src/btcmarkets.js +4 -0
  11. package/dist/cjs/src/btcturk.js +4 -0
  12. package/dist/cjs/src/bybit.js +138 -6
  13. package/dist/cjs/src/idex.js +52 -1
  14. package/dist/cjs/src/independentreserve.js +48 -0
  15. package/dist/cjs/src/indodax.js +120 -19
  16. package/dist/cjs/src/latoken.js +16 -0
  17. package/dist/cjs/src/luno.js +18 -0
  18. package/dist/cjs/src/lykke.js +19 -0
  19. package/dist/cjs/src/ndax.js +18 -0
  20. package/dist/cjs/src/okx.js +32 -5
  21. package/dist/cjs/src/pro/ascendex.js +22 -7
  22. package/dist/cjs/src/pro/bitget.js +28 -7
  23. package/dist/cjs/src/pro/bitstamp.js +1 -1
  24. package/dist/cjs/src/pro/hitbtc.js +6 -11
  25. package/dist/cjs/src/pro/mexc.js +2 -1
  26. package/dist/cjs/src/upbit.js +100 -17
  27. package/js/ccxt.d.ts +1 -1
  28. package/js/ccxt.js +1 -1
  29. package/js/src/abstract/bitstamp.d.ts +8 -0
  30. package/js/src/abstract/indodax.d.ts +9 -8
  31. package/js/src/binance.js +10 -4
  32. package/js/src/bitmart.js +30 -4
  33. package/js/src/bitstamp.js +8 -0
  34. package/js/src/btcalpha.js +4 -0
  35. package/js/src/btcmarkets.js +4 -0
  36. package/js/src/btcturk.js +4 -0
  37. package/js/src/bybit.d.ts +3 -1
  38. package/js/src/bybit.js +138 -6
  39. package/js/src/idex.d.ts +7 -0
  40. package/js/src/idex.js +52 -1
  41. package/js/src/independentreserve.d.ts +15 -1
  42. package/js/src/independentreserve.js +48 -0
  43. package/js/src/indodax.d.ts +3 -1
  44. package/js/src/indodax.js +120 -19
  45. package/js/src/latoken.js +16 -0
  46. package/js/src/luno.js +18 -0
  47. package/js/src/lykke.js +19 -0
  48. package/js/src/ndax.js +18 -0
  49. package/js/src/okx.js +32 -5
  50. package/js/src/pro/ascendex.d.ts +1 -0
  51. package/js/src/pro/ascendex.js +22 -7
  52. package/js/src/pro/bitget.js +28 -7
  53. package/js/src/pro/bitstamp.js +1 -1
  54. package/js/src/pro/hitbtc.js +6 -11
  55. package/js/src/pro/mexc.js +2 -1
  56. package/js/src/upbit.d.ts +2 -0
  57. package/js/src/upbit.js +100 -17
  58. package/package.json +3 -1
  59. package/skip-tests.json +4 -2
@@ -184,6 +184,7 @@ class lykke extends lykke$1 {
184
184
  * @method
185
185
  * @name lykke#fetchCurrencies
186
186
  * @description fetches all available currencies on an exchange
187
+ * @see https://lykkecity.github.io/Trading-API/#get-all-assets
187
188
  * @param {object} [params] extra parameters specific to the exchange API endpoint
188
189
  * @returns {object} an associative dictionary of currencies
189
190
  */
@@ -262,6 +263,7 @@ class lykke extends lykke$1 {
262
263
  * @method
263
264
  * @name lykke#fetchMarkets
264
265
  * @description retrieves data on all markets for lykke
266
+ * @see https://lykkecity.github.io/Trading-API/#get-asset-by-id
265
267
  * @param {object} [params] extra parameters specific to the exchange API endpoint
266
268
  * @returns {object[]} an array of objects representing market data
267
269
  */
@@ -421,6 +423,8 @@ class lykke extends lykke$1 {
421
423
  * @method
422
424
  * @name lykke#fetchTicker
423
425
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
426
+ * @see https://lykkecity.github.io/Trading-API/#get-current-prices
427
+ * @see https://lykkecity.github.io/Trading-API/#24hr-ticker-price-change-statistics
424
428
  * @param {string} symbol unified symbol of the market to fetch the ticker for
425
429
  * @param {object} [params] extra parameters specific to the exchange API endpoint
426
430
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -480,6 +484,7 @@ class lykke extends lykke$1 {
480
484
  * @method
481
485
  * @name lykke#fetchTickers
482
486
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
487
+ * @see https://lykkecity.github.io/Trading-API/#24hr-ticker-price-change-statistics
483
488
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
484
489
  * @param {object} [params] extra parameters specific to the exchange API endpoint
485
490
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -511,6 +516,7 @@ class lykke extends lykke$1 {
511
516
  * @method
512
517
  * @name lykke#fetchOrderBook
513
518
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
519
+ * @see https://lykkecity.github.io/Trading-API/#asset-pair-order-book-ticker
514
520
  * @param {string} symbol unified symbol of the market to fetch the order book for
515
521
  * @param {int} [limit] the maximum amount of order book entries to return
516
522
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -615,6 +621,7 @@ class lykke extends lykke$1 {
615
621
  * @method
616
622
  * @name lykke#fetchTrades
617
623
  * @description get the list of most recent trades for a particular symbol
624
+ * @see https://lykkecity.github.io/Trading-API/#get-public-trades
618
625
  * @param {string} symbol unified symbol of the market to fetch trades for
619
626
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
620
627
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -679,6 +686,7 @@ class lykke extends lykke$1 {
679
686
  * @method
680
687
  * @name lykke#fetchBalance
681
688
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
689
+ * @see https://lykkecity.github.io/Trading-API/#get-the-current-balance
682
690
  * @param {object} [params] extra parameters specific to the exchange API endpoint
683
691
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
684
692
  */
@@ -774,6 +782,8 @@ class lykke extends lykke$1 {
774
782
  * @method
775
783
  * @name lykke#createOrder
776
784
  * @description create a trade order
785
+ * @see https://lykkecity.github.io/Trading-API/#place-a-limit-order
786
+ * @see https://lykkecity.github.io/Trading-API/#place-a-market-order
777
787
  * @param {string} symbol unified symbol of the market to create an order in
778
788
  * @param {string} type 'market' or 'limit'
779
789
  * @param {string} side 'buy' or 'sell'
@@ -850,6 +860,7 @@ class lykke extends lykke$1 {
850
860
  * @method
851
861
  * @name lykke#cancelOrder
852
862
  * @description cancels an open order
863
+ * @see https://lykkecity.github.io/Trading-API/#cancel-orders-by-id
853
864
  * @param {string} id order id
854
865
  * @param {string} symbol unified symbol of the market the order was made in
855
866
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -871,6 +882,7 @@ class lykke extends lykke$1 {
871
882
  * @method
872
883
  * @name lykke#cancelAllOrders
873
884
  * @description cancel all open orders
885
+ * @see https://lykkecity.github.io/Trading-API/#mass-cancel-orders
874
886
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
875
887
  * @param {object} [params] extra parameters specific to the exchange API endpoint
876
888
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -897,6 +909,7 @@ class lykke extends lykke$1 {
897
909
  * @method
898
910
  * @name lykke#fetchOrder
899
911
  * @description fetches information on an order made by the user
912
+ * @see https://lykkecity.github.io/Trading-API/#get-order-by-id
900
913
  * @param {string} symbol not used by lykke fetchOrder
901
914
  * @param {object} [params] extra parameters specific to the exchange API endpoint
902
915
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -933,6 +946,7 @@ class lykke extends lykke$1 {
933
946
  * @method
934
947
  * @name lykke#fetchOpenOrders
935
948
  * @description fetch all unfilled currently open orders
949
+ * @see https://lykkecity.github.io/Trading-API/#get-active-or-closed-orders
936
950
  * @param {string} symbol unified market symbol
937
951
  * @param {int} [since] the earliest time in ms to fetch open orders for
938
952
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -981,6 +995,7 @@ class lykke extends lykke$1 {
981
995
  * @method
982
996
  * @name lykke#fetchClosedOrders
983
997
  * @description fetches information on multiple closed orders made by the user
998
+ * @see https://lykkecity.github.io/Trading-API/#get-active-or-closed-orders
984
999
  * @param {string} symbol unified market symbol of the market orders were made in
985
1000
  * @param {int} [since] the earliest time in ms to fetch orders for
986
1001
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -1029,6 +1044,7 @@ class lykke extends lykke$1 {
1029
1044
  * @method
1030
1045
  * @name lykke#fetchMyTrades
1031
1046
  * @description fetch all trades made by the user
1047
+ * @see https://lykkecity.github.io/Trading-API/#get-trade-history
1032
1048
  * @param {string} symbol unified market symbol
1033
1049
  * @param {int} [since] the earliest time in ms to fetch trades for
1034
1050
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -1088,6 +1104,7 @@ class lykke extends lykke$1 {
1088
1104
  * @method
1089
1105
  * @name lykke#fetchDepositAddress
1090
1106
  * @description fetch the deposit address for a currency associated with this account
1107
+ * @see https://lykkecity.github.io/Trading-API/#get-deposit-address-for-a-given-asset
1091
1108
  * @param {string} code unified currency code
1092
1109
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1093
1110
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
@@ -1185,6 +1202,7 @@ class lykke extends lykke$1 {
1185
1202
  * @method
1186
1203
  * @name lykke#fetchDepositsWithdrawals
1187
1204
  * @description fetch history of deposits and withdrawals
1205
+ * @see https://lykkecity.github.io/Trading-API/#get-the-history-of-withdrawals-and-deposits
1188
1206
  * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
1189
1207
  * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
1190
1208
  * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
@@ -1227,6 +1245,7 @@ class lykke extends lykke$1 {
1227
1245
  * @method
1228
1246
  * @name lykke#withdraw
1229
1247
  * @description make a withdrawal
1248
+ * @see https://lykkecity.github.io/Trading-API/#withdrawal
1230
1249
  * @param {string} code unified currency code
1231
1250
  * @param {float} amount the amount to withdraw
1232
1251
  * @param {string} address the address to withdraw to
@@ -280,6 +280,7 @@ class ndax extends ndax$1 {
280
280
  * @method
281
281
  * @name ndax#signIn
282
282
  * @description sign in, must be called prior to using other authenticated methods
283
+ * @see https://apidoc.ndax.io/#authenticate2fa
283
284
  * @param {object} [params] extra parameters specific to the exchange API endpoint
284
285
  * @returns response from exchange
285
286
  */
@@ -333,6 +334,7 @@ class ndax extends ndax$1 {
333
334
  * @method
334
335
  * @name ndax#fetchCurrencies
335
336
  * @description fetches all available currencies on an exchange
337
+ * @see https://apidoc.ndax.io/#getproduct
336
338
  * @param {object} [params] extra parameters specific to the exchange API endpoint
337
339
  * @returns {object} an associative dictionary of currencies
338
340
  */
@@ -402,6 +404,7 @@ class ndax extends ndax$1 {
402
404
  * @method
403
405
  * @name ndax#fetchMarkets
404
406
  * @description retrieves data on all markets for ndax
407
+ * @see https://apidoc.ndax.io/#getinstruments
405
408
  * @param {object} [params] extra parameters specific to the exchange API endpoint
406
409
  * @returns {object[]} an array of objects representing market data
407
410
  */
@@ -561,6 +564,7 @@ class ndax extends ndax$1 {
561
564
  * @method
562
565
  * @name ndax#fetchOrderBook
563
566
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
567
+ * @see https://apidoc.ndax.io/#getl2snapshot
564
568
  * @param {string} symbol unified symbol of the market to fetch the order book for
565
569
  * @param {int} [limit] the maximum amount of order book entries to return
566
570
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -671,6 +675,7 @@ class ndax extends ndax$1 {
671
675
  * @method
672
676
  * @name ndax#fetchTicker
673
677
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
678
+ * @see https://apidoc.ndax.io/#getlevel1
674
679
  * @param {string} symbol unified symbol of the market to fetch the ticker for
675
680
  * @param {object} [params] extra parameters specific to the exchange API endpoint
676
681
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -743,6 +748,7 @@ class ndax extends ndax$1 {
743
748
  * @method
744
749
  * @name ndax#fetchOHLCV
745
750
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
751
+ * @see https://apidoc.ndax.io/#gettickerhistory
746
752
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
747
753
  * @param {string} timeframe the length of time each candle represents
748
754
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -989,6 +995,7 @@ class ndax extends ndax$1 {
989
995
  * @method
990
996
  * @name ndax#fetchAccounts
991
997
  * @description fetch all the accounts associated with a profile
998
+ * @see https://apidoc.ndax.io/#getuseraccounts
992
999
  * @param {object} [params] extra parameters specific to the exchange API endpoint
993
1000
  * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
994
1001
  */
@@ -1042,6 +1049,7 @@ class ndax extends ndax$1 {
1042
1049
  * @method
1043
1050
  * @name ndax#fetchBalance
1044
1051
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
1052
+ * @see https://apidoc.ndax.io/#getaccountpositions
1045
1053
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1046
1054
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1047
1055
  */
@@ -1169,6 +1177,7 @@ class ndax extends ndax$1 {
1169
1177
  * @method
1170
1178
  * @name ndax#fetchLedger
1171
1179
  * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1180
+ * @see https://apidoc.ndax.io/#getaccounttransactions
1172
1181
  * @param {string} code unified currency code, default is undefined
1173
1182
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1174
1183
  * @param {int} [limit] max number of ledger entrys to return, default is undefined
@@ -1323,6 +1332,7 @@ class ndax extends ndax$1 {
1323
1332
  * @method
1324
1333
  * @name ndax#createOrder
1325
1334
  * @description create a trade order
1335
+ * @see https://apidoc.ndax.io/#sendorder
1326
1336
  * @param {string} symbol unified symbol of the market to create an order in
1327
1337
  * @param {string} type 'market' or 'limit'
1328
1338
  * @param {string} side 'buy' or 'sell'
@@ -1441,6 +1451,7 @@ class ndax extends ndax$1 {
1441
1451
  * @method
1442
1452
  * @name ndax#fetchMyTrades
1443
1453
  * @description fetch all trades made by the user
1454
+ * @see https://apidoc.ndax.io/#gettradeshistory
1444
1455
  * @param {string} symbol unified market symbol
1445
1456
  * @param {int} [since] the earliest time in ms to fetch trades for
1446
1457
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -1528,6 +1539,7 @@ class ndax extends ndax$1 {
1528
1539
  * @method
1529
1540
  * @name ndax#cancelAllOrders
1530
1541
  * @description cancel all open orders
1542
+ * @see https://apidoc.ndax.io/#cancelallorders
1531
1543
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
1532
1544
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1533
1545
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -1562,6 +1574,7 @@ class ndax extends ndax$1 {
1562
1574
  * @method
1563
1575
  * @name ndax#cancelOrder
1564
1576
  * @description cancels an open order
1577
+ * @see https://apidoc.ndax.io/#cancelorder
1565
1578
  * @param {string} id order id
1566
1579
  * @param {string} symbol unified symbol of the market the order was made in
1567
1580
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1601,6 +1614,7 @@ class ndax extends ndax$1 {
1601
1614
  * @method
1602
1615
  * @name ndax#fetchOpenOrders
1603
1616
  * @description fetch all unfilled currently open orders
1617
+ * @see https://apidoc.ndax.io/#getopenorders
1604
1618
  * @param {string} symbol unified market symbol
1605
1619
  * @param {int} [since] the earliest time in ms to fetch open orders for
1606
1620
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -1679,6 +1693,7 @@ class ndax extends ndax$1 {
1679
1693
  * @method
1680
1694
  * @name ndax#fetchOrders
1681
1695
  * @description fetches information on multiple orders made by the user
1696
+ * @see https://apidoc.ndax.io/#getorderhistory
1682
1697
  * @param {string} symbol unified market symbol of the market orders were made in
1683
1698
  * @param {int} [since] the earliest time in ms to fetch orders for
1684
1699
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -1773,6 +1788,7 @@ class ndax extends ndax$1 {
1773
1788
  * @method
1774
1789
  * @name ndax#fetchOrder
1775
1790
  * @description fetches information on an order made by the user
1791
+ * @see https://apidoc.ndax.io/#getorderstatus
1776
1792
  * @param {string} symbol unified symbol of the market the order was made in
1777
1793
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1778
1794
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -1848,6 +1864,7 @@ class ndax extends ndax$1 {
1848
1864
  * @method
1849
1865
  * @name ndax#fetchOrderTrades
1850
1866
  * @description fetch all the trades made from a single order
1867
+ * @see https://apidoc.ndax.io/#getorderhistorybyorderid
1851
1868
  * @param {string} id order id
1852
1869
  * @param {string} symbol unified market symbol
1853
1870
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -2076,6 +2093,7 @@ class ndax extends ndax$1 {
2076
2093
  * @method
2077
2094
  * @name ndax#fetchWithdrawals
2078
2095
  * @description fetch all withdrawals made from an account
2096
+ * @see https://apidoc.ndax.io/#getwithdraws
2079
2097
  * @param {string} code unified currency code
2080
2098
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
2081
2099
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -5228,6 +5228,7 @@ class okx extends okx$1 {
5228
5228
  * @method
5229
5229
  * @name okx#fetchPositions
5230
5230
  * @see https://www.okx.com/docs-v5/en/#rest-api-account-get-positions
5231
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions-history history
5231
5232
  * @description fetch all open positions
5232
5233
  * @param {string[]|undefined} symbols list of unified market symbols
5233
5234
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -5368,13 +5369,38 @@ class okx extends okx$1 {
5368
5369
  // "vegaBS": "",
5369
5370
  // "vegaPA": ""
5370
5371
  // }
5372
+ // history
5373
+ // {
5374
+ // "cTime":"1708351230102",
5375
+ // "ccy":"USDT",
5376
+ // "closeAvgPx":"1.2567",
5377
+ // "closeTotalPos":"40",
5378
+ // "direction":"short",
5379
+ // "fee":"-0.0351036",
5380
+ // "fundingFee":"0",
5381
+ // "instId":"SUSHI-USDT-SWAP",
5382
+ // "instType":"SWAP",
5383
+ // "lever":"10.0",
5384
+ // "liqPenalty":"0",
5385
+ // "mgnMode":"isolated",
5386
+ // "openAvgPx":"1.2462",
5387
+ // "openMaxPos":"40",
5388
+ // "pnl":"-0.42",
5389
+ // "pnlRatio":"-0.0912982667308618",
5390
+ // "posId":"666159086676836352",
5391
+ // "realizedPnl":"-0.4551036",
5392
+ // "triggerPx":"",
5393
+ // "type":"2",
5394
+ // "uTime":"1708354805699",
5395
+ // "uly":"SUSHI-USDT"
5396
+ // }
5371
5397
  //
5372
5398
  const marketId = this.safeString(position, 'instId');
5373
5399
  market = this.safeMarket(marketId, market);
5374
5400
  const symbol = market['symbol'];
5375
5401
  const pos = this.safeString(position, 'pos'); // 'pos' field: One way mode: 0 if position is not open, 1 if open | Two way (hedge) mode: -1 if short, 1 if long, 0 if position is not open
5376
5402
  const contractsAbs = Precise["default"].stringAbs(pos);
5377
- let side = this.safeString(position, 'posSide');
5403
+ let side = this.safeString2(position, 'posSide', 'direction');
5378
5404
  const hedged = side !== 'net';
5379
5405
  const contracts = this.parseNumber(contractsAbs);
5380
5406
  if (market['margin']) {
@@ -5415,7 +5441,7 @@ class okx extends okx$1 {
5415
5441
  const notional = this.parseNumber(notionalString);
5416
5442
  const marginMode = this.safeString(position, 'mgnMode');
5417
5443
  let initialMarginString = undefined;
5418
- const entryPriceString = this.safeString(position, 'avgPx');
5444
+ const entryPriceString = this.safeString2(position, 'avgPx', 'openAvgPx');
5419
5445
  const unrealizedPnlString = this.safeString(position, 'upl');
5420
5446
  const leverageString = this.safeString(position, 'lever');
5421
5447
  let initialMarginPercentage = undefined;
@@ -5446,23 +5472,24 @@ class okx extends okx$1 {
5446
5472
  const marginRatio = this.parseNumber(Precise["default"].stringDiv(maintenanceMarginString, collateralString, 4));
5447
5473
  return this.safePosition({
5448
5474
  'info': position,
5449
- 'id': undefined,
5475
+ 'id': this.safeString(position, 'posId'),
5450
5476
  'symbol': symbol,
5451
5477
  'notional': notional,
5452
5478
  'marginMode': marginMode,
5453
5479
  'liquidationPrice': liquidationPrice,
5454
5480
  'entryPrice': this.parseNumber(entryPriceString),
5455
5481
  'unrealizedPnl': this.parseNumber(unrealizedPnlString),
5482
+ 'realizedPnl': this.safeNumber(position, 'realizedPnl'),
5456
5483
  'percentage': percentage,
5457
5484
  'contracts': contracts,
5458
5485
  'contractSize': contractSize,
5459
5486
  'markPrice': this.parseNumber(markPriceString),
5460
- 'lastPrice': undefined,
5487
+ 'lastPrice': this.safeNumber(position, 'closeAvgPx'),
5461
5488
  'side': side,
5462
5489
  'hedged': hedged,
5463
5490
  'timestamp': timestamp,
5464
5491
  'datetime': this.iso8601(timestamp),
5465
- 'lastUpdateTimestamp': undefined,
5492
+ 'lastUpdateTimestamp': this.safeInteger(position, 'uTime'),
5466
5493
  'maintenanceMargin': maintenanceMargin,
5467
5494
  'maintenanceMarginPercentage': maintenanceMarginPercentage,
5468
5495
  'collateral': this.parseNumber(collateralString),
@@ -208,7 +208,7 @@ class ascendex extends ascendex$1 {
208
208
  */
209
209
  await this.loadMarkets();
210
210
  const market = this.market(symbol);
211
- const channel = 'depth-realtime' + ':' + market['id'];
211
+ const channel = 'depth' + ':' + market['id'];
212
212
  params = this.extend(params, {
213
213
  'ch': channel,
214
214
  });
@@ -218,7 +218,7 @@ class ascendex extends ascendex$1 {
218
218
  async watchOrderBookSnapshot(symbol, limit = undefined, params = {}) {
219
219
  await this.loadMarkets();
220
220
  const market = this.market(symbol);
221
- const action = 'depth-snapshot-realtime';
221
+ const action = 'depth-snapshot';
222
222
  const channel = action + ':' + market['id'];
223
223
  params = this.extend(params, {
224
224
  'action': action,
@@ -230,6 +230,15 @@ class ascendex extends ascendex$1 {
230
230
  const orderbook = await this.watchPublic(channel, params);
231
231
  return orderbook.limit();
232
232
  }
233
+ async fetchOrderBookSnapshot(symbol, limit = undefined, params = {}) {
234
+ const restOrderBook = await this.fetchRestOrderBookSafe(symbol, limit, params);
235
+ if (!(symbol in this.orderbooks)) {
236
+ this.orderbooks[symbol] = this.orderBook();
237
+ }
238
+ const orderbook = this.orderbooks[symbol];
239
+ orderbook.reset(restOrderBook);
240
+ return orderbook;
241
+ }
233
242
  handleOrderBookSnapshot(client, message) {
234
243
  //
235
244
  // {
@@ -866,8 +875,8 @@ class ascendex extends ascendex$1 {
866
875
  'ping': this.handlePing,
867
876
  'auth': this.handleAuthenticate,
868
877
  'sub': this.handleSubscriptionStatus,
869
- 'depth-realtime': this.handleOrderBook,
870
- 'depth-snapshot-realtime': this.handleOrderBookSnapshot,
878
+ 'depth': this.handleOrderBook,
879
+ 'depth-snapshot': this.handleOrderBookSnapshot,
871
880
  'trades': this.handleTrades,
872
881
  'bar': this.handleOHLCV,
873
882
  'balance': this.handleBalance,
@@ -894,7 +903,7 @@ class ascendex extends ascendex$1 {
894
903
  // { m: 'sub', id: "1647515701", ch: "depth:BTC/USDT", code: 0 }
895
904
  //
896
905
  const channel = this.safeString(message, 'ch', '');
897
- if (channel.indexOf('depth-realtime') > -1) {
906
+ if (channel.indexOf('depth') > -1 && !(channel.indexOf('depth-snapshot') > -1)) {
898
907
  this.handleOrderBookSubscription(client, message);
899
908
  }
900
909
  return message;
@@ -903,12 +912,18 @@ class ascendex extends ascendex$1 {
903
912
  const channel = this.safeString(message, 'ch');
904
913
  const parts = channel.split(':');
905
914
  const marketId = parts[1];
906
- const symbol = this.safeSymbol(marketId);
915
+ const market = this.safeMarket(marketId);
916
+ const symbol = market['symbol'];
907
917
  if (symbol in this.orderbooks) {
908
918
  delete this.orderbooks[symbol];
909
919
  }
910
920
  this.orderbooks[symbol] = this.orderBook({});
911
- this.spawn(this.watchOrderBookSnapshot, symbol);
921
+ if (this.options['defaultType'] === 'swap' || market['contract']) {
922
+ this.spawn(this.fetchOrderBookSnapshot, symbol);
923
+ }
924
+ else {
925
+ this.spawn(this.watchOrderBookSnapshot, symbol);
926
+ }
912
927
  }
913
928
  async pong(client, message) {
914
929
  //
@@ -962,6 +962,7 @@ class bitget extends bitget$1 {
962
962
  // "clientOid": "798d1425-d31d-4ada-a51b-ec701e00a1d9",
963
963
  // "price": "35000.00",
964
964
  // "size": "7.0000",
965
+ // "newSize": "500.0000",
965
966
  // "notional": "7.000000",
966
967
  // "orderType": "limit",
967
968
  // "force": "gtc",
@@ -1129,6 +1130,7 @@ class bitget extends bitget$1 {
1129
1130
  // "clientOid": "798d1425-d31d-4ada-a51b-ec701e00a1d9",
1130
1131
  // "price": "35000.00",
1131
1132
  // "size": "7.0000",
1133
+ // "newSize": "500.0000",
1132
1134
  // "notional": "7.000000",
1133
1135
  // "orderType": "limit",
1134
1136
  // "force": "gtc",
@@ -1236,6 +1238,25 @@ class bitget extends bitget$1 {
1236
1238
  };
1237
1239
  }
1238
1240
  const triggerPrice = this.safeNumber(order, 'triggerPrice');
1241
+ const price = this.safeString(order, 'price');
1242
+ const avgPrice = this.omitZero(this.safeString2(order, 'priceAvg', 'fillPrice'));
1243
+ let cost = this.safeStringN(order, ['notional', 'notionalUsd', 'quoteSize']);
1244
+ const side = this.safeString(order, 'side');
1245
+ const type = this.safeString(order, 'orderType');
1246
+ if (side === 'buy' && market['spot'] && (type === 'market')) {
1247
+ cost = this.safeString(order, 'newSize', cost);
1248
+ }
1249
+ let filled = this.safeString2(order, 'accBaseVolume', 'baseVolume');
1250
+ if (market['spot'] && (rawStatus !== 'live')) {
1251
+ filled = Precise["default"].stringDiv(cost, avgPrice);
1252
+ }
1253
+ let amount = this.safeString(order, 'baseVolume');
1254
+ if (!market['spot'] || !(side === 'buy' && type === 'market')) {
1255
+ amount = this.safeString(order, 'newSize', amount);
1256
+ }
1257
+ if (market['swap'] && (amount === undefined)) {
1258
+ amount = this.safeString(order, 'size');
1259
+ }
1239
1260
  return this.safeOrder({
1240
1261
  'info': order,
1241
1262
  'symbol': symbol,
@@ -1244,17 +1265,17 @@ class bitget extends bitget$1 {
1244
1265
  'timestamp': timestamp,
1245
1266
  'datetime': this.iso8601(timestamp),
1246
1267
  'lastTradeTimestamp': this.safeInteger(order, 'uTime'),
1247
- 'type': this.safeString(order, 'orderType'),
1268
+ 'type': type,
1248
1269
  'timeInForce': this.safeStringUpper(order, 'force'),
1249
1270
  'postOnly': undefined,
1250
- 'side': this.safeString(order, 'side'),
1251
- 'price': this.safeString(order, 'price'),
1271
+ 'side': side,
1272
+ 'price': price,
1252
1273
  'stopPrice': triggerPrice,
1253
1274
  'triggerPrice': triggerPrice,
1254
- 'amount': this.safeString(order, 'baseVolume'),
1255
- 'cost': this.safeStringN(order, ['notional', 'notionalUsd', 'quoteSize']),
1256
- 'average': this.omitZero(this.safeString2(order, 'priceAvg', 'fillPrice')),
1257
- 'filled': this.safeString2(order, 'accBaseVolume', 'baseVolume'),
1275
+ 'amount': amount,
1276
+ 'cost': cost,
1277
+ 'average': avgPrice,
1278
+ 'filled': filled,
1258
1279
  'remaining': undefined,
1259
1280
  'status': this.parseWsOrderStatus(rawStatus),
1260
1281
  'fee': feeObject,
@@ -106,7 +106,7 @@ class bitstamp extends bitstamp$1 {
106
106
  // usually it takes at least 4-5 deltas to resolve
107
107
  const snapshotDelay = this.handleOption('watchOrderBook', 'snapshotDelay', 6);
108
108
  if (cacheLength === snapshotDelay) {
109
- this.spawn(this.loadOrderBook, client, messageHash, symbol);
109
+ this.spawn(this.loadOrderBook, client, messageHash, symbol, null, {});
110
110
  }
111
111
  storedOrderBook.cache.push(delta);
112
112
  return;
@@ -220,7 +220,7 @@ class hitbtc extends hitbtc$1 {
220
220
  'symbols': [market['id']],
221
221
  },
222
222
  };
223
- const orderbook = await this.subscribePublic(name, name, [symbol], this.deepExtend(request, params));
223
+ const orderbook = await this.subscribePublic(name, 'orderbooks', [symbol], this.deepExtend(request, params));
224
224
  return orderbook.limit();
225
225
  }
226
226
  handleOrderBook(client, message) {
@@ -249,13 +249,12 @@ class hitbtc extends hitbtc$1 {
249
249
  //
250
250
  const data = this.safeValue2(message, 'snapshot', 'update', {});
251
251
  const marketIds = Object.keys(data);
252
- const channel = this.safeString(message, 'ch');
253
252
  for (let i = 0; i < marketIds.length; i++) {
254
253
  const marketId = marketIds[i];
255
254
  const market = this.safeMarket(marketId);
256
255
  const symbol = market['symbol'];
257
256
  const item = data[marketId];
258
- const messageHash = channel + '::' + symbol;
257
+ const messageHash = 'orderbooks::' + symbol;
259
258
  if (!(symbol in this.orderbooks)) {
260
259
  const subscription = this.safeValue(client.subscriptions, messageHash, {});
261
260
  const limit = this.safeInteger(subscription, 'limit');
@@ -313,7 +312,7 @@ class hitbtc extends hitbtc$1 {
313
312
  'symbols': [market['id']],
314
313
  },
315
314
  };
316
- const result = await this.subscribePublic(name, 'ticker', [symbol], this.deepExtend(request, params));
315
+ const result = await this.subscribePublic(name, 'tickers', [symbol], this.deepExtend(request, params));
317
316
  return this.safeValue(result, symbol);
318
317
  }
319
318
  async watchTickers(symbols = undefined, params = {}) {
@@ -396,7 +395,6 @@ class hitbtc extends hitbtc$1 {
396
395
  //
397
396
  const data = this.safeValue(message, 'data', {});
398
397
  const marketIds = Object.keys(data);
399
- const channel = this.safeString(message, 'ch');
400
398
  const newTickers = {};
401
399
  for (let i = 0; i < marketIds.length; i++) {
402
400
  const marketId = marketIds[i];
@@ -405,8 +403,6 @@ class hitbtc extends hitbtc$1 {
405
403
  const ticker = this.parseWsTicker(data[marketId], market);
406
404
  this.tickers[symbol] = ticker;
407
405
  newTickers[symbol] = ticker;
408
- const messageHash = channel + '::' + symbol;
409
- client.resolve(newTickers, messageHash);
410
406
  }
411
407
  client.resolve(newTickers, 'tickers');
412
408
  const messageHashes = this.findMessageHashes(client, 'tickers::');
@@ -422,7 +418,6 @@ class hitbtc extends hitbtc$1 {
422
418
  client.resolve(tickers, messageHash);
423
419
  }
424
420
  }
425
- client.resolve(this.tickers, channel);
426
421
  return message;
427
422
  }
428
423
  parseWsTicker(ticker, market = undefined) {
@@ -503,7 +498,7 @@ class hitbtc extends hitbtc$1 {
503
498
  request['limit'] = limit;
504
499
  }
505
500
  const name = 'trades';
506
- const trades = await this.subscribePublic(name, name, [symbol], this.deepExtend(request, params));
501
+ const trades = await this.subscribePublic(name, 'trades', [symbol], this.deepExtend(request, params));
507
502
  if (this.newUpdates) {
508
503
  limit = trades.getLimit(symbol, limit);
509
504
  }
@@ -632,7 +627,7 @@ class hitbtc extends hitbtc$1 {
632
627
  if (limit !== undefined) {
633
628
  request['params']['limit'] = limit;
634
629
  }
635
- const ohlcv = await this.subscribePublic(name, name, [symbol], this.deepExtend(request, params));
630
+ const ohlcv = await this.subscribePublic(name, 'candles', [symbol], this.deepExtend(request, params));
636
631
  if (this.newUpdates) {
637
632
  limit = ohlcv.getLimit(symbol, limit);
638
633
  }
@@ -693,7 +688,7 @@ class hitbtc extends hitbtc$1 {
693
688
  for (let j = 0; j < ohlcvs.length; j++) {
694
689
  stored.append(ohlcvs[j]);
695
690
  }
696
- const messageHash = channel + '::' + symbol;
691
+ const messageHash = 'candles::' + symbol;
697
692
  client.resolve(stored, messageHash);
698
693
  }
699
694
  return message;
@@ -450,6 +450,7 @@ class mexc extends mexc$1 {
450
450
  const symbol = this.safeSymbol(marketId);
451
451
  const messageHash = 'orderbook:' + symbol;
452
452
  const subscription = this.safeValue(client.subscriptions, messageHash);
453
+ const limit = this.safeInteger(subscription, 'limit');
453
454
  if (subscription === true) {
454
455
  // we set client.subscriptions[messageHash] to 1
455
456
  // once we have received the first delta and initialized the orderbook
@@ -462,7 +463,7 @@ class mexc extends mexc$1 {
462
463
  const cacheLength = storedOrderBook.cache.length;
463
464
  const snapshotDelay = this.handleOption('watchOrderBook', 'snapshotDelay', 25);
464
465
  if (cacheLength === snapshotDelay) {
465
- this.spawn(this.loadOrderBook, client, messageHash, symbol);
466
+ this.spawn(this.loadOrderBook, client, messageHash, symbol, limit, {});
466
467
  }
467
468
  storedOrderBook.cache.push(data);
468
469
  return;