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
@@ -205,6 +205,11 @@ export default class coinbase extends Exchange {
205
205
  'public': {
206
206
  'get': {
207
207
  'brokerage/time': 3,
208
+ 'brokerage/market/product_book': 3,
209
+ 'brokerage/market/products': 3,
210
+ 'brokerage/market/products/{product_id}': 3,
211
+ 'brokerage/market/products/{product_id}/candles': 3,
212
+ 'brokerage/market/products/{product_id}/ticker': 3,
208
213
  },
209
214
  },
210
215
  'private': {
@@ -1094,7 +1099,7 @@ export default class coinbase extends Exchange {
1094
1099
  /**
1095
1100
  * @method
1096
1101
  * @name coinbase#fetchMarkets
1097
- * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getproducts
1102
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpublicproducts
1098
1103
  * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-currencies#get-fiat-currencies
1099
1104
  * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates#get-exchange-rates
1100
1105
  * @description retrieves data on all markets for coinbase
@@ -1181,20 +1186,92 @@ export default class coinbase extends Exchange {
1181
1186
  }
1182
1187
  async fetchMarketsV3(params = {}) {
1183
1188
  const spotUnresolvedPromises = [
1184
- this.v3PrivateGetBrokerageProducts(params),
1185
- this.v3PrivateGetBrokerageTransactionSummary(params),
1189
+ this.v3PublicGetBrokerageMarketProducts(params),
1190
+ //
1191
+ // {
1192
+ // products: [
1193
+ // {
1194
+ // product_id: 'BTC-USD',
1195
+ // price: '67060',
1196
+ // price_percentage_change_24h: '3.30054960636883',
1197
+ // volume_24h: '10967.87426597',
1198
+ // volume_percentage_change_24h: '141.73048325503036',
1199
+ // base_increment: '0.00000001',
1200
+ // quote_increment: '0.01',
1201
+ // quote_min_size: '1',
1202
+ // quote_max_size: '150000000',
1203
+ // base_min_size: '0.00000001',
1204
+ // base_max_size: '3400',
1205
+ // base_name: 'Bitcoin',
1206
+ // quote_name: 'US Dollar',
1207
+ // watched: false,
1208
+ // is_disabled: false,
1209
+ // new: false,
1210
+ // status: 'online',
1211
+ // cancel_only: false,
1212
+ // limit_only: false,
1213
+ // post_only: false,
1214
+ // trading_disabled: false,
1215
+ // auction_mode: false,
1216
+ // product_type: 'SPOT',
1217
+ // quote_currency_id: 'USD',
1218
+ // base_currency_id: 'BTC',
1219
+ // fcm_trading_session_details: null,
1220
+ // mid_market_price: '',
1221
+ // alias: '',
1222
+ // alias_to: [ 'BTC-USDC' ],
1223
+ // base_display_symbol: 'BTC',
1224
+ // quote_display_symbol: 'USD',
1225
+ // view_only: false,
1226
+ // price_increment: '0.01',
1227
+ // display_name: 'BTC-USD',
1228
+ // product_venue: 'CBE'
1229
+ // },
1230
+ // ...
1231
+ // ],
1232
+ // num_products: '646'
1233
+ // }
1234
+ //
1186
1235
  ];
1236
+ if (this.checkRequiredCredentials(false)) {
1237
+ spotUnresolvedPromises.push(this.v3PrivateGetBrokerageTransactionSummary(params));
1238
+ }
1239
+ //
1240
+ // {
1241
+ // total_volume: '9.995989116664404',
1242
+ // total_fees: '0.07996791093331522',
1243
+ // fee_tier: {
1244
+ // pricing_tier: 'Advanced 1',
1245
+ // usd_from: '0',
1246
+ // usd_to: '1000',
1247
+ // taker_fee_rate: '0.008',
1248
+ // maker_fee_rate: '0.006',
1249
+ // aop_from: '',
1250
+ // aop_to: ''
1251
+ // },
1252
+ // margin_rate: null,
1253
+ // goods_and_services_tax: null,
1254
+ // advanced_trade_only_volume: '9.995989116664404',
1255
+ // advanced_trade_only_fees: '0.07996791093331522',
1256
+ // coinbase_pro_volume: '0',
1257
+ // coinbase_pro_fees: '0',
1258
+ // total_balance: '',
1259
+ // has_promo_fee: false
1260
+ // }
1261
+ //
1187
1262
  let unresolvedContractPromises = [];
1188
1263
  try {
1189
1264
  unresolvedContractPromises = [
1190
- this.v3PrivateGetBrokerageProducts(this.extend(params, { 'product_type': 'FUTURE' })),
1191
- this.v3PrivateGetBrokerageProducts(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1192
- this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE' })),
1193
- this.v3PrivateGetBrokerageTransactionSummary(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1265
+ this.v3PublicGetBrokerageMarketProducts(this.extend(params, { 'product_type': 'FUTURE' })),
1266
+ this.v3PublicGetBrokerageMarketProducts(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' })),
1194
1267
  ];
1268
+ if (this.checkRequiredCredentials(false)) {
1269
+ unresolvedContractPromises.push(this.extend(params, { 'product_type': 'FUTURE' }));
1270
+ unresolvedContractPromises.push(this.extend(params, { 'product_type': 'FUTURE', 'contract_expiry_type': 'PERPETUAL' }));
1271
+ }
1195
1272
  }
1196
1273
  catch (e) {
1197
- unresolvedContractPromises = []; // the sync version of ccxt won't have the promise.all line so the request is made here
1274
+ 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
1198
1275
  }
1199
1276
  const promises = await Promise.all(spotUnresolvedPromises);
1200
1277
  let contractPromises = undefined;
@@ -1463,6 +1540,7 @@ export default class coinbase extends Exchange {
1463
1540
  const contractSize = this.safeNumber(futureProductDetails, 'contract_size');
1464
1541
  const contractExpire = this.safeString(futureProductDetails, 'contract_expiry');
1465
1542
  const expireTimestamp = this.parse8601(contractExpire);
1543
+ const expireDateTime = this.iso8601(expireTimestamp);
1466
1544
  const isSwap = (contractExpiryType === 'PERPETUAL');
1467
1545
  const baseId = this.safeString(futureProductDetails, 'contract_root_unit');
1468
1546
  const quoteId = this.safeString(market, 'quote_currency_id');
@@ -1506,7 +1584,7 @@ export default class coinbase extends Exchange {
1506
1584
  'maker': maker,
1507
1585
  'contractSize': contractSize,
1508
1586
  'expiry': expireTimestamp,
1509
- 'expiryDatetime': contractExpire,
1587
+ 'expiryDatetime': expireDateTime,
1510
1588
  'strike': undefined,
1511
1589
  'optionType': undefined,
1512
1590
  'precision': {
@@ -1731,7 +1809,7 @@ export default class coinbase extends Exchange {
1731
1809
  if (symbols !== undefined) {
1732
1810
  request['product_ids'] = this.marketIds(symbols);
1733
1811
  }
1734
- const response = await this.v3PrivateGetBrokerageProducts(this.extend(request, params));
1812
+ const response = await this.v3PublicGetBrokerageMarketProducts(this.extend(request, params));
1735
1813
  //
1736
1814
  // {
1737
1815
  // "products": [
@@ -1834,7 +1912,7 @@ export default class coinbase extends Exchange {
1834
1912
  'product_id': market['id'],
1835
1913
  'limit': 1,
1836
1914
  };
1837
- const response = await this.v3PrivateGetBrokerageProductsProductIdTicker(this.extend(request, params));
1915
+ const response = await this.v3PublicGetBrokerageMarketProductsProductIdTicker(this.extend(request, params));
1838
1916
  //
1839
1917
  // {
1840
1918
  // "trades": [
@@ -3395,7 +3473,7 @@ export default class coinbase extends Exchange {
3395
3473
  * @method
3396
3474
  * @name coinbase#fetchOHLCV
3397
3475
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
3398
- * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getcandles
3476
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpubliccandles
3399
3477
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
3400
3478
  * @param {string} timeframe the length of time each candle represents
3401
3479
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -3438,7 +3516,7 @@ export default class coinbase extends Exchange {
3438
3516
  // 300 candles max
3439
3517
  request['end'] = Precise.stringAdd(sinceString, requestedDuration.toString());
3440
3518
  }
3441
- const response = await this.v3PrivateGetBrokerageProductsProductIdCandles(this.extend(request, params));
3519
+ const response = await this.v3PublicGetBrokerageMarketProductsProductIdCandles(this.extend(request, params));
3442
3520
  //
3443
3521
  // {
3444
3522
  // "candles": [
@@ -3483,7 +3561,7 @@ export default class coinbase extends Exchange {
3483
3561
  * @method
3484
3562
  * @name coinbase#fetchTrades
3485
3563
  * @description get the list of most recent trades for a particular symbol
3486
- * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getmarkettrades
3564
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpublicmarkettrades
3487
3565
  * @param {string} symbol unified market symbol of the trades
3488
3566
  * @param {int} [since] not used by coinbase fetchTrades
3489
3567
  * @param {int} [limit] the maximum number of trade structures to fetch
@@ -3509,7 +3587,7 @@ export default class coinbase extends Exchange {
3509
3587
  else if (since !== undefined) {
3510
3588
  throw new ArgumentsRequired(this.id + ' fetchTrades() requires a `until` parameter when you use `since` argument');
3511
3589
  }
3512
- const response = await this.v3PrivateGetBrokerageProductsProductIdTicker(this.extend(request, params));
3590
+ const response = await this.v3PublicGetBrokerageMarketProductsProductIdTicker(this.extend(request, params));
3513
3591
  //
3514
3592
  // {
3515
3593
  // "trades": [
@@ -3606,7 +3684,7 @@ export default class coinbase extends Exchange {
3606
3684
  * @method
3607
3685
  * @name coinbase#fetchOrderBook
3608
3686
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
3609
- * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getproductbook
3687
+ * @see https://docs.cloud.coinbase.com/advanced-trade-api/reference/retailbrokerageapi_getpublicproductbook
3610
3688
  * @param {string} symbol unified symbol of the market to fetch the order book for
3611
3689
  * @param {int} [limit] the maximum amount of order book entries to return
3612
3690
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3620,7 +3698,7 @@ export default class coinbase extends Exchange {
3620
3698
  if (limit !== undefined) {
3621
3699
  request['limit'] = limit;
3622
3700
  }
3623
- const response = await this.v3PrivateGetBrokerageProductBook(this.extend(request, params));
3701
+ const response = await this.v3PublicGetBrokerageMarketProductBook(this.extend(request, params));
3624
3702
  //
3625
3703
  // {
3626
3704
  // "pricebook": {
@@ -114,7 +114,7 @@ export default class coinbaseinternational extends Exchange {
114
114
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
115
115
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
116
116
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
117
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
117
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
118
118
  safeNetwork(network: any): {
119
119
  info: any;
120
120
  id: string;
@@ -93,8 +93,10 @@ export default class coinbaseinternational extends Exchange {
93
93
  'fetchOrderBook': false,
94
94
  'fetchOrders': false,
95
95
  'fetchPosition': true,
96
+ 'fetchPositionHistory': false,
96
97
  'fetchPositionMode': false,
97
98
  'fetchPositions': true,
99
+ 'fetchPositionsHistory': false,
98
100
  'fetchPositionsRisk': false,
99
101
  'fetchPremiumIndexOHLCV': false,
100
102
  'fetchTicker': true,
@@ -39,7 +39,7 @@ export default class coinbasepro extends Exchange {
39
39
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
40
40
  cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
41
41
  fetchPaymentMethods(params?: {}): Promise<any>;
42
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
42
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
43
43
  parseLedgerEntryType(type: any): string;
44
44
  parseLedgerEntry(item: any, currency?: Currency): {
45
45
  id: string;
@@ -56,7 +56,13 @@ export default class coinbasepro extends Exchange {
56
56
  'fetchOrderBook': true,
57
57
  'fetchOrders': true,
58
58
  'fetchOrderTrades': true,
59
+ 'fetchPosition': false,
60
+ 'fetchPositionHistory': false,
59
61
  'fetchPositionMode': false,
62
+ 'fetchPositions': false,
63
+ 'fetchPositionsForSymbol': false,
64
+ 'fetchPositionsHistory': false,
65
+ 'fetchPositionsRisk': false,
60
66
  'fetchTicker': true,
61
67
  'fetchTickers': true,
62
68
  'fetchTime': true,
@@ -55,8 +55,11 @@ export default class coincheck extends Exchange {
55
55
  'fetchOpenOrders': true,
56
56
  'fetchOrderBook': true,
57
57
  'fetchPosition': false,
58
+ 'fetchPositionHistory': false,
58
59
  'fetchPositionMode': false,
59
60
  'fetchPositions': false,
61
+ 'fetchPositionsForSymbol': false,
62
+ 'fetchPositionsHistory': false,
60
63
  'fetchPositionsRisk': false,
61
64
  'fetchPremiumIndexOHLCV': false,
62
65
  'fetchTicker': true,
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/coinex.js';
2
- import type { Balances, Currency, FundingHistory, FundingRateHistory, Int, Market, OHLCV, Order, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, OrderRequest, TransferEntry, Leverage, Leverages, Num, MarginModification, TradingFeeInterface, Currencies, TradingFees } from './base/types.js';
2
+ import type { Balances, Currency, FundingHistory, FundingRateHistory, Int, Market, OHLCV, Order, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, OrderRequest, TransferEntry, Leverage, Leverages, Num, MarginModification, TradingFeeInterface, Currencies, TradingFees, Position } from './base/types.js';
3
3
  /**
4
4
  * @class coinex
5
5
  * @augments Exchange
@@ -65,17 +65,17 @@ export default class coinex extends Exchange {
65
65
  network: any;
66
66
  };
67
67
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
68
- fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
69
- fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
70
- parsePosition(position: any, market?: Market): import("./base/types.js").Position;
68
+ fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
69
+ fetchPosition(symbol: string, params?: {}): Promise<Position>;
70
+ parsePosition(position: any, market?: Market): Position;
71
71
  setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
72
72
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
73
73
  fetchLeverageTiers(symbols?: Strings, params?: {}): Promise<{}>;
74
74
  parseMarketLeverageTiers(item: any, market?: Market): any[];
75
75
  modifyMarginHelper(symbol: string, amount: any, addOrReduce: any, params?: {}): Promise<any>;
76
76
  parseMarginModification(data: any, market?: Market): MarginModification;
77
- addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
78
- reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
77
+ addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
78
+ reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
79
79
  fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
80
80
  fetchFundingRate(symbol: string, params?: {}): Promise<{
81
81
  info: any;
@@ -116,7 +116,7 @@ export default class coinex extends Exchange {
116
116
  previousFundingDatetime: any;
117
117
  };
118
118
  fetchFundingRates(symbols?: Strings, params?: {}): Promise<any>;
119
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
119
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
120
120
  parseTransactionStatus(status: any): string;
121
121
  fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
122
122
  parseTransaction(transaction: any, currency?: Currency): Transaction;
@@ -188,6 +188,7 @@ export default class coinex extends Exchange {
188
188
  parseDepositWithdrawFees(response: any, codes?: any, currencyIdKey?: any): {};
189
189
  fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
190
190
  parseLeverage(leverage: any, market?: any): Leverage;
191
+ fetchPositionHistory(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Position>;
191
192
  handleMarginModeAndParams(methodName: any, params?: {}, defaultValue?: any): any[];
192
193
  nonce(): number;
193
194
  sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
package/js/src/coinex.js CHANGED
@@ -93,7 +93,9 @@ export default class coinex extends Exchange {
93
93
  'fetchOrder': true,
94
94
  'fetchOrderBook': true,
95
95
  'fetchPosition': true,
96
+ 'fetchPositionHistory': true,
96
97
  'fetchPositions': true,
98
+ 'fetchPositionsHistory': false,
97
99
  'fetchPositionsRisk': false,
98
100
  'fetchPremiumIndexOHLCV': false,
99
101
  'fetchTicker': true,
@@ -1455,24 +1457,24 @@ export default class coinex extends Exchange {
1455
1457
  }
1456
1458
  parseOHLCV(ohlcv, market = undefined) {
1457
1459
  //
1458
- // [
1459
- // 1591484400,
1460
- // "0.02505349",
1461
- // "0.02506988",
1462
- // "0.02507000",
1463
- // "0.02505304",
1464
- // "343.19716223",
1465
- // "8.6021323866383196",
1466
- // "ETHBTC"
1467
- // ]
1460
+ // {
1461
+ // "close": "66999.95",
1462
+ // "created_at": 1713934620000,
1463
+ // "high": "66999.95",
1464
+ // "low": "66988.53",
1465
+ // "market": "BTCUSDT",
1466
+ // "open": "66988.53",
1467
+ // "value": "0.1572393", // base volume
1468
+ // "volume": "10533.2501364336" // quote volume
1469
+ // }
1468
1470
  //
1469
1471
  return [
1470
- this.safeTimestamp(ohlcv, 0),
1471
- this.safeNumber(ohlcv, 1),
1472
- this.safeNumber(ohlcv, 3),
1473
- this.safeNumber(ohlcv, 4),
1474
- this.safeNumber(ohlcv, 2),
1475
- this.safeNumber(ohlcv, 5),
1472
+ this.safeInteger(ohlcv, 'created_at'),
1473
+ this.safeNumber(ohlcv, 'open'),
1474
+ this.safeNumber(ohlcv, 'high'),
1475
+ this.safeNumber(ohlcv, 'low'),
1476
+ this.safeNumber(ohlcv, 'close'),
1477
+ this.safeNumber(ohlcv, 'value'),
1476
1478
  ];
1477
1479
  }
1478
1480
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
@@ -1480,8 +1482,8 @@ export default class coinex extends Exchange {
1480
1482
  * @method
1481
1483
  * @name coinex#fetchOHLCV
1482
1484
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1483
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market006_market_kline
1484
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http012_market_kline
1485
+ * @see https://docs.coinex.com/api/v2/spot/market/http/list-market-kline
1486
+ * @see https://docs.coinex.com/api/v2/futures/market/http/list-market-kline
1485
1487
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1486
1488
  * @param {string} timeframe the length of time each candle represents
1487
1489
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -1493,39 +1495,34 @@ export default class coinex extends Exchange {
1493
1495
  const market = this.market(symbol);
1494
1496
  const request = {
1495
1497
  'market': market['id'],
1496
- 'type': this.safeString(this.timeframes, timeframe, timeframe),
1498
+ 'period': this.safeString(this.timeframes, timeframe, timeframe),
1497
1499
  };
1498
1500
  if (limit !== undefined) {
1499
1501
  request['limit'] = limit;
1500
1502
  }
1501
1503
  let response = undefined;
1502
1504
  if (market['swap']) {
1503
- response = await this.v1PerpetualPublicGetMarketKline(this.extend(request, params));
1505
+ response = await this.v2PublicGetFuturesKline(this.extend(request, params));
1504
1506
  }
1505
1507
  else {
1506
- response = await this.v1PublicGetMarketKline(this.extend(request, params));
1508
+ response = await this.v2PublicGetSpotKline(this.extend(request, params));
1507
1509
  }
1508
1510
  //
1509
- // Spot
1510
- //
1511
- // {
1512
- // "code": 0,
1513
- // "data": [
1514
- // [1591484400, "0.02505349", "0.02506988", "0.02507000", "0.02505304", "343.19716223", "8.6021323866383196", "ETHBTC"],
1515
- // [1591484700, "0.02506990", "0.02508109", "0.02508109", "0.02506979", "91.59841581", "2.2972047780447000", "ETHBTC"],
1516
- // [1591485000, "0.02508106", "0.02507996", "0.02508106", "0.02507500", "65.15307697", "1.6340597822306000", "ETHBTC"],
1517
- // ],
1518
- // "message": "OK"
1519
- // }
1520
- //
1521
- // Swap
1511
+ // Spot and Swap
1522
1512
  //
1523
1513
  // {
1524
1514
  // "code": 0,
1525
1515
  // "data": [
1526
- // [1650569400, "41524.64", "41489.31", "41564.61", "41480.58", "29.7060", "1233907.099562"],
1527
- // [1650569700, "41489.31", "41438.29", "41489.31", "41391.87", "42.4115", "1756154.189061"],
1528
- // [1650570000, "41438.29", "41482.21", "41485.05", "41427.31", "22.2892", "924000.317861"]
1516
+ // {
1517
+ // "close": "66999.95",
1518
+ // "created_at": 1713934620000,
1519
+ // "high": "66999.95",
1520
+ // "low": "66988.53",
1521
+ // "market": "BTCUSDT",
1522
+ // "open": "66988.53",
1523
+ // "value": "0.1572393",
1524
+ // "volume": "10533.2501364336"
1525
+ // },
1529
1526
  // ],
1530
1527
  // "message": "OK"
1531
1528
  // }
@@ -3766,7 +3763,7 @@ export default class coinex extends Exchange {
3766
3763
  // "side": 2,
3767
3764
  // "stop_loss_price": "0.00000000000000000000",
3768
3765
  // "stop_loss_type": 0,
3769
- // "sys": 0,
3766
+ // "sy s": 0,
3770
3767
  // "take_profit_price": "0.00000000000000000000",
3771
3768
  // "take_profit_type": 0,
3772
3769
  // "taker_fee": "0.00000000000000000000",
@@ -3848,7 +3845,7 @@ export default class coinex extends Exchange {
3848
3845
  // "side": 2,
3849
3846
  // "stop_loss_price": "0.00000000000000000000",
3850
3847
  // "stop_loss_type": 0,
3851
- // "sys": 0,
3848
+ // "s ys": 0,
3852
3849
  // "take_profit_price": "0.00000000000000000000",
3853
3850
  // "take_profit_type": 0,
3854
3851
  // "taker_fee": "0.00000000000000000000",
@@ -3865,6 +3862,8 @@ export default class coinex extends Exchange {
3865
3862
  return this.parsePosition(data[0], market);
3866
3863
  }
3867
3864
  parsePosition(position, market = undefined) {
3865
+ //
3866
+ // fetchPosition
3868
3867
  //
3869
3868
  // {
3870
3869
  // "adl_sort": 3396,
@@ -3908,7 +3907,7 @@ export default class coinex extends Exchange {
3908
3907
  // "side": 2,
3909
3908
  // "stop_loss_price": "0.00000000000000000000",
3910
3909
  // "stop_loss_type": 0,
3911
- // "sys": 0,
3910
+ // "s ys": 0,
3912
3911
  // "take_profit_price": "0.00000000000000000000",
3913
3912
  // "take_profit_type": 0,
3914
3913
  // "taker_fee": "0.00000000000000000000",
@@ -3918,6 +3917,40 @@ export default class coinex extends Exchange {
3918
3917
  // "user_id": 3620173
3919
3918
  // }
3920
3919
  //
3920
+ //
3921
+ // fetchPositionHistory
3922
+ //
3923
+ // {
3924
+ // amount_max: '10',
3925
+ // amount_max_margin: '2.03466666666666666666',
3926
+ // bkr_price: '0',
3927
+ // create_time: '1711150526.2581',
3928
+ // deal_all: '12.591',
3929
+ // deal_asset_fee: '0',
3930
+ // fee_asset: '',
3931
+ // finish_type: '5',
3932
+ // first_price: '0.6104',
3933
+ // latest_price: '0.6487',
3934
+ // leverage: '3',
3935
+ // liq_amount: '0',
3936
+ // liq_price: '0',
3937
+ // liq_profit: '0',
3938
+ // mainten_margin: '0.01',
3939
+ // market: 'XRPUSDT',
3940
+ // market_type: '1',
3941
+ // open_price: '0.6104',
3942
+ // open_val_max: '6.104',
3943
+ // position_id: '297371462',
3944
+ // profit_real: '0.35702107169',
3945
+ // settle_price: '0.6104',
3946
+ // settle_val: '0',
3947
+ // side: '2',
3948
+ // s ys: "0",
3949
+ // type: '2',
3950
+ // update_time: '1711391446.133233',
3951
+ // user_id: '3685860'
3952
+ // }
3953
+ //
3921
3954
  const marketId = this.safeString(position, 'market');
3922
3955
  market = this.safeMarket(marketId, market, undefined, 'swap');
3923
3956
  const symbol = market['symbol'];
@@ -3933,7 +3966,7 @@ export default class coinex extends Exchange {
3933
3966
  const timestamp = this.safeTimestamp(position, 'update_time');
3934
3967
  const maintenanceMargin = this.safeString(position, 'mainten_margin_amount');
3935
3968
  const maintenanceMarginPercentage = this.safeString(position, 'mainten_margin');
3936
- const collateral = this.safeString(position, 'margin_amount');
3969
+ const collateral = this.safeString2(position, 'margin_amount', 'amount_max_margin');
3937
3970
  const leverage = this.safeString(position, 'leverage');
3938
3971
  const notional = this.safeString(position, 'open_val');
3939
3972
  const initialMargin = Precise.stringDiv(notional, leverage);
@@ -4163,7 +4196,7 @@ export default class coinex extends Exchange {
4163
4196
  // "side": 2,
4164
4197
  // "stop_loss_price": "0.00000000000000000000",
4165
4198
  // "stop_loss_type": 0,
4166
- // "sys": 0,
4199
+ // "s ys": 0,
4167
4200
  // "take_profit_price": "0.00000000000000000000",
4168
4201
  // "take_profit_type": 0,
4169
4202
  // "taker_fee": "0.00000000000000000000",
@@ -4228,7 +4261,7 @@ export default class coinex extends Exchange {
4228
4261
  // "side": 2,
4229
4262
  // "stop_loss_price": "0.00000000000000000000",
4230
4263
  // "stop_loss_type": 0,
4231
- // "sys": 0,
4264
+ // "sy s": 0,
4232
4265
  // "take_profit_price": "0.00000000000000000000",
4233
4266
  // "take_profit_type": 0,
4234
4267
  // "taker_fee": "0.00000000000000000000",
@@ -5611,6 +5644,80 @@ export default class coinex extends Exchange {
5611
5644
  'shortLeverage': leverageValue,
5612
5645
  };
5613
5646
  }
5647
+ async fetchPositionHistory(symbol, since = undefined, limit = undefined, params = {}) {
5648
+ /**
5649
+ * @method
5650
+ * @name coinex#fetchPositionHistory
5651
+ * @description fetches historical positions
5652
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033-0_finished_position
5653
+ * @param {string} symbol unified contract symbol
5654
+ * @param {int} [since] not used by coinex fetchPositionHistory
5655
+ * @param {int} [limit] the maximum amount of records to fetch, default=1000
5656
+ * @param {object} params extra parameters specific to the exchange api endpoint
5657
+ *
5658
+ * EXCHANGE SPECIFIC PARAMETERS
5659
+ * @param {int} [params.side] 0: all 1: sell, 2: buy
5660
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
5661
+ */
5662
+ await this.loadMarkets();
5663
+ const market = this.market(symbol);
5664
+ if (limit === undefined) {
5665
+ limit = 1000;
5666
+ }
5667
+ const request = {
5668
+ 'market': market['id'],
5669
+ 'side': 0,
5670
+ 'limit': limit,
5671
+ };
5672
+ const response = await this.v1PerpetualPrivateGetPositionFinished(this.extend(request, params));
5673
+ //
5674
+ // {
5675
+ // code: '0',
5676
+ // data: {
5677
+ // limit: '1000',
5678
+ // offset: '0',
5679
+ // records: [
5680
+ // {
5681
+ // amount_max: '10',
5682
+ // amount_max_margin: '2.03466666666666666666',
5683
+ // bkr_price: '0',
5684
+ // create_time: '1711150526.2581',
5685
+ // deal_all: '12.591',
5686
+ // deal_asset_fee: '0',
5687
+ // fee_asset: '',
5688
+ // finish_type: '5',
5689
+ // first_price: '0.6104',
5690
+ // latest_price: '0.6487',
5691
+ // leverage: '3',
5692
+ // liq_amount: '0',
5693
+ // liq_price: '0',
5694
+ // liq_profit: '0',
5695
+ // mainten_margin: '0.01',
5696
+ // market: 'XRPUSDT',
5697
+ // market_type: '1',
5698
+ // open_price: '0.6104',
5699
+ // open_val_max: '6.104',
5700
+ // position_id: '297371462',
5701
+ // profit_real: '0.35702107169',
5702
+ // settle_price: '0.6104',
5703
+ // settle_val: '0',
5704
+ // side: '2',
5705
+ // sy s: '0',
5706
+ // type: '2',
5707
+ // update_time: '1711391446.133233',
5708
+ // user_id: '3685860'
5709
+ // },
5710
+ // ...
5711
+ // ]
5712
+ // },
5713
+ // message: 'OK'
5714
+ // }
5715
+ //
5716
+ const data = this.safeDict(response, 'data');
5717
+ const records = this.safeList(data, 'records');
5718
+ const positions = this.parsePositions(records);
5719
+ return this.filterBySymbolSinceLimit(positions, symbol, since, limit);
5720
+ }
5614
5721
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
5615
5722
  /**
5616
5723
  * @ignore
@@ -63,7 +63,7 @@ export default class coinlist extends Exchange {
63
63
  };
64
64
  parseTransferStatus(status: any): string;
65
65
  fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
66
- withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
66
+ withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
67
67
  parseTransaction(transaction: any, currency?: Currency): Transaction;
68
68
  parseTransactionType(type: any): string;
69
69
  fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
@@ -90,7 +90,11 @@ export default class coinlist extends Exchange {
90
90
  'fetchOrders': true,
91
91
  'fetchOrderTrades': true,
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,