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
@@ -26,7 +26,7 @@ export default class bithumb extends Exchange {
26
26
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
27
27
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
28
28
  cancelUnifiedOrder(order: any, params?: {}): Promise<any>;
29
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
29
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
30
30
  parseTransaction(transaction: any, currency?: Currency): Transaction;
31
31
  fixCommaNumber(numberStr: any): any;
32
32
  nonce(): number;
package/js/src/bithumb.js CHANGED
@@ -58,7 +58,11 @@ export default class bithumb extends Exchange {
58
58
  'fetchOrder': true,
59
59
  'fetchOrderBook': true,
60
60
  'fetchPosition': false,
61
+ 'fetchPositionHistory': false,
62
+ 'fetchPositionMode': false,
61
63
  'fetchPositions': false,
64
+ 'fetchPositionsForSymbol': false,
65
+ 'fetchPositionsHistory': false,
62
66
  'fetchPositionsRisk': false,
63
67
  'fetchPremiumIndexOHLCV': false,
64
68
  'fetchTicker': true,
@@ -80,7 +80,7 @@ export default class bitmart extends Exchange {
80
80
  network: any;
81
81
  };
82
82
  safeNetworkCode(networkId: any, currency?: any): string;
83
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<any>;
83
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<any>;
84
84
  fetchTransactionsByType(type: any, code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
85
85
  fetchDeposit(id: string, code?: Str, params?: {}): Promise<Transaction>;
86
86
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
@@ -67,7 +67,7 @@ export default class bitmex extends Exchange {
67
67
  parseLeverage(leverage: any, market?: any): Leverage;
68
68
  fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
69
69
  parsePosition(position: any, market?: Market): import("./base/types.js").Position;
70
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
70
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
71
71
  fetchFundingRates(symbols?: Strings, params?: {}): Promise<any>;
72
72
  parseFundingRate(contract: any, market?: Market): {
73
73
  info: any;
package/js/src/bitmex.js CHANGED
@@ -79,7 +79,9 @@ export default class bitmex extends Exchange {
79
79
  'fetchOrderBook': true,
80
80
  'fetchOrders': true,
81
81
  'fetchPosition': false,
82
+ 'fetchPositionHistory': false,
82
83
  'fetchPositions': true,
84
+ 'fetchPositionsHistory': false,
83
85
  'fetchPositionsRisk': false,
84
86
  'fetchPremiumIndexOHLCV': false,
85
87
  'fetchTicker': true,
@@ -37,7 +37,7 @@ export default class bitopro extends Exchange {
37
37
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
38
38
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
39
39
  fetchWithdrawal(id: string, code?: Str, params?: {}): Promise<Transaction>;
40
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
40
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
41
41
  parseDepositWithdrawFee(fee: any, currency?: Currency): {
42
42
  info: any;
43
43
  withdraw: {
package/js/src/bitopro.js CHANGED
@@ -68,8 +68,13 @@ export default class bitopro extends Exchange {
68
68
  'fetchOrderBook': true,
69
69
  'fetchOrders': false,
70
70
  'fetchOrderTrades': false,
71
+ 'fetchPosition': false,
72
+ 'fetchPositionHistory': false,
71
73
  'fetchPositionMode': false,
72
74
  'fetchPositions': false,
75
+ 'fetchPositionsForSymbol': false,
76
+ 'fetchPositionsHistory': false,
77
+ 'fetchPositionsRisk': false,
73
78
  'fetchPremiumIndexOHLCV': false,
74
79
  'fetchTicker': true,
75
80
  'fetchTickers': true,
@@ -45,7 +45,7 @@ export default class bitrue extends Exchange {
45
45
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
46
46
  parseTransactionStatusByType(status: any, type?: any): string;
47
47
  parseTransaction(transaction: any, currency?: Currency): Transaction;
48
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
48
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
49
49
  parseDepositWithdrawFee(fee: any, currency?: Currency): {
50
50
  info: any;
51
51
  withdraw: {
package/js/src/bitso.d.ts CHANGED
@@ -58,7 +58,7 @@ export default class bitso extends Exchange {
58
58
  fetchTransactionFees(codes?: string[], params?: {}): Promise<{}>;
59
59
  fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<{}>;
60
60
  parseDepositWithdrawFees(response: any, codes?: any, currencyIdKey?: any): {};
61
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
61
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
62
62
  safeNetwork(networkId: any): string;
63
63
  parseTransaction(transaction: any, currency?: Currency): Transaction;
64
64
  parseTransactionStatus(status: any): string;
package/js/src/bitso.js CHANGED
@@ -72,8 +72,11 @@ export default class bitso extends Exchange {
72
72
  'fetchOrderBook': true,
73
73
  'fetchOrderTrades': true,
74
74
  'fetchPosition': false,
75
+ 'fetchPositionHistory': false,
75
76
  'fetchPositionMode': false,
76
77
  'fetchPositions': false,
78
+ 'fetchPositionsForSymbol': false,
79
+ 'fetchPositionsHistory': false,
77
80
  'fetchPositionsRisk': false,
78
81
  'fetchPremiumIndexOHLCV': false,
79
82
  'fetchTicker': true,
@@ -119,7 +119,7 @@ export default class bitstamp extends Exchange {
119
119
  network: any;
120
120
  info: any;
121
121
  }>;
122
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
122
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
123
123
  transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
124
124
  parseTransfer(transfer: any, currency?: any): {
125
125
  info: any;
@@ -72,8 +72,11 @@ export default class bitstamp extends Exchange {
72
72
  'fetchOrder': true,
73
73
  'fetchOrderBook': true,
74
74
  'fetchPosition': false,
75
+ 'fetchPositionHistory': false,
75
76
  'fetchPositionMode': false,
76
77
  'fetchPositions': false,
78
+ 'fetchPositionsForSymbol': false,
79
+ 'fetchPositionsHistory': false,
77
80
  'fetchPositionsRisk': false,
78
81
  'fetchPremiumIndexOHLCV': false,
79
82
  'fetchTicker': true,
package/js/src/bitteam.js CHANGED
@@ -90,7 +90,11 @@ export default class bitteam extends Exchange {
90
90
  'fetchOrders': true,
91
91
  'fetchOrderTrades': false,
92
92
  'fetchPosition': false,
93
+ 'fetchPositionHistory': false,
94
+ 'fetchPositionMode': false,
93
95
  'fetchPositions': false,
96
+ 'fetchPositionsForSymbol': false,
97
+ 'fetchPositionsHistory': false,
94
98
  'fetchPositionsRisk': false,
95
99
  'fetchPremiumIndexOHLCV': false,
96
100
  'fetchStatus': false,
@@ -50,7 +50,7 @@ export default class bitvavo extends Exchange {
50
50
  fetchMyTradesRequest(symbol?: Str, since?: Int, limit?: Int, params?: {}): any;
51
51
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
52
52
  withdrawRequest(code: Str, amount: any, address: any, tag?: any, params?: {}): any;
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
  fetchWithdrawalsRequest(code?: Str, since?: Int, limit?: Int, params?: {}): any;
55
55
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
56
56
  fetchDepositsRequest(code?: Str, since?: Int, limit?: Int, params?: {}): any;
package/js/src/bitvavo.js CHANGED
@@ -73,8 +73,11 @@ export default class bitvavo extends Exchange {
73
73
  'fetchOrderBook': true,
74
74
  'fetchOrders': true,
75
75
  'fetchPosition': false,
76
+ 'fetchPositionHistory': false,
76
77
  'fetchPositionMode': false,
77
78
  'fetchPositions': false,
79
+ 'fetchPositionsForSymbol': false,
80
+ 'fetchPositionsHistory': false,
78
81
  'fetchPositionsRisk': false,
79
82
  'fetchPremiumIndexOHLCV': false,
80
83
  'fetchTicker': true,
package/js/src/bl3p.js CHANGED
@@ -62,8 +62,11 @@ export default class bl3p extends Exchange {
62
62
  'fetchOpenInterestHistory': false,
63
63
  'fetchOrderBook': true,
64
64
  'fetchPosition': false,
65
+ 'fetchPositionHistory': false,
65
66
  'fetchPositionMode': false,
66
67
  'fetchPositions': false,
68
+ 'fetchPositionsForSymbol': false,
69
+ 'fetchPositionsHistory': false,
67
70
  'fetchPositionsRisk': false,
68
71
  'fetchPremiumIndexOHLCV': false,
69
72
  'fetchTicker': true,
@@ -36,7 +36,7 @@ export default class blockchaincom extends Exchange {
36
36
  }>;
37
37
  parseTransactionState(state: any): string;
38
38
  parseTransaction(transaction: any, currency?: Currency): Transaction;
39
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
39
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
40
40
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
41
41
  fetchWithdrawal(id: string, code?: Str, params?: {}): Promise<Transaction>;
42
42
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
@@ -70,8 +70,11 @@ export default class btcalpha extends Exchange {
70
70
  'fetchOrderBook': true,
71
71
  'fetchOrders': true,
72
72
  'fetchPosition': false,
73
+ 'fetchPositionHistory': false,
73
74
  'fetchPositionMode': false,
74
75
  'fetchPositions': false,
76
+ 'fetchPositionsForSymbol': false,
77
+ 'fetchPositionsHistory': false,
75
78
  'fetchPositionsRisk': false,
76
79
  'fetchPremiumIndexOHLCV': false,
77
80
  'fetchTicker': true,
package/js/src/btcbox.js CHANGED
@@ -58,8 +58,11 @@ export default class btcbox extends Exchange {
58
58
  'fetchOrderBook': true,
59
59
  'fetchOrders': true,
60
60
  'fetchPosition': false,
61
+ 'fetchPositionHistory': false,
61
62
  'fetchPositionMode': false,
62
63
  'fetchPositions': false,
64
+ 'fetchPositionsForSymbol': false,
65
+ 'fetchPositionsHistory': false,
63
66
  'fetchPositionsRisk': false,
64
67
  'fetchPremiumIndexOHLCV': false,
65
68
  'fetchTicker': true,
@@ -42,7 +42,7 @@ export default class btcmarkets extends Exchange {
42
42
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
43
43
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
44
44
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
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
  nonce(): number;
47
47
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
48
48
  url: string;
@@ -68,8 +68,11 @@ export default class btcmarkets extends Exchange {
68
68
  'fetchOrderBook': true,
69
69
  'fetchOrders': true,
70
70
  'fetchPosition': false,
71
+ 'fetchPositionHistory': false,
71
72
  'fetchPositionMode': false,
72
73
  'fetchPositions': false,
74
+ 'fetchPositionsForSymbol': false,
75
+ 'fetchPositionsHistory': false,
73
76
  'fetchPositionsRisk': false,
74
77
  'fetchPremiumIndexOHLCV': false,
75
78
  'fetchTicker': true,
package/js/src/btcturk.js CHANGED
@@ -63,8 +63,11 @@ export default class btcturk extends Exchange {
63
63
  'fetchOrderBook': true,
64
64
  'fetchOrders': true,
65
65
  'fetchPosition': false,
66
+ 'fetchPositionHistory': false,
66
67
  'fetchPositionMode': false,
67
68
  'fetchPositions': false,
69
+ 'fetchPositionsForSymbol': false,
70
+ 'fetchPositionsHistory': false,
68
71
  'fetchPositionsRisk': false,
69
72
  'fetchPremiumIndexOHLCV': false,
70
73
  'fetchTicker': true,
package/js/src/bybit.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bybit.js';
2
- import type { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Liquidation, Leverage, Num, FundingHistory, Option, OptionChain, TradingFeeInterface, Currencies, TradingFees, CancellationRequest } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Liquidation, Leverage, Num, FundingHistory, Option, OptionChain, TradingFeeInterface, Currencies, TradingFees, CancellationRequest, Position } from './base/types.js';
3
3
  /**
4
4
  * @class bybit
5
5
  * @augments Exchange
@@ -122,11 +122,11 @@ export default class bybit extends Exchange {
122
122
  info: any;
123
123
  };
124
124
  parseLedgerEntryType(type: any): string;
125
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
126
- fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
127
- fetchUsdcPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
128
- fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
129
- parsePosition(position: any, market?: Market): import("./base/types.js").Position;
125
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
126
+ fetchPosition(symbol: string, params?: {}): Promise<Position>;
127
+ fetchUsdcPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
128
+ fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
129
+ parsePosition(position: any, market?: Market): Position;
130
130
  fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
131
131
  parseLeverage(leverage: any, market?: any): Leverage;
132
132
  setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
@@ -278,6 +278,7 @@ export default class bybit extends Exchange {
278
278
  baseVolume: number;
279
279
  quoteVolume: any;
280
280
  };
281
+ fetchPositionsHistory(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
281
282
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
282
283
  url: string;
283
284
  method: string;
package/js/src/bybit.js CHANGED
@@ -105,7 +105,9 @@ export default class bybit extends Exchange {
105
105
  'fetchOrders': false,
106
106
  'fetchOrderTrades': true,
107
107
  'fetchPosition': true,
108
+ 'fetchPositionHistory': 'emulated',
108
109
  'fetchPositions': true,
110
+ 'fetchPositionsHistory': true,
109
111
  'fetchPremiumIndexOHLCV': true,
110
112
  'fetchSettlementHistory': true,
111
113
  'fetchTicker': true,
@@ -6460,37 +6462,64 @@ export default class bybit extends Exchange {
6460
6462
  // "tradeMode": 0
6461
6463
  // }
6462
6464
  //
6465
+ // fetchPositionsHistory
6466
+ //
6467
+ // {
6468
+ // symbol: 'XRPUSDT',
6469
+ // orderType: 'Market',
6470
+ // leverage: '10',
6471
+ // updatedTime: '1712717265572',
6472
+ // side: 'Sell',
6473
+ // orderId: '071749f3-a9fa-427b-b5ca-27b2f52b81de',
6474
+ // closedPnl: '-0.00049568',
6475
+ // avgEntryPrice: '0.6045',
6476
+ // qty: '3',
6477
+ // cumEntryValue: '1.8135',
6478
+ // createdTime: '1712717265566',
6479
+ // orderPrice: '0.5744',
6480
+ // closedSize: '3',
6481
+ // avgExitPrice: '0.605',
6482
+ // execType: 'Trade',
6483
+ // fillCount: '1',
6484
+ // cumExitValue: '1.815'
6485
+ // }
6486
+ //
6487
+ const closedSize = this.safeString(position, 'closedSize');
6488
+ const isHistory = (closedSize !== undefined);
6463
6489
  const contract = this.safeString(position, 'symbol');
6464
6490
  market = this.safeMarket(contract, market, undefined, 'contract');
6465
- const size = Precise.stringAbs(this.safeString(position, 'size'));
6491
+ const size = Precise.stringAbs(this.safeString2(position, 'size', 'qty'));
6466
6492
  let side = this.safeString(position, 'side');
6467
6493
  if (side !== undefined) {
6468
6494
  if (side === 'Buy') {
6469
- side = 'long';
6495
+ side = isHistory ? 'short' : 'long';
6470
6496
  }
6471
6497
  else if (side === 'Sell') {
6472
- side = 'short';
6498
+ side = isHistory ? 'long' : 'short';
6473
6499
  }
6474
6500
  else {
6475
6501
  side = undefined;
6476
6502
  }
6477
6503
  }
6478
- const notional = this.safeString(position, 'positionValue');
6504
+ const notional = this.safeString2(position, 'positionValue', 'cumExitValue');
6479
6505
  const unrealisedPnl = this.omitZero(this.safeString(position, 'unrealisedPnl'));
6480
- let initialMarginString = this.safeString(position, 'positionIM');
6506
+ let initialMarginString = this.safeStringN(position, ['positionIM', 'cumEntryValue']);
6481
6507
  let maintenanceMarginString = this.safeString(position, 'positionMM');
6482
- let timestamp = this.parse8601(this.safeString(position, 'updated_at'));
6483
- if (timestamp === undefined) {
6484
- timestamp = this.safeIntegerN(position, ['updatedTime', 'updatedAt']);
6508
+ const timestamp = this.safeIntegerN(position, ['createdTime', 'createdAt']);
6509
+ let lastUpdateTimestamp = this.parse8601(this.safeString(position, 'updated_at'));
6510
+ if (lastUpdateTimestamp === undefined) {
6511
+ lastUpdateTimestamp = this.safeIntegerN(position, ['updatedTime', 'updatedAt', 'updatedTime']);
6485
6512
  }
6486
6513
  const tradeMode = this.safeInteger(position, 'tradeMode', 0);
6487
6514
  let marginMode = undefined;
6488
6515
  if ((!this.options['enableUnifiedAccount']) || (this.options['enableUnifiedAccount'] && market['inverse'])) {
6489
6516
  // tradeMode would work for classic and UTA(inverse)
6490
- marginMode = (tradeMode === 1) ? 'isolated' : 'cross';
6517
+ if (!isHistory) { // cannot tell marginMode for fetchPositionsHistory, and closedSize will only be defined for fetchPositionsHistory response
6518
+ marginMode = (tradeMode === 1) ? 'isolated' : 'cross';
6519
+ }
6491
6520
  }
6492
6521
  let collateralString = this.safeString(position, 'positionBalance');
6493
- const entryPrice = this.omitZero(this.safeString2(position, 'entryPrice', 'avgPrice'));
6522
+ const entryPrice = this.omitZero(this.safeStringN(position, ['entryPrice', 'avgPrice', 'avgEntryPrice']));
6494
6523
  const liquidationPrice = this.omitZero(this.safeString(position, 'liqPrice'));
6495
6524
  const leverage = this.safeString(position, 'leverage');
6496
6525
  if (liquidationPrice !== undefined) {
@@ -6536,7 +6565,7 @@ export default class bybit extends Exchange {
6536
6565
  'symbol': market['symbol'],
6537
6566
  'timestamp': timestamp,
6538
6567
  'datetime': this.iso8601(timestamp),
6539
- 'lastUpdateTimestamp': undefined,
6568
+ 'lastUpdateTimestamp': lastUpdateTimestamp,
6540
6569
  'initialMargin': this.parseNumber(initialMarginString),
6541
6570
  'initialMarginPercentage': this.parseNumber(Precise.stringDiv(initialMarginString, notional)),
6542
6571
  'maintenanceMargin': this.parseNumber(maintenanceMarginString),
@@ -6545,12 +6574,13 @@ export default class bybit extends Exchange {
6545
6574
  'notional': this.parseNumber(notional),
6546
6575
  'leverage': this.parseNumber(leverage),
6547
6576
  'unrealizedPnl': this.parseNumber(unrealisedPnl),
6577
+ 'realizedPnl': this.safeNumber(position, 'closedPnl'),
6548
6578
  'contracts': this.parseNumber(size),
6549
6579
  'contractSize': this.safeNumber(market, 'contractSize'),
6550
6580
  'marginRatio': this.parseNumber(marginRatio),
6551
6581
  'liquidationPrice': this.parseNumber(liquidationPrice),
6552
6582
  'markPrice': this.safeNumber(position, 'markPrice'),
6553
- 'lastPrice': undefined,
6583
+ 'lastPrice': this.safeNumber(position, 'avgExitPrice'),
6554
6584
  'collateral': this.parseNumber(collateralString),
6555
6585
  'marginMode': marginMode,
6556
6586
  'side': side,
@@ -8477,6 +8507,87 @@ export default class bybit extends Exchange {
8477
8507
  'quoteVolume': undefined,
8478
8508
  };
8479
8509
  }
8510
+ async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
8511
+ /**
8512
+ * @method
8513
+ * @name bybit#fetchPositionsHistory
8514
+ * @description fetches historical positions
8515
+ * @see https://bybit-exchange.github.io/docs/v5/position/close-pnl
8516
+ * @param {string} [symbol] unified market symbols, symbols must have the same subType (must all be linear or all be inverse)
8517
+ * @param {int} [since] timestamp in ms of the earliest position to fetch, params["until"] - since <= 7 days
8518
+ * @param {int} [limit] the maximum amount of records to fetch, default=50, max=100
8519
+ * @param {object} params extra parameters specific to the exchange api endpoint
8520
+ * @param {int} [params.until] timestamp in ms of the latest position to fetch, params["until"] - since <= 7 days
8521
+ * @param {string} [params.subType] 'linear' or 'inverse'
8522
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
8523
+ */
8524
+ await this.loadMarkets();
8525
+ let market = undefined;
8526
+ let subType = undefined;
8527
+ let symbolsLength = 0;
8528
+ if (symbols !== undefined) {
8529
+ symbolsLength = symbols.length;
8530
+ if (symbolsLength > 0) {
8531
+ market = this.market(symbols[0]);
8532
+ }
8533
+ }
8534
+ const until = this.safeInteger(params, 'until');
8535
+ [subType, params] = this.handleSubTypeAndParams('fetchPositionsHistory', market, params, 'linear');
8536
+ params = this.omit(params, 'until');
8537
+ const request = {
8538
+ 'category': subType,
8539
+ };
8540
+ if ((symbols !== undefined) && (symbolsLength === 1)) {
8541
+ request['symbol'] = market['id'];
8542
+ }
8543
+ if (since !== undefined) {
8544
+ request['startTime'] = since;
8545
+ }
8546
+ if (limit !== undefined) {
8547
+ request['limit'] = limit;
8548
+ }
8549
+ if (until !== undefined) {
8550
+ request['endTime'] = until;
8551
+ }
8552
+ const response = await this.privateGetV5PositionClosedPnl(this.extend(request, params));
8553
+ //
8554
+ // {
8555
+ // retCode: '0',
8556
+ // retMsg: 'OK',
8557
+ // result: {
8558
+ // nextPageCursor: '071749f3-a9fa-427b-b5ca-27b2f52b81de%3A1712717265566520788%2C071749f3-a9fa-427b-b5ca-27b2f52b81de%3A1712717265566520788',
8559
+ // category: 'linear',
8560
+ // list: [
8561
+ // {
8562
+ // symbol: 'XRPUSDT',
8563
+ // orderType: 'Market',
8564
+ // leverage: '10',
8565
+ // updatedTime: '1712717265572',
8566
+ // side: 'Sell',
8567
+ // orderId: '071749f3-a9fa-427b-b5ca-27b2f52b81de',
8568
+ // closedPnl: '-0.00049568',
8569
+ // avgEntryPrice: '0.6045',
8570
+ // qty: '3',
8571
+ // cumEntryValue: '1.8135',
8572
+ // createdTime: '1712717265566',
8573
+ // orderPrice: '0.5744',
8574
+ // closedSize: '3',
8575
+ // avgExitPrice: '0.605',
8576
+ // execType: 'Trade',
8577
+ // fillCount: '1',
8578
+ // cumExitValue: '1.815'
8579
+ // }
8580
+ // ]
8581
+ // },
8582
+ // retExtInfo: {},
8583
+ // time: '1712717286073'
8584
+ // }
8585
+ //
8586
+ const result = this.safeDict(response, 'result');
8587
+ const rawPositions = this.safeList(result, 'list');
8588
+ const positions = this.parsePositions(rawPositions, symbols, params);
8589
+ return this.filterBySinceLimit(positions, since, limit);
8590
+ }
8480
8591
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
8481
8592
  let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
8482
8593
  if (api === 'public') {
package/js/src/cex.js CHANGED
@@ -65,7 +65,13 @@ export default class cex extends Exchange {
65
65
  'fetchOrder': true,
66
66
  'fetchOrderBook': true,
67
67
  'fetchOrders': true,
68
+ 'fetchPosition': false,
69
+ 'fetchPositionHistory': false,
68
70
  'fetchPositionMode': false,
71
+ 'fetchPositions': false,
72
+ 'fetchPositionsForSymbol': false,
73
+ 'fetchPositionsHistory': false,
74
+ 'fetchPositionsRisk': false,
69
75
  'fetchPremiumIndexOHLCV': false,
70
76
  'fetchTicker': true,
71
77
  'fetchTickers': true,
@@ -93,7 +93,7 @@ export default class coinbase extends Exchange {
93
93
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
94
94
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
95
95
  fetchBidsAsks(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Dictionary<Ticker>>;
96
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
96
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
97
97
  fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<{}>;
98
98
  parseDepositAddress(depositAddress: any, currency?: Currency): {
99
99
  info: any;