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
@@ -202,6 +202,11 @@ class coinbase extends coinbase$1 {
202
202
  'public': {
203
203
  'get': {
204
204
  'brokerage/time': 3,
205
+ 'brokerage/market/product_book': 3,
206
+ 'brokerage/market/products': 3,
207
+ 'brokerage/market/products/{product_id}': 3,
208
+ 'brokerage/market/products/{product_id}/candles': 3,
209
+ 'brokerage/market/products/{product_id}/ticker': 3,
205
210
  },
206
211
  },
207
212
  'private': {
@@ -1091,7 +1096,7 @@ class coinbase extends coinbase$1 {
1091
1096
  /**
1092
1097
  * @method
1093
1098
  * @name coinbase#fetchMarkets
1094
- * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getproducts
1099
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpublicproducts
1095
1100
  * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-currencies#get-fiat-currencies
1096
1101
  * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates#get-exchange-rates
1097
1102
  * @description retrieves data on all markets for coinbase
@@ -1178,20 +1183,92 @@ class coinbase extends coinbase$1 {
1178
1183
  }
1179
1184
  async fetchMarketsV3(params = {}) {
1180
1185
  const spotUnresolvedPromises = [
1181
- this.v3PrivateGetBrokerageProducts(params),
1182
- this.v3PrivateGetBrokerageTransactionSummary(params),
1186
+ this.v3PublicGetBrokerageMarketProducts(params),
1187
+ //
1188
+ // {
1189
+ // products: [
1190
+ // {
1191
+ // product_id: 'BTC-USD',
1192
+ // price: '67060',
1193
+ // price_percentage_change_24h: '3.30054960636883',
1194
+ // volume_24h: '10967.87426597',
1195
+ // volume_percentage_change_24h: '141.73048325503036',
1196
+ // base_increment: '0.00000001',
1197
+ // quote_increment: '0.01',
1198
+ // quote_min_size: '1',
1199
+ // quote_max_size: '150000000',
1200
+ // base_min_size: '0.00000001',
1201
+ // base_max_size: '3400',
1202
+ // base_name: 'Bitcoin',
1203
+ // quote_name: 'US Dollar',
1204
+ // watched: false,
1205
+ // is_disabled: false,
1206
+ // new: false,
1207
+ // status: 'online',
1208
+ // cancel_only: false,
1209
+ // limit_only: false,
1210
+ // post_only: false,
1211
+ // trading_disabled: false,
1212
+ // auction_mode: false,
1213
+ // product_type: 'SPOT',
1214
+ // quote_currency_id: 'USD',
1215
+ // base_currency_id: 'BTC',
1216
+ // fcm_trading_session_details: null,
1217
+ // mid_market_price: '',
1218
+ // alias: '',
1219
+ // alias_to: [ 'BTC-USDC' ],
1220
+ // base_display_symbol: 'BTC',
1221
+ // quote_display_symbol: 'USD',
1222
+ // view_only: false,
1223
+ // price_increment: '0.01',
1224
+ // display_name: 'BTC-USD',
1225
+ // product_venue: 'CBE'
1226
+ // },
1227
+ // ...
1228
+ // ],
1229
+ // num_products: '646'
1230
+ // }
1231
+ //
1183
1232
  ];
1233
+ if (this.checkRequiredCredentials(false)) {
1234
+ spotUnresolvedPromises.push(this.v3PrivateGetBrokerageTransactionSummary(params));
1235
+ }
1236
+ //
1237
+ // {
1238
+ // total_volume: '9.995989116664404',
1239
+ // total_fees: '0.07996791093331522',
1240
+ // fee_tier: {
1241
+ // pricing_tier: 'Advanced 1',
1242
+ // usd_from: '0',
1243
+ // usd_to: '1000',
1244
+ // taker_fee_rate: '0.008',
1245
+ // maker_fee_rate: '0.006',
1246
+ // aop_from: '',
1247
+ // aop_to: ''
1248
+ // },
1249
+ // margin_rate: null,
1250
+ // goods_and_services_tax: null,
1251
+ // advanced_trade_only_volume: '9.995989116664404',
1252
+ // advanced_trade_only_fees: '0.07996791093331522',
1253
+ // coinbase_pro_volume: '0',
1254
+ // coinbase_pro_fees: '0',
1255
+ // total_balance: '',
1256
+ // has_promo_fee: false
1257
+ // }
1258
+ //
1184
1259
  let unresolvedContractPromises = [];
1185
1260
  try {
1186
1261
  unresolvedContractPromises = [
1187
- this.v3PrivateGetBrokerageProducts(this.extend(params, { 'product_type': 'FUTURE' })),
1188
- this.v3PrivateGetBrokerageProducts(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1189
- this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE' })),
1190
- this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1262
+ this.v3PublicGetBrokerageMarketProducts(this.extend(params, { 'product_type': 'FUTURE' })),
1263
+ this.v3PublicGetBrokerageMarketProducts(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1191
1264
  ];
1265
+ if (this.checkRequiredCredentials(false)) {
1266
+ unresolvedContractPromises.push(this.extend(params, { 'product_type': 'FUTURE' }));
1267
+ unresolvedContractPromises.push(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' }));
1268
+ }
1192
1269
  }
1193
1270
  catch (e) {
1194
- unresolvedContractPromises = []; // the sync version of ccxt won't have the promise.all line so the request is made here
1271
+ unresolvedContractPromises = []; // the sync version of ccxt won't have the promise.all line so the request is made here. Some users can't access perpetual products
1195
1272
  }
1196
1273
  const promises = await Promise.all(spotUnresolvedPromises);
1197
1274
  let contractPromises = undefined;
@@ -1460,6 +1537,7 @@ class coinbase extends coinbase$1 {
1460
1537
  const contractSize = this.safeNumber(futureProductDetails, 'contract_size');
1461
1538
  const contractExpire = this.safeString(futureProductDetails, 'contract_expiry');
1462
1539
  const expireTimestamp = this.parse8601(contractExpire);
1540
+ const expireDateTime = this.iso8601(expireTimestamp);
1463
1541
  const isSwap = (contractExpiryType === 'PERPETUAL');
1464
1542
  const baseId = this.safeString(futureProductDetails, 'contract_root_unit');
1465
1543
  const quoteId = this.safeString(market, 'quote_currency_id');
@@ -1503,7 +1581,7 @@ class coinbase extends coinbase$1 {
1503
1581
  'maker': maker,
1504
1582
  'contractSize': contractSize,
1505
1583
  'expiry': expireTimestamp,
1506
- 'expiryDatetime': contractExpire,
1584
+ 'expiryDatetime': expireDateTime,
1507
1585
  'strike': undefined,
1508
1586
  'optionType': undefined,
1509
1587
  'precision': {
@@ -1728,7 +1806,7 @@ class coinbase extends coinbase$1 {
1728
1806
  if (symbols !== undefined) {
1729
1807
  request['product_ids'] = this.marketIds(symbols);
1730
1808
  }
1731
- const response = await this.v3PrivateGetBrokerageProducts(this.extend(request, params));
1809
+ const response = await this.v3PublicGetBrokerageMarketProducts(this.extend(request, params));
1732
1810
  //
1733
1811
  // {
1734
1812
  // "products": [
@@ -1831,7 +1909,7 @@ class coinbase extends coinbase$1 {
1831
1909
  'product_id': market['id'],
1832
1910
  'limit': 1,
1833
1911
  };
1834
- const response = await this.v3PrivateGetBrokerageProductsProductIdTicker(this.extend(request, params));
1912
+ const response = await this.v3PublicGetBrokerageMarketProductsProductIdTicker(this.extend(request, params));
1835
1913
  //
1836
1914
  // {
1837
1915
  // "trades": [
@@ -3392,7 +3470,7 @@ class coinbase extends coinbase$1 {
3392
3470
  * @method
3393
3471
  * @name coinbase#fetchOHLCV
3394
3472
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
3395
- * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getcandles
3473
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpubliccandles
3396
3474
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
3397
3475
  * @param {string} timeframe the length of time each candle represents
3398
3476
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -3435,7 +3513,7 @@ class coinbase extends coinbase$1 {
3435
3513
  // 300 candles max
3436
3514
  request['end'] = Precise["default"].stringAdd(sinceString, requestedDuration.toString());
3437
3515
  }
3438
- const response = await this.v3PrivateGetBrokerageProductsProductIdCandles(this.extend(request, params));
3516
+ const response = await this.v3PublicGetBrokerageMarketProductsProductIdCandles(this.extend(request, params));
3439
3517
  //
3440
3518
  // {
3441
3519
  // "candles": [
@@ -3480,7 +3558,7 @@ class coinbase extends coinbase$1 {
3480
3558
  * @method
3481
3559
  * @name coinbase#fetchTrades
3482
3560
  * @description get the list of most recent trades for a particular symbol
3483
- * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getmarkettrades
3561
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpublicmarkettrades
3484
3562
  * @param {string} symbol unified market symbol of the trades
3485
3563
  * @param {int} [since] not used by coinbase fetchTrades
3486
3564
  * @param {int} [limit] the maximum number of trade structures to fetch
@@ -3506,7 +3584,7 @@ class coinbase extends coinbase$1 {
3506
3584
  else if (since !== undefined) {
3507
3585
  throw new errors.ArgumentsRequired(this.id + ' fetchTrades() requires a `until` parameter when you use `since` argument');
3508
3586
  }
3509
- const response = await this.v3PrivateGetBrokerageProductsProductIdTicker(this.extend(request, params));
3587
+ const response = await this.v3PublicGetBrokerageMarketProductsProductIdTicker(this.extend(request, params));
3510
3588
  //
3511
3589
  // {
3512
3590
  // "trades": [
@@ -3603,7 +3681,7 @@ class coinbase extends coinbase$1 {
3603
3681
  * @method
3604
3682
  * @name coinbase#fetchOrderBook
3605
3683
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
3606
- * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getproductbook
3684
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpublicproductbook
3607
3685
  * @param {string} symbol unified symbol of the market to fetch the order book for
3608
3686
  * @param {int} [limit] the maximum amount of order book entries to return
3609
3687
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3617,7 +3695,7 @@ class coinbase extends coinbase$1 {
3617
3695
  if (limit !== undefined) {
3618
3696
  request['limit'] = limit;
3619
3697
  }
3620
- const response = await this.v3PrivateGetBrokerageProductBook(this.extend(request, params));
3698
+ const response = await this.v3PublicGetBrokerageMarketProductBook(this.extend(request, params));
3621
3699
  //
3622
3700
  // {
3623
3701
  // "pricebook": {
@@ -90,8 +90,10 @@ class coinbaseinternational extends coinbaseinternational$1 {
90
90
  'fetchOrderBook': false,
91
91
  'fetchOrders': false,
92
92
  'fetchPosition': true,
93
+ 'fetchPositionHistory': false,
93
94
  'fetchPositionMode': false,
94
95
  'fetchPositions': true,
96
+ 'fetchPositionsHistory': false,
95
97
  'fetchPositionsRisk': false,
96
98
  'fetchPremiumIndexOHLCV': false,
97
99
  'fetchTicker': true,
@@ -53,7 +53,13 @@ class coinbasepro extends coinbasepro$1 {
53
53
  'fetchOrderBook': true,
54
54
  'fetchOrders': true,
55
55
  'fetchOrderTrades': true,
56
+ 'fetchPosition': false,
57
+ 'fetchPositionHistory': false,
56
58
  'fetchPositionMode': false,
59
+ 'fetchPositions': false,
60
+ 'fetchPositionsForSymbol': false,
61
+ 'fetchPositionsHistory': false,
62
+ 'fetchPositionsRisk': false,
57
63
  'fetchTicker': true,
58
64
  'fetchTickers': true,
59
65
  'fetchTime': true,
@@ -52,8 +52,11 @@ class coincheck extends coincheck$1 {
52
52
  'fetchOpenOrders': true,
53
53
  'fetchOrderBook': true,
54
54
  'fetchPosition': false,
55
+ 'fetchPositionHistory': false,
55
56
  'fetchPositionMode': false,
56
57
  'fetchPositions': false,
58
+ 'fetchPositionsForSymbol': false,
59
+ 'fetchPositionsHistory': false,
57
60
  'fetchPositionsRisk': false,
58
61
  'fetchPremiumIndexOHLCV': false,
59
62
  'fetchTicker': true,
@@ -90,7 +90,9 @@ class coinex extends coinex$1 {
90
90
  'fetchOrder': true,
91
91
  'fetchOrderBook': true,
92
92
  'fetchPosition': true,
93
+ 'fetchPositionHistory': true,
93
94
  'fetchPositions': true,
95
+ 'fetchPositionsHistory': false,
94
96
  'fetchPositionsRisk': false,
95
97
  'fetchPremiumIndexOHLCV': false,
96
98
  'fetchTicker': true,
@@ -1452,24 +1454,24 @@ class coinex extends coinex$1 {
1452
1454
  }
1453
1455
  parseOHLCV(ohlcv, market = undefined) {
1454
1456
  //
1455
- // [
1456
- // 1591484400,
1457
- // "0.02505349",
1458
- // "0.02506988",
1459
- // "0.02507000",
1460
- // "0.02505304",
1461
- // "343.19716223",
1462
- // "8.6021323866383196",
1463
- // "ETHBTC"
1464
- // ]
1457
+ // {
1458
+ // "close": "66999.95",
1459
+ // "created_at": 1713934620000,
1460
+ // "high": "66999.95",
1461
+ // "low": "66988.53",
1462
+ // "market": "BTCUSDT",
1463
+ // "open": "66988.53",
1464
+ // "value": "0.1572393", // base volume
1465
+ // "volume": "10533.2501364336" // quote volume
1466
+ // }
1465
1467
  //
1466
1468
  return [
1467
- this.safeTimestamp(ohlcv, 0),
1468
- this.safeNumber(ohlcv, 1),
1469
- this.safeNumber(ohlcv, 3),
1470
- this.safeNumber(ohlcv, 4),
1471
- this.safeNumber(ohlcv, 2),
1472
- this.safeNumber(ohlcv, 5),
1469
+ this.safeInteger(ohlcv, 'created_at'),
1470
+ this.safeNumber(ohlcv, 'open'),
1471
+ this.safeNumber(ohlcv, 'high'),
1472
+ this.safeNumber(ohlcv, 'low'),
1473
+ this.safeNumber(ohlcv, 'close'),
1474
+ this.safeNumber(ohlcv, 'value'),
1473
1475
  ];
1474
1476
  }
1475
1477
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
@@ -1477,8 +1479,8 @@ class coinex extends coinex$1 {
1477
1479
  * @method
1478
1480
  * @name coinex#fetchOHLCV
1479
1481
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1480
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market006_market_kline
1481
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http012_market_kline
1482
+ * @see https://docs.coinex.com/api/v2/spot/market/http/list-market-kline
1483
+ * @see https://docs.coinex.com/api/v2/futures/market/http/list-market-kline
1482
1484
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1483
1485
  * @param {string} timeframe the length of time each candle represents
1484
1486
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -1490,39 +1492,34 @@ class coinex extends coinex$1 {
1490
1492
  const market = this.market(symbol);
1491
1493
  const request = {
1492
1494
  'market': market['id'],
1493
- 'type': this.safeString(this.timeframes, timeframe, timeframe),
1495
+ 'period': this.safeString(this.timeframes, timeframe, timeframe),
1494
1496
  };
1495
1497
  if (limit !== undefined) {
1496
1498
  request['limit'] = limit;
1497
1499
  }
1498
1500
  let response = undefined;
1499
1501
  if (market['swap']) {
1500
- response = await this.v1PerpetualPublicGetMarketKline(this.extend(request, params));
1502
+ response = await this.v2PublicGetFuturesKline(this.extend(request, params));
1501
1503
  }
1502
1504
  else {
1503
- response = await this.v1PublicGetMarketKline(this.extend(request, params));
1505
+ response = await this.v2PublicGetSpotKline(this.extend(request, params));
1504
1506
  }
1505
1507
  //
1506
- // Spot
1507
- //
1508
- // {
1509
- // "code": 0,
1510
- // "data": [
1511
- // [1591484400, "0.02505349", "0.02506988", "0.02507000", "0.02505304", "343.19716223", "8.6021323866383196", "ETHBTC"],
1512
- // [1591484700, "0.02506990", "0.02508109", "0.02508109", "0.02506979", "91.59841581", "2.2972047780447000", "ETHBTC"],
1513
- // [1591485000, "0.02508106", "0.02507996", "0.02508106", "0.02507500", "65.15307697", "1.6340597822306000", "ETHBTC"],
1514
- // ],
1515
- // "message": "OK"
1516
- // }
1517
- //
1518
- // Swap
1508
+ // Spot and Swap
1519
1509
  //
1520
1510
  // {
1521
1511
  // "code": 0,
1522
1512
  // "data": [
1523
- // [1650569400, "41524.64", "41489.31", "41564.61", "41480.58", "29.7060", "1233907.099562"],
1524
- // [1650569700, "41489.31", "41438.29", "41489.31", "41391.87", "42.4115", "1756154.189061"],
1525
- // [1650570000, "41438.29", "41482.21", "41485.05", "41427.31", "22.2892", "924000.317861"]
1513
+ // {
1514
+ // "close": "66999.95",
1515
+ // "created_at": 1713934620000,
1516
+ // "high": "66999.95",
1517
+ // "low": "66988.53",
1518
+ // "market": "BTCUSDT",
1519
+ // "open": "66988.53",
1520
+ // "value": "0.1572393",
1521
+ // "volume": "10533.2501364336"
1522
+ // },
1526
1523
  // ],
1527
1524
  // "message": "OK"
1528
1525
  // }
@@ -3763,7 +3760,7 @@ class coinex extends coinex$1 {
3763
3760
  // "side": 2,
3764
3761
  // "stop_loss_price": "0.00000000000000000000",
3765
3762
  // "stop_loss_type": 0,
3766
- // "sys": 0,
3763
+ // "sy s": 0,
3767
3764
  // "take_profit_price": "0.00000000000000000000",
3768
3765
  // "take_profit_type": 0,
3769
3766
  // "taker_fee": "0.00000000000000000000",
@@ -3845,7 +3842,7 @@ class coinex extends coinex$1 {
3845
3842
  // "side": 2,
3846
3843
  // "stop_loss_price": "0.00000000000000000000",
3847
3844
  // "stop_loss_type": 0,
3848
- // "sys": 0,
3845
+ // "s ys": 0,
3849
3846
  // "take_profit_price": "0.00000000000000000000",
3850
3847
  // "take_profit_type": 0,
3851
3848
  // "taker_fee": "0.00000000000000000000",
@@ -3862,6 +3859,8 @@ class coinex extends coinex$1 {
3862
3859
  return this.parsePosition(data[0], market);
3863
3860
  }
3864
3861
  parsePosition(position, market = undefined) {
3862
+ //
3863
+ // fetchPosition
3865
3864
  //
3866
3865
  // {
3867
3866
  // "adl_sort": 3396,
@@ -3905,7 +3904,7 @@ class coinex extends coinex$1 {
3905
3904
  // "side": 2,
3906
3905
  // "stop_loss_price": "0.00000000000000000000",
3907
3906
  // "stop_loss_type": 0,
3908
- // "sys": 0,
3907
+ // "s ys": 0,
3909
3908
  // "take_profit_price": "0.00000000000000000000",
3910
3909
  // "take_profit_type": 0,
3911
3910
  // "taker_fee": "0.00000000000000000000",
@@ -3915,6 +3914,40 @@ class coinex extends coinex$1 {
3915
3914
  // "user_id": 3620173
3916
3915
  // }
3917
3916
  //
3917
+ //
3918
+ // fetchPositionHistory
3919
+ //
3920
+ // {
3921
+ // amount_max: '10',
3922
+ // amount_max_margin: '2.03466666666666666666',
3923
+ // bkr_price: '0',
3924
+ // create_time: '1711150526.2581',
3925
+ // deal_all: '12.591',
3926
+ // deal_asset_fee: '0',
3927
+ // fee_asset: '',
3928
+ // finish_type: '5',
3929
+ // first_price: '0.6104',
3930
+ // latest_price: '0.6487',
3931
+ // leverage: '3',
3932
+ // liq_amount: '0',
3933
+ // liq_price: '0',
3934
+ // liq_profit: '0',
3935
+ // mainten_margin: '0.01',
3936
+ // market: 'XRPUSDT',
3937
+ // market_type: '1',
3938
+ // open_price: '0.6104',
3939
+ // open_val_max: '6.104',
3940
+ // position_id: '297371462',
3941
+ // profit_real: '0.35702107169',
3942
+ // settle_price: '0.6104',
3943
+ // settle_val: '0',
3944
+ // side: '2',
3945
+ // s ys: "0",
3946
+ // type: '2',
3947
+ // update_time: '1711391446.133233',
3948
+ // user_id: '3685860'
3949
+ // }
3950
+ //
3918
3951
  const marketId = this.safeString(position, 'market');
3919
3952
  market = this.safeMarket(marketId, market, undefined, 'swap');
3920
3953
  const symbol = market['symbol'];
@@ -3930,7 +3963,7 @@ class coinex extends coinex$1 {
3930
3963
  const timestamp = this.safeTimestamp(position, 'update_time');
3931
3964
  const maintenanceMargin = this.safeString(position, 'mainten_margin_amount');
3932
3965
  const maintenanceMarginPercentage = this.safeString(position, 'mainten_margin');
3933
- const collateral = this.safeString(position, 'margin_amount');
3966
+ const collateral = this.safeString2(position, 'margin_amount', 'amount_max_margin');
3934
3967
  const leverage = this.safeString(position, 'leverage');
3935
3968
  const notional = this.safeString(position, 'open_val');
3936
3969
  const initialMargin = Precise["default"].stringDiv(notional, leverage);
@@ -4160,7 +4193,7 @@ class coinex extends coinex$1 {
4160
4193
  // "side": 2,
4161
4194
  // "stop_loss_price": "0.00000000000000000000",
4162
4195
  // "stop_loss_type": 0,
4163
- // "sys": 0,
4196
+ // "s ys": 0,
4164
4197
  // "take_profit_price": "0.00000000000000000000",
4165
4198
  // "take_profit_type": 0,
4166
4199
  // "taker_fee": "0.00000000000000000000",
@@ -4225,7 +4258,7 @@ class coinex extends coinex$1 {
4225
4258
  // "side": 2,
4226
4259
  // "stop_loss_price": "0.00000000000000000000",
4227
4260
  // "stop_loss_type": 0,
4228
- // "sys": 0,
4261
+ // "sy s": 0,
4229
4262
  // "take_profit_price": "0.00000000000000000000",
4230
4263
  // "take_profit_type": 0,
4231
4264
  // "taker_fee": "0.00000000000000000000",
@@ -5608,6 +5641,80 @@ class coinex extends coinex$1 {
5608
5641
  'shortLeverage': leverageValue,
5609
5642
  };
5610
5643
  }
5644
+ async fetchPositionHistory(symbol, since = undefined, limit = undefined, params = {}) {
5645
+ /**
5646
+ * @method
5647
+ * @name coinex#fetchPositionHistory
5648
+ * @description fetches historical positions
5649
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033-0_finished_position
5650
+ * @param {string} symbol unified contract symbol
5651
+ * @param {int} [since] not used by coinex fetchPositionHistory
5652
+ * @param {int} [limit] the maximum amount of records to fetch, default=1000
5653
+ * @param {object} params extra parameters specific to the exchange api endpoint
5654
+ *
5655
+ * EXCHANGE SPECIFIC PARAMETERS
5656
+ * @param {int} [params.side] 0: all 1: sell, 2: buy
5657
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
5658
+ */
5659
+ await this.loadMarkets();
5660
+ const market = this.market(symbol);
5661
+ if (limit === undefined) {
5662
+ limit = 1000;
5663
+ }
5664
+ const request = {
5665
+ 'market': market['id'],
5666
+ 'side': 0,
5667
+ 'limit': limit,
5668
+ };
5669
+ const response = await this.v1PerpetualPrivateGetPositionFinished(this.extend(request, params));
5670
+ //
5671
+ // {
5672
+ // code: '0',
5673
+ // data: {
5674
+ // limit: '1000',
5675
+ // offset: '0',
5676
+ // records: [
5677
+ // {
5678
+ // amount_max: '10',
5679
+ // amount_max_margin: '2.03466666666666666666',
5680
+ // bkr_price: '0',
5681
+ // create_time: '1711150526.2581',
5682
+ // deal_all: '12.591',
5683
+ // deal_asset_fee: '0',
5684
+ // fee_asset: '',
5685
+ // finish_type: '5',
5686
+ // first_price: '0.6104',
5687
+ // latest_price: '0.6487',
5688
+ // leverage: '3',
5689
+ // liq_amount: '0',
5690
+ // liq_price: '0',
5691
+ // liq_profit: '0',
5692
+ // mainten_margin: '0.01',
5693
+ // market: 'XRPUSDT',
5694
+ // market_type: '1',
5695
+ // open_price: '0.6104',
5696
+ // open_val_max: '6.104',
5697
+ // position_id: '297371462',
5698
+ // profit_real: '0.35702107169',
5699
+ // settle_price: '0.6104',
5700
+ // settle_val: '0',
5701
+ // side: '2',
5702
+ // sy s: '0',
5703
+ // type: '2',
5704
+ // update_time: '1711391446.133233',
5705
+ // user_id: '3685860'
5706
+ // },
5707
+ // ...
5708
+ // ]
5709
+ // },
5710
+ // message: 'OK'
5711
+ // }
5712
+ //
5713
+ const data = this.safeDict(response, 'data');
5714
+ const records = this.safeList(data, 'records');
5715
+ const positions = this.parsePositions(records);
5716
+ return this.filterBySymbolSinceLimit(positions, symbol, since, limit);
5717
+ }
5611
5718
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
5612
5719
  /**
5613
5720
  * @ignore
@@ -87,7 +87,11 @@ class coinlist extends coinlist$1 {
87
87
  'fetchOrders': true,
88
88
  'fetchOrderTrades': true,
89
89
  'fetchPosition': false,
90
+ 'fetchPositionHistory': false,
91
+ 'fetchPositionMode': false,
90
92
  'fetchPositions': false,
93
+ 'fetchPositionsForSymbol': false,
94
+ 'fetchPositionsHistory': false,
91
95
  'fetchPositionsRisk': false,
92
96
  'fetchPremiumIndexOHLCV': false,
93
97
  'fetchStatus': false,
@@ -57,8 +57,11 @@ class coinmate extends coinmate$1 {
57
57
  'fetchOrderBook': true,
58
58
  'fetchOrders': true,
59
59
  'fetchPosition': false,
60
+ 'fetchPositionHistory': false,
60
61
  'fetchPositionMode': false,
61
62
  'fetchPositions': false,
63
+ 'fetchPositionsForSymbol': false,
64
+ 'fetchPositionsHistory': false,
62
65
  'fetchPositionsRisk': false,
63
66
  'fetchPremiumIndexOHLCV': false,
64
67
  'fetchTicker': true,
@@ -65,8 +65,11 @@ class coinone extends coinone$1 {
65
65
  'fetchOrder': true,
66
66
  'fetchOrderBook': true,
67
67
  'fetchPosition': false,
68
+ 'fetchPositionHistory': false,
68
69
  'fetchPositionMode': false,
69
70
  'fetchPositions': false,
71
+ 'fetchPositionsForSymbol': false,
72
+ 'fetchPositionsHistory': false,
70
73
  'fetchPositionsRisk': false,
71
74
  'fetchPremiumIndexOHLCV': false,
72
75
  'fetchTicker': true,
@@ -89,7 +89,11 @@ class coinsph extends coinsph$1 {
89
89
  'fetchOrders': false,
90
90
  'fetchOrderTrades': true,
91
91
  'fetchPosition': false,
92
+ 'fetchPositionHistory': false,
93
+ 'fetchPositionMode': false,
92
94
  'fetchPositions': false,
95
+ 'fetchPositionsForSymbol': false,
96
+ 'fetchPositionsHistory': false,
93
97
  'fetchPositionsRisk': false,
94
98
  'fetchPremiumIndexOHLCV': false,
95
99
  'fetchStatus': true,
@@ -57,8 +57,11 @@ class coinspot extends coinspot$1 {
57
57
  'fetchOpenInterestHistory': false,
58
58
  'fetchOrderBook': true,
59
59
  'fetchPosition': false,
60
+ 'fetchPositionHistory': false,
60
61
  'fetchPositionMode': false,
61
62
  'fetchPositions': false,
63
+ 'fetchPositionsForSymbol': false,
64
+ 'fetchPositionsHistory': false,
62
65
  'fetchPositionsRisk': false,
63
66
  'fetchPremiumIndexOHLCV': false,
64
67
  'fetchTicker': true,
@@ -80,8 +80,10 @@ class cryptocom extends cryptocom$1 {
80
80
  'fetchOrderBook': true,
81
81
  'fetchOrders': true,
82
82
  'fetchPosition': true,
83
+ 'fetchPositionHistory': false,
83
84
  'fetchPositionMode': false,
84
85
  'fetchPositions': true,
86
+ 'fetchPositionsHistory': false,
85
87
  'fetchPremiumIndexOHLCV': false,
86
88
  'fetchSettlementHistory': true,
87
89
  'fetchStatus': false,
@@ -62,7 +62,12 @@ class exmo extends exmo$1 {
62
62
  'fetchOrderBook': true,
63
63
  'fetchOrderBooks': true,
64
64
  'fetchOrderTrades': true,
65
+ 'fetchPosition': false,
66
+ 'fetchPositionHistory': false,
65
67
  'fetchPositionMode': false,
68
+ 'fetchPositions': false,
69
+ 'fetchPositionsHistory': false,
70
+ 'fetchPositionsRisk': false,
66
71
  'fetchPremiumIndexOHLCV': false,
67
72
  'fetchTicker': true,
68
73
  'fetchTickers': true,