ccxt 4.1.80 → 4.1.82

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 (46) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.js +445 -175
  3. package/dist/ccxt.browser.min.js +5 -5
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/bybit.js +4 -2
  6. package/dist/cjs/src/coinex.js +191 -71
  7. package/dist/cjs/src/digifinex.js +42 -8
  8. package/dist/cjs/src/htx.js +12 -10
  9. package/dist/cjs/src/lbank.js +70 -38
  10. package/dist/cjs/src/okx.js +52 -7
  11. package/dist/cjs/src/pro/binance.js +1 -1
  12. package/dist/cjs/src/pro/bingx.js +1 -1
  13. package/dist/cjs/src/pro/bitget.js +1 -1
  14. package/dist/cjs/src/pro/bybit.js +1 -1
  15. package/dist/cjs/src/pro/cex.js +1 -1
  16. package/dist/cjs/src/pro/coinbasepro.js +1 -1
  17. package/dist/cjs/src/pro/cryptocom.js +1 -1
  18. package/dist/cjs/src/pro/gate.js +1 -1
  19. package/dist/cjs/src/pro/kucoin.js +1 -1
  20. package/dist/cjs/src/pro/kucoinfutures.js +1 -1
  21. package/dist/cjs/src/pro/okx.js +1 -1
  22. package/dist/cjs/src/whitebit.js +62 -27
  23. package/js/ccxt.d.ts +1 -1
  24. package/js/ccxt.js +1 -1
  25. package/js/src/abstract/bybit.d.ts +1 -0
  26. package/js/src/bybit.js +4 -2
  27. package/js/src/coinex.js +191 -71
  28. package/js/src/digifinex.d.ts +1 -0
  29. package/js/src/digifinex.js +42 -8
  30. package/js/src/htx.js +12 -10
  31. package/js/src/lbank.d.ts +1 -0
  32. package/js/src/lbank.js +71 -39
  33. package/js/src/okx.js +52 -7
  34. package/js/src/pro/binance.js +1 -1
  35. package/js/src/pro/bingx.js +1 -1
  36. package/js/src/pro/bitget.js +1 -1
  37. package/js/src/pro/bybit.js +1 -1
  38. package/js/src/pro/cex.js +1 -1
  39. package/js/src/pro/coinbasepro.js +1 -1
  40. package/js/src/pro/cryptocom.js +1 -1
  41. package/js/src/pro/gate.js +1 -1
  42. package/js/src/pro/kucoin.js +1 -1
  43. package/js/src/pro/kucoinfutures.js +1 -1
  44. package/js/src/pro/okx.js +1 -1
  45. package/js/src/whitebit.js +62 -27
  46. package/package.json +1 -1
@@ -466,6 +466,8 @@ class coinex extends coinex$1 {
466
466
  * @method
467
467
  * @name coinex#fetchMarkets
468
468
  * @description retrieves data on all markets for coinex
469
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market002_all_market_info
470
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http006_market_list
469
471
  * @param {object} [params] extra parameters specific to the exchange API endpoint
470
472
  * @returns {object[]} an array of objects representing market data
471
473
  */
@@ -737,6 +739,8 @@ class coinex extends coinex$1 {
737
739
  * @method
738
740
  * @name coinex#fetchTicker
739
741
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
742
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market007_single_market_ticker
743
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http008_market_ticker
740
744
  * @param {string} symbol unified symbol of the market to fetch the ticker for
741
745
  * @param {object} [params] extra parameters specific to the exchange API endpoint
742
746
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -746,8 +750,13 @@ class coinex extends coinex$1 {
746
750
  const request = {
747
751
  'market': market['id'],
748
752
  };
749
- const method = market['swap'] ? 'perpetualPublicGetMarketTicker' : 'publicGetMarketTicker';
750
- const response = await this[method](this.extend(request, params));
753
+ let response = undefined;
754
+ if (market['swap']) {
755
+ response = await this.perpetualPublicGetMarketTicker(this.extend(request, params));
756
+ }
757
+ else {
758
+ response = await this.publicGetMarketTicker(this.extend(request, params));
759
+ }
751
760
  //
752
761
  // Spot
753
762
  //
@@ -823,8 +832,13 @@ class coinex extends coinex$1 {
823
832
  market = this.market(symbol);
824
833
  }
825
834
  const [marketType, query] = this.handleMarketTypeAndParams('fetchTickers', market, params);
826
- const method = (marketType === 'swap') ? 'perpetualPublicGetMarketTickerAll' : 'publicGetMarketTickerAll';
827
- const response = await this[method](query);
835
+ let response = undefined;
836
+ if (marketType === 'swap') {
837
+ response = await this.perpetualPublicGetMarketTickerAll(query);
838
+ }
839
+ else {
840
+ response = await this.publicGetMarketTickerAll();
841
+ }
828
842
  //
829
843
  // Spot
830
844
  //
@@ -906,6 +920,7 @@ class coinex extends coinex$1 {
906
920
  * @method
907
921
  * @name coinex#fetchTime
908
922
  * @description fetches the current integer timestamp in milliseconds from the exchange server
923
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http005_system_time
909
924
  * @param {object} [params] extra parameters specific to the exchange API endpoint
910
925
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
911
926
  */
@@ -924,6 +939,8 @@ class coinex extends coinex$1 {
924
939
  * @method
925
940
  * @name coinex#fetchOrderBook
926
941
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
942
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market004_market_depth
943
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http010_market_depth
927
944
  * @param {string} symbol unified symbol of the market to fetch the order book for
928
945
  * @param {int} [limit] the maximum amount of order book entries to return
929
946
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -939,8 +956,13 @@ class coinex extends coinex$1 {
939
956
  'merge': '0',
940
957
  'limit': limit.toString(),
941
958
  };
942
- const method = market['swap'] ? 'perpetualPublicGetMarketDepth' : 'publicGetMarketDepth';
943
- const response = await this[method](this.extend(request, params));
959
+ let response = undefined;
960
+ if (market['swap']) {
961
+ response = await this.perpetualPublicGetMarketDepth(this.extend(request, params));
962
+ }
963
+ else {
964
+ response = await this.publicGetMarketDepth(this.extend(request, params));
965
+ }
944
966
  //
945
967
  // Spot
946
968
  //
@@ -1120,6 +1142,8 @@ class coinex extends coinex$1 {
1120
1142
  * @method
1121
1143
  * @name coinex#fetchTrades
1122
1144
  * @description get the list of most recent trades for a particular symbol
1145
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market005_market_deals
1146
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http011_market_deals
1123
1147
  * @param {string} symbol unified symbol of the market to fetch trades for
1124
1148
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
1125
1149
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -1135,8 +1159,13 @@ class coinex extends coinex$1 {
1135
1159
  if (limit !== undefined) {
1136
1160
  request['limit'] = limit;
1137
1161
  }
1138
- const method = market['swap'] ? 'perpetualPublicGetMarketDeals' : 'publicGetMarketDeals';
1139
- const response = await this[method](this.extend(request, params));
1162
+ let response = undefined;
1163
+ if (market['swap']) {
1164
+ response = await this.perpetualPublicGetMarketDeals(this.extend(request, params));
1165
+ }
1166
+ else {
1167
+ response = await this.publicGetMarketDeals(this.extend(request, params));
1168
+ }
1140
1169
  //
1141
1170
  // Spot and Swap
1142
1171
  //
@@ -1162,6 +1191,7 @@ class coinex extends coinex$1 {
1162
1191
  * @method
1163
1192
  * @name coinex#fetchTradingFee
1164
1193
  * @description fetch the trading fees for a market
1194
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market003_single_market_info
1165
1195
  * @param {string} symbol unified market symbol
1166
1196
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1167
1197
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
@@ -1196,6 +1226,7 @@ class coinex extends coinex$1 {
1196
1226
  * @method
1197
1227
  * @name coinex#fetchTradingFees
1198
1228
  * @description fetch the trading fees for multiple markets
1229
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market002_all_market_info
1199
1230
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1200
1231
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
1201
1232
  */
@@ -1268,6 +1299,8 @@ class coinex extends coinex$1 {
1268
1299
  * @method
1269
1300
  * @name coinex#fetchOHLCV
1270
1301
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1302
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market006_market_kline
1303
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http012_market_kline
1271
1304
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1272
1305
  * @param {string} timeframe the length of time each candle represents
1273
1306
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -1284,8 +1317,13 @@ class coinex extends coinex$1 {
1284
1317
  if (limit !== undefined) {
1285
1318
  request['limit'] = limit;
1286
1319
  }
1287
- const method = market['swap'] ? 'perpetualPublicGetMarketKline' : 'publicGetMarketKline';
1288
- const response = await this[method](this.extend(request, params));
1320
+ let response = undefined;
1321
+ if (market['swap']) {
1322
+ response = await this.perpetualPublicGetMarketKline(this.extend(request, params));
1323
+ }
1324
+ else {
1325
+ response = await this.publicGetMarketKline(this.extend(request, params));
1326
+ }
1289
1327
  //
1290
1328
  // Spot
1291
1329
  //
@@ -2533,6 +2571,10 @@ class coinex extends coinex$1 {
2533
2571
  * @method
2534
2572
  * @name coinex#cancelOrder
2535
2573
  * @description cancels an open order
2574
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade018_cancle_stop_pending_order
2575
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade015_cancel_order
2576
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http023_cancel_stop_order
2577
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http021_cancel_order
2536
2578
  * @param {string} id order id
2537
2579
  * @param {string} symbol unified symbol of the market the order was made in
2538
2580
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2550,15 +2592,6 @@ class coinex extends coinex$1 {
2550
2592
  };
2551
2593
  const idRequest = swap ? 'order_id' : 'id';
2552
2594
  request[idRequest] = id;
2553
- let method = swap ? 'perpetualPrivatePostOrderCancel' : 'privateDeleteOrderPending';
2554
- if (stop) {
2555
- if (swap) {
2556
- method = 'perpetualPrivatePostOrderCancelStop';
2557
- }
2558
- else {
2559
- method = 'privateDeleteOrderStopPendingId';
2560
- }
2561
- }
2562
2595
  const accountId = this.safeInteger(params, 'account_id');
2563
2596
  const defaultType = this.safeString(this.options, 'defaultType');
2564
2597
  if (defaultType === 'margin') {
@@ -2568,7 +2601,23 @@ class coinex extends coinex$1 {
2568
2601
  request['account_id'] = accountId;
2569
2602
  }
2570
2603
  const query = this.omit(params, ['stop', 'account_id']);
2571
- const response = await this[method](this.extend(request, query));
2604
+ let response = undefined;
2605
+ if (stop) {
2606
+ if (swap) {
2607
+ response = await this.perpetualPrivatePostOrderCancelStop(this.extend(request, query));
2608
+ }
2609
+ else {
2610
+ response = await this.privateDeleteOrderStopPendingId(this.extend(request, query));
2611
+ }
2612
+ }
2613
+ else {
2614
+ if (swap) {
2615
+ response = await this.perpetualPrivatePostOrderCancel(this.extend(request, query));
2616
+ }
2617
+ else {
2618
+ response = await this.privateDeleteOrderPending(this.extend(request, query));
2619
+ }
2620
+ }
2572
2621
  //
2573
2622
  // Spot and Margin
2574
2623
  //
@@ -2683,6 +2732,10 @@ class coinex extends coinex$1 {
2683
2732
  * @method
2684
2733
  * @name coinex#cancelAllOrders
2685
2734
  * @description cancel all open orders in a market
2735
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade018_cancle_stop_pending_order
2736
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade015_cancel_order
2737
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http024_cancel_stop_all
2738
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http022_cancel_all
2686
2739
  * @param {string} symbol unified market symbol of the market to cancel orders in
2687
2740
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2688
2741
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -2701,22 +2754,25 @@ class coinex extends coinex$1 {
2701
2754
  };
2702
2755
  const swap = market['swap'];
2703
2756
  const stop = this.safeValue(params, 'stop');
2704
- let method;
2757
+ params = this.omit(params, ['stop', 'account_id']);
2758
+ let response = undefined;
2705
2759
  if (swap) {
2706
- method = 'perpetualPrivatePostOrderCancelAll';
2707
2760
  if (stop) {
2708
- method = 'perpetualPrivatePostOrderCancelStopAll';
2761
+ response = await this.perpetualPrivatePostOrderCancelStopAll(this.extend(request, params));
2762
+ }
2763
+ else {
2764
+ response = await this.perpetualPrivatePostOrderCancelAll(this.extend(request, params));
2709
2765
  }
2710
2766
  }
2711
2767
  else {
2712
- method = 'privateDeleteOrderPending';
2768
+ request['account_id'] = accountId;
2713
2769
  if (stop) {
2714
- method = 'privateDeleteOrderStopPending';
2770
+ response = await this.privateDeleteOrderStopPending(this.extend(request, params));
2771
+ }
2772
+ else {
2773
+ response = await this.privateDeleteOrderPending(this.extend(request, params));
2715
2774
  }
2716
- request['account_id'] = accountId;
2717
2775
  }
2718
- params = this.omit(params, ['stop', 'account_id']);
2719
- const response = await this[method](this.extend(request, params));
2720
2776
  //
2721
2777
  // Spot and Margin
2722
2778
  //
@@ -2733,6 +2789,9 @@ class coinex extends coinex$1 {
2733
2789
  * @method
2734
2790
  * @name coinex#fetchOrder
2735
2791
  * @description fetches information on an order made by the user
2792
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http028_stop_status
2793
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http026_order_status
2794
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade007_order_status
2736
2795
  * @param {string} symbol unified symbol of the market the order was made in
2737
2796
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2738
2797
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -2744,6 +2803,7 @@ class coinex extends coinex$1 {
2744
2803
  const market = this.market(symbol);
2745
2804
  const swap = market['swap'];
2746
2805
  const stop = this.safeValue(params, 'stop');
2806
+ params = this.omit(params, 'stop');
2747
2807
  const request = {
2748
2808
  'market': market['id'],
2749
2809
  // 'id': id, // SPOT
@@ -2751,15 +2811,18 @@ class coinex extends coinex$1 {
2751
2811
  };
2752
2812
  const idRequest = swap ? 'order_id' : 'id';
2753
2813
  request[idRequest] = id;
2754
- let method = undefined;
2814
+ let response = undefined;
2755
2815
  if (swap) {
2756
- method = stop ? 'perpetualPrivateGetOrderStopStatus' : 'perpetualPrivateGetOrderStatus';
2816
+ if (stop) {
2817
+ response = await this.perpetualPrivateGetOrderStopStatus(this.extend(request, params));
2818
+ }
2819
+ else {
2820
+ response = await this.perpetualPrivateGetOrderStatus(this.extend(request, params));
2821
+ }
2757
2822
  }
2758
2823
  else {
2759
- method = 'privateGetOrderStatus';
2824
+ response = await this.privateGetOrderStatus(this.extend(request, params));
2760
2825
  }
2761
- params = this.omit(params, 'stop');
2762
- const response = await this[method](this.extend(request, params));
2763
2826
  //
2764
2827
  // Spot
2765
2828
  //
@@ -2879,15 +2942,20 @@ class coinex extends coinex$1 {
2879
2942
  request['market'] = market['id'];
2880
2943
  }
2881
2944
  const [marketType, query] = this.handleMarketTypeAndParams('fetchOrdersByStatus', market, params);
2882
- let method = undefined;
2945
+ const accountId = this.safeInteger(params, 'account_id');
2946
+ const defaultType = this.safeString(this.options, 'defaultType');
2947
+ if (defaultType === 'margin') {
2948
+ if (accountId === undefined) {
2949
+ throw new errors.BadRequest(this.id + ' fetchOpenOrders() and fetchClosedOrders() require an account_id parameter for margin orders');
2950
+ }
2951
+ request['account_id'] = accountId;
2952
+ }
2953
+ params = this.omit(query, 'account_id');
2954
+ let response = undefined;
2883
2955
  if (marketType === 'swap') {
2884
2956
  if (symbol === undefined) {
2885
2957
  throw new errors.ArgumentsRequired(this.id + ' fetchOrdersByStatus() requires a symbol argument for swap markets');
2886
2958
  }
2887
- method = 'perpetualPrivateGetOrder' + this.capitalize(status);
2888
- if (stop) {
2889
- method = 'perpetualPrivateGetOrderStopPending';
2890
- }
2891
2959
  if (side !== undefined) {
2892
2960
  request['side'] = side;
2893
2961
  }
@@ -2895,24 +2963,37 @@ class coinex extends coinex$1 {
2895
2963
  request['side'] = 0;
2896
2964
  }
2897
2965
  request['offset'] = 0;
2898
- }
2899
- else {
2900
- method = 'privateGetOrder' + this.capitalize(status);
2901
2966
  if (stop) {
2902
- method = 'privateGetOrderStop' + this.capitalize(status);
2967
+ response = await this.perpetualPrivateGetOrderStopPending(this.extend(request, params));
2968
+ }
2969
+ else {
2970
+ if (status === 'finished') {
2971
+ response = await this.perpetualPrivateGetOrderFinished(this.extend(request, params));
2972
+ }
2973
+ else if (status === 'pending') {
2974
+ response = await this.perpetualPrivateGetOrderPending(this.extend(request, params));
2975
+ }
2903
2976
  }
2904
- request['page'] = 1;
2905
2977
  }
2906
- const accountId = this.safeInteger(params, 'account_id');
2907
- const defaultType = this.safeString(this.options, 'defaultType');
2908
- if (defaultType === 'margin') {
2909
- if (accountId === undefined) {
2910
- throw new errors.BadRequest(this.id + ' fetchOpenOrders() and fetchClosedOrders() require an account_id parameter for margin orders');
2978
+ else {
2979
+ request['page'] = 1;
2980
+ if (status === 'finished') {
2981
+ if (stop) {
2982
+ response = await this.privateGetOrderStopFinished(this.extend(request, params));
2983
+ }
2984
+ else {
2985
+ response = await this.privateGetOrderFinished(this.extend(request, params));
2986
+ }
2987
+ }
2988
+ else if (status === 'pending') {
2989
+ if (stop) {
2990
+ response = await this.privateGetOrderStopPending(this.extend(request, params));
2991
+ }
2992
+ else {
2993
+ response = await this.privateGetOrderPending(this.extend(request, params));
2994
+ }
2911
2995
  }
2912
- request['account_id'] = accountId;
2913
2996
  }
2914
- params = this.omit(query, 'account_id');
2915
- const response = await this[method](this.extend(request, params));
2916
2997
  //
2917
2998
  // Spot and Margin
2918
2999
  //
@@ -3073,6 +3154,10 @@ class coinex extends coinex$1 {
3073
3154
  * @method
3074
3155
  * @name coinex#fetchOpenOrders
3075
3156
  * @description fetch all unfilled currently open orders
3157
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http027_query_pending_stop
3158
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http025_query_pending
3159
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade013_stop_pending_order
3160
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade011_pending_order
3076
3161
  * @param {string} symbol unified market symbol
3077
3162
  * @param {int} [since] the earliest time in ms to fetch open orders for
3078
3163
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -3086,6 +3171,9 @@ class coinex extends coinex$1 {
3086
3171
  * @method
3087
3172
  * @name coinex#fetchClosedOrders
3088
3173
  * @description fetches information on multiple closed orders made by the user
3174
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http029_query_finished
3175
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade010_stop_finished_order
3176
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade012_finished_order
3089
3177
  * @param {string} symbol unified market symbol of the market orders were made in
3090
3178
  * @param {int} [since] the earliest time in ms to fetch orders for
3091
3179
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -3099,6 +3187,7 @@ class coinex extends coinex$1 {
3099
3187
  * @method
3100
3188
  * @name coinex#createDepositAddress
3101
3189
  * @description create a currency deposit address
3190
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account019_update_deposit_address
3102
3191
  * @param {string} code unified currency code of the currency for the deposit address
3103
3192
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3104
3193
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
@@ -3131,6 +3220,7 @@ class coinex extends coinex$1 {
3131
3220
  * @method
3132
3221
  * @name coinex#fetchDepositAddress
3133
3222
  * @description fetch the deposit address for a currency associated with this account
3223
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account020_query_deposit_address
3134
3224
  * @param {string} code unified currency code
3135
3225
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3136
3226
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
@@ -3225,6 +3315,8 @@ class coinex extends coinex$1 {
3225
3315
  * @method
3226
3316
  * @name coinex#fetchMyTrades
3227
3317
  * @description fetch all trades made by the user
3318
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http013_user_deals
3319
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade014_user_deals
3228
3320
  * @param {string} symbol unified market symbol
3229
3321
  * @param {int} [since] the earliest time in ms to fetch trades for
3230
3322
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -3254,9 +3346,17 @@ class coinex extends coinex$1 {
3254
3346
  throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument for non-spot markets');
3255
3347
  }
3256
3348
  const swap = (type === 'swap');
3257
- let method = undefined;
3349
+ const accountId = this.safeInteger(params, 'account_id');
3350
+ const defaultType = this.safeString(this.options, 'defaultType');
3351
+ if (defaultType === 'margin') {
3352
+ if (accountId === undefined) {
3353
+ throw new errors.BadRequest(this.id + ' fetchMyTrades() requires an account_id parameter for margin trades');
3354
+ }
3355
+ request['account_id'] = accountId;
3356
+ params = this.omit(params, 'account_id');
3357
+ }
3358
+ let response = undefined;
3258
3359
  if (swap) {
3259
- method = 'perpetualPublicGetMarketUserDeals';
3260
3360
  const side = this.safeInteger(params, 'side');
3261
3361
  if (side === undefined) {
3262
3362
  throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires a side parameter for swap markets');
@@ -3266,21 +3366,12 @@ class coinex extends coinex$1 {
3266
3366
  }
3267
3367
  request['side'] = side;
3268
3368
  params = this.omit(params, 'side');
3369
+ response = await this.perpetualPublicGetMarketUserDeals(this.extend(request, params));
3269
3370
  }
3270
3371
  else {
3271
- method = 'privateGetOrderUserDeals';
3272
3372
  request['page'] = 1;
3373
+ response = await this.privateGetOrderUserDeals(this.extend(request, params));
3273
3374
  }
3274
- const accountId = this.safeInteger(params, 'account_id');
3275
- const defaultType = this.safeString(this.options, 'defaultType');
3276
- if (defaultType === 'margin') {
3277
- if (accountId === undefined) {
3278
- throw new errors.BadRequest(this.id + ' fetchMyTrades() requires an account_id parameter for margin trades');
3279
- }
3280
- request['account_id'] = accountId;
3281
- params = this.omit(params, 'account_id');
3282
- }
3283
- const response = await this[method](this.extend(request, params));
3284
3375
  //
3285
3376
  // Spot and Margin
3286
3377
  //
@@ -3363,6 +3454,7 @@ class coinex extends coinex$1 {
3363
3454
  * @method
3364
3455
  * @name coinex#fetchPositions
3365
3456
  * @description fetch all open positions
3457
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033_pending_position
3366
3458
  * @param {string[]|undefined} symbols list of unified market symbols
3367
3459
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3368
3460
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
@@ -3458,6 +3550,7 @@ class coinex extends coinex$1 {
3458
3550
  * @method
3459
3551
  * @name coinex#fetchPosition
3460
3552
  * @description fetch data on a single open contract trade position
3553
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033_pending_position
3461
3554
  * @param {string} symbol unified market symbol of the market the position is held in, default is undefined
3462
3555
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3463
3556
  * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
@@ -3640,6 +3733,7 @@ class coinex extends coinex$1 {
3640
3733
  * @method
3641
3734
  * @name coinex#setMarginMode
3642
3735
  * @description set margin mode to 'cross' or 'isolated'
3736
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http014_adjust_leverage
3643
3737
  * @param {string} marginMode 'cross' or 'isolated'
3644
3738
  * @param {string} symbol unified market symbol
3645
3739
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3729,6 +3823,7 @@ class coinex extends coinex$1 {
3729
3823
  * @method
3730
3824
  * @name coinex#fetchLeverageTiers
3731
3825
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
3826
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http007_market_limit
3732
3827
  * @param {string[]|undefined} symbols list of unified market symbols
3733
3828
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3734
3829
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
@@ -3893,6 +3988,7 @@ class coinex extends coinex$1 {
3893
3988
  * @method
3894
3989
  * @name coinex#addMargin
3895
3990
  * @description add margin
3991
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http032_adjust_position_margin
3896
3992
  * @param {string} symbol unified market symbol
3897
3993
  * @param {float} amount amount of margin to add
3898
3994
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3905,6 +4001,7 @@ class coinex extends coinex$1 {
3905
4001
  * @method
3906
4002
  * @name coinex#reduceMargin
3907
4003
  * @description remove margin from a position
4004
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http032_adjust_position_margin
3908
4005
  * @param {string} symbol unified market symbol
3909
4006
  * @param {float} amount the amount of margin to remove
3910
4007
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3917,6 +4014,7 @@ class coinex extends coinex$1 {
3917
4014
  * @method
3918
4015
  * @name coinex#fetchFundingHistory
3919
4016
  * @description fetch the history of funding payments paid and received on this account
4017
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http034_funding_position
3920
4018
  * @param {string} symbol unified market symbol
3921
4019
  * @param {int} [since] the earliest time in ms to fetch funding history for
3922
4020
  * @param {int} [limit] the maximum number of funding history structures to retrieve
@@ -3992,6 +4090,7 @@ class coinex extends coinex$1 {
3992
4090
  * @method
3993
4091
  * @name coinex#fetchFundingRate
3994
4092
  * @description fetch the current funding rate
4093
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http008_market_ticker
3995
4094
  * @param {string} symbol unified market symbol
3996
4095
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3997
4096
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
@@ -4100,6 +4199,7 @@ class coinex extends coinex$1 {
4100
4199
  * @method
4101
4200
  * @name coinex#fetchFundingRates
4102
4201
  * @description fetch the current funding rates
4202
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http009_market_ticker_all
4103
4203
  * @param {string[]} symbols unified market symbols
4104
4204
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4105
4205
  * @returns {object[]} an array of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
@@ -4426,6 +4526,8 @@ class coinex extends coinex$1 {
4426
4526
  * @method
4427
4527
  * @name coinex#transfer
4428
4528
  * @description transfer currency internally between wallets on the same account
4529
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account014_balance_contract_transfer
4530
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account013_margin_transfer
4429
4531
  * @param {string} code unified currency code
4430
4532
  * @param {float} amount amount to transfer
4431
4533
  * @param {string} fromAccount account to transfer from
@@ -4440,12 +4542,14 @@ class coinex extends coinex$1 {
4440
4542
  'amount': amountToPrecision,
4441
4543
  'coin_type': currency['id'],
4442
4544
  };
4443
- let method = 'privatePostContractBalanceTransfer';
4545
+ let response = undefined;
4444
4546
  if ((fromAccount === 'spot') && (toAccount === 'swap')) {
4445
4547
  request['transfer_side'] = 'in'; // 'in' spot to swap, 'out' swap to spot
4548
+ response = await this.privatePostContractBalanceTransfer(this.extend(request, params));
4446
4549
  }
4447
4550
  else if ((fromAccount === 'swap') && (toAccount === 'spot')) {
4448
4551
  request['transfer_side'] = 'out'; // 'in' spot to swap, 'out' swap to spot
4552
+ response = await this.privatePostContractBalanceTransfer(this.extend(request, params));
4449
4553
  }
4450
4554
  else {
4451
4555
  const accountsById = this.safeValue(this.options, 'accountsById', {});
@@ -4455,9 +4559,8 @@ class coinex extends coinex$1 {
4455
4559
  // spot is 0, use fetchBalance() to find the margin account id
4456
4560
  request['from_account'] = parseInt(fromId);
4457
4561
  request['to_account'] = parseInt(toId);
4458
- method = 'privatePostMarginTransfer';
4562
+ response = await this.privatePostMarginTransfer(this.extend(request, params));
4459
4563
  }
4460
- const response = await this[method](this.extend(request, params));
4461
4564
  //
4462
4565
  // {"code": 0, "data": null, "message": "Success"}
4463
4566
  //
@@ -4539,6 +4642,8 @@ class coinex extends coinex$1 {
4539
4642
  * @method
4540
4643
  * @name coinex#fetchTransfers
4541
4644
  * @description fetch a history of internal transfers made on an account
4645
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account025_margin_transfer_history
4646
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account024_contract_transfer_history
4542
4647
  * @param {string} code unified currency code of the currency transferred
4543
4648
  * @param {int} [since] the earliest time in ms to fetch transfers for
4544
4649
  * @param {int} [limit] the maximum number of transfers structures to retrieve
@@ -4549,7 +4654,7 @@ class coinex extends coinex$1 {
4549
4654
  let currency = undefined;
4550
4655
  const request = {
4551
4656
  'page': 1,
4552
- 'limit': limit,
4657
+ // 'limit': limit,
4553
4658
  // 'asset': 'USDT',
4554
4659
  // 'start_time': since,
4555
4660
  // 'end_time': 1515806440,
@@ -4560,16 +4665,27 @@ class coinex extends coinex$1 {
4560
4665
  request['page'] = page;
4561
4666
  }
4562
4667
  if (code !== undefined) {
4563
- currency = this.safeCurrencyCode(code);
4668
+ currency = this.currency(code);
4564
4669
  request['asset'] = currency['id'];
4565
4670
  }
4566
4671
  if (since !== undefined) {
4567
4672
  request['start_time'] = since;
4568
4673
  }
4674
+ if (limit !== undefined) {
4675
+ request['limit'] = limit;
4676
+ }
4677
+ else {
4678
+ request['limit'] = 100;
4679
+ }
4569
4680
  params = this.omit(params, 'page');
4570
4681
  const defaultType = this.safeString(this.options, 'defaultType');
4571
- const method = (defaultType === 'margin') ? 'privateGetMarginTransferHistory' : 'privateGetContractTransferHistory';
4572
- const response = await this[method](this.extend(request, params));
4682
+ let response = undefined;
4683
+ if (defaultType === 'margin') {
4684
+ response = await this.privateGetMarginTransferHistory(this.extend(request, params));
4685
+ }
4686
+ else {
4687
+ response = await this.privateGetContractTransferHistory(this.extend(request, params));
4688
+ }
4573
4689
  //
4574
4690
  // Swap
4575
4691
  //
@@ -4623,6 +4739,7 @@ class coinex extends coinex$1 {
4623
4739
  * @method
4624
4740
  * @name coinex#fetchWithdrawals
4625
4741
  * @description fetch all withdrawals made from an account
4742
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account026_withdraw_list
4626
4743
  * @param {string} code unified currency code
4627
4744
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
4628
4745
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -4689,6 +4806,7 @@ class coinex extends coinex$1 {
4689
4806
  * @method
4690
4807
  * @name coinex#fetchDeposits
4691
4808
  * @description fetch all deposits made to an account
4809
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account009_deposit_list
4692
4810
  * @param {string} code unified currency code
4693
4811
  * @param {int} [since] the earliest time in ms to fetch deposits for
4694
4812
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -4788,6 +4906,7 @@ class coinex extends coinex$1 {
4788
4906
  * @method
4789
4907
  * @name coinex#fetchIsolatedBorrowRate
4790
4908
  * @description fetch the rate of interest to borrow a currency for margin trading
4909
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
4791
4910
  * @param {string} symbol unified symbol of the market to fetch the borrow rate for
4792
4911
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4793
4912
  * @returns {object} an [isolated borrow rate structure]{@link https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure}
@@ -4826,6 +4945,7 @@ class coinex extends coinex$1 {
4826
4945
  * @method
4827
4946
  * @name coinex#fetchIsolatedBorrowRates
4828
4947
  * @description fetch the borrow interest rates of all currencies
4948
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
4829
4949
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4830
4950
  * @returns {object} a list of [isolated borrow rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#isolated-borrow-rate-structure}
4831
4951
  */