ccxt 4.3.7 → 4.3.9

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 (44) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/base/Exchange.js +13 -3
  4. package/dist/cjs/src/binance.js +1 -1
  5. package/dist/cjs/src/bingx.js +22 -12
  6. package/dist/cjs/src/bitget.js +1 -1
  7. package/dist/cjs/src/coinex.js +629 -433
  8. package/dist/cjs/src/coinmetro.js +31 -31
  9. package/dist/cjs/src/okx.js +59 -2
  10. package/dist/cjs/src/woo.js +1 -1
  11. package/js/ccxt.d.ts +1 -1
  12. package/js/ccxt.js +1 -1
  13. package/js/src/abstract/bingx.d.ts +1 -1
  14. package/js/src/abstract/coinmetro.d.ts +1 -0
  15. package/js/src/base/Exchange.d.ts +19 -19
  16. package/js/src/base/Exchange.js +13 -3
  17. package/js/src/base/functions/generic.d.ts +20 -19
  18. package/js/src/binance.js +1 -1
  19. package/js/src/bingx.d.ts +2 -2
  20. package/js/src/bingx.js +22 -12
  21. package/js/src/bitget.js +1 -1
  22. package/js/src/bybit.d.ts +1 -1
  23. package/js/src/coinbase.d.ts +1 -1
  24. package/js/src/coinbaseinternational.d.ts +1 -1
  25. package/js/src/coinex.js +629 -433
  26. package/js/src/coinmetro.d.ts +1 -1
  27. package/js/src/coinmetro.js +31 -31
  28. package/js/src/gemini.d.ts +1 -1
  29. package/js/src/hollaex.d.ts +1 -1
  30. package/js/src/htx.d.ts +2 -2
  31. package/js/src/idex.d.ts +1 -1
  32. package/js/src/kucoin.d.ts +1 -1
  33. package/js/src/mexc.d.ts +1 -1
  34. package/js/src/okcoin.d.ts +1 -1
  35. package/js/src/okx.d.ts +5 -1
  36. package/js/src/okx.js +59 -2
  37. package/js/src/paymium.d.ts +1 -1
  38. package/js/src/pro/luno.d.ts +2 -2
  39. package/js/src/probit.d.ts +1 -1
  40. package/js/src/upbit.d.ts +1 -1
  41. package/js/src/whitebit.d.ts +1 -1
  42. package/js/src/woo.js +1 -1
  43. package/js/src/zonda.d.ts +1 -1
  44. package/package.json +7 -7
@@ -161,6 +161,7 @@ class coinmetro extends coinmetro$1 {
161
161
  'private': {
162
162
  'get': {
163
163
  'users/balances': 1,
164
+ 'users/wallets': 1,
164
165
  'users/wallets/history/{since}': 1.67,
165
166
  'exchange/orders/status/{orderID}': 1,
166
167
  'exchange/orders/active': 1,
@@ -941,49 +942,48 @@ class coinmetro extends coinmetro$1 {
941
942
  * @method
942
943
  * @name coinmetro#fetchBalance
943
944
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
944
- * @see https://documenter.getpostman.com/view/3653795/SVfWN6KS#698ae067-43dd-4e19-a0ac-d9ba91381816
945
+ * @see https://documenter.getpostman.com/view/3653795/SVfWN6KS#741a1dcc-7307-40d0-acca-28d003d1506a
945
946
  * @param {object} [params] extra parameters specific to the exchange API endpoint
946
947
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
947
948
  */
948
949
  await this.loadMarkets();
949
- const response = await this.privateGetUsersBalances(params);
950
- return this.parseBalance(response);
950
+ const response = await this.privateGetUsersWallets(params);
951
+ const list = this.safeList(response, 'list', []);
952
+ return this.parseBalance(list);
951
953
  }
952
- parseBalance(response) {
954
+ parseBalance(balances) {
953
955
  //
954
- // {
955
- // "USDC": {
956
- // "USDC": 99,
957
- // "EUR": 91.16,
958
- // "BTC": 0.002334
959
- // },
960
- // "XCM": {
961
- // "XCM": 0,
962
- // "EUR": 0,
963
- // "BTC": 0
964
- // },
965
- // "TOTAL": {
966
- // "EUR": 91.16,
967
- // "BTC": 0.002334
956
+ // [
957
+ // {
958
+ // "xcmLocks": [],
959
+ // "xcmLockAmounts": [],
960
+ // "refList": [],
961
+ // "balanceHistory": [],
962
+ // "_id": "5fecd3c998e75c2e4d63f7c3",
963
+ // "currency": "BTC",
964
+ // "label": "BTC",
965
+ // "userId": "5fecd3c97fbfed1521db23bd",
966
+ // "__v": 0,
967
+ // "balance": 0.5,
968
+ // "createdAt": "2020-12-30T19:23:53.646Z",
969
+ // "disabled": false,
970
+ // "updatedAt": "2020-12-30T19:23:53.653Z",
971
+ // "reserved": 0,
972
+ // "id": "5fecd3c998e75c2e4d63f7c3"
968
973
  // },
969
- // "REF": {
970
- // "XCM": 0,
971
- // "EUR": 0,
972
- // "BTC": 0
973
- // }
974
- // }
974
+ // ...
975
+ // ]
975
976
  //
976
977
  const result = {
977
- 'info': response,
978
+ 'info': balances,
978
979
  };
979
- const balances = this.omit(response, ['TOTAL', 'REF']);
980
- const currencyIds = Object.keys(balances);
981
- for (let i = 0; i < currencyIds.length; i++) {
982
- const currencyId = currencyIds[i];
980
+ for (let i = 0; i < balances.length; i++) {
981
+ const balanceEntry = this.safeDict(balances, i, {});
982
+ const currencyId = this.safeString(balanceEntry, 'currency');
983
983
  const code = this.safeCurrencyCode(currencyId);
984
984
  const account = this.account();
985
- const currency = this.safeValue(balances, currencyId, {});
986
- account['total'] = this.safeString(currency, currencyId);
985
+ account['total'] = this.safeString(balanceEntry, 'balance');
986
+ account['used'] = this.safeString(balanceEntry, 'reserved');
987
987
  result[code] = account;
988
988
  }
989
989
  return this.safeBalance(result);
@@ -2629,6 +2629,8 @@ class okx extends okx$1 {
2629
2629
  const takeProfitDefined = (takeProfit !== undefined);
2630
2630
  const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRatio');
2631
2631
  const isTrailingPercentOrder = trailingPercent !== undefined;
2632
+ const trigger = (triggerPrice !== undefined) || (type === 'trigger');
2633
+ const isReduceOnly = this.safeValue(params, 'reduceOnly', false);
2632
2634
  const defaultMarginMode = this.safeString2(this.options, 'defaultMarginMode', 'marginMode', 'cross');
2633
2635
  let marginMode = this.safeString2(params, 'marginMode', 'tdMode'); // cross or isolated, tdMode not ommited so as to be extended into the request
2634
2636
  let margin = false;
@@ -2655,6 +2657,25 @@ class okx extends okx$1 {
2655
2657
  if (positionSide !== undefined) {
2656
2658
  request['posSide'] = positionSide;
2657
2659
  }
2660
+ else {
2661
+ let hedged = undefined;
2662
+ [hedged, params] = this.handleOptionAndParams(params, 'createOrder', 'hedged');
2663
+ if (hedged) {
2664
+ const isBuy = (side === 'buy');
2665
+ const isProtective = (takeProfitPrice !== undefined) || (stopLossPrice !== undefined) || isReduceOnly;
2666
+ if (isProtective) {
2667
+ // in case of protective orders, the posSide should be opposite of position side
2668
+ // reduceOnly is emulated and not natively supported by the exchange
2669
+ request['posSide'] = isBuy ? 'short' : 'long';
2670
+ if (isReduceOnly) {
2671
+ params = this.omit(params, 'reduceOnly');
2672
+ }
2673
+ }
2674
+ else {
2675
+ request['posSide'] = isBuy ? 'long' : 'short';
2676
+ }
2677
+ }
2678
+ }
2658
2679
  }
2659
2680
  request['tdMode'] = marginMode;
2660
2681
  }
@@ -2664,7 +2685,6 @@ class okx extends okx$1 {
2664
2685
  params = this.omit(params, ['currency', 'ccy', 'marginMode', 'timeInForce', 'stopPrice', 'triggerPrice', 'clientOrderId', 'stopLossPrice', 'takeProfitPrice', 'slOrdPx', 'tpOrdPx', 'margin', 'stopLoss', 'takeProfit', 'trailingPercent']);
2665
2686
  const ioc = (timeInForce === 'IOC') || (type === 'ioc');
2666
2687
  const fok = (timeInForce === 'FOK') || (type === 'fok');
2667
- const trigger = (triggerPrice !== undefined) || (type === 'trigger');
2668
2688
  const conditional = (stopLossPrice !== undefined) || (takeProfitPrice !== undefined) || (type === 'conditional');
2669
2689
  const marketIOC = (isMarketOrder && ioc) || (type === 'optimal_limit_ioc');
2670
2690
  const defaultTgtCcy = this.safeString(this.options, 'tgtCcy', 'base_ccy');
@@ -2874,6 +2894,7 @@ class okx extends okx$1 {
2874
2894
  * @param {string} [params.positionSide] if position mode is one-way: set to 'net', if position mode is hedge-mode: set to 'long' or 'short'
2875
2895
  * @param {string} [params.trailingPercent] the percent to trail away from the current market price
2876
2896
  * @param {string} [params.tpOrdKind] 'condition' or 'limit', the default is 'condition'
2897
+ * @param {string} [params.hedged] true/false, to automatically set exchange-specific params needed when trading in hedge mode
2877
2898
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2878
2899
  */
2879
2900
  await this.loadMarkets();
@@ -6261,6 +6282,42 @@ class okx extends okx$1 {
6261
6282
  //
6262
6283
  return response;
6263
6284
  }
6285
+ async fetchPositionMode(symbol = undefined, params = {}) {
6286
+ /**
6287
+ * @method
6288
+ * @name okx#fetchPositionMode
6289
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-account-configuration
6290
+ * @description fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
6291
+ * @param {string} symbol unified symbol of the market to fetch the order book for
6292
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
6293
+ * @param {string} [param.accountId] if you have multiple accounts, you must specify the account id to fetch the position mode
6294
+ * @returns {object} an object detailing whether the market is in hedged or one-way mode
6295
+ */
6296
+ const accounts = await this.fetchAccounts();
6297
+ const length = accounts.length;
6298
+ let selectedAccount = undefined;
6299
+ if (length > 1) {
6300
+ const accountId = this.safeString(params, 'accountId');
6301
+ if (accountId === undefined) {
6302
+ const accountIds = this.getListFromObjectValues(accounts, 'id');
6303
+ throw new errors.ExchangeError(this.id + ' fetchPositionMode() can not detect position mode, because you have multiple accounts. Set params["accountId"] to desired id from: ' + accountIds.join(', '));
6304
+ }
6305
+ else {
6306
+ const accountsById = this.indexBy(accounts, 'id');
6307
+ selectedAccount = this.safeDict(accountsById, accountId);
6308
+ }
6309
+ }
6310
+ else {
6311
+ selectedAccount = accounts[0];
6312
+ }
6313
+ const mainAccount = selectedAccount['info'];
6314
+ const posMode = this.safeString(mainAccount, 'posMode'); // long_short_mode, net_mode
6315
+ const isHedged = posMode === 'long_short_mode';
6316
+ return {
6317
+ 'info': mainAccount,
6318
+ 'hedged': isHedged,
6319
+ };
6320
+ }
6264
6321
  async setPositionMode(hedged, symbol = undefined, params = {}) {
6265
6322
  /**
6266
6323
  * @method
@@ -7925,7 +7982,7 @@ class okx extends okx$1 {
7925
7982
  // }
7926
7983
  //
7927
7984
  const rows = this.safeList(response, 'data', []);
7928
- return this.parseConversions(rows, 'baseCcy', 'quoteCcy', since, limit);
7985
+ return this.parseConversions(rows, code, 'baseCcy', 'quoteCcy', since, limit);
7929
7986
  }
7930
7987
  parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
7931
7988
  //
@@ -3182,7 +3182,7 @@ class woo extends woo$1 {
3182
3182
  //
3183
3183
  const data = this.safeDict(response, 'data', {});
3184
3184
  const rows = this.safeList(data, 'tradeVos', []);
3185
- return this.parseConversions(rows, 'sellAsset', 'buyAsset', since, limit);
3185
+ return this.parseConversions(rows, code, 'sellAsset', 'buyAsset', since, limit);
3186
3186
  }
3187
3187
  parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
3188
3188
  //
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
7
- declare const version = "4.3.6";
7
+ declare const version = "4.3.8";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.7';
41
+ const version = '4.3.9';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -85,13 +85,13 @@ interface Exchange {
85
85
  walletsV1PrivatePostCapitalDepositCreateSubAddress(params?: {}): Promise<implicitReturnType>;
86
86
  subAccountV1PrivateGetList(params?: {}): Promise<implicitReturnType>;
87
87
  subAccountV1PrivateGetAssets(params?: {}): Promise<implicitReturnType>;
88
- subAccountV1PrivateGetApiKeyQuery(params?: {}): Promise<implicitReturnType>;
89
88
  subAccountV1PrivatePostCreate(params?: {}): Promise<implicitReturnType>;
90
89
  subAccountV1PrivatePostApiKeyCreate(params?: {}): Promise<implicitReturnType>;
91
90
  subAccountV1PrivatePostApiKeyEdit(params?: {}): Promise<implicitReturnType>;
92
91
  subAccountV1PrivatePostApiKeyDel(params?: {}): Promise<implicitReturnType>;
93
92
  subAccountV1PrivatePostUpdateStatus(params?: {}): Promise<implicitReturnType>;
94
93
  accountV1PrivateGetUid(params?: {}): Promise<implicitReturnType>;
94
+ accountV1PrivateGetApiKeyQuery(params?: {}): Promise<implicitReturnType>;
95
95
  accountV1PrivatePostInnerTransferAuthorizeSubAccount(params?: {}): Promise<implicitReturnType>;
96
96
  userAuthPrivatePostUserDataStream(params?: {}): Promise<implicitReturnType>;
97
97
  userAuthPrivatePutUserDataStream(params?: {}): Promise<implicitReturnType>;
@@ -10,6 +10,7 @@ interface Exchange {
10
10
  publicGetExchangeBookPair(params?: {}): Promise<implicitReturnType>;
11
11
  publicGetExchangeBookUpdatesPairFrom(params?: {}): Promise<implicitReturnType>;
12
12
  privateGetUsersBalances(params?: {}): Promise<implicitReturnType>;
13
+ privateGetUsersWallets(params?: {}): Promise<implicitReturnType>;
13
14
  privateGetUsersWalletsHistorySince(params?: {}): Promise<implicitReturnType>;
14
15
  privateGetExchangeOrdersStatusOrderID(params?: {}): Promise<implicitReturnType>;
15
16
  privateGetExchangeOrdersActive(params?: {}): Promise<implicitReturnType>;
@@ -166,21 +166,21 @@ export default class Exchange {
166
166
  newUpdates: boolean;
167
167
  streaming: {};
168
168
  alias: boolean;
169
- deepExtend: (...xs: any[]) => any;
169
+ deepExtend: (...xs: any) => any;
170
170
  isNode: boolean;
171
171
  keys: {
172
172
  (o: object): string[];
173
173
  (o: {}): string[];
174
174
  };
175
- values: (x: any) => any[];
175
+ values: (x: any[] | Dictionary<any>) => any[];
176
176
  extend: (...args: any[]) => any;
177
177
  clone: (x: any) => any;
178
- flatten: (x: any, out?: any[]) => any[];
179
- unique: (x: any) => any[];
180
- indexBy: (x: any, k: any, out?: {}) => {};
181
- sortBy: (array: any, key: any, descending?: boolean, defaultValue?: any, direction?: number) => any;
182
- sortBy2: (array: any, key1: any, key2: any, descending?: boolean, direction?: number) => any;
183
- groupBy: (x: any, k: any, out?: {}) => {};
178
+ flatten: (x: any[], out?: any[]) => any[];
179
+ unique: (x: any[]) => any[];
180
+ indexBy: (x: Dictionary<any>, k: IndexType, out?: Dictionary<any>) => Dictionary<any>;
181
+ sortBy: (array: any[], key: IndexType, descending?: boolean, defaultValue?: any, direction?: number) => any[];
182
+ sortBy2: (array: any[], key1: IndexType, key2: IndexType, descending?: boolean, direction?: number) => any[];
183
+ groupBy: (x: Dictionary<any>, k: string, out?: Dictionary<any>) => Dictionary<any>;
184
184
  aggregate: typeof functions.aggregate;
185
185
  uuid: (a?: any) => string;
186
186
  unCamelCase: (s: string) => string;
@@ -200,7 +200,7 @@ export default class Exchange {
200
200
  numberToBE: (n: number, padding: number) => Uint8Array;
201
201
  base16ToBinary: (str: string) => Uint8Array;
202
202
  iso8601: (timestamp: any) => string;
203
- omit: (x: any, ...args: any[]) => any;
203
+ omit: (x: Dictionary<any>, ...args: any[]) => any;
204
204
  isJsonEncodedObject: (object: any) => boolean;
205
205
  safeInteger: (o: any, k: IndexType, $default?: number) => number;
206
206
  sum: (...xs: any[]) => any;
@@ -209,7 +209,7 @@ export default class Exchange {
209
209
  extractParams: (string: any) => any[];
210
210
  json: (data: any, params?: any) => string;
211
211
  vwap: typeof functions.vwap;
212
- merge: (target: any, ...args: any[]) => any;
212
+ merge: (target: Dictionary<any>, ...args: any) => Dictionary<any>;
213
213
  binaryConcat: typeof import("../static_dependencies/noble-curves/abstract/utils.js").concatBytes;
214
214
  hash: (request: import("../static_dependencies/noble-hashes/utils.js").Input, hash: {
215
215
  (message: import("../static_dependencies/noble-hashes/utils.js").Input): Uint8Array;
@@ -217,7 +217,7 @@ export default class Exchange {
217
217
  blockLen: number;
218
218
  create(): import("../static_dependencies/noble-hashes/utils.js").Hash<import("../static_dependencies/noble-hashes/utils.js").Hash<any>>;
219
219
  }, digest?: "binary" | "hex" | "base64") => any;
220
- arrayConcat: (a: any, b: any) => any;
220
+ arrayConcat: (a: any[], b: any[]) => any[];
221
221
  encode: (str: string) => Uint8Array;
222
222
  urlencode: (object: object) => string;
223
223
  hmac: (request: import("../static_dependencies/noble-hashes/utils.js").Input, secret: import("../static_dependencies/noble-hashes/utils.js").Input, hash: {
@@ -249,19 +249,19 @@ export default class Exchange {
249
249
  base64ToBinary: (str: string) => Uint8Array;
250
250
  safeTimestamp2: (o: any, k1: IndexType, k2: IndexType, $default?: any) => number;
251
251
  rawencode: (object: object) => string;
252
- keysort: (x: any, out?: {}) => {};
253
- inArray: (needle: any, haystack: any) => any;
252
+ keysort: (x: Dictionary<any>, out?: Dictionary<any>) => Dictionary<any>;
253
+ inArray: (needle: any, haystack: any[]) => boolean;
254
254
  safeStringLower2: (o: any, k1: IndexType, k2: IndexType, $default?: string) => string;
255
255
  safeStringUpper2: (o: any, k1: IndexType, k2: IndexType, $default?: string) => string;
256
- isEmpty: (object: any) => boolean;
257
- ordered: (x: any) => any;
258
- filterBy: (x: any, k: any, value?: any, out?: any[]) => any[];
256
+ isEmpty: (object: any[] | Dictionary<any>) => boolean;
257
+ ordered: (x: any[] | Dictionary<any>) => any[] | Dictionary<any>;
258
+ filterBy: (x: Dictionary<any>, k: string, value?: any, out?: Dictionary<any>[]) => Dictionary<any>[];
259
259
  uuid16: (a?: any) => string;
260
260
  urlencodeWithArrayRepeat: (object: object) => string;
261
261
  microseconds: () => number;
262
262
  binaryToBase64: (data: Uint8Array) => string;
263
263
  strip: (s: string) => string;
264
- toArray: (object: any) => unknown[];
264
+ toArray: (object: any[] | Dictionary<any>) => any[];
265
265
  safeFloatN: (o: any, k: IndexType[], $default?: number) => number;
266
266
  safeIntegerN: (o: any, k: IndexType[], $default?: number) => number;
267
267
  safeIntegerProductN: (o: any, k: IndexType[], $factor: number, $default?: number) => number;
@@ -1017,7 +1017,7 @@ export default class Exchange {
1017
1017
  filterBySymbolsSinceLimit(array: any, symbols?: string[], since?: Int, limit?: Int, tail?: boolean): any;
1018
1018
  parseLastPrices(pricesData: any, symbols?: string[], params?: {}): LastPrices;
1019
1019
  parseTickers(tickers: any, symbols?: string[], params?: {}): Dictionary<Ticker>;
1020
- parseDepositAddresses(addresses: any, codes?: string[], indexed?: boolean, params?: {}): {};
1020
+ parseDepositAddresses(addresses: any, codes?: string[], indexed?: boolean, params?: {}): Dictionary<any>;
1021
1021
  parseBorrowInterests(response: any, market?: Market): any[];
1022
1022
  parseFundingRateHistories(response: any, market?: any, since?: Int, limit?: Int): FundingRateHistory[];
1023
1023
  safeSymbol(marketId: Str, market?: Market, delimiter?: Str, marketType?: Str): string;
@@ -1072,7 +1072,7 @@ export default class Exchange {
1072
1072
  parseMarginMode(marginMode: any, market?: Market): MarginMode;
1073
1073
  parseLeverages(response: object[], symbols?: string[], symbolKey?: Str, marketType?: MarketType): Leverages;
1074
1074
  parseLeverage(leverage: any, market?: Market): Leverage;
1075
- parseConversions(conversions: any[], fromCurrencyKey?: Str, toCurrencyKey?: Str, since?: Int, limit?: Int, params?: {}): Conversion[];
1075
+ parseConversions(conversions: any[], code?: Str, fromCurrencyKey?: Str, toCurrencyKey?: Str, since?: Int, limit?: Int, params?: {}): Conversion[];
1076
1076
  parseConversion(conversion: any, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
1077
1077
  convertExpireDate(date: string): string;
1078
1078
  convertExpireDateToMarketIdDate(date: string): string;
@@ -6091,7 +6091,7 @@ export default class Exchange {
6091
6091
  parseLeverage(leverage, market = undefined) {
6092
6092
  throw new NotSupported(this.id + ' parseLeverage () is not supported yet');
6093
6093
  }
6094
- parseConversions(conversions, fromCurrencyKey = undefined, toCurrencyKey = undefined, since = undefined, limit = undefined, params = {}) {
6094
+ parseConversions(conversions, code = undefined, fromCurrencyKey = undefined, toCurrencyKey = undefined, since = undefined, limit = undefined, params = {}) {
6095
6095
  conversions = this.toArray(conversions);
6096
6096
  const result = [];
6097
6097
  let fromCurrency = undefined;
@@ -6110,8 +6110,18 @@ export default class Exchange {
6110
6110
  result.push(conversion);
6111
6111
  }
6112
6112
  const sorted = this.sortBy(result, 'timestamp');
6113
- const code = (fromCurrency !== undefined) ? fromCurrency['code'] : undefined;
6114
- return this.filterByCurrencySinceLimit(sorted, code, since, limit);
6113
+ let currency = undefined;
6114
+ if (code !== undefined) {
6115
+ currency = this.currency(code);
6116
+ code = currency['code'];
6117
+ }
6118
+ if (code === undefined) {
6119
+ return this.filterBySinceLimit(sorted, since, limit);
6120
+ }
6121
+ const fromConversion = this.filterBy(sorted, 'fromCurrency', code);
6122
+ const toConversion = this.filterBy(sorted, 'toCurrency', code);
6123
+ const both = this.arrayConcat(fromConversion, toConversion);
6124
+ return this.filterBySinceLimit(both, since, limit);
6115
6125
  }
6116
6126
  parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
6117
6127
  throw new NotSupported(this.id + ' parseConversion () is not supported yet');
@@ -1,27 +1,28 @@
1
+ import { Dictionary, IndexType } from '../types.js';
1
2
  declare const keys: {
2
3
  (o: object): string[];
3
4
  (o: {}): string[];
4
5
  };
5
- declare const values: (x: any) => any[];
6
- declare const index: (x: any) => Set<any>;
6
+ declare const values: (x: any[] | Dictionary<any>) => any[];
7
+ declare const index: (x: any[]) => Set<any>;
7
8
  declare const extend: (...args: any[]) => any;
8
9
  declare const clone: (x: any) => any;
9
- declare const ordered: (x: any) => any;
10
- declare const unique: (x: any) => any[];
11
- declare const arrayConcat: (a: any, b: any) => any;
12
- declare const inArray: (needle: any, haystack: any) => any;
13
- declare const toArray: (object: any) => unknown[];
14
- declare const isEmpty: (object: any) => boolean;
15
- declare const keysort: (x: any, out?: {}) => {};
16
- declare const groupBy: (x: any, k: any, out?: {}) => {};
17
- declare const indexBy: (x: any, k: any, out?: {}) => {};
18
- declare const filterBy: (x: any, k: any, value?: any, out?: any[]) => any[];
19
- declare const sortBy: (array: any, key: any, descending?: boolean, defaultValue?: any, direction?: number) => any;
20
- declare const sortBy2: (array: any, key1: any, key2: any, descending?: boolean, direction?: number) => any;
21
- declare const flatten: (x: any, out?: any[]) => any[];
22
- declare const pluck: (x: any, k: any) => any[];
23
- declare const omit: (x: any, ...args: any[]) => any;
10
+ declare const ordered: (x: any[] | Dictionary<any>) => any[] | Dictionary<any>;
11
+ declare const unique: (x: any[]) => any[];
12
+ declare const arrayConcat: (a: any[], b: any[]) => any[];
13
+ declare const inArray: (needle: any, haystack: any[]) => boolean;
14
+ declare const toArray: (object: Dictionary<any> | any[]) => any[];
15
+ declare const isEmpty: (object: any[] | Dictionary<any>) => boolean;
16
+ declare const keysort: (x: Dictionary<any>, out?: Dictionary<any>) => Dictionary<any>;
17
+ declare const groupBy: (x: Dictionary<any>, k: string, out?: Dictionary<any>) => Dictionary<any>;
18
+ declare const indexBy: (x: Dictionary<any>, k: IndexType, out?: Dictionary<any>) => Dictionary<any>;
19
+ declare const filterBy: (x: Dictionary<any>, k: string, value?: any, out?: Dictionary<any>[]) => Dictionary<any>[];
20
+ declare const sortBy: (array: any[], key: IndexType, descending?: boolean, defaultValue?: any, direction?: number) => any[];
21
+ declare const sortBy2: (array: any[], key1: IndexType, key2: IndexType, descending?: boolean, direction?: number) => any[];
22
+ declare const flatten: (x: any[], out?: any[]) => any[];
23
+ declare const pluck: (x: Dictionary<any>, k: any) => any[];
24
+ declare const omit: (x: Dictionary<any>, ...args: any[]) => any;
24
25
  declare const sum: (...xs: any[]) => any;
25
- declare const deepExtend: (...xs: any[]) => any;
26
- declare const merge: (target: any, ...args: any[]) => any;
26
+ declare const deepExtend: (...xs: any) => any;
27
+ declare const merge: (target: Dictionary<any>, ...args: any) => Dictionary<any>;
27
28
  export { keys, values, extend, clone, index, ordered, unique, arrayConcat, inArray, toArray, isEmpty, keysort, indexBy, groupBy, filterBy, sortBy, sortBy2, flatten, pluck, omit, sum, deepExtend, merge, };
package/js/src/binance.js CHANGED
@@ -12922,7 +12922,7 @@ export default class binance extends Exchange {
12922
12922
  //
12923
12923
  }
12924
12924
  const rows = this.safeList(response, responseQuery, []);
12925
- return this.parseConversions(rows, fromCurrencyKey, toCurrencyKey, since, limit);
12925
+ return this.parseConversions(rows, code, fromCurrencyKey, toCurrencyKey, since, limit);
12926
12926
  }
12927
12927
  parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
12928
12928
  //
package/js/src/bingx.d.ts CHANGED
@@ -97,7 +97,7 @@ export default class bingx extends Exchange {
97
97
  toAccount: string;
98
98
  status: string;
99
99
  };
100
- fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<{}>;
100
+ fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<import("./base/types.js").Dictionary<any>>;
101
101
  fetchDepositAddress(code: string, params?: {}): Promise<import("./base/types.js").Dictionary<any>>;
102
102
  parseDepositAddress(depositAddress: any, currency?: Currency): {
103
103
  currency: string;
@@ -133,7 +133,7 @@ export default class bingx extends Exchange {
133
133
  };
134
134
  fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<any>;
135
135
  withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
136
- parseParams(params: any): {};
136
+ parseParams(params: any): import("./base/types.js").Dictionary<any>;
137
137
  fetchMyLiquidations(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Liquidation[]>;
138
138
  parseLiquidation(liquidation: any, market?: Market): import("./base/types.js").Liquidation;
139
139
  closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
package/js/src/bingx.js CHANGED
@@ -292,7 +292,6 @@ export default class bingx extends Exchange {
292
292
  'get': {
293
293
  'list': 3,
294
294
  'assets': 3,
295
- 'apiKey/query': 1,
296
295
  },
297
296
  'post': {
298
297
  'create': 3,
@@ -309,6 +308,7 @@ export default class bingx extends Exchange {
309
308
  'private': {
310
309
  'get': {
311
310
  'uid': 1,
311
+ 'apiKey/query': 1,
312
312
  },
313
313
  'post': {
314
314
  'innerTransfer/authorizeSubAccount': 3,
@@ -1838,6 +1838,12 @@ export default class bingx extends Exchange {
1838
1838
  };
1839
1839
  const isMarketOrder = type === 'MARKET';
1840
1840
  const isSpot = marketType === 'spot';
1841
+ const stopLossPrice = this.safeString(params, 'stopLossPrice');
1842
+ const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
1843
+ const triggerPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
1844
+ const isTriggerOrder = triggerPrice !== undefined;
1845
+ const isStopLossPriceOrder = stopLossPrice !== undefined;
1846
+ const isTakeProfitPriceOrder = takeProfitPrice !== undefined;
1841
1847
  const exchangeClientOrderId = isSpot ? 'newClientOrderId' : 'clientOrderID';
1842
1848
  const clientOrderId = this.safeString2(params, exchangeClientOrderId, 'clientOrderId');
1843
1849
  if (clientOrderId !== undefined) {
@@ -1854,7 +1860,6 @@ export default class bingx extends Exchange {
1854
1860
  else if (timeInForce === 'GTC') {
1855
1861
  request['timeInForce'] = 'GTC';
1856
1862
  }
1857
- const triggerPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
1858
1863
  if (isSpot) {
1859
1864
  const cost = this.safeNumber2(params, 'cost', 'quoteOrderQty');
1860
1865
  params = this.omit(params, 'cost');
@@ -1886,19 +1891,24 @@ export default class bingx extends Exchange {
1886
1891
  request['type'] = 'TRIGGER_MARKET';
1887
1892
  }
1888
1893
  }
1894
+ else if ((stopLossPrice !== undefined) || (takeProfitPrice !== undefined)) {
1895
+ const stopTakePrice = (stopLossPrice !== undefined) ? stopLossPrice : takeProfitPrice;
1896
+ if (type === 'LIMIT') {
1897
+ request['type'] = 'TAKE_STOP_LIMIT';
1898
+ }
1899
+ else if (type === 'MARKET') {
1900
+ request['type'] = 'TAKE_STOP_MARKET';
1901
+ }
1902
+ request['stopPrice'] = this.parseToNumeric(this.priceToPrecision(symbol, stopTakePrice));
1903
+ }
1889
1904
  }
1890
1905
  else {
1891
1906
  if (timeInForce === 'FOK') {
1892
1907
  request['timeInForce'] = 'FOK';
1893
1908
  }
1894
- const stopLossPrice = this.safeString(params, 'stopLossPrice');
1895
- const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
1896
1909
  const trailingAmount = this.safeString(params, 'trailingAmount');
1897
1910
  const trailingPercent = this.safeString2(params, 'trailingPercent', 'priceRate');
1898
1911
  const trailingType = this.safeString(params, 'trailingType', 'TRAILING_STOP_MARKET');
1899
- const isTriggerOrder = triggerPrice !== undefined;
1900
- const isStopLossPriceOrder = stopLossPrice !== undefined;
1901
- const isTakeProfitPriceOrder = takeProfitPrice !== undefined;
1902
1912
  const isTrailingAmountOrder = trailingAmount !== undefined;
1903
1913
  const isTrailingPercentOrder = trailingPercent !== undefined;
1904
1914
  const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
@@ -1997,8 +2007,8 @@ export default class bingx extends Exchange {
1997
2007
  }
1998
2008
  request['positionSide'] = positionSide;
1999
2009
  request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
2000
- params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingType', 'takeProfit', 'stopLoss', 'clientOrderId']);
2001
2010
  }
2011
+ params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingType', 'takeProfit', 'stopLoss', 'clientOrderId']);
2002
2012
  return this.extend(request, params);
2003
2013
  }
2004
2014
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -2018,9 +2028,9 @@ export default class bingx extends Exchange {
2018
2028
  * @param {bool} [params.postOnly] true to place a post only order
2019
2029
  * @param {string} [params.timeInForce] spot supports 'PO', 'GTC' and 'IOC', swap supports 'PO', 'GTC', 'IOC' and 'FOK'
2020
2030
  * @param {bool} [params.reduceOnly] *swap only* true or false whether the order is reduce only
2021
- * @param {float} [params.triggerPrice] *swap only* triggerPrice at which the attached take profit / stop loss order will be triggered
2022
- * @param {float} [params.stopLossPrice] *swap only* stop loss trigger price
2023
- * @param {float} [params.takeProfitPrice] *swap only* take profit trigger price
2031
+ * @param {float} [params.triggerPrice] triggerPrice at which the attached take profit / stop loss order will be triggered
2032
+ * @param {float} [params.stopLossPrice] stop loss trigger price
2033
+ * @param {float} [params.takeProfitPrice] take profit trigger price
2024
2034
  * @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount
2025
2035
  * @param {float} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
2026
2036
  * @param {float} [params.trailingPercent] *swap only* the percent to trail away from the current market price
@@ -2466,7 +2476,7 @@ export default class bingx extends Exchange {
2466
2476
  return this.safeOrder({
2467
2477
  'info': info,
2468
2478
  'id': this.safeString2(order, 'orderId', 'i'),
2469
- 'clientOrderId': this.safeStringN(order, ['clientOrderID', 'origClientOrderId', 'c']),
2479
+ 'clientOrderId': this.safeStringN(order, ['clientOrderID', 'clientOrderId', 'origClientOrderId', 'c']),
2470
2480
  'symbol': this.safeSymbol(marketId, market, '-', marketType),
2471
2481
  'timestamp': timestamp,
2472
2482
  'datetime': this.iso8601(timestamp),
package/js/src/bitget.js CHANGED
@@ -8675,7 +8675,7 @@ export default class bitget extends Exchange {
8675
8675
  //
8676
8676
  const data = this.safeDict(response, 'data', {});
8677
8677
  const dataList = this.safeList(data, 'dataList', []);
8678
- return this.parseConversions(dataList, 'fromCoin', 'toCoin', since, limit);
8678
+ return this.parseConversions(dataList, code, 'fromCoin', 'toCoin', since, limit);
8679
8679
  }
8680
8680
  parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
8681
8681
  //
package/js/src/bybit.d.ts CHANGED
@@ -91,7 +91,7 @@ export default class bybit extends Exchange {
91
91
  network: string;
92
92
  info: any;
93
93
  };
94
- fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<{}>;
94
+ fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<import("./base/types.js").Dictionary<any>>;
95
95
  fetchDepositAddress(code: string, params?: {}): Promise<{
96
96
  currency: string;
97
97
  address: string;
@@ -94,7 +94,7 @@ export default class coinbase extends Exchange {
94
94
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
95
95
  fetchBidsAsks(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Dictionary<Ticker>>;
96
96
  withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
97
- fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<{}>;
97
+ fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<import("./base/types.js").Dictionary<any>>;
98
98
  parseDepositAddress(depositAddress: any, currency?: Currency): {
99
99
  info: any;
100
100
  currency: string;
@@ -42,7 +42,7 @@ export default class coinbaseinternational extends Exchange {
42
42
  address: string;
43
43
  info: any;
44
44
  }>;
45
- findDefaultNetwork(networks: any): unknown;
45
+ findDefaultNetwork(networks: any): any;
46
46
  loadCurrencyNetworks(code: any, params?: {}): Promise<void>;
47
47
  parseNetworks(networks: any, params?: {}): {};
48
48
  parseNetwork(network: any, params?: {}): {