ccxt 4.2.15 → 4.2.16

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.
package/js/src/bingx.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/bingx.js';
9
- import { AuthenticationError, ExchangeNotAvailable, PermissionDenied, AccountSuspended, ExchangeError, InsufficientFunds, BadRequest, OrderNotFound, DDoSProtection, BadSymbol, ArgumentsRequired } from './base/errors.js';
9
+ import { AuthenticationError, ExchangeNotAvailable, PermissionDenied, AccountSuspended, ExchangeError, InsufficientFunds, BadRequest, OrderNotFound, DDoSProtection, BadSymbol, ArgumentsRequired, NotSupported } from './base/errors.js';
10
10
  import { Precise } from './base/Precise.js';
11
11
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
12
12
  import { DECIMAL_PLACES } from './base/functions/number.js';
@@ -25,7 +25,7 @@ export default class bingx extends Exchange {
25
25
  'has': {
26
26
  'CORS': undefined,
27
27
  'spot': true,
28
- 'margin': true,
28
+ 'margin': false,
29
29
  'swap': true,
30
30
  'future': false,
31
31
  'option': false,
@@ -88,6 +88,9 @@ export default class bingx extends Exchange {
88
88
  'account': 'https://open-api.{hostname}/openApi',
89
89
  'copyTrading': 'https://open-api.{hostname}/openApi',
90
90
  },
91
+ 'test': {
92
+ 'swap': 'https://open-api-vst.{hostname}/openApi', // only swap is really "test" but since the API keys are the same, we want to keep all the functionalities when the user enables the sandboxmode
93
+ },
91
94
  'www': 'https://bingx.com/',
92
95
  'doc': 'https://bingx-api.github.io/docs/',
93
96
  'referral': 'https://bingx.com/invite/OHETOM',
@@ -421,6 +424,10 @@ export default class bingx extends Exchange {
421
424
  if (!this.checkRequiredCredentials(false)) {
422
425
  return undefined;
423
426
  }
427
+ const isSandbox = this.safeValue(this.options, 'sandboxMode', false);
428
+ if (isSandbox) {
429
+ return undefined;
430
+ }
424
431
  const response = await this.walletsV1PrivateGetCapitalConfigGetall(params);
425
432
  //
426
433
  // {
@@ -660,7 +667,11 @@ export default class bingx extends Exchange {
660
667
  * @param {object} [params] extra parameters specific to the exchange API endpoint
661
668
  * @returns {object[]} an array of objects representing market data
662
669
  */
663
- const requests = [this.fetchSpotMarkets(params), this.fetchSwapMarkets(params)];
670
+ const requests = [this.fetchSwapMarkets(params)];
671
+ const isSandbox = this.safeValue(this.options, 'sandboxMode', false);
672
+ if (!isSandbox) {
673
+ requests.push(this.fetchSpotMarkets(params)); // sandbox is swap only
674
+ }
664
675
  const promises = await Promise.all(requests);
665
676
  const spotMarkets = this.safeValue(promises, 0, []);
666
677
  const swapMarkets = this.safeValue(promises, 1, []);
@@ -3091,6 +3102,21 @@ export default class bingx extends Exchange {
3091
3102
  // "txId": "0xb5ef8c13b968a406cc62a93a8bd80f9e9a906ef1b3fcf20a2e48573c17659268"
3092
3103
  // }
3093
3104
  //
3105
+ // withdraw
3106
+ //
3107
+ // {
3108
+ // "code":0,
3109
+ // "timestamp":1705274263621,
3110
+ // "data":{
3111
+ // "id":"1264246141278773252"
3112
+ // }
3113
+ // }
3114
+ //
3115
+ // parse withdraw-type output first...
3116
+ //
3117
+ const data = this.safeValue(transaction, 'data');
3118
+ const dataId = (data === undefined) ? undefined : this.safeString(data, 'id');
3119
+ const id = this.safeString(transaction, 'id', dataId);
3094
3120
  const address = this.safeString(transaction, 'address');
3095
3121
  const tag = this.safeString(transaction, 'addressTag');
3096
3122
  let timestamp = this.safeInteger(transaction, 'insertTime');
@@ -3111,7 +3137,7 @@ export default class bingx extends Exchange {
3111
3137
  const type = (rawType === '0') ? 'deposit' : 'withdrawal';
3112
3138
  return {
3113
3139
  'info': transaction,
3114
- 'id': this.safeString(transaction, 'id'),
3140
+ 'id': id,
3115
3141
  'txid': this.safeString(transaction, 'txId'),
3116
3142
  'type': type,
3117
3143
  'currency': code,
@@ -3745,6 +3771,10 @@ export default class bingx extends Exchange {
3745
3771
  const type = section[0];
3746
3772
  const version = section[1];
3747
3773
  const access = section[2];
3774
+ const isSandbox = this.safeValue(this.options, 'sandboxMode', false);
3775
+ if (isSandbox && (type !== 'swap')) {
3776
+ throw new NotSupported(this.id + ' does not have a testnet/sandbox URL for ' + type + ' endpoints');
3777
+ }
3748
3778
  let url = this.implodeHostname(this.urls['api'][type]);
3749
3779
  if (type === 'spot' && version === 'v3') {
3750
3780
  url += '/api';
@@ -3787,6 +3817,10 @@ export default class bingx extends Exchange {
3787
3817
  nonce() {
3788
3818
  return this.milliseconds();
3789
3819
  }
3820
+ setSandboxMode(enable) {
3821
+ super.setSandboxMode(enable);
3822
+ this.options['sandboxMode'] = enable;
3823
+ }
3790
3824
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3791
3825
  if (response === undefined) {
3792
3826
  return undefined; // fallback to default error handler
package/js/src/bitmex.js CHANGED
@@ -1503,8 +1503,8 @@ export default class bitmex extends Exchange {
1503
1503
  if (fetchOHLCVOpenTimestamp) {
1504
1504
  timestamp = this.sum(timestamp, duration);
1505
1505
  }
1506
- const ymdhms = this.ymdhms(timestamp);
1507
- request['startTime'] = ymdhms; // starting date filter for results
1506
+ const startTime = this.iso8601(timestamp);
1507
+ request['startTime'] = startTime; // starting date filter for results
1508
1508
  }
1509
1509
  else {
1510
1510
  request['reverse'] = true;
@@ -2614,12 +2614,9 @@ export default class bitmex extends Exchange {
2614
2614
  throw new ArgumentsRequired(this.id + ' fetchDepositAddress requires params["network"]');
2615
2615
  }
2616
2616
  const currency = this.currency(code);
2617
- let currencyId = currency['id'];
2618
- const idLength = currencyId.length;
2619
- currencyId = currencyId.slice(0, idLength - 1) + currencyId.slice(idLength - 1, idLength).toLowerCase(); // make the last letter lowercase
2620
2617
  params = this.omit(params, 'network');
2621
2618
  const request = {
2622
- 'currency': currencyId,
2619
+ 'currency': currency['id'],
2623
2620
  'network': this.networkCodeToId(networkCode, currency['code']),
2624
2621
  };
2625
2622
  const response = await this.privateGetUserDepositAddress(this.extend(request, params));
package/js/src/coinone.js CHANGED
@@ -79,7 +79,7 @@ export default class coinone extends Exchange {
79
79
  'setLeverage': false,
80
80
  'setMarginMode': false,
81
81
  'setPositionMode': false,
82
- 'ws': false,
82
+ 'ws': true,
83
83
  },
84
84
  'urls': {
85
85
  'logo': 'https://user-images.githubusercontent.com/1294454/38003300-adc12fba-323f-11e8-8525-725f53c4a659.jpg',
package/js/src/phemex.js CHANGED
@@ -2979,12 +2979,14 @@ export default class phemex extends Exchange {
2979
2979
  * @description fetch all unfilled currently open orders
2980
2980
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#queryopenorder
2981
2981
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md
2982
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Spot-API-en.md#spotListAllOpenOrder
2982
2983
  * @param {string} symbol unified market symbol
2983
2984
  * @param {int} [since] the earliest time in ms to fetch open orders for
2984
2985
  * @param {int} [limit] the maximum number of open order structures to retrieve
2985
2986
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2986
2987
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2987
2988
  */
2989
+ await this.loadMarkets();
2988
2990
  if (symbol === undefined) {
2989
2991
  throw new ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
2990
2992
  }
@@ -3026,20 +3028,25 @@ export default class phemex extends Exchange {
3026
3028
  * @name phemex#fetchClosedOrders
3027
3029
  * @description fetches information on multiple closed orders made by the user
3028
3030
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#queryorder
3031
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#queryorder
3032
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedgedd-Perpetual-API.md#query-closed-orders-by-symbol
3033
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Spot-API-en.md#spotDataOrdersByIds
3029
3034
  * @param {string} symbol unified market symbol of the market orders were made in
3030
3035
  * @param {int} [since] the earliest time in ms to fetch orders for
3031
3036
  * @param {int} [limit] the maximum number of order structures to retrieve
3032
3037
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3038
+ * @param {string} [params.settle] the settlement currency to fetch orders for
3033
3039
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3034
3040
  */
3035
- if (symbol === undefined) {
3036
- throw new ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument');
3037
- }
3038
3041
  await this.loadMarkets();
3039
- const market = this.market(symbol);
3040
- const request = {
3041
- 'symbol': market['id'],
3042
- };
3042
+ let market = undefined;
3043
+ if (symbol !== undefined) {
3044
+ market = this.market(symbol);
3045
+ }
3046
+ const request = {};
3047
+ if (market !== undefined) {
3048
+ request['symbol'] = market['id'];
3049
+ }
3043
3050
  if (since !== undefined) {
3044
3051
  request['start'] = since;
3045
3052
  }
@@ -3047,8 +3054,8 @@ export default class phemex extends Exchange {
3047
3054
  request['limit'] = limit;
3048
3055
  }
3049
3056
  let response = undefined;
3050
- if (market['settle'] === 'USDT') {
3051
- request['currency'] = market['settle'];
3057
+ if ((symbol === undefined) || (this.safeString(market, 'settle') === 'USDT')) {
3058
+ request['currency'] = this.safeString(params, 'settle', 'USDT');
3052
3059
  response = await this.privateGetExchangeOrderV2OrderList(this.extend(request, params));
3053
3060
  }
3054
3061
  else if (market['swap']) {
@@ -3109,23 +3116,25 @@ export default class phemex extends Exchange {
3109
3116
  * @description fetch all trades made by the user
3110
3117
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#query-user-trade
3111
3118
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#query-user-trade
3119
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Spot-API-en.md#spotDataTradesHist
3112
3120
  * @param {string} symbol unified market symbol
3113
3121
  * @param {int} [since] the earliest time in ms to fetch trades for
3114
3122
  * @param {int} [limit] the maximum number of trades structures to retrieve
3115
3123
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3116
3124
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
3117
3125
  */
3118
- if (symbol === undefined) {
3119
- throw new ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
3120
- }
3121
3126
  await this.loadMarkets();
3122
- const market = this.market(symbol);
3127
+ let market = undefined;
3128
+ if (symbol !== undefined) {
3129
+ market = this.market(symbol);
3130
+ }
3123
3131
  const request = {};
3124
3132
  if (limit !== undefined) {
3125
3133
  limit = Math.min(200, limit);
3126
3134
  request['limit'] = limit;
3127
3135
  }
3128
- if (market['settle'] === 'USDT') {
3136
+ const isUSDTSettled = (symbol === undefined) || (this.safeString(market, 'settle') === 'USDT');
3137
+ if (isUSDTSettled) {
3129
3138
  request['currency'] = 'USDT';
3130
3139
  request['offset'] = 0;
3131
3140
  if (limit === undefined) {
@@ -3138,18 +3147,12 @@ export default class phemex extends Exchange {
3138
3147
  if (since !== undefined) {
3139
3148
  request['start'] = since;
3140
3149
  }
3141
- if (market['swap'] && (limit !== undefined)) {
3142
- request['limit'] = limit;
3143
- }
3144
- const isUSDTSettled = market['settle'] === 'USDT';
3145
3150
  let response = undefined;
3146
- if (market['swap']) {
3147
- if (isUSDTSettled) {
3148
- response = await this.privateGetExchangeOrderV2TradingList(this.extend(request, params));
3149
- }
3150
- else {
3151
- response = await this.privateGetExchangeOrderTrade(this.extend(request, params));
3152
- }
3151
+ if (isUSDTSettled) {
3152
+ response = await this.privateGetExchangeOrderV2TradingList(this.extend(request, params));
3153
+ }
3154
+ else if (market['swap']) {
3155
+ response = await this.privateGetExchangeOrderTrade(this.extend(request, params));
3153
3156
  }
3154
3157
  else {
3155
3158
  response = await this.privateGetExchangeSpotOrderTrades(this.extend(request, params));
@@ -0,0 +1,21 @@
1
+ import coinoneRest from '../coinone.js';
2
+ import type { Int, Market, OrderBook, Ticker, Trade } from '../base/types.js';
3
+ import Client from '../base/ws/Client.js';
4
+ export default class coinone extends coinoneRest {
5
+ describe(): any;
6
+ watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
7
+ handleOrderBook(client: any, message: any): void;
8
+ handleDelta(bookside: any, delta: any): void;
9
+ watchTicker(symbol: string, params?: {}): Promise<Ticker>;
10
+ handleTicker(client: Client, message: any): void;
11
+ parseWsTicker(ticker: any, market?: Market): Ticker;
12
+ watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
13
+ handleTrades(client: Client, message: any): void;
14
+ parseWsTrade(trade: any, market?: Market): Trade;
15
+ handleErrorMessage(client: Client, message: any): boolean;
16
+ handleMessage(client: Client, message: any): void;
17
+ ping(client: any): {
18
+ request_type: string;
19
+ };
20
+ handlePong(client: Client, message: any): any;
21
+ }