ccxt 4.3.85 → 4.3.86

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 +7 -5
  2. package/dist/ccxt.browser.min.js +15 -15
  3. package/dist/cjs/ccxt.js +6 -1
  4. package/dist/cjs/src/abstract/hashkey.js +9 -0
  5. package/dist/cjs/src/base/Exchange.js +1 -1
  6. package/dist/cjs/src/binance.js +4 -2
  7. package/dist/cjs/src/bitfinex.js +2 -2
  8. package/dist/cjs/src/hashkey.js +4328 -0
  9. package/dist/cjs/src/hyperliquid.js +85 -65
  10. package/dist/cjs/src/indodax.js +37 -9
  11. package/dist/cjs/src/krakenfutures.js +12 -10
  12. package/dist/cjs/src/pro/ascendex.js +45 -5
  13. package/dist/cjs/src/pro/bingx.js +13 -12
  14. package/dist/cjs/src/pro/hashkey.js +839 -0
  15. package/dist/cjs/src/pro/hyperliquid.js +123 -0
  16. package/dist/cjs/src/pro/mexc.js +13 -7
  17. package/dist/cjs/src/pro/woo.js +1 -0
  18. package/dist/cjs/src/pro/woofipro.js +1 -0
  19. package/dist/cjs/src/pro/xt.js +1 -0
  20. package/js/ccxt.d.ts +8 -2
  21. package/js/ccxt.js +6 -2
  22. package/js/src/abstract/hashkey.d.ts +70 -0
  23. package/js/src/abstract/hashkey.js +11 -0
  24. package/js/src/base/Exchange.js +1 -1
  25. package/js/src/binance.js +4 -2
  26. package/js/src/bitfinex.js +2 -2
  27. package/js/src/hashkey.d.ts +178 -0
  28. package/js/src/hashkey.js +4329 -0
  29. package/js/src/hyperliquid.d.ts +3 -0
  30. package/js/src/hyperliquid.js +85 -65
  31. package/js/src/indodax.js +37 -9
  32. package/js/src/krakenfutures.js +12 -10
  33. package/js/src/pro/ascendex.d.ts +2 -0
  34. package/js/src/pro/ascendex.js +45 -5
  35. package/js/src/pro/bingx.js +13 -12
  36. package/js/src/pro/hashkey.d.ts +34 -0
  37. package/js/src/pro/hashkey.js +840 -0
  38. package/js/src/pro/hyperliquid.d.ts +7 -1
  39. package/js/src/pro/hyperliquid.js +123 -0
  40. package/js/src/pro/mexc.js +13 -7
  41. package/js/src/pro/woo.js +1 -0
  42. package/js/src/pro/woofipro.js +1 -0
  43. package/js/src/pro/xt.js +1 -0
  44. package/package.json +1 -1
@@ -1,8 +1,11 @@
1
1
  import hyperliquidRest from '../hyperliquid.js';
2
2
  import Client from '../base/ws/Client.js';
3
- import { Int, Str, Market, OrderBook, Trade, OHLCV, Order, Dict, Strings, Ticker, Tickers } from '../base/types.js';
3
+ import { Int, Str, Market, OrderBook, Trade, OHLCV, Order, Dict, Strings, Ticker, Tickers, type Num, OrderType, OrderSide, type OrderRequest } from '../base/types.js';
4
4
  export default class hyperliquid extends hyperliquidRest {
5
5
  describe(): any;
6
+ createOrdersWs(orders: OrderRequest[], params?: {}): Promise<Order[]>;
7
+ createOrderWs(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
8
+ editOrderWs(id: string, symbol: string, type: string, side: string, amount?: Num, price?: Num, params?: {}): Promise<Order>;
6
9
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
7
10
  handleOrderBook(client: any, message: any): void;
8
11
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
@@ -15,6 +18,7 @@ export default class hyperliquid extends hyperliquidRest {
15
18
  parseWsTrade(trade: Dict, market?: Market): Trade;
16
19
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
17
20
  handleOHLCV(client: Client, message: any): void;
21
+ handleWsPost(client: Client, message: any): void;
18
22
  watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
19
23
  handleOrder(client: Client, message: any): void;
20
24
  handleErrorMessage(client: Client, message: any): boolean;
@@ -23,4 +27,6 @@ export default class hyperliquid extends hyperliquidRest {
23
27
  method: string;
24
28
  };
25
29
  handlePong(client: Client, message: any): any;
30
+ requestId(): number;
31
+ wrapAsPostAction(request: Dict): Dict;
26
32
  }
@@ -14,6 +14,9 @@ export default class hyperliquid extends hyperliquidRest {
14
14
  return this.deepExtend(super.describe(), {
15
15
  'has': {
16
16
  'ws': true,
17
+ 'createOrderWs': true,
18
+ 'createOrdersWs': true,
19
+ 'editOrderWs': true,
17
20
  'watchBalance': false,
18
21
  'watchMyTrades': true,
19
22
  'watchOHLCV': true,
@@ -48,6 +51,90 @@ export default class hyperliquid extends hyperliquidRest {
48
51
  },
49
52
  });
50
53
  }
54
+ async createOrdersWs(orders, params = {}) {
55
+ /**
56
+ * @method
57
+ * @name hyperliquid#createOrdersWs
58
+ * @description create a list of trade orders using WebSocket post request
59
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
60
+ * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
61
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
62
+ */
63
+ await this.loadMarkets();
64
+ const url = this.urls['api']['ws']['public'];
65
+ const ordersRequest = this.createOrdersRequest(orders, params);
66
+ const wrapped = this.wrapAsPostAction(ordersRequest);
67
+ const request = this.safeDict(wrapped, 'request', {});
68
+ const requestId = this.safeString(wrapped, 'requestId');
69
+ const response = await this.watch(url, requestId, request, requestId);
70
+ const responseOjb = this.safeDict(response, 'response', {});
71
+ const data = this.safeDict(responseOjb, 'data', {});
72
+ const statuses = this.safeList(data, 'statuses', []);
73
+ return this.parseOrders(statuses, undefined);
74
+ }
75
+ async createOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
76
+ /**
77
+ * @method
78
+ * @name hyperliquid#createOrder
79
+ * @description create a trade order using WebSocket post request
80
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
81
+ * @param {string} symbol unified symbol of the market to create an order in
82
+ * @param {string} type 'market' or 'limit'
83
+ * @param {string} side 'buy' or 'sell'
84
+ * @param {float} amount how much of currency you want to trade in units of base currency
85
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
86
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
87
+ * @param {string} [params.timeInForce] 'Gtc', 'Ioc', 'Alo'
88
+ * @param {bool} [params.postOnly] true or false whether the order is post-only
89
+ * @param {bool} [params.reduceOnly] true or false whether the order is reduce-only
90
+ * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
91
+ * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
92
+ * @param {string} [params.slippage] the slippage for market order
93
+ * @param {string} [params.vaultAddress] the vault address for order
94
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
95
+ */
96
+ await this.loadMarkets();
97
+ const [order, globalParams] = this.parseCreateOrderArgs(symbol, type, side, amount, price, params);
98
+ const orders = await this.createOrdersWs([order], globalParams);
99
+ return orders[0];
100
+ }
101
+ async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
102
+ /**
103
+ * @method
104
+ * @name hyperliquid#editOrder
105
+ * @description edit a trade order
106
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-an-order
107
+ * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-multiple-orders
108
+ * @param {string} id cancel order id
109
+ * @param {string} symbol unified symbol of the market to create an order in
110
+ * @param {string} type 'market' or 'limit'
111
+ * @param {string} side 'buy' or 'sell'
112
+ * @param {float} amount how much of currency you want to trade in units of base currency
113
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
114
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
115
+ * @param {string} [params.timeInForce] 'Gtc', 'Ioc', 'Alo'
116
+ * @param {bool} [params.postOnly] true or false whether the order is post-only
117
+ * @param {bool} [params.reduceOnly] true or false whether the order is reduce-only
118
+ * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
119
+ * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
120
+ * @param {string} [params.vaultAddress] the vault address for order
121
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
122
+ */
123
+ await this.loadMarkets();
124
+ const market = this.market(symbol);
125
+ const url = this.urls['api']['ws']['public'];
126
+ const postRequest = this.editOrderRequest(id, symbol, type, side, amount, price, params);
127
+ const wrapped = this.wrapAsPostAction(postRequest);
128
+ const request = this.safeDict(wrapped, 'request', {});
129
+ const requestId = this.safeString(wrapped, 'requestId');
130
+ const response = await this.watch(url, requestId, request, requestId);
131
+ // response is the same as in this.editOrder
132
+ const responseObject = this.safeDict(response, 'response', {});
133
+ const dataObject = this.safeDict(responseObject, 'data', {});
134
+ const statuses = this.safeList(dataObject, 'statuses', []);
135
+ const first = this.safeDict(statuses, 0, {});
136
+ return this.parseOrder(first, market);
137
+ }
51
138
  async watchOrderBook(symbol, limit = undefined, params = {}) {
52
139
  /**
53
140
  * @method
@@ -513,6 +600,22 @@ export default class hyperliquid extends hyperliquidRest {
513
600
  const messageHash = 'candles:' + timeframe + ':' + symbol;
514
601
  client.resolve(ohlcv, messageHash);
515
602
  }
603
+ handleWsPost(client, message) {
604
+ // {
605
+ // channel: "post",
606
+ // data: {
607
+ // id: <number>,
608
+ // response: {
609
+ // type: "info" | "action" | "error",
610
+ // payload: { ... }
611
+ // }
612
+ // }
613
+ const data = this.safeDict(message, 'data');
614
+ const id = this.safeString(data, 'id');
615
+ const response = this.safeDict(data, 'response');
616
+ const payload = this.safeDict(response, 'payload');
617
+ client.resolve(payload, id);
618
+ }
516
619
  async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
517
620
  /**
518
621
  * @method
@@ -627,6 +730,7 @@ export default class hyperliquid extends hyperliquidRest {
627
730
  'orderUpdates': this.handleOrder,
628
731
  'userFills': this.handleMyTrades,
629
732
  'webData2': this.handleWsTickers,
733
+ 'post': this.handleWsPost,
630
734
  };
631
735
  const exacMethod = this.safeValue(methods, topic);
632
736
  if (exacMethod !== undefined) {
@@ -657,4 +761,23 @@ export default class hyperliquid extends hyperliquidRest {
657
761
  client.lastPong = this.safeInteger(message, 'pong');
658
762
  return message;
659
763
  }
764
+ requestId() {
765
+ const requestId = this.sum(this.safeInteger(this.options, 'requestId', 0), 1);
766
+ this.options['requestId'] = requestId;
767
+ return requestId;
768
+ }
769
+ wrapAsPostAction(request) {
770
+ const requestId = this.requestId();
771
+ return {
772
+ 'requestId': requestId,
773
+ 'request': {
774
+ 'method': 'post',
775
+ 'id': requestId,
776
+ 'request': {
777
+ 'type': 'action',
778
+ 'payload': request,
779
+ },
780
+ },
781
+ };
782
+ }
660
783
  }
@@ -32,6 +32,7 @@ export default class mexc extends mexcRest {
32
32
  'watchTicker': true,
33
33
  'watchTickers': false,
34
34
  'watchTrades': true,
35
+ 'watchTradesForSymbols': false,
35
36
  },
36
37
  'urls': {
37
38
  'api': {
@@ -74,6 +75,8 @@ export default class mexc extends mexcRest {
74
75
  * @method
75
76
  * @name mexc#watchTicker
76
77
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
78
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#individual-symbol-book-ticker-streams
79
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#public-channels
77
80
  * @param {string} symbol unified symbol of the market to fetch the ticker for
78
81
  * @param {object} [params] extra parameters specific to the exchange API endpoint
79
82
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -206,7 +209,7 @@ export default class mexc extends mexcRest {
206
209
  /**
207
210
  * @method
208
211
  * @name mexc#watchOHLCV
209
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#kline-streams
212
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#kline-streams
210
213
  * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
211
214
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
212
215
  * @param {string} timeframe the length of time each candle represents
@@ -352,7 +355,8 @@ export default class mexc extends mexcRest {
352
355
  /**
353
356
  * @method
354
357
  * @name mexc#watchOrderBook
355
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#diff-depth-stream
358
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#diff-depth-stream
359
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#public-channels
356
360
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
357
361
  * @param {string} symbol unified symbol of the market to fetch the order book for
358
362
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -522,7 +526,8 @@ export default class mexc extends mexcRest {
522
526
  /**
523
527
  * @method
524
528
  * @name mexc#watchTrades
525
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#trade-streams
529
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#trade-streams
530
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#public-channels
526
531
  * @description get the list of most recent trades for a particular symbol
527
532
  * @param {string} symbol unified symbol of the market to fetch trades for
528
533
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
@@ -611,7 +616,8 @@ export default class mexc extends mexcRest {
611
616
  /**
612
617
  * @method
613
618
  * @name mexc#watchMyTrades
614
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#spot-account-deals
619
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#spot-account-deals
620
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#private-channels
615
621
  * @description watches information on multiple trades made by the user
616
622
  * @param {string} symbol unified market symbol of the market trades were made in
617
623
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -758,8 +764,8 @@ export default class mexc extends mexcRest {
758
764
  /**
759
765
  * @method
760
766
  * @name mexc#watchOrders
761
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#spot-account-orders
762
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#margin-account-orders
767
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#spot-account-orders
768
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#margin-account-orders
763
769
  * @description watches information on multiple orders made by the user
764
770
  * @param {string} symbol unified market symbol of the market orders were made in
765
771
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -1010,7 +1016,7 @@ export default class mexc extends mexcRest {
1010
1016
  /**
1011
1017
  * @method
1012
1018
  * @name mexc#watchBalance
1013
- * @see https://mxcdevelop.github.io/apidocs/spot_v3_en/#spot-account-upadte
1019
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#spot-account-upadte
1014
1020
  * @description watch balance and get the amount of funds available for trading or funds locked in orders
1015
1021
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1016
1022
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
package/js/src/pro/woo.js CHANGED
@@ -24,6 +24,7 @@ export default class woo extends wooRest {
24
24
  'watchTicker': true,
25
25
  'watchTickers': true,
26
26
  'watchTrades': true,
27
+ 'watchTradesForSymbols': false,
27
28
  'watchPositions': true,
28
29
  },
29
30
  'urls': {
@@ -25,6 +25,7 @@ export default class woofipro extends woofiproRest {
25
25
  'watchTicker': true,
26
26
  'watchTickers': true,
27
27
  'watchTrades': true,
28
+ 'watchTradesForSymbols': false,
28
29
  'watchPositions': true,
29
30
  },
30
31
  'urls': {
package/js/src/pro/xt.js CHANGED
@@ -18,6 +18,7 @@ export default class xt extends xtRest {
18
18
  'watchTicker': true,
19
19
  'watchTickers': true,
20
20
  'watchTrades': true,
21
+ 'watchTradesForSymbols': false,
21
22
  'watchBalance': true,
22
23
  'watchOrders': true,
23
24
  'watchMyTrades': true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.3.85",
3
+ "version": "4.3.86",
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",