ccxt 4.5.14 → 4.5.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +20 -5
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/ascendex.js +1 -0
  5. package/dist/cjs/src/backpack.js +7 -2
  6. package/dist/cjs/src/base/Exchange.js +46 -0
  7. package/dist/cjs/src/binance.js +3 -0
  8. package/dist/cjs/src/bingx.js +73 -46
  9. package/dist/cjs/src/bitget.js +19 -6
  10. package/dist/cjs/src/blofin.js +7 -6
  11. package/dist/cjs/src/bybit.js +16 -6
  12. package/dist/cjs/src/delta.js +98 -3
  13. package/dist/cjs/src/gate.js +152 -151
  14. package/dist/cjs/src/htx.js +1 -0
  15. package/dist/cjs/src/kraken.js +99 -4
  16. package/dist/cjs/src/kucoin.js +1 -0
  17. package/dist/cjs/src/mexc.js +1 -0
  18. package/dist/cjs/src/okx.js +10 -0
  19. package/dist/cjs/src/phemex.js +6 -3
  20. package/dist/cjs/src/poloniex.js +3 -0
  21. package/dist/cjs/src/pro/binance.js +1 -1
  22. package/dist/cjs/src/pro/kraken.js +1 -1
  23. package/dist/cjs/src/pro/upbit.js +25 -1
  24. package/dist/cjs/src/woo.js +41 -20
  25. package/js/ccxt.d.ts +1 -1
  26. package/js/ccxt.js +1 -1
  27. package/js/src/abstract/bingx.d.ts +17 -0
  28. package/js/src/abstract/bybit.d.ts +1 -0
  29. package/js/src/abstract/delta.d.ts +5 -1
  30. package/js/src/abstract/woo.d.ts +0 -3
  31. package/js/src/ascendex.js +1 -0
  32. package/js/src/backpack.d.ts +1 -1
  33. package/js/src/backpack.js +7 -2
  34. package/js/src/base/Exchange.d.ts +31 -0
  35. package/js/src/base/Exchange.js +47 -1
  36. package/js/src/base/types.d.ts +2 -0
  37. package/js/src/binance.js +3 -0
  38. package/js/src/bingx.d.ts +2 -2
  39. package/js/src/bingx.js +73 -46
  40. package/js/src/bitget.js +19 -6
  41. package/js/src/blofin.js +7 -6
  42. package/js/src/bybit.d.ts +1 -1
  43. package/js/src/bybit.js +16 -6
  44. package/js/src/delta.d.ts +13 -0
  45. package/js/src/delta.js +98 -3
  46. package/js/src/derive.js +1 -1
  47. package/js/src/gate.d.ts +140 -140
  48. package/js/src/gate.js +152 -151
  49. package/js/src/htx.js +1 -0
  50. package/js/src/kraken.d.ts +11 -1
  51. package/js/src/kraken.js +99 -4
  52. package/js/src/kucoin.js +1 -0
  53. package/js/src/mexc.js +1 -0
  54. package/js/src/okx.js +10 -0
  55. package/js/src/phemex.js +6 -3
  56. package/js/src/poloniex.js +3 -0
  57. package/js/src/pro/binance.js +1 -1
  58. package/js/src/pro/gate.js +1 -1
  59. package/js/src/pro/gemini.js +1 -1
  60. package/js/src/pro/kraken.d.ts +1 -1
  61. package/js/src/pro/kraken.js +1 -1
  62. package/js/src/pro/onetrading.js +1 -1
  63. package/js/src/pro/upbit.js +25 -1
  64. package/js/src/woo.d.ts +1 -1
  65. package/js/src/woo.js +41 -20
  66. package/package.json +1 -1
package/js/src/bybit.js CHANGED
@@ -509,6 +509,7 @@ export default class bybit extends Exchange {
509
509
  'v5/account/mmp-reset': 5,
510
510
  'v5/account/borrow': 5,
511
511
  'v5/account/repay': 5,
512
+ 'v5/account/no-convert-repay': 5,
512
513
  // asset
513
514
  'v5/asset/exchange/quote-apply': 1,
514
515
  'v5/asset/exchange/convert-execute': 1,
@@ -3943,7 +3944,7 @@ export default class bybit extends Exchange {
3943
3944
  * @param {string} [params.positionIdx] *contracts only* 0 for one-way mode, 1 buy side of hedged mode, 2 sell side of hedged mode
3944
3945
  * @param {bool} [params.hedged] *contracts only* true for hedged mode, false for one way mode, default is false
3945
3946
  * @param {int} [params.isLeverage] *unified spot only* false then spot trading true then margin trading
3946
- * @param {string} [params.tpslMode] *contract only* 'full' or 'partial'
3947
+ * @param {string} [params.tpslMode] *contract only* 'Full' or 'Partial'
3947
3948
  * @param {string} [params.mmp] *option only* market maker protection
3948
3949
  * @param {string} [params.triggerDirection] *contract only* the direction for trigger orders, 'ascending' or 'descending'
3949
3950
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
@@ -4067,22 +4068,31 @@ export default class bybit extends Exchange {
4067
4068
  throw new InvalidOrder(this.id + ' the API endpoint used only supports contract trailingAmount, stopLossPrice and takeProfitPrice orders');
4068
4069
  }
4069
4070
  if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
4071
+ const tpslMode = this.safeString(params, 'tpslMode', 'Partial');
4072
+ const isFullTpsl = tpslMode === 'Full';
4073
+ const isPartialTpsl = tpslMode === 'Partial';
4074
+ if (isLimit && isFullTpsl) {
4075
+ throw new InvalidOrder(this.id + ' tpsl orders with "full" tpslMode only support "market" type');
4076
+ }
4077
+ request['tpslMode'] = tpslMode;
4070
4078
  if (isStopLossTriggerOrder) {
4071
4079
  request['stopLoss'] = this.getPrice(symbol, stopLossTriggerPrice);
4080
+ if (isPartialTpsl) {
4081
+ request['slSize'] = amountString;
4082
+ }
4072
4083
  if (isLimit) {
4073
- request['tpslMode'] = 'Partial';
4074
4084
  request['slOrderType'] = 'Limit';
4075
4085
  request['slLimitPrice'] = priceString;
4076
- request['slSize'] = amountString;
4077
4086
  }
4078
4087
  }
4079
4088
  else if (isTakeProfitTriggerOrder) {
4080
4089
  request['takeProfit'] = this.getPrice(symbol, takeProfitTriggerPrice);
4090
+ if (isPartialTpsl) {
4091
+ request['tpSize'] = amountString;
4092
+ }
4081
4093
  if (isLimit) {
4082
- request['tpslMode'] = 'Partial';
4083
4094
  request['tpOrderType'] = 'Limit';
4084
4095
  request['tpLimitPrice'] = priceString;
4085
- request['tpSize'] = amountString;
4086
4096
  }
4087
4097
  }
4088
4098
  }
@@ -4268,7 +4278,7 @@ export default class bybit extends Exchange {
4268
4278
  }
4269
4279
  request['positionIdx'] = (side === 'buy') ? 1 : 2;
4270
4280
  }
4271
- params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice', 'hedged']);
4281
+ params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice', 'hedged', 'tpslMode']);
4272
4282
  return this.extend(request, params);
4273
4283
  }
4274
4284
  /**
package/js/src/delta.d.ts CHANGED
@@ -194,6 +194,19 @@ export default class delta extends Exchange {
194
194
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
195
195
  */
196
196
  cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
197
+ /**
198
+ * @method
199
+ * @name delta#fetchOrder
200
+ * @description fetches information on an order made by the user
201
+ * @see https://docs.delta.exchange/#get-order-by-id
202
+ * @see https://docs.delta.exchange/#get-order-by-client-oid
203
+ * @param {string} id the order id
204
+ * @param {string} [symbol] unified symbol of the market the order was made in
205
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
206
+ * @param {string} [params.clientOrderId] client order id of the order
207
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
208
+ */
209
+ fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
197
210
  /**
198
211
  * @method
199
212
  * @name delta#fetchOpenOrders
package/js/src/delta.js CHANGED
@@ -62,6 +62,7 @@ export default class delta extends Exchange {
62
62
  'fetchOpenOrders': true,
63
63
  'fetchOption': true,
64
64
  'fetchOptionChain': false,
65
+ 'fetchOrder': true,
65
66
  'fetchOrderBook': true,
66
67
  'fetchPosition': true,
67
68
  'fetchPositionMode': false,
@@ -140,6 +141,8 @@ export default class delta extends Exchange {
140
141
  'private': {
141
142
  'get': [
142
143
  'orders',
144
+ 'orders/{order_id}',
145
+ 'orders/client_order_id/{client_oid}',
143
146
  'products/{product_id}/orders/leverage',
144
147
  'positions/margined',
145
148
  'positions',
@@ -153,8 +156,8 @@ export default class delta extends Exchange {
153
156
  'users/trading_preferences',
154
157
  'sub_accounts',
155
158
  'profile',
159
+ 'heartbeat',
156
160
  'deposits/address',
157
- 'orders/leverage',
158
161
  ],
159
162
  'post': [
160
163
  'orders',
@@ -164,6 +167,8 @@ export default class delta extends Exchange {
164
167
  'positions/change_margin',
165
168
  'positions/close_all',
166
169
  'wallets/sub_account_balance_transfer',
170
+ 'heartbeat/create',
171
+ 'heartbeat',
167
172
  'orders/cancel_after',
168
173
  'orders/leverage',
169
174
  ],
@@ -1880,9 +1885,40 @@ export default class delta extends Exchange {
1880
1885
  // "user_id":22142
1881
1886
  // }
1882
1887
  //
1888
+ // fetchOrder
1889
+ //
1890
+ // {
1891
+ // "id": 123,
1892
+ // "user_id": 453671,
1893
+ // "size": 10,
1894
+ // "unfilled_size": 2,
1895
+ // "side": "buy",
1896
+ // "order_type": "limit_order",
1897
+ // "limit_price": "59000",
1898
+ // "stop_order_type": "stop_loss_order",
1899
+ // "stop_price": "55000",
1900
+ // "paid_commission": "0.5432",
1901
+ // "commission": "0.5432",
1902
+ // "reduce_only": false,
1903
+ // "client_order_id": "my_signal_34521712",
1904
+ // "state": "open",
1905
+ // "created_at": "1725865012000000",
1906
+ // "product_id": 27,
1907
+ // "product_symbol": "BTCUSD"
1908
+ // }
1909
+ //
1883
1910
  const id = this.safeString(order, 'id');
1884
1911
  const clientOrderId = this.safeString(order, 'client_order_id');
1885
- const timestamp = this.parse8601(this.safeString(order, 'created_at'));
1912
+ const createdAt = this.safeString(order, 'created_at');
1913
+ let timestamp = undefined;
1914
+ if (createdAt !== undefined) {
1915
+ if (createdAt.indexOf('-') >= 0) {
1916
+ timestamp = this.parse8601(createdAt);
1917
+ }
1918
+ else {
1919
+ timestamp = this.safeIntegerProduct(order, 'created_at', 0.001);
1920
+ }
1921
+ }
1886
1922
  const marketId = this.safeString(order, 'product_id');
1887
1923
  const marketsByNumericId = this.safeDict(this.options, 'marketsByNumericId', {});
1888
1924
  market = this.safeValue(marketsByNumericId, marketId, market);
@@ -1890,7 +1926,9 @@ export default class delta extends Exchange {
1890
1926
  const status = this.parseOrderStatus(this.safeString(order, 'state'));
1891
1927
  const side = this.safeString(order, 'side');
1892
1928
  let type = this.safeString(order, 'order_type');
1893
- type = type.replace('_order', '');
1929
+ if (type !== undefined) {
1930
+ type = type.replace('_order', '');
1931
+ }
1894
1932
  const price = this.safeString(order, 'limit_price');
1895
1933
  const amount = this.safeString(order, 'size');
1896
1934
  const remaining = this.safeString(order, 'unfilled_size');
@@ -2155,6 +2193,63 @@ export default class delta extends Exchange {
2155
2193
  }),
2156
2194
  ];
2157
2195
  }
2196
+ /**
2197
+ * @method
2198
+ * @name delta#fetchOrder
2199
+ * @description fetches information on an order made by the user
2200
+ * @see https://docs.delta.exchange/#get-order-by-id
2201
+ * @see https://docs.delta.exchange/#get-order-by-client-oid
2202
+ * @param {string} id the order id
2203
+ * @param {string} [symbol] unified symbol of the market the order was made in
2204
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2205
+ * @param {string} [params.clientOrderId] client order id of the order
2206
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2207
+ */
2208
+ async fetchOrder(id, symbol = undefined, params = {}) {
2209
+ await this.loadMarkets();
2210
+ let market = undefined;
2211
+ if (symbol !== undefined) {
2212
+ market = this.market(symbol);
2213
+ }
2214
+ const clientOrderId = this.safeStringN(params, ['clientOrderId', 'client_oid', 'clientOid']);
2215
+ params = this.omit(params, ['clientOrderId', 'client_oid', 'clientOid']);
2216
+ const request = {};
2217
+ let response = undefined;
2218
+ if (clientOrderId !== undefined) {
2219
+ request['client_oid'] = clientOrderId;
2220
+ response = await this.privateGetOrdersClientOrderIdClientOid(this.extend(request, params));
2221
+ }
2222
+ else {
2223
+ request['order_id'] = id;
2224
+ response = await this.privateGetOrdersOrderId(this.extend(request, params));
2225
+ }
2226
+ //
2227
+ // {
2228
+ // "success": true,
2229
+ // "result": {
2230
+ // "id": 123,
2231
+ // "user_id": 453671,
2232
+ // "size": 10,
2233
+ // "unfilled_size": 2,
2234
+ // "side": "buy",
2235
+ // "order_type": "limit_order",
2236
+ // "limit_price": "59000",
2237
+ // "stop_order_type": "stop_loss_order",
2238
+ // "stop_price": "55000",
2239
+ // "paid_commission": "0.5432",
2240
+ // "commission": "0.5432",
2241
+ // "reduce_only": false,
2242
+ // "client_order_id": "my_signal_34521712",
2243
+ // "state": "open",
2244
+ // "created_at": "1725865012000000",
2245
+ // "product_id": 27,
2246
+ // "product_symbol": "BTCUSD"
2247
+ // }
2248
+ // }
2249
+ //
2250
+ const result = this.safeDict(response, 'result', {});
2251
+ return this.parseOrder(result, market);
2252
+ }
2158
2253
  /**
2159
2254
  * @method
2160
2255
  * @name delta#fetchOpenOrders
package/js/src/derive.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // ---------------------------------------------------------------------------
2
2
  import Exchange from './abstract/derive.js';
3
- import Precise from './base/Precise.js';
3
+ import { Precise } from './base/Precise.js';
4
4
  import { BadRequest, InvalidOrder, ExchangeError, OrderNotFound, ArgumentsRequired, InsufficientFunds, RateLimitExceeded, AuthenticationError } from './base/errors.js';
5
5
  import { ecdsa } from './base/functions/crypto.js';
6
6
  import { keccak_256 as keccak } from './static_dependencies/noble-hashes/sha3.js';