ccxt 4.3.6 → 4.3.7

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 (193) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/ace.js +5 -0
  4. package/dist/cjs/src/alpaca.js +6 -0
  5. package/dist/cjs/src/base/Exchange.js +34 -0
  6. package/dist/cjs/src/binance.js +2 -0
  7. package/dist/cjs/src/bingx.js +2 -0
  8. package/dist/cjs/src/bitbank.js +3 -0
  9. package/dist/cjs/src/bitget.js +74 -1
  10. package/dist/cjs/src/bithumb.js +4 -0
  11. package/dist/cjs/src/bitmex.js +2 -0
  12. package/dist/cjs/src/bitopro.js +5 -0
  13. package/dist/cjs/src/bitso.js +3 -0
  14. package/dist/cjs/src/bitstamp.js +3 -0
  15. package/dist/cjs/src/bitteam.js +4 -0
  16. package/dist/cjs/src/bitvavo.js +3 -0
  17. package/dist/cjs/src/bl3p.js +3 -0
  18. package/dist/cjs/src/btcalpha.js +3 -0
  19. package/dist/cjs/src/btcbox.js +3 -0
  20. package/dist/cjs/src/btcmarkets.js +3 -0
  21. package/dist/cjs/src/btcturk.js +3 -0
  22. package/dist/cjs/src/bybit.js +123 -12
  23. package/dist/cjs/src/cex.js +6 -0
  24. package/dist/cjs/src/coinbase.js +95 -17
  25. package/dist/cjs/src/coinbaseinternational.js +2 -0
  26. package/dist/cjs/src/coinbasepro.js +6 -0
  27. package/dist/cjs/src/coincheck.js +3 -0
  28. package/dist/cjs/src/coinex.js +150 -43
  29. package/dist/cjs/src/coinlist.js +4 -0
  30. package/dist/cjs/src/coinmate.js +3 -0
  31. package/dist/cjs/src/coinone.js +3 -0
  32. package/dist/cjs/src/coinsph.js +4 -0
  33. package/dist/cjs/src/coinspot.js +3 -0
  34. package/dist/cjs/src/cryptocom.js +2 -0
  35. package/dist/cjs/src/exmo.js +5 -0
  36. package/dist/cjs/src/gate.js +124 -22
  37. package/dist/cjs/src/hitbtc.js +4 -3
  38. package/dist/cjs/src/htx.js +2 -0
  39. package/dist/cjs/src/idex.js +3 -0
  40. package/dist/cjs/src/independentreserve.js +3 -0
  41. package/dist/cjs/src/indodax.js +3 -0
  42. package/dist/cjs/src/kucoin.js +2 -0
  43. package/dist/cjs/src/kucoinfutures.js +2 -0
  44. package/dist/cjs/src/latoken.js +6 -0
  45. package/dist/cjs/src/luno.js +3 -0
  46. package/dist/cjs/src/lykke.js +5 -0
  47. package/dist/cjs/src/mercado.js +3 -0
  48. package/dist/cjs/src/mexc.js +111 -0
  49. package/dist/cjs/src/ndax.js +4 -0
  50. package/dist/cjs/src/novadax.js +4 -0
  51. package/dist/cjs/src/okx.js +83 -0
  52. package/dist/cjs/src/onetrading.js +3 -0
  53. package/dist/cjs/src/p2b.js +3 -0
  54. package/dist/cjs/src/pro/bybit.js +1 -1
  55. package/dist/cjs/src/pro/coinbase.js +30 -29
  56. package/dist/cjs/src/probit.js +3 -0
  57. package/dist/cjs/src/timex.js +3 -0
  58. package/dist/cjs/src/tradeogre.js +3 -0
  59. package/dist/cjs/src/wavesexchange.js +3 -0
  60. package/dist/cjs/src/wazirx.js +3 -0
  61. package/dist/cjs/src/woo.js +2 -0
  62. package/dist/cjs/src/yobit.js +3 -0
  63. package/js/ccxt.d.ts +1 -1
  64. package/js/ccxt.js +1 -1
  65. package/js/src/abstract/coinbase.d.ts +5 -0
  66. package/js/src/ace.js +5 -0
  67. package/js/src/alpaca.js +6 -0
  68. package/js/src/ascendex.d.ts +2 -2
  69. package/js/src/base/Exchange.d.ts +4 -0
  70. package/js/src/base/Exchange.js +34 -0
  71. package/js/src/bigone.d.ts +1 -1
  72. package/js/src/binance.d.ts +3 -3
  73. package/js/src/binance.js +2 -0
  74. package/js/src/bingx.d.ts +1 -1
  75. package/js/src/bingx.js +2 -0
  76. package/js/src/bitbank.d.ts +1 -1
  77. package/js/src/bitbank.js +3 -0
  78. package/js/src/bitfinex.d.ts +1 -1
  79. package/js/src/bitfinex2.d.ts +1 -1
  80. package/js/src/bitflyer.d.ts +1 -1
  81. package/js/src/bitget.d.ts +4 -3
  82. package/js/src/bitget.js +74 -1
  83. package/js/src/bithumb.d.ts +1 -1
  84. package/js/src/bithumb.js +4 -0
  85. package/js/src/bitmart.d.ts +1 -1
  86. package/js/src/bitmex.d.ts +1 -1
  87. package/js/src/bitmex.js +2 -0
  88. package/js/src/bitopro.d.ts +1 -1
  89. package/js/src/bitopro.js +5 -0
  90. package/js/src/bitrue.d.ts +1 -1
  91. package/js/src/bitso.d.ts +1 -1
  92. package/js/src/bitso.js +3 -0
  93. package/js/src/bitstamp.d.ts +1 -1
  94. package/js/src/bitstamp.js +3 -0
  95. package/js/src/bitteam.js +4 -0
  96. package/js/src/bitvavo.d.ts +1 -1
  97. package/js/src/bitvavo.js +3 -0
  98. package/js/src/bl3p.js +3 -0
  99. package/js/src/blockchaincom.d.ts +1 -1
  100. package/js/src/btcalpha.js +3 -0
  101. package/js/src/btcbox.js +3 -0
  102. package/js/src/btcmarkets.d.ts +1 -1
  103. package/js/src/btcmarkets.js +3 -0
  104. package/js/src/btcturk.js +3 -0
  105. package/js/src/bybit.d.ts +7 -6
  106. package/js/src/bybit.js +123 -12
  107. package/js/src/cex.js +6 -0
  108. package/js/src/coinbase.d.ts +1 -1
  109. package/js/src/coinbase.js +95 -17
  110. package/js/src/coinbaseinternational.d.ts +1 -1
  111. package/js/src/coinbaseinternational.js +2 -0
  112. package/js/src/coinbasepro.d.ts +1 -1
  113. package/js/src/coinbasepro.js +6 -0
  114. package/js/src/coincheck.js +3 -0
  115. package/js/src/coinex.d.ts +8 -7
  116. package/js/src/coinex.js +150 -43
  117. package/js/src/coinlist.d.ts +1 -1
  118. package/js/src/coinlist.js +4 -0
  119. package/js/src/coinmate.d.ts +1 -1
  120. package/js/src/coinmate.js +3 -0
  121. package/js/src/coinone.js +3 -0
  122. package/js/src/coinsph.d.ts +1 -1
  123. package/js/src/coinsph.js +4 -0
  124. package/js/src/coinspot.js +3 -0
  125. package/js/src/cryptocom.d.ts +1 -1
  126. package/js/src/cryptocom.js +2 -0
  127. package/js/src/delta.d.ts +2 -2
  128. package/js/src/deribit.d.ts +1 -1
  129. package/js/src/digifinex.d.ts +3 -3
  130. package/js/src/exmo.d.ts +3 -3
  131. package/js/src/exmo.js +5 -0
  132. package/js/src/gate.d.ts +8 -7
  133. package/js/src/gate.js +124 -22
  134. package/js/src/gemini.d.ts +1 -1
  135. package/js/src/hitbtc.d.ts +3 -3
  136. package/js/src/hitbtc.js +4 -3
  137. package/js/src/hollaex.d.ts +1 -1
  138. package/js/src/htx.d.ts +1 -1
  139. package/js/src/htx.js +2 -0
  140. package/js/src/huobijp.d.ts +1 -1
  141. package/js/src/hyperliquid.d.ts +2 -2
  142. package/js/src/idex.d.ts +1 -1
  143. package/js/src/idex.js +3 -0
  144. package/js/src/independentreserve.js +3 -0
  145. package/js/src/indodax.d.ts +1 -1
  146. package/js/src/indodax.js +3 -0
  147. package/js/src/kraken.d.ts +1 -1
  148. package/js/src/kucoin.d.ts +1 -1
  149. package/js/src/kucoin.js +2 -0
  150. package/js/src/kucoinfutures.d.ts +1 -1
  151. package/js/src/kucoinfutures.js +2 -0
  152. package/js/src/kuna.d.ts +1 -1
  153. package/js/src/latoken.js +6 -0
  154. package/js/src/lbank.d.ts +1 -1
  155. package/js/src/luno.js +3 -0
  156. package/js/src/lykke.d.ts +1 -1
  157. package/js/src/lykke.js +5 -0
  158. package/js/src/mercado.d.ts +1 -1
  159. package/js/src/mercado.js +3 -0
  160. package/js/src/mexc.d.ts +4 -3
  161. package/js/src/mexc.js +111 -0
  162. package/js/src/ndax.d.ts +1 -1
  163. package/js/src/ndax.js +4 -0
  164. package/js/src/novadax.d.ts +1 -1
  165. package/js/src/novadax.js +4 -0
  166. package/js/src/okcoin.d.ts +1 -1
  167. package/js/src/okx.d.ts +9 -8
  168. package/js/src/okx.js +83 -0
  169. package/js/src/onetrading.d.ts +1 -1
  170. package/js/src/onetrading.js +3 -0
  171. package/js/src/p2b.js +3 -0
  172. package/js/src/phemex.d.ts +1 -1
  173. package/js/src/poloniex.d.ts +1 -1
  174. package/js/src/pro/bybit.js +1 -1
  175. package/js/src/pro/coinbase.d.ts +2 -2
  176. package/js/src/pro/coinbase.js +30 -29
  177. package/js/src/probit.d.ts +1 -1
  178. package/js/src/probit.js +3 -0
  179. package/js/src/timex.js +3 -0
  180. package/js/src/tokocrypto.d.ts +1 -1
  181. package/js/src/tradeogre.js +3 -0
  182. package/js/src/upbit.d.ts +1 -1
  183. package/js/src/wavesexchange.d.ts +1 -1
  184. package/js/src/wavesexchange.js +3 -0
  185. package/js/src/wazirx.js +3 -0
  186. package/js/src/whitebit.d.ts +1 -1
  187. package/js/src/woo.d.ts +1 -1
  188. package/js/src/woo.js +2 -0
  189. package/js/src/yobit.d.ts +1 -1
  190. package/js/src/yobit.js +3 -0
  191. package/js/src/zaif.d.ts +1 -1
  192. package/js/src/zonda.d.ts +1 -1
  193. package/package.json +1 -1
@@ -37,7 +37,7 @@ export default class kucoinfutures extends kucoin {
37
37
  createContractOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): any;
38
38
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
39
39
  cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
40
- addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
40
+ addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
41
41
  parseMarginModification(info: any, market?: Market): MarginModification;
42
42
  fetchOrdersByStatus(status: any, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
43
43
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
@@ -81,8 +81,10 @@ export default class kucoinfutures extends kucoin {
81
81
  'fetchOrder': true,
82
82
  'fetchOrderBook': true,
83
83
  'fetchPosition': true,
84
+ 'fetchPositionHistory': false,
84
85
  'fetchPositionMode': false,
85
86
  'fetchPositions': true,
87
+ 'fetchPositionsHistory': false,
86
88
  'fetchPremiumIndexOHLCV': false,
87
89
  'fetchStatus': true,
88
90
  'fetchTicker': true,
package/js/src/kuna.d.ts CHANGED
@@ -54,7 +54,7 @@ export default class kuna extends Exchange {
54
54
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
55
55
  fetchOrdersByStatus(status: any, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
56
56
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
57
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
57
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
58
58
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
59
59
  fetchWithdrawal(id: string, code?: Str, params?: {}): Promise<Transaction>;
60
60
  createDepositAddress(code: string, params?: {}): Promise<{
package/js/src/latoken.js CHANGED
@@ -58,7 +58,13 @@ export default class latoken extends Exchange {
58
58
  'fetchOrder': true,
59
59
  'fetchOrderBook': true,
60
60
  'fetchOrders': true,
61
+ 'fetchPosition': false,
62
+ 'fetchPositionHistory': false,
61
63
  'fetchPositionMode': false,
64
+ 'fetchPositions': false,
65
+ 'fetchPositionsForSymbol': false,
66
+ 'fetchPositionsHistory': false,
67
+ 'fetchPositionsRisk': false,
62
68
  'fetchTicker': true,
63
69
  'fetchTickers': true,
64
70
  'fetchTime': true,
package/js/src/lbank.d.ts CHANGED
@@ -51,7 +51,7 @@ export default class lbank extends Exchange {
51
51
  network: string;
52
52
  info: any;
53
53
  }>;
54
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
54
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
55
55
  parseTransactionStatus(status: any, type: any): string;
56
56
  parseTransaction(transaction: any, currency?: Currency): Transaction;
57
57
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
package/js/src/luno.js CHANGED
@@ -64,8 +64,11 @@ export default class luno extends Exchange {
64
64
  'fetchOrderBook': true,
65
65
  'fetchOrders': true,
66
66
  'fetchPosition': false,
67
+ 'fetchPositionHistory': false,
67
68
  'fetchPositionMode': false,
68
69
  'fetchPositions': false,
70
+ 'fetchPositionsForSymbol': false,
71
+ 'fetchPositionsHistory': false,
69
72
  'fetchPositionsRisk': false,
70
73
  'fetchPremiumIndexOHLCV': false,
71
74
  'fetchTicker': true,
package/js/src/lykke.d.ts CHANGED
@@ -35,7 +35,7 @@ export default class lykke extends Exchange {
35
35
  }>;
36
36
  parseTransaction(transaction: any, currency?: Currency): Transaction;
37
37
  fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
38
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
38
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
39
39
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
40
40
  url: string;
41
41
  method: string;
package/js/src/lykke.js CHANGED
@@ -66,8 +66,13 @@ export default class lykke extends Exchange {
66
66
  'fetchOrderBook': true,
67
67
  'fetchOrders': false,
68
68
  'fetchOrderTrades': false,
69
+ 'fetchPosition': false,
70
+ 'fetchPositionHistory': false,
69
71
  'fetchPositionMode': false,
70
72
  'fetchPositions': false,
73
+ 'fetchPositionsForSymbol': false,
74
+ 'fetchPositionsHistory': false,
75
+ 'fetchPositionsRisk': false,
71
76
  'fetchPremiumIndexOHLCV': false,
72
77
  'fetchTicker': true,
73
78
  'fetchTickers': true,
@@ -19,7 +19,7 @@ export default class mercado extends Exchange {
19
19
  parseOrderStatus(status: any): string;
20
20
  parseOrder(order: any, market?: Market): Order;
21
21
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
22
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
22
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
23
23
  parseTransaction(transaction: any, currency?: Currency): Transaction;
24
24
  parseOHLCV(ohlcv: any, market?: Market): OHLCV;
25
25
  fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
package/js/src/mercado.js CHANGED
@@ -66,8 +66,11 @@ export default class mercado extends Exchange {
66
66
  'fetchOrderBook': true,
67
67
  'fetchOrders': true,
68
68
  'fetchPosition': false,
69
+ 'fetchPositionHistory': false,
69
70
  'fetchPositionMode': false,
70
71
  'fetchPositions': false,
72
+ 'fetchPositionsForSymbol': false,
73
+ 'fetchPositionsHistory': false,
71
74
  'fetchPositionsRisk': false,
72
75
  'fetchPremiumIndexOHLCV': false,
73
76
  'fetchTicker': true,
package/js/src/mexc.d.ts CHANGED
@@ -59,8 +59,8 @@ export default class mexc extends Exchange {
59
59
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
60
60
  fetchOrderTrades(id: string, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
61
61
  modifyMarginHelper(symbol: string, amount: any, addOrReduce: any, params?: {}): Promise<any>;
62
- reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
63
- addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
62
+ reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
63
+ addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
64
64
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
65
65
  fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
66
66
  parseFundingRate(contract: any, market?: Market): {
@@ -153,7 +153,7 @@ export default class mexc extends Exchange {
153
153
  };
154
154
  parseAccountId(status: any): string;
155
155
  parseTransferStatus(status: any): string;
156
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
156
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
157
157
  setPositionMode(hedged: boolean, symbol?: Str, params?: {}): Promise<any>;
158
158
  fetchPositionMode(symbol?: Str, params?: {}): Promise<{
159
159
  info: any;
@@ -175,6 +175,7 @@ export default class mexc extends Exchange {
175
175
  fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
176
176
  parseLeverage(leverage: any, market?: any): Leverage;
177
177
  handleMarginModeAndParams(methodName: any, params?: {}, defaultValue?: any): any[];
178
+ fetchPositionsHistory(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
178
179
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
179
180
  url: any;
180
181
  method: string;
package/js/src/mexc.js CHANGED
@@ -93,8 +93,10 @@ export default class mexc extends Exchange {
93
93
  'fetchOrders': true,
94
94
  'fetchOrderTrades': true,
95
95
  'fetchPosition': true,
96
+ 'fetchPositionHistory': 'emulated',
96
97
  'fetchPositionMode': true,
97
98
  'fetchPositions': true,
99
+ 'fetchPositionsHistory': true,
98
100
  'fetchPositionsRisk': undefined,
99
101
  'fetchPremiumIndexOHLCV': false,
100
102
  'fetchStatus': true,
@@ -4867,6 +4869,8 @@ export default class mexc extends Exchange {
4867
4869
  return this.parsePositions(data, symbols);
4868
4870
  }
4869
4871
  parsePosition(position, market = undefined) {
4872
+ //
4873
+ // fetchPositions
4870
4874
  //
4871
4875
  // {
4872
4876
  // "positionId": 1394650,
@@ -4891,6 +4895,40 @@ export default class mexc extends Exchange {
4891
4895
  // "autoAddIm": false
4892
4896
  // }
4893
4897
  //
4898
+ // fetchPositionsHistory
4899
+ //
4900
+ // {
4901
+ // positionId: '390281084',
4902
+ // symbol: 'RVN_USDT',
4903
+ // positionType: '1',
4904
+ // openType: '2',
4905
+ // state: '3',
4906
+ // holdVol: '0',
4907
+ // frozenVol: '0',
4908
+ // closeVol: '1141',
4909
+ // holdAvgPrice: '0.03491',
4910
+ // holdAvgPriceFullyScale: '0.03491',
4911
+ // openAvgPrice: '0.03491',
4912
+ // openAvgPriceFullyScale: '0.03491',
4913
+ // closeAvgPrice: '0.03494',
4914
+ // liquidatePrice: '0.03433',
4915
+ // oim: '0',
4916
+ // im: '0',
4917
+ // holdFee: '0',
4918
+ // realised: '0.1829',
4919
+ // leverage: '50',
4920
+ // createTime: '1711512408000',
4921
+ // updateTime: '1711512553000',
4922
+ // autoAddIm: false,
4923
+ // version: '4',
4924
+ // profitRatio: '0.0227',
4925
+ // newOpenAvgPrice: '0.03491',
4926
+ // newCloseAvgPrice: '0.03494',
4927
+ // closeProfitLoss: '0.3423',
4928
+ // fee: '0.1593977',
4929
+ // positionShowStatus: 'CLOSED'
4930
+ // }
4931
+ //
4894
4932
  market = this.safeMarket(this.safeString(position, 'symbol'), market);
4895
4933
  const symbol = market['symbol'];
4896
4934
  const contracts = this.safeString(position, 'holdVol');
@@ -5528,6 +5566,79 @@ export default class mexc extends Exchange {
5528
5566
  }
5529
5567
  return [marginMode, params];
5530
5568
  }
5569
+ async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
5570
+ /**
5571
+ * @method
5572
+ * @name mexc#fetchPositionsHistory
5573
+ * @description fetches historical positions
5574
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
5575
+ * @param {string[]} [symbols] unified contract symbols
5576
+ * @param {int} [since] not used by mexc fetchPositionsHistory
5577
+ * @param {int} [limit] the maximum amount of candles to fetch, default=1000
5578
+ * @param {object} params extra parameters specific to the exchange api endpoint
5579
+ *
5580
+ * EXCHANGE SPECIFIC PARAMETERS
5581
+ * @param {int} type position type,1: long, 2: short
5582
+ * @param {int} page_num current page number, default is 1
5583
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
5584
+ */
5585
+ await this.loadMarkets();
5586
+ const request = {};
5587
+ if (symbols !== undefined) {
5588
+ const symbolsLength = symbols.length;
5589
+ if (symbolsLength === 1) {
5590
+ const market = this.market(symbols[0]);
5591
+ request['symbol'] = market['id'];
5592
+ }
5593
+ }
5594
+ if (limit !== undefined) {
5595
+ request['page_size'] = limit;
5596
+ }
5597
+ const response = await this.contractPrivateGetPositionListHistoryPositions(this.extend(request, params));
5598
+ //
5599
+ // {
5600
+ // success: true,
5601
+ // code: '0',
5602
+ // data: [
5603
+ // {
5604
+ // positionId: '390281084',
5605
+ // symbol: 'RVN_USDT',
5606
+ // positionType: '1',
5607
+ // openType: '2',
5608
+ // state: '3',
5609
+ // holdVol: '0',
5610
+ // frozenVol: '0',
5611
+ // closeVol: '1141',
5612
+ // holdAvgPrice: '0.03491',
5613
+ // holdAvgPriceFullyScale: '0.03491',
5614
+ // openAvgPrice: '0.03491',
5615
+ // openAvgPriceFullyScale: '0.03491',
5616
+ // closeAvgPrice: '0.03494',
5617
+ // liquidatePrice: '0.03433',
5618
+ // oim: '0',
5619
+ // im: '0',
5620
+ // holdFee: '0',
5621
+ // realised: '0.1829',
5622
+ // leverage: '50',
5623
+ // createTime: '1711512408000',
5624
+ // updateTime: '1711512553000',
5625
+ // autoAddIm: false,
5626
+ // version: '4',
5627
+ // profitRatio: '0.0227',
5628
+ // newOpenAvgPrice: '0.03491',
5629
+ // newCloseAvgPrice: '0.03494',
5630
+ // closeProfitLoss: '0.3423',
5631
+ // fee: '0.1593977',
5632
+ // positionShowStatus: 'CLOSED'
5633
+ // },
5634
+ // ...
5635
+ // ]
5636
+ // }
5637
+ //
5638
+ const data = this.safeList(response, 'data');
5639
+ const positions = this.parsePositions(data, symbols, params);
5640
+ return this.filterBySinceLimit(positions, since, limit);
5641
+ }
5531
5642
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
5532
5643
  const section = this.safeString(api, 0);
5533
5644
  const access = this.safeString(api, 1);
package/js/src/ndax.d.ts CHANGED
@@ -76,7 +76,7 @@ export default class ndax extends Exchange {
76
76
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
77
77
  parseTransactionStatusByType(status: any, type?: any): string;
78
78
  parseTransaction(transaction: any, currency?: Currency): Transaction;
79
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
79
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
80
80
  nonce(): number;
81
81
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
82
82
  url: string;
package/js/src/ndax.js CHANGED
@@ -73,7 +73,11 @@ export default class ndax extends Exchange {
73
73
  'fetchOrders': true,
74
74
  'fetchOrderTrades': true,
75
75
  'fetchPosition': false,
76
+ 'fetchPositionHistory': false,
77
+ 'fetchPositionMode': false,
76
78
  'fetchPositions': false,
79
+ 'fetchPositionsForSymbol': false,
80
+ 'fetchPositionsHistory': false,
77
81
  'fetchPositionsRisk': false,
78
82
  'fetchPremiumIndexOHLCV': false,
79
83
  'fetchTicker': true,
@@ -42,7 +42,7 @@ export default class novadax extends Exchange {
42
42
  status: string;
43
43
  };
44
44
  parseTransferStatus(status: any): string;
45
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
45
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
46
46
  fetchAccounts(params?: {}): Promise<Account[]>;
47
47
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
48
48
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
package/js/src/novadax.js CHANGED
@@ -78,7 +78,11 @@ export default class novadax extends Exchange {
78
78
  'fetchOrders': true,
79
79
  'fetchOrderTrades': true,
80
80
  'fetchPosition': false,
81
+ 'fetchPositionHistory': false,
82
+ 'fetchPositionMode': false,
81
83
  'fetchPositions': false,
84
+ 'fetchPositionsForSymbol': false,
85
+ 'fetchPositionsHistory': false,
82
86
  'fetchPositionsRisk': false,
83
87
  'fetchPremiumIndexOHLCV': false,
84
88
  'fetchTicker': true,
@@ -56,7 +56,7 @@ export default class okcoin extends Exchange {
56
56
  status: string;
57
57
  };
58
58
  parseTransferStatus(status: any): string;
59
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
59
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
60
60
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
61
61
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
62
62
  parseTransactionStatus(status: any): string;
package/js/src/okx.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/okx.js';
2
- import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Greeks, Strings, MarketInterface, Currency, Leverage, Num, Account, OptionChain, Option, MarginModification, TradingFeeInterface, Currencies, Conversion, CancellationRequest } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Greeks, Strings, MarketInterface, Currency, Leverage, Num, Account, OptionChain, Option, MarginModification, TradingFeeInterface, Currencies, Conversion, CancellationRequest, Position } from './base/types.js';
3
3
  /**
4
4
  * @class okx
5
5
  * @augments Exchange
@@ -87,7 +87,7 @@ export default class okx extends Exchange {
87
87
  };
88
88
  fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<{}>;
89
89
  fetchDepositAddress(code: string, params?: {}): Promise<any>;
90
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
90
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
91
91
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
92
92
  fetchDeposit(id: string, code?: Str, params?: {}): Promise<Transaction>;
93
93
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
@@ -96,10 +96,10 @@ export default class okx extends Exchange {
96
96
  parseTransaction(transaction: any, currency?: Currency): Transaction;
97
97
  fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
98
98
  parseLeverage(leverage: any, market?: any): Leverage;
99
- fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
100
- fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
101
- fetchPositionsForSymbol(symbol: string, params?: {}): Promise<import("./base/types.js").Position[]>;
102
- parsePosition(position: any, market?: Market): import("./base/types.js").Position;
99
+ fetchPosition(symbol: string, params?: {}): Promise<Position>;
100
+ fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
101
+ fetchPositionsForSymbol(symbol: string, params?: {}): Promise<Position[]>;
102
+ parsePosition(position: any, market?: Market): Position;
103
103
  transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
104
104
  parseTransfer(transfer: any, currency?: Currency): {
105
105
  info: any;
@@ -196,8 +196,8 @@ export default class okx extends Exchange {
196
196
  fetchBorrowRateHistory(code: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
197
197
  modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
198
198
  parseMarginModification(data: any, market?: Market): MarginModification;
199
- reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
200
- addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
199
+ reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
200
+ addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
201
201
  fetchMarketLeverageTiers(symbol: string, params?: {}): Promise<any[]>;
202
202
  parseMarketLeverageTiers(info: any, market?: Market): any[];
203
203
  fetchBorrowInterest(code?: Str, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
@@ -307,4 +307,5 @@ export default class okx extends Exchange {
307
307
  fetchConvertCurrencies(params?: {}): Promise<Currencies>;
308
308
  handleErrors(httpCode: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
309
309
  fetchMarginAdjustmentHistory(symbol?: Str, type?: Str, since?: Num, limit?: Num, params?: {}): Promise<MarginModification[]>;
310
+ fetchPositionsHistory(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
310
311
  }
package/js/src/okx.js CHANGED
@@ -114,8 +114,10 @@ export default class okx extends Exchange {
114
114
  'fetchOrderTrades': true,
115
115
  'fetchPermissions': undefined,
116
116
  'fetchPosition': true,
117
+ 'fetchPositionHistory': 'emulated',
117
118
  'fetchPositions': true,
118
119
  'fetchPositionsForSymbol': true,
120
+ 'fetchPositionsHistory': true,
119
121
  'fetchPositionsRisk': false,
120
122
  'fetchPremiumIndexOHLCV': false,
121
123
  'fetchSettlementHistory': true,
@@ -8202,4 +8204,85 @@ export default class okx extends Exchange {
8202
8204
  const modifications = this.parseMarginModifications(data);
8203
8205
  return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
8204
8206
  }
8207
+ async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
8208
+ /**
8209
+ * @method
8210
+ * @name okx#fetchPositionsHistory
8211
+ * @description fetches historical positions
8212
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions-history
8213
+ * @param {string} [symbols] unified market symbols
8214
+ * @param {int} [since] timestamp in ms of the earliest position to fetch
8215
+ * @param {int} [limit] the maximum amount of records to fetch, default=100, max=100
8216
+ * @param {object} params extra parameters specific to the exchange api endpoint
8217
+ * @param {string} [params.marginMode] "cross" or "isolated"
8218
+ *
8219
+ * EXCHANGE SPECIFIC PARAMETERS
8220
+ * @param {string} [params.instType] margin, swap, futures or option
8221
+ * @param {string} [params.type] the type of latest close position 1: close position partially, 2:close all, 3:liquidation, 4:partial liquidation; 5:adl, is it is the latest type if there are several types for the same position
8222
+ * @param {string} [params.posId] position id, there is attribute expiration, the posid will be expired if it is more than 30 days after the last full close position, then position will use new posid
8223
+ * @param {string} [params.before] timestamp in ms of the earliest position to fetch based on the last update time of the position
8224
+ * @param {string} [params.after] timestamp in ms of the latest position to fetch based on the last update time of the position
8225
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
8226
+ */
8227
+ await this.loadMarkets();
8228
+ const marginMode = this.safeString(params, 'marginMode');
8229
+ const instType = this.safeStringUpper(params, 'instType');
8230
+ params = this.omit(params, ['until', 'marginMode', 'instType']);
8231
+ if (limit === undefined) {
8232
+ limit = 100;
8233
+ }
8234
+ const request = {
8235
+ 'limit': limit,
8236
+ };
8237
+ if (symbols !== undefined) {
8238
+ const symbolsLength = symbols.length;
8239
+ if (symbolsLength === 1) {
8240
+ const market = this.market(symbols[0]);
8241
+ request['instId'] = market['id'];
8242
+ }
8243
+ }
8244
+ if (marginMode !== undefined) {
8245
+ request['mgnMode'] = marginMode;
8246
+ }
8247
+ if (instType !== undefined) {
8248
+ request['instType'] = instType;
8249
+ }
8250
+ const response = await this.privateGetAccountPositionsHistory(this.extend(request, params));
8251
+ //
8252
+ // {
8253
+ // code: '0',
8254
+ // data: [
8255
+ // {
8256
+ // cTime: '1708735940395',
8257
+ // ccy: 'USDT',
8258
+ // closeAvgPx: '0.6330444444444444',
8259
+ // closeTotalPos: '27',
8260
+ // direction: 'long',
8261
+ // fee: '-1.69566',
8262
+ // fundingFee: '-11.870404179341788',
8263
+ // instId: 'XRP-USDT-SWAP',
8264
+ // instType: 'SWAP',
8265
+ // lever: '3.0',
8266
+ // liqPenalty: '0',
8267
+ // mgnMode: 'cross',
8268
+ // openAvgPx: '0.623',
8269
+ // openMaxPos: '15',
8270
+ // pnl: '27.11999999999988',
8271
+ // pnlRatio: '0.0241732402722634',
8272
+ // posId: '681423155054862336',
8273
+ // realizedPnl: '13.553935820658092',
8274
+ // triggerPx: '',
8275
+ // type: '2',
8276
+ // uTime: '1711088748170',
8277
+ // uly: 'XRP-USDT'
8278
+ // },
8279
+ // ...
8280
+ // ],
8281
+ // msg: ''
8282
+ // }
8283
+ //
8284
+ const data = this.safeList(response, 'data');
8285
+ const positions = this.parsePositions(data, symbols, params);
8286
+ return this.filterBySinceLimit(positions, since, limit);
8287
+ }
8205
8288
  }
@@ -50,7 +50,7 @@ export default class onetrading extends Exchange {
50
50
  }>;
51
51
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
52
52
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
53
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
53
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
54
54
  parseTransaction(transaction: any, currency?: Currency): Transaction;
55
55
  parseOrderStatus(status: any): string;
56
56
  parseOrder(order: any, market?: Market): Order;
@@ -77,8 +77,11 @@ export default class onetrading extends Exchange {
77
77
  'fetchOrders': false,
78
78
  'fetchOrderTrades': true,
79
79
  'fetchPosition': false,
80
+ 'fetchPositionHistory': false,
80
81
  'fetchPositionMode': false,
81
82
  'fetchPositions': false,
83
+ 'fetchPositionsForSymbol': false,
84
+ 'fetchPositionsHistory': false,
82
85
  'fetchPositionsRisk': false,
83
86
  'fetchPremiumIndexOHLCV': false,
84
87
  'fetchTicker': true,
package/js/src/p2b.js CHANGED
@@ -82,8 +82,11 @@ export default class p2b extends Exchange {
82
82
  'fetchOrderTrades': true,
83
83
  'fetchPermissions': false,
84
84
  'fetchPosition': false,
85
+ 'fetchPositionHistory': false,
86
+ 'fetchPositionMode': false,
85
87
  'fetchPositions': false,
86
88
  'fetchPositionsForSymbol': false,
89
+ 'fetchPositionsHistory': false,
87
90
  'fetchPositionsRisk': false,
88
91
  'fetchPremiumIndexOHLCV': false,
89
92
  'fetchTicker': true,
@@ -128,6 +128,6 @@ export default class phemex extends Exchange {
128
128
  };
129
129
  parseTransferStatus(status: any): string;
130
130
  fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
131
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
131
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
132
132
  handleErrors(httpCode: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
133
133
  }
@@ -62,7 +62,7 @@ export default class poloniex extends Exchange {
62
62
  toAccount: any;
63
63
  status: any;
64
64
  };
65
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
65
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
66
66
  fetchTransactionsHelper(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
67
67
  fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
68
68
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
@@ -120,7 +120,7 @@ export default class bybit extends bybitRest {
120
120
  },
121
121
  'streaming': {
122
122
  'ping': this.ping,
123
- 'keepAlive': 20000,
123
+ 'keepAlive': 19000,
124
124
  },
125
125
  });
126
126
  }
@@ -2,7 +2,7 @@ import coinbaseRest from '../coinbase.js';
2
2
  import { Strings, Tickers, Ticker, Int, Trade, OrderBook, Order, Str } from '../base/types.js';
3
3
  export default class coinbase extends coinbaseRest {
4
4
  describe(): any;
5
- subscribe(name: any, symbol?: any, params?: {}): Promise<any>;
5
+ subscribe(name: string, isPrivate: boolean, symbol?: any, params?: {}): Promise<any>;
6
6
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
7
7
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
8
8
  handleTickers(client: any, message: any): any;
@@ -14,7 +14,7 @@ export default class coinbase extends coinbaseRest {
14
14
  handleOrder(client: any, message: any): any;
15
15
  parseWsOrder(order: any, market?: any): Order;
16
16
  handleOrderBookHelper(orderbook: any, updates: any): void;
17
- handleOrderBook(client: any, message: any): any;
17
+ handleOrderBook(client: any, message: any): void;
18
18
  handleSubscriptionStatus(client: any, message: any): any;
19
19
  handleMessage(client: any, message: any): void;
20
20
  }