ccxt 4.3.8 → 4.3.10

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.
@@ -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);
@@ -81,13 +81,14 @@ class kucoinfutures extends kucoinfutures$1 {
81
81
  'fetchPositionHistory': false,
82
82
  'fetchPositionMode': false,
83
83
  'fetchPositions': true,
84
- 'fetchPositionsHistory': false,
84
+ 'fetchPositionsHistory': true,
85
85
  'fetchPremiumIndexOHLCV': false,
86
86
  'fetchStatus': true,
87
87
  'fetchTicker': true,
88
88
  'fetchTickers': true,
89
89
  'fetchTime': true,
90
90
  'fetchTrades': true,
91
+ 'fetchTradingFee': true,
91
92
  'fetchTransactionFee': false,
92
93
  'fetchWithdrawals': true,
93
94
  'setLeverage': false,
@@ -164,6 +165,8 @@ class kucoinfutures extends kucoinfutures$1 {
164
165
  'funding-history': 4.44,
165
166
  'sub/api-key': 1,
166
167
  'trade-statistics': 1,
168
+ 'trade-fees': 1,
169
+ 'history-positions': 1,
167
170
  },
168
171
  'post': {
169
172
  'withdrawals': 1,
@@ -1137,6 +1140,76 @@ class kucoinfutures extends kucoinfutures$1 {
1137
1140
  const data = this.safeList(response, 'data');
1138
1141
  return this.parsePositions(data, symbols);
1139
1142
  }
1143
+ async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
1144
+ /**
1145
+ * @method
1146
+ * @name kucoinfutures#fetchPositionsHistory
1147
+ * @description fetches historical positions
1148
+ * @see https://www.kucoin.com/docs/rest/futures-trading/positions/get-positions-history
1149
+ * @param {string[]} [symbols] list of unified market symbols
1150
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1151
+ * @param {int} [params.until] closing end time
1152
+ * @param {int} [params.pageId] page id
1153
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
1154
+ */
1155
+ await this.loadMarkets();
1156
+ if (limit === undefined) {
1157
+ limit = 200;
1158
+ }
1159
+ const request = {
1160
+ 'limit': limit,
1161
+ };
1162
+ if (since !== undefined) {
1163
+ request['from'] = since;
1164
+ }
1165
+ const until = this.safeInteger(params, 'until');
1166
+ if (until !== undefined) {
1167
+ params = this.omit(params, 'until');
1168
+ request['to'] = until;
1169
+ }
1170
+ const response = await this.futuresPrivateGetHistoryPositions(this.extend(request, params));
1171
+ //
1172
+ // {
1173
+ // "success": true,
1174
+ // "code": "200",
1175
+ // "msg": "success",
1176
+ // "retry": false,
1177
+ // "data": {
1178
+ // "currentPage": 1,
1179
+ // "pageSize": 10,
1180
+ // "totalNum": 25,
1181
+ // "totalPage": 3,
1182
+ // "items": [
1183
+ // {
1184
+ // "closeId": "300000000000000030",
1185
+ // "positionId": "300000000000000009",
1186
+ // "uid": 99996908309485,
1187
+ // "userId": "6527d4fc8c7f3d0001f40f5f",
1188
+ // "symbol": "XBTUSDM",
1189
+ // "settleCurrency": "XBT",
1190
+ // "leverage": "0.0",
1191
+ // "type": "LIQUID_LONG",
1192
+ // "side": null,
1193
+ // "closeSize": null,
1194
+ // "pnl": "-1.0000003793999999",
1195
+ // "realisedGrossCost": "0.9993849748999999",
1196
+ // "withdrawPnl": "0.0",
1197
+ // "roe": null,
1198
+ // "tradeFee": "0.0006154045",
1199
+ // "fundingFee": "0.0",
1200
+ // "openTime": 1713785751181,
1201
+ // "closeTime": 1713785752784,
1202
+ // "openPrice": null,
1203
+ // "closePrice": null
1204
+ // }
1205
+ // ]
1206
+ // }
1207
+ // }
1208
+ //
1209
+ const data = this.safeDict(response, 'data');
1210
+ const items = this.safeList(data, 'items', []);
1211
+ return this.parsePositions(items, symbols);
1212
+ }
1140
1213
  parsePosition(position, market = undefined) {
1141
1214
  //
1142
1215
  // {
@@ -1183,17 +1256,51 @@ class kucoinfutures extends kucoinfutures$1 {
1183
1256
  // }
1184
1257
  // ]
1185
1258
  // }
1259
+ // position history
1260
+ // {
1261
+ // "closeId": "300000000000000030",
1262
+ // "positionId": "300000000000000009",
1263
+ // "uid": 99996908309485,
1264
+ // "userId": "6527d4fc8c7f3d0001f40f5f",
1265
+ // "symbol": "XBTUSDM",
1266
+ // "settleCurrency": "XBT",
1267
+ // "leverage": "0.0",
1268
+ // "type": "LIQUID_LONG",
1269
+ // "side": null,
1270
+ // "closeSize": null,
1271
+ // "pnl": "-1.0000003793999999",
1272
+ // "realisedGrossCost": "0.9993849748999999",
1273
+ // "withdrawPnl": "0.0",
1274
+ // "roe": null,
1275
+ // "tradeFee": "0.0006154045",
1276
+ // "fundingFee": "0.0",
1277
+ // "openTime": 1713785751181,
1278
+ // "closeTime": 1713785752784,
1279
+ // "openPrice": null,
1280
+ // "closePrice": null
1281
+ // }
1186
1282
  //
1187
1283
  const symbol = this.safeString(position, 'symbol');
1188
1284
  market = this.safeMarket(symbol, market);
1189
1285
  const timestamp = this.safeInteger(position, 'currentTimestamp');
1190
1286
  const size = this.safeString(position, 'currentQty');
1191
1287
  let side = undefined;
1192
- if (Precise["default"].stringGt(size, '0')) {
1193
- side = 'long';
1288
+ const type = this.safeStringLower(position, 'type');
1289
+ if (size !== undefined) {
1290
+ if (Precise["default"].stringGt(size, '0')) {
1291
+ side = 'long';
1292
+ }
1293
+ else if (Precise["default"].stringLt(size, '0')) {
1294
+ side = 'short';
1295
+ }
1194
1296
  }
1195
- else if (Precise["default"].stringLt(size, '0')) {
1196
- side = 'short';
1297
+ else if (type !== undefined) {
1298
+ if (type.indexOf('long') > -1) {
1299
+ side = 'long';
1300
+ }
1301
+ else {
1302
+ side = 'short';
1303
+ }
1197
1304
  }
1198
1305
  const notional = Precise["default"].stringAbs(this.safeString(position, 'posCost'));
1199
1306
  const initialMargin = this.safeString(position, 'posInit');
@@ -1202,25 +1309,28 @@ class kucoinfutures extends kucoinfutures$1 {
1202
1309
  const unrealisedPnl = this.safeString(position, 'unrealisedPnl');
1203
1310
  const crossMode = this.safeValue(position, 'crossMode');
1204
1311
  // currently crossMode is always set to false and only isolated positions are supported
1205
- const marginMode = crossMode ? 'cross' : 'isolated';
1312
+ let marginMode = undefined;
1313
+ if (crossMode !== undefined) {
1314
+ marginMode = crossMode ? 'cross' : 'isolated';
1315
+ }
1206
1316
  return this.safePosition({
1207
1317
  'info': position,
1208
- 'id': this.safeString(position, 'id'),
1318
+ 'id': this.safeString2(position, 'id', 'positionId'),
1209
1319
  'symbol': this.safeString(market, 'symbol'),
1210
1320
  'timestamp': timestamp,
1211
1321
  'datetime': this.iso8601(timestamp),
1212
- 'lastUpdateTimestamp': undefined,
1322
+ 'lastUpdateTimestamp': this.safeInteger(position, 'closeTime'),
1213
1323
  'initialMargin': this.parseNumber(initialMargin),
1214
1324
  'initialMarginPercentage': this.parseNumber(initialMarginPercentage),
1215
1325
  'maintenanceMargin': this.safeNumber(position, 'posMaint'),
1216
1326
  'maintenanceMarginPercentage': this.safeNumber(position, 'maintMarginReq'),
1217
- 'entryPrice': this.safeNumber(position, 'avgEntryPrice'),
1327
+ 'entryPrice': this.safeNumber2(position, 'avgEntryPrice', 'openPrice'),
1218
1328
  'notional': this.parseNumber(notional),
1219
- 'leverage': this.safeNumber(position, 'realLeverage'),
1329
+ 'leverage': this.safeNumber2(position, 'realLeverage', 'leverage'),
1220
1330
  'unrealizedPnl': this.parseNumber(unrealisedPnl),
1221
1331
  'contracts': this.parseNumber(Precise["default"].stringAbs(size)),
1222
1332
  'contractSize': this.safeValue(market, 'contractSize'),
1223
- 'realizedPnl': this.safeNumber(position, 'realisedPnl'),
1333
+ 'realizedPnl': this.safeNumber2(position, 'realisedPnl', 'pnl'),
1224
1334
  'marginRatio': undefined,
1225
1335
  'liquidationPrice': this.safeNumber(position, 'liquidationPrice'),
1226
1336
  'markPrice': this.safeNumber(position, 'markPrice'),
@@ -2701,6 +2811,44 @@ class kucoinfutures extends kucoinfutures$1 {
2701
2811
  }
2702
2812
  return this.parseOrder(response, market);
2703
2813
  }
2814
+ async fetchTradingFee(symbol, params = {}) {
2815
+ /**
2816
+ * @method
2817
+ * @name kucoinfutures#fetchTradingFee
2818
+ * @description fetch the trading fees for a market
2819
+ * @see https://www.kucoin.com/docs/rest/funding/trade-fee/trading-pair-actual-fee-futures
2820
+ * @param {string} symbol unified market symbol
2821
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2822
+ * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
2823
+ */
2824
+ await this.loadMarkets();
2825
+ const market = this.market(symbol);
2826
+ const request = {
2827
+ 'symbols': market['id'],
2828
+ };
2829
+ const response = await this.privateGetTradeFees(this.extend(request, params));
2830
+ //
2831
+ // {
2832
+ // "code": "200000",
2833
+ // "data": {
2834
+ // "symbol": "XBTUSDTM",
2835
+ // "takerFeeRate": "0.0006",
2836
+ // "makerFeeRate": "0.0002"
2837
+ // }
2838
+ // }
2839
+ //
2840
+ const data = this.safeList(response, 'data', []);
2841
+ const first = this.safeDict(data, 0);
2842
+ const marketId = this.safeString(first, 'symbol');
2843
+ return {
2844
+ 'info': response,
2845
+ 'symbol': this.safeSymbol(marketId, market),
2846
+ 'maker': this.safeNumber(first, 'makerFeeRate'),
2847
+ 'taker': this.safeNumber(first, 'takerFeeRate'),
2848
+ 'percentage': true,
2849
+ 'tierBased': true,
2850
+ };
2851
+ }
2704
2852
  }
2705
2853
 
2706
2854
  module.exports = kucoinfutures;
@@ -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
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.7";
7
+ declare const version = "4.3.9";
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.8';
41
+ const version = '4.3.10';
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>;
@@ -183,6 +183,8 @@ interface kucoin {
183
183
  futuresPrivateGetWithdrawalList(params?: {}): Promise<implicitReturnType>;
184
184
  futuresPrivateGetSubApiKey(params?: {}): Promise<implicitReturnType>;
185
185
  futuresPrivateGetTradeStatistics(params?: {}): Promise<implicitReturnType>;
186
+ futuresPrivateGetTradeFees(params?: {}): Promise<implicitReturnType>;
187
+ futuresPrivateGetHistoryPositions(params?: {}): Promise<implicitReturnType>;
186
188
  futuresPrivatePostTransferOut(params?: {}): Promise<implicitReturnType>;
187
189
  futuresPrivatePostTransferIn(params?: {}): Promise<implicitReturnType>;
188
190
  futuresPrivatePostOrders(params?: {}): Promise<implicitReturnType>;
@@ -6101,10 +6101,10 @@ export default class Exchange {
6101
6101
  const fromId = this.safeString(entry, fromCurrencyKey);
6102
6102
  const toId = this.safeString(entry, toCurrencyKey);
6103
6103
  if (fromId !== undefined) {
6104
- fromCurrency = this.currency(fromId);
6104
+ fromCurrency = this.safeCurrency(fromId);
6105
6105
  }
6106
6106
  if (toId !== undefined) {
6107
- toCurrency = this.currency(toId);
6107
+ toCurrency = this.safeCurrency(toId);
6108
6108
  }
6109
6109
  const conversion = this.extend(this.parseConversion(entry, fromCurrency, toCurrency), params);
6110
6110
  result.push(conversion);
@@ -6112,7 +6112,7 @@ export default class Exchange {
6112
6112
  const sorted = this.sortBy(result, 'timestamp');
6113
6113
  let currency = undefined;
6114
6114
  if (code !== undefined) {
6115
- currency = this.currency(code);
6115
+ currency = this.safeCurrency(code);
6116
6116
  code = currency['code'];
6117
6117
  }
6118
6118
  if (code === undefined) {
@@ -121,6 +121,8 @@ export interface Order {
121
121
  cost: number;
122
122
  trades: Trade[];
123
123
  fee: Fee;
124
+ reduceOnly: Bool;
125
+ postOnly: Bool;
124
126
  info: any;
125
127
  }
126
128
  export interface OrderBook {
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
package/js/src/bitget.js CHANGED
@@ -8458,7 +8458,7 @@ export default class bitget extends Exchange {
8458
8458
  * @name bitget#fetchPositionsHistory
8459
8459
  * @description fetches historical positions
8460
8460
  * @see https://www.bitget.com/api-doc/contract/position/Get-History-Position
8461
- * @param {string} [symbol] unified contract symbols
8461
+ * @param {string[]} [symbols] unified contract symbols
8462
8462
  * @param {int} [since] timestamp in ms of the earliest position to fetch, default=3 months ago, max range for params["until"] - since is 3 months
8463
8463
  * @param {int} [limit] the maximum amount of records to fetch, default=20, max=100
8464
8464
  * @param {object} params extra parameters specific to the exchange api endpoint