ccxt 4.4.32 → 4.4.33

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/bybit.js CHANGED
@@ -7,7 +7,7 @@
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/bybit.js';
9
9
  import { TICK_SIZE } from './base/functions/number.js';
10
- import { AuthenticationError, ExchangeError, ArgumentsRequired, PermissionDenied, InvalidOrder, OrderNotFound, InsufficientFunds, BadRequest, RateLimitExceeded, InvalidNonce, NotSupported, RequestTimeout, MarginModeAlreadySet, NoChange, ManualInteractionNeeded, BadSymbol } from './base/errors.js';
10
+ import { AuthenticationError, ExchangeError, ArgumentsRequired, PermissionDenied, AccountSuspended, InvalidOrder, OrderNotFound, InsufficientFunds, BadRequest, RateLimitExceeded, InvalidNonce, NotSupported, RequestTimeout, MarginModeAlreadySet, NoChange, ManualInteractionNeeded, BadSymbol } from './base/errors.js';
11
11
  import { Precise } from './base/Precise.js';
12
12
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
13
13
  import { rsa } from './base/functions/rsa.js';
@@ -554,7 +554,7 @@ export default class bybit extends Exchange {
554
554
  '10005': PermissionDenied,
555
555
  '10006': RateLimitExceeded,
556
556
  '10007': AuthenticationError,
557
- '10008': AuthenticationError,
557
+ '10008': AccountSuspended,
558
558
  '10009': AuthenticationError,
559
559
  '10010': PermissionDenied,
560
560
  '10014': BadRequest,
@@ -998,7 +998,7 @@ export default class bybit extends Exchange {
998
998
  'enableUnifiedMargin': undefined,
999
999
  'enableUnifiedAccount': undefined,
1000
1000
  'unifiedMarginStatus': undefined,
1001
- 'createMarketBuyOrderRequiresPrice': true,
1001
+ 'createMarketBuyOrderRequiresPrice': false,
1002
1002
  'createUnifiedMarginAccount': false,
1003
1003
  'defaultType': 'swap',
1004
1004
  'defaultSubType': 'linear',
@@ -1058,6 +1058,122 @@ export default class bybit extends Exchange {
1058
1058
  '1d': '1d',
1059
1059
  },
1060
1060
  },
1061
+ 'features': {
1062
+ 'default': {
1063
+ 'sandbox': true,
1064
+ 'createOrder': {
1065
+ 'triggerPrice': true,
1066
+ 'triggerPriceType': {
1067
+ 'last': true,
1068
+ 'mark': true,
1069
+ 'index': true,
1070
+ },
1071
+ 'triggerDirection': true,
1072
+ 'stopLossPrice': true,
1073
+ 'takeProfitPrice': true,
1074
+ 'attachedStopLossTakeProfit': {
1075
+ 'triggerPriceType': {
1076
+ 'last': true,
1077
+ 'mark': true,
1078
+ 'index': true,
1079
+ },
1080
+ 'limitPrice': true,
1081
+ },
1082
+ 'marginMode': false,
1083
+ 'timeInForce': {
1084
+ 'GTC': true,
1085
+ 'IOC': true,
1086
+ 'FOK': true,
1087
+ 'PO': true,
1088
+ 'GTD': false,
1089
+ },
1090
+ 'hedged': true,
1091
+ // exchange-supported features
1092
+ 'selfTradePrevention': true,
1093
+ 'trailing': true,
1094
+ 'twap': false,
1095
+ 'iceberg': false,
1096
+ 'oco': false,
1097
+ },
1098
+ 'createOrders': {
1099
+ 'max': 10,
1100
+ },
1101
+ 'fetchMyTrades': {
1102
+ 'limit': 100,
1103
+ 'daysBack': 365 * 2,
1104
+ 'untilDays': 7, // days between start-end
1105
+ },
1106
+ 'fetchOrder': {
1107
+ 'marginMode': false,
1108
+ 'trigger': true,
1109
+ 'trailing': false,
1110
+ },
1111
+ 'fetchOpenOrders': {
1112
+ 'limit': 50,
1113
+ 'marginMode': false,
1114
+ 'trigger': true,
1115
+ 'trailing': false,
1116
+ },
1117
+ 'fetchOrders': undefined,
1118
+ 'fetchClosedOrders': {
1119
+ 'limit': 50,
1120
+ 'daysBackClosed': 365 * 2,
1121
+ 'daysBackCanceled': 1,
1122
+ 'untilDays': 7,
1123
+ 'marginMode': false,
1124
+ 'trigger': true,
1125
+ 'trailing': false,
1126
+ },
1127
+ 'fetchOHLCV': {
1128
+ 'limit': 1000,
1129
+ },
1130
+ },
1131
+ 'spot': {
1132
+ 'extends': 'default',
1133
+ 'createOrder': {
1134
+ 'triggerPrice': true,
1135
+ 'triggerPriceType': undefined,
1136
+ 'triggerDirection': false,
1137
+ 'stopLossPrice': true,
1138
+ 'takeProfitPrice': true,
1139
+ 'attachedStopLossTakeProfit': {
1140
+ 'triggerPriceType': undefined,
1141
+ 'limitPrice': true,
1142
+ },
1143
+ 'marginMode': false,
1144
+ 'timeInForce': {
1145
+ 'GTC': true,
1146
+ 'IOC': true,
1147
+ 'FOK': true,
1148
+ 'PO': true,
1149
+ 'GTD': false,
1150
+ },
1151
+ 'hedged': true,
1152
+ // exchange-supported features
1153
+ 'selfTradePrevention': true,
1154
+ 'trailing': true,
1155
+ 'twap': false,
1156
+ 'iceberg': false,
1157
+ 'oco': false,
1158
+ },
1159
+ },
1160
+ 'swap': {
1161
+ 'linear': {
1162
+ 'extends': 'default',
1163
+ },
1164
+ 'inverse': {
1165
+ 'extends': 'default',
1166
+ },
1167
+ },
1168
+ 'future': {
1169
+ 'linear': {
1170
+ 'extends': 'default',
1171
+ },
1172
+ 'inverse': {
1173
+ 'extends': 'default',
1174
+ },
1175
+ },
1176
+ },
1061
1177
  'fees': {
1062
1178
  'trading': {
1063
1179
  'feeSide': 'get',
@@ -3489,11 +3605,19 @@ export default class bybit extends Exchange {
3489
3605
  market = this.safeMarket(marketId, market, undefined, marketType);
3490
3606
  const symbol = market['symbol'];
3491
3607
  const timestamp = this.safeInteger2(order, 'createdTime', 'createdAt');
3608
+ const marketUnit = this.safeString(order, 'marketUnit', 'baseCoin');
3492
3609
  const id = this.safeString(order, 'orderId');
3493
3610
  const type = this.safeStringLower(order, 'orderType');
3494
3611
  const price = this.safeString(order, 'price');
3495
- const amount = this.safeString(order, 'qty');
3496
- const cost = this.safeString(order, 'cumExecValue');
3612
+ let amount = undefined;
3613
+ let cost = undefined;
3614
+ if (marketUnit === 'baseCoin') {
3615
+ amount = this.safeString(order, 'qty');
3616
+ cost = this.safeString(order, 'cumExecValue');
3617
+ }
3618
+ else {
3619
+ cost = this.safeString(order, 'cumExecValue');
3620
+ }
3497
3621
  const filled = this.safeString(order, 'cumExecQty');
3498
3622
  const remaining = this.safeString(order, 'leavesQty');
3499
3623
  const lastTradeTimestamp = this.safeInteger2(order, 'updatedTime', 'updatedAt');
@@ -3858,7 +3982,7 @@ export default class bybit extends Exchange {
3858
3982
  // classic accounts
3859
3983
  // for market buy it requires the amount of quote currency to spend
3860
3984
  let createMarketBuyOrderRequiresPrice = true;
3861
- [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
3985
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice');
3862
3986
  if (createMarketBuyOrderRequiresPrice) {
3863
3987
  if ((price === undefined) && (cost === undefined)) {
3864
3988
  throw new InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument');
@@ -3870,7 +3994,15 @@ export default class bybit extends Exchange {
3870
3994
  }
3871
3995
  }
3872
3996
  else {
3873
- request['qty'] = this.getCost(symbol, this.numberToString(amount));
3997
+ if (cost !== undefined) {
3998
+ request['qty'] = this.getCost(symbol, this.numberToString(cost));
3999
+ }
4000
+ else if (price !== undefined) {
4001
+ request['qty'] = this.getCost(symbol, Precise.stringMul(amountString, priceString));
4002
+ }
4003
+ else {
4004
+ request['qty'] = this.getCost(symbol, this.numberToString(amount));
4005
+ }
3874
4006
  }
3875
4007
  }
3876
4008
  else {
package/js/src/cex.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/cex.js';
9
- import { ExchangeError, ArgumentsRequired, NullResponse, PermissionDenied, InsufficientFunds, BadRequest } from './base/errors.js';
9
+ import { ExchangeError, ArgumentsRequired, NullResponse, PermissionDenied, InsufficientFunds, BadRequest, AuthenticationError } from './base/errors.js';
10
10
  import { Precise } from './base/Precise.js';
11
11
  import { TICK_SIZE } from './base/functions/number.js';
12
12
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
@@ -121,7 +121,8 @@ export default class cex extends Exchange {
121
121
  'check failed': BadRequest,
122
122
  'Insufficient funds': InsufficientFunds,
123
123
  'Get deposit address for main account is not allowed': PermissionDenied,
124
- 'Market Trigger orders are not allowed': BadRequest, // for some reason, triggerPrice does not work for market orders
124
+ 'Market Trigger orders are not allowed': BadRequest,
125
+ 'key not passed or incorrect': AuthenticationError,
125
126
  },
126
127
  },
127
128
  'timeframes': {
@@ -852,7 +853,7 @@ export default class cex extends Exchange {
852
853
  const code = this.safeCurrencyCode(key);
853
854
  const account = {
854
855
  'used': this.safeString(balance, 'balanceOnHold'),
855
- 'free': this.safeString(balance, 'balance'),
856
+ 'total': this.safeString(balance, 'balance'),
856
857
  };
857
858
  result[code] = account;
858
859
  }
@@ -2379,28 +2379,8 @@ export default class coinbase extends Exchange {
2379
2379
  const pagination = this.safeDict(response, 'pagination', {});
2380
2380
  const cursor = this.safeString(pagination, 'next_starting_after');
2381
2381
  if ((cursor !== undefined) && (cursor !== '')) {
2382
- const lastFee = this.safeDict(last, 'fee');
2383
- last['next_starting_after'] = cursor;
2384
- ledger[lastIndex] = {
2385
- 'info': this.safeDict(last, 'info'),
2386
- 'id': this.safeString(last, 'id'),
2387
- 'timestamp': this.safeInteger(last, 'timestamp'),
2388
- 'datetime': this.safeString(last, 'datetime'),
2389
- 'direction': this.safeString(last, 'direction'),
2390
- 'account': this.safeString(last, 'account'),
2391
- 'referenceId': undefined,
2392
- 'referenceAccount': undefined,
2393
- 'type': this.safeString(last, 'type'),
2394
- 'currency': this.safeString(last, 'currency'),
2395
- 'amount': this.safeNumber(last, 'amount'),
2396
- 'before': undefined,
2397
- 'after': undefined,
2398
- 'status': this.safeString(last, 'status'),
2399
- 'fee': {
2400
- 'cost': this.safeNumber(lastFee, 'cost'),
2401
- 'currency': this.safeString(lastFee, 'currency'),
2402
- },
2403
- };
2382
+ last['info']['next_starting_after'] = cursor;
2383
+ ledger[lastIndex] = last;
2404
2384
  }
2405
2385
  return ledger;
2406
2386
  }
@@ -119,7 +119,8 @@ export default class coinbaseexchange extends Exchange {
119
119
  'products/{id}/ticker',
120
120
  'products/{id}/trades',
121
121
  'time',
122
- 'products/spark-lines', // experimental
122
+ 'products/spark-lines',
123
+ 'products/volume-summary',
123
124
  ],
124
125
  },
125
126
  'private': {
package/js/src/coinex.js CHANGED
@@ -4773,6 +4773,7 @@ export default class coinex extends Exchange {
4773
4773
  'not_pass': 'failed',
4774
4774
  'cancel': 'canceled',
4775
4775
  'finish': 'ok',
4776
+ 'finished': 'ok',
4776
4777
  'fail': 'failed',
4777
4778
  };
4778
4779
  return this.safeString(statuses, status, status);
@@ -74,8 +74,9 @@ export default class hyperliquid extends Exchange {
74
74
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
75
75
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
76
76
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
77
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
77
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
78
78
  * @param {object} [params] extra parameters specific to the exchange API endpoint
79
+ * @param {string} [params.type] 'spot' or 'swap', by default fetches both
79
80
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
80
81
  */
81
82
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
@@ -730,15 +730,27 @@ export default class hyperliquid extends Exchange {
730
730
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
731
731
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
732
732
  * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
733
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
733
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
734
734
  * @param {object} [params] extra parameters specific to the exchange API endpoint
735
+ * @param {string} [params.type] 'spot' or 'swap', by default fetches both
735
736
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
736
737
  */
737
738
  async fetchTickers(symbols = undefined, params = {}) {
738
739
  await this.loadMarkets();
739
740
  symbols = this.marketSymbols(symbols);
740
741
  // at this stage, to get tickers data, we use fetchMarkets endpoints
741
- const response = await this.fetchMarkets(params);
742
+ let response = [];
743
+ const type = this.safeString(params, 'type');
744
+ params = this.omit(params, 'type');
745
+ if (type === 'spot') {
746
+ response = await this.fetchSpotMarkets(params);
747
+ }
748
+ else if (type === 'swap') {
749
+ response = await this.fetchSwapMarkets(params);
750
+ }
751
+ else {
752
+ response = await this.fetchMarkets(params);
753
+ }
742
754
  // same response as under "fetchMarkets"
743
755
  const result = {};
744
756
  for (let i = 0; i < response.length; i++) {
package/js/src/kraken.js CHANGED
@@ -182,6 +182,7 @@ export default class kraken extends Exchange {
182
182
  'AddOrder': 0,
183
183
  'AddOrderBatch': 0,
184
184
  'AddExport': 3,
185
+ 'AmendOrder': 0,
185
186
  'Balance': 3,
186
187
  'CancelAll': 3,
187
188
  'CancelAllOrdersAfter': 3,
@@ -185,7 +185,7 @@ export default class kucoinfutures extends kucoin {
185
185
  * @param {string} [params.postOnly] Post only flag, invalid when timeInForce is IOC or FOK
186
186
  * @param {float} [params.cost] the cost of the order in units of USDT
187
187
  * ----------------- Exchange Specific Parameters -----------------
188
- * @param {float} [params.leverage] Leverage size of the order
188
+ * @param {float} [params.leverage] Leverage size of the order (mandatory param in request, default is 1)
189
189
  * @param {string} [params.clientOid] client order id, defaults to uuid if not passed
190
190
  * @param {string} [params.remark] remark for the order, length cannot exceed 100 utf8 characters
191
191
  * @param {string} [params.stop] 'up' or 'down', the direction the stopPrice is triggered from, requires stopPrice. down: Triggers when the price reaches or goes below the stopPrice. up: Triggers when the price reaches or goes above the stopPrice.
@@ -1447,7 +1447,7 @@ export default class kucoinfutures extends kucoin {
1447
1447
  * @param {string} [params.postOnly] Post only flag, invalid when timeInForce is IOC or FOK
1448
1448
  * @param {float} [params.cost] the cost of the order in units of USDT
1449
1449
  * ----------------- Exchange Specific Parameters -----------------
1450
- * @param {float} [params.leverage] Leverage size of the order
1450
+ * @param {float} [params.leverage] Leverage size of the order (mandatory param in request, default is 1)
1451
1451
  * @param {string} [params.clientOid] client order id, defaults to uuid if not passed
1452
1452
  * @param {string} [params.remark] remark for the order, length cannot exceed 100 utf8 characters
1453
1453
  * @param {string} [params.stop] 'up' or 'down', the direction the stopPrice is triggered from, requires stopPrice. down: Triggers when the price reaches or goes below the stopPrice. up: Triggers when the price reaches or goes above the stopPrice.
package/js/src/lbank.js CHANGED
@@ -212,6 +212,7 @@ export default class lbank extends Exchange {
212
212
  },
213
213
  },
214
214
  'commonCurrencies': {
215
+ 'HIT': 'Hiver',
215
216
  'VET_ERC20': 'VEN',
216
217
  'PNT': 'Penta',
217
218
  },
package/js/src/okx.js CHANGED
@@ -1176,6 +1176,97 @@ export default class okx extends Exchange {
1176
1176
  },
1177
1177
  'brokerId': 'e847386590ce4dBC',
1178
1178
  },
1179
+ 'features': {
1180
+ // https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
1181
+ 'default': {
1182
+ 'sandbox': true,
1183
+ 'createOrder': {
1184
+ 'triggerPrice': true,
1185
+ 'triggerPriceType': {
1186
+ 'last': true,
1187
+ 'mark': true,
1188
+ 'index': true,
1189
+ },
1190
+ 'triggerDirection': false,
1191
+ 'stopLossPrice': true,
1192
+ 'takeProfitPrice': true,
1193
+ 'marginMode': true,
1194
+ 'attachedStopLossTakeProfit': {
1195
+ 'triggerPriceType': {
1196
+ 'last': true,
1197
+ 'mark': true,
1198
+ 'index': true,
1199
+ },
1200
+ 'limitPrice': true,
1201
+ },
1202
+ 'timeInForce': {
1203
+ 'GTC': true,
1204
+ 'IOC': true,
1205
+ 'FOK': true,
1206
+ 'PO': true,
1207
+ 'GTD': false,
1208
+ },
1209
+ 'hedged': true,
1210
+ // even though the below params not unified yet, it's useful metadata for users to know that exchange supports them
1211
+ 'selfTradePrevention': true,
1212
+ 'trailing': true,
1213
+ 'twap': true,
1214
+ 'iceberg': true,
1215
+ 'oco': true,
1216
+ },
1217
+ 'createOrders': {
1218
+ 'max': 20,
1219
+ },
1220
+ 'fetchMyTrades': {
1221
+ 'daysBack': 90,
1222
+ 'limit': 100,
1223
+ 'untilDays': 10000,
1224
+ },
1225
+ 'fetchOrder': {
1226
+ 'marginMode': false,
1227
+ 'trigger': true,
1228
+ 'trailing': true,
1229
+ },
1230
+ 'fetchOpenOrders': {
1231
+ 'limit': 100,
1232
+ 'marginMode': false,
1233
+ 'trigger': true,
1234
+ 'trailing': true,
1235
+ },
1236
+ 'fetchOrders': undefined,
1237
+ 'fetchClosedOrders': {
1238
+ 'limit': 100,
1239
+ 'daysBackClosed': 90,
1240
+ 'daysBackCanceled': 1 / 12,
1241
+ 'untilDays': undefined,
1242
+ 'marginMode': false,
1243
+ 'trigger': true,
1244
+ 'trailing': true,
1245
+ },
1246
+ 'fetchOHLCV': {
1247
+ 'limit': 300,
1248
+ },
1249
+ },
1250
+ 'spot': {
1251
+ 'extends': 'default',
1252
+ },
1253
+ 'swap': {
1254
+ 'linear': {
1255
+ 'extends': 'default',
1256
+ },
1257
+ 'inverse': {
1258
+ 'extends': 'default',
1259
+ },
1260
+ },
1261
+ 'future': {
1262
+ 'linear': {
1263
+ 'extends': 'default',
1264
+ },
1265
+ 'inverse': {
1266
+ 'extends': 'default',
1267
+ },
1268
+ },
1269
+ },
1179
1270
  'commonCurrencies': {
1180
1271
  // the exchange refers to ERC20 version of Aeternity (AEToken)
1181
1272
  'AE': 'AET',
@@ -3221,7 +3312,7 @@ export default class okx extends Exchange {
3221
3312
  request['newPx'] = this.priceToPrecision(symbol, price);
3222
3313
  }
3223
3314
  }
3224
- params = this.omit(params, ['clOrdId', 'clientOrderId', 'takeProfitPrice', 'stopLossPrice', 'stopLoss', 'takeProfit']);
3315
+ params = this.omit(params, ['clOrdId', 'clientOrderId', 'takeProfitPrice', 'stopLossPrice', 'stopLoss', 'takeProfit', 'postOnly']);
3225
3316
  return this.extend(request, params);
3226
3317
  }
3227
3318
  /**
@@ -334,6 +334,7 @@ export default class phemex extends Exchange {
334
334
  * @method
335
335
  * @name phemex#setMarginMode
336
336
  * @description set margin mode to 'cross' or 'isolated'
337
+ * @see https://phemex-docs.github.io/#set-leverage
337
338
  * @param {string} marginMode 'cross' or 'isolated'
338
339
  * @param {string} symbol unified market symbol
339
340
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -385,6 +386,8 @@ export default class phemex extends Exchange {
385
386
  * @method
386
387
  * @name phemex#transfer
387
388
  * @description transfer currency internally between wallets on the same account
389
+ * @see https://phemex-docs.github.io/#transfer-between-spot-and-futures
390
+ * @see https://phemex-docs.github.io/#universal-transfer-main-account-only-transfer-between-sub-to-main-main-to-sub-or-sub-to-sub
388
391
  * @param {string} code unified currency code
389
392
  * @param {float} amount amount to transfer
390
393
  * @param {string} fromAccount account to transfer from
@@ -398,6 +401,7 @@ export default class phemex extends Exchange {
398
401
  * @method
399
402
  * @name phemex#fetchTransfers
400
403
  * @description fetch a history of internal transfers made on an account
404
+ * @see https://phemex-docs.github.io/#query-transfer-history
401
405
  * @param {string} code unified currency code of the currency transferred
402
406
  * @param {int} [since] the earliest time in ms to fetch transfers for
403
407
  * @param {int} [limit] the maximum number of transfers structures to retrieve
package/js/src/phemex.js CHANGED
@@ -513,7 +513,7 @@ export default class phemex extends Exchange {
513
513
  parseSwapMarket(market) {
514
514
  //
515
515
  // {
516
- // "symbol":"BTCUSD",
516
+ // "symbol":"BTCUSD", //
517
517
  // "code":"1",
518
518
  // "type":"Perpetual",
519
519
  // "displaySymbol":"BTC / USD",
@@ -521,7 +521,7 @@ export default class phemex extends Exchange {
521
521
  // "markSymbol":".MBTC",
522
522
  // "fundingRateSymbol":".BTCFR",
523
523
  // "fundingRate8hSymbol":".BTCFR8H",
524
- // "contractUnderlyingAssets":"USD",
524
+ // "contractUnderlyingAssets":"USD", // or eg. `1000 SHIB`
525
525
  // "settleCurrency":"BTC",
526
526
  // "quoteCurrency":"USD",
527
527
  // "contractSize":"1 USD",
@@ -564,7 +564,8 @@ export default class phemex extends Exchange {
564
564
  const baseId = this.safeString2(market, 'baseCurrency', 'contractUnderlyingAssets');
565
565
  const quoteId = this.safeString(market, 'quoteCurrency');
566
566
  const settleId = this.safeString(market, 'settleCurrency');
567
- const base = this.safeCurrencyCode(baseId);
567
+ let base = this.safeCurrencyCode(baseId);
568
+ base = base.replace(' ', ''); // replace space for junction codes, eg. `1000 SHIB`
568
569
  const quote = this.safeCurrencyCode(quoteId);
569
570
  const settle = this.safeCurrencyCode(settleId);
570
571
  let inverse = false;
@@ -2644,7 +2645,7 @@ export default class phemex extends Exchange {
2644
2645
  if (stopLossDefined) {
2645
2646
  const stopLossTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice');
2646
2647
  if (stopLossTriggerPrice === undefined) {
2647
- throw new InvalidOrder(this.id + ' createOrder() requires a trigger price in params["stopLoss"]["triggerPrice"], or params["stopLoss"]["stopPrice"] for a stop loss order');
2648
+ throw new InvalidOrder(this.id + ' createOrder() requires a trigger price in params["stopLoss"]["triggerPrice"] for a stop loss order');
2648
2649
  }
2649
2650
  if (market['settle'] === 'USDT') {
2650
2651
  request['stopLossRp'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
@@ -2664,7 +2665,7 @@ export default class phemex extends Exchange {
2664
2665
  if (takeProfitDefined) {
2665
2666
  const takeProfitTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice');
2666
2667
  if (takeProfitTriggerPrice === undefined) {
2667
- throw new InvalidOrder(this.id + ' createOrder() requires a trigger price in params["takeProfit"]["triggerPrice"], or params["takeProfit"]["stopPrice"] for a take profit order');
2668
+ throw new InvalidOrder(this.id + ' createOrder() requires a trigger price in params["takeProfit"]["triggerPrice"] for a take profit order');
2668
2669
  }
2669
2670
  if (market['settle'] === 'USDT') {
2670
2671
  request['takeProfitRp'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
@@ -2854,7 +2855,7 @@ export default class phemex extends Exchange {
2854
2855
  request['baseQtyEV'] = this.toEv(amount, market);
2855
2856
  }
2856
2857
  }
2857
- const stopPrice = this.safeString2(params, 'stopPx', 'stopPrice');
2858
+ const stopPrice = this.safeStringN(params, ['triggerPrice', 'stopPx', 'stopPrice']);
2858
2859
  if (stopPrice !== undefined) {
2859
2860
  if (isUSDTSettled) {
2860
2861
  request['stopPxRp'] = this.priceToPrecision(symbol, stopPrice);
@@ -2863,7 +2864,7 @@ export default class phemex extends Exchange {
2863
2864
  request['stopPxEp'] = this.toEp(stopPrice, market);
2864
2865
  }
2865
2866
  }
2866
- params = this.omit(params, ['stopPx', 'stopPrice']);
2867
+ params = this.omit(params, ['triggerPrice', 'stopPx', 'stopPrice']);
2867
2868
  let response = undefined;
2868
2869
  if (isUSDTSettled) {
2869
2870
  const posSide = this.safeString(params, 'posSide');
@@ -4207,6 +4208,7 @@ export default class phemex extends Exchange {
4207
4208
  * @method
4208
4209
  * @name phemex#setMarginMode
4209
4210
  * @description set margin mode to 'cross' or 'isolated'
4211
+ * @see https://phemex-docs.github.io/#set-leverage
4210
4212
  * @param {string} marginMode 'cross' or 'isolated'
4211
4213
  * @param {string} symbol unified market symbol
4212
4214
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -4497,6 +4499,8 @@ export default class phemex extends Exchange {
4497
4499
  * @method
4498
4500
  * @name phemex#transfer
4499
4501
  * @description transfer currency internally between wallets on the same account
4502
+ * @see https://phemex-docs.github.io/#transfer-between-spot-and-futures
4503
+ * @see https://phemex-docs.github.io/#universal-transfer-main-account-only-transfer-between-sub-to-main-main-to-sub-or-sub-to-sub
4500
4504
  * @param {string} code unified currency code
4501
4505
  * @param {float} amount amount to transfer
4502
4506
  * @param {string} fromAccount account to transfer from
@@ -4584,6 +4588,7 @@ export default class phemex extends Exchange {
4584
4588
  * @method
4585
4589
  * @name phemex#fetchTransfers
4586
4590
  * @description fetch a history of internal transfers made on an account
4591
+ * @see https://phemex-docs.github.io/#query-transfer-history
4587
4592
  * @param {string} code unified currency code of the currency transferred
4588
4593
  * @param {int} [since] the earliest time in ms to fetch transfers for
4589
4594
  * @param {int} [limit] the maximum number of transfers structures to retrieve
package/js/src/pro/okx.js CHANGED
@@ -2257,6 +2257,7 @@ export default class okx extends okxRest {
2257
2257
  //
2258
2258
  // { event: 'error', msg: "Illegal request: {"op":"subscribe","args":["spot/ticker:BTC-USDT"]}", code: "60012" }
2259
2259
  // { event: 'error", msg: "channel:ticker,instId:BTC-USDT doesn"t exist", code: "60018" }
2260
+ // {"event":"error","msg":"Illegal request: {\\"id\\":\\"17321173472466905\\",\\"op\\":\\"amend-order\\",\\"args\\":[{\\"instId\\":\\"ETH-USDC\\",\\"ordId\\":\\"2000345622407479296\\",\\"newSz\\":\\"0.050857\\",\\"newPx\\":\\"2949.4\\",\\"postOnly\\":true}],\\"postOnly\\":true}","code":"60012","connId":"0808af6c"}
2260
2261
  //
2261
2262
  let errorCode = this.safeString(message, 'code');
2262
2263
  try {
@@ -2289,7 +2290,16 @@ export default class okx extends okxRest {
2289
2290
  catch (e) {
2290
2291
  // if the message contains an id, it means it is a response to a request
2291
2292
  // so we only reject that promise, instead of deleting all futures, destroying the authentication future
2292
- const id = this.safeString(message, 'id');
2293
+ let id = this.safeString(message, 'id');
2294
+ if (id === undefined) {
2295
+ // try to parse it from the stringified json inside msg
2296
+ const msg = this.safeString(message, 'msg');
2297
+ if (msg !== undefined && msg.startsWith('Illegal request: {')) {
2298
+ const stringifiedJson = msg.replace('Illegal request: ', '');
2299
+ const parsedJson = this.parseJson(stringifiedJson);
2300
+ id = this.safeString(parsedJson, 'id');
2301
+ }
2302
+ }
2293
2303
  if (id !== undefined) {
2294
2304
  client.reject(e, id);
2295
2305
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.4.32",
3
+ "version": "4.4.33",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",