ccxt 4.3.47 → 4.3.49
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/README.md +3 -3
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ace.js +4 -7
- package/dist/cjs/src/binance.js +19 -22
- package/dist/cjs/src/bitso.js +13 -1
- package/dist/cjs/src/gate.js +103 -54
- package/dist/cjs/src/hyperliquid.js +14 -2
- package/dist/cjs/src/kraken.js +4 -3
- package/dist/cjs/src/krakenfutures.js +6 -2
- package/dist/cjs/src/pro/bingx.js +5 -5
- package/dist/cjs/src/pro/coinbaseinternational.js +5 -0
- package/dist/cjs/src/pro/gate.js +365 -34
- package/dist/cjs/src/woo.js +6 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/krakenfutures.d.ts +4 -0
- package/js/src/ace.js +4 -7
- package/js/src/binance.d.ts +1 -1
- package/js/src/binance.js +20 -23
- package/js/src/bitso.d.ts +1 -1
- package/js/src/bitso.js +13 -1
- package/js/src/coinbase.d.ts +1 -1
- package/js/src/gate.d.ts +4 -0
- package/js/src/gate.js +103 -54
- package/js/src/hyperliquid.d.ts +2 -2
- package/js/src/hyperliquid.js +14 -2
- package/js/src/kraken.js +4 -3
- package/js/src/krakenfutures.js +6 -2
- package/js/src/pro/bingx.js +5 -5
- package/js/src/pro/coinbaseinternational.js +5 -0
- package/js/src/pro/gate.d.ts +15 -3
- package/js/src/pro/gate.js +366 -35
- package/js/src/woo.js +6 -0
- package/package.json +1 -1
package/js/src/pro/gate.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import gateRest from '../gate.js';
|
|
2
|
-
import type { Int, Str, Strings, OrderBook, Order, Trade, Ticker, Tickers, OHLCV, Position, Balances, Liquidation } from '../base/types.js';
|
|
2
|
+
import type { Int, Str, Strings, OrderBook, Order, Trade, Ticker, Tickers, OHLCV, Position, Balances, Liquidation, OrderType, OrderSide, Num, Market, MarketType, OrderRequest } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class gate extends gateRest {
|
|
5
5
|
describe(): any;
|
|
6
|
+
createOrderWs(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
|
|
7
|
+
createOrdersWs(orders: OrderRequest[], params?: {}): Promise<Order[]>;
|
|
8
|
+
cancelAllOrdersWs(symbol?: Str, params?: {}): Promise<Order[]>;
|
|
9
|
+
cancelOrderWs(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
10
|
+
editOrderWs(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
|
|
11
|
+
fetchOrderWs(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
12
|
+
fetchOpenOrdersWs(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
13
|
+
fetchClosedOrdersWs(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
14
|
+
fetchOrdersByStatusWs(status: string, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
6
15
|
watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
7
16
|
handleOrderBookSubscription(client: Client, message: any, subscription: any): void;
|
|
8
17
|
handleOrderBook(client: Client, message: any): void;
|
|
@@ -40,11 +49,14 @@ export default class gate extends gateRest {
|
|
|
40
49
|
handleSubscriptionStatus(client: Client, message: any): void;
|
|
41
50
|
handleMessage(client: Client, message: any): void;
|
|
42
51
|
getUrlByMarket(market: any): any;
|
|
43
|
-
getTypeByMarket(market:
|
|
44
|
-
getUrlByMarketType(type:
|
|
52
|
+
getTypeByMarket(market: Market): "spot" | "futures" | "options";
|
|
53
|
+
getUrlByMarketType(type: MarketType, isInverse?: boolean): any;
|
|
45
54
|
getMarketTypeByUrl(url: string): any;
|
|
46
55
|
requestId(): any;
|
|
47
56
|
subscribePublic(url: any, messageHash: any, payload: any, channel: any, params?: {}, subscription?: any): Promise<any>;
|
|
48
57
|
subscribePublicMultiple(url: any, messageHashes: any, payload: any, channel: any, params?: {}): Promise<any>;
|
|
58
|
+
authenticate(url: any, messageType: any): Promise<any>;
|
|
59
|
+
handleAuthenticationMessage(client: Client, message: any): void;
|
|
60
|
+
requestPrivate(url: any, reqParams: any, channel: any, requestId?: Str): Promise<any>;
|
|
49
61
|
subscribePrivate(url: any, messageHash: any, payload: any, channel: any, params: any, requiresUid?: boolean): Promise<any>;
|
|
50
62
|
}
|
package/js/src/pro/gate.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import gateRest from '../gate.js';
|
|
9
|
-
import { AuthenticationError, BadRequest, ArgumentsRequired, InvalidNonce } from '../base/errors.js';
|
|
9
|
+
import { AuthenticationError, BadRequest, ArgumentsRequired, InvalidNonce, ExchangeError, NotSupported } from '../base/errors.js';
|
|
10
10
|
import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
|
|
11
11
|
import { sha512 } from '../static_dependencies/noble-hashes/sha512.js';
|
|
12
12
|
import Precise from '../base/Precise.js';
|
|
@@ -16,6 +16,27 @@ export default class gate extends gateRest {
|
|
|
16
16
|
return this.deepExtend(super.describe(), {
|
|
17
17
|
'has': {
|
|
18
18
|
'ws': true,
|
|
19
|
+
'cancelAllOrdersWs': true,
|
|
20
|
+
'cancelOrderWs': true,
|
|
21
|
+
'createMarketBuyOrderWithCostWs': true,
|
|
22
|
+
'createMarketOrderWs': true,
|
|
23
|
+
'createMarketOrderWithCostWs': false,
|
|
24
|
+
'createMarketSellOrderWithCostWs': false,
|
|
25
|
+
'createOrderWs': true,
|
|
26
|
+
'createOrdersWs': true,
|
|
27
|
+
'createPostOnlyOrderWs': true,
|
|
28
|
+
'createReduceOnlyOrderWs': true,
|
|
29
|
+
'createStopLimitOrderWs': true,
|
|
30
|
+
'createStopLossOrderWs': true,
|
|
31
|
+
'createStopMarketOrderWs': false,
|
|
32
|
+
'createStopOrderWs': true,
|
|
33
|
+
'createTakeProfitOrderWs': true,
|
|
34
|
+
'createTriggerOrderWs': true,
|
|
35
|
+
'editOrderWs': true,
|
|
36
|
+
'fetchOrderWs': true,
|
|
37
|
+
'fetchOrdersWs': false,
|
|
38
|
+
'fetchOpenOrdersWs': true,
|
|
39
|
+
'fetchClosedOrdersWs': true,
|
|
19
40
|
'watchOrderBook': true,
|
|
20
41
|
'watchTicker': true,
|
|
21
42
|
'watchTickers': true,
|
|
@@ -89,15 +110,249 @@ export default class gate extends gateRest {
|
|
|
89
110
|
'exceptions': {
|
|
90
111
|
'ws': {
|
|
91
112
|
'exact': {
|
|
113
|
+
'1': BadRequest,
|
|
92
114
|
'2': BadRequest,
|
|
93
115
|
'4': AuthenticationError,
|
|
94
116
|
'6': AuthenticationError,
|
|
95
117
|
'11': AuthenticationError,
|
|
96
118
|
},
|
|
119
|
+
'broad': {},
|
|
97
120
|
},
|
|
98
121
|
},
|
|
99
122
|
});
|
|
100
123
|
}
|
|
124
|
+
async createOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
|
|
125
|
+
/**
|
|
126
|
+
* @method
|
|
127
|
+
* @name gate#createOrderWs
|
|
128
|
+
* @see https://www.gate.io/docs/developers/apiv4/ws/en/#order-place
|
|
129
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-place
|
|
130
|
+
* @description Create an order on the exchange
|
|
131
|
+
* @param {string} symbol Unified CCXT market symbol
|
|
132
|
+
* @param {string} type 'limit' or 'market' *"market" is contract only*
|
|
133
|
+
* @param {string} side 'buy' or 'sell'
|
|
134
|
+
* @param {float} amount the amount of currency to trade
|
|
135
|
+
* @param {float} [price] *ignored in "market" orders* the price at which the order is to be fullfilled at in units of the quote currency
|
|
136
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
137
|
+
* @param {float} [params.stopPrice] The price at which a trigger order is triggered at
|
|
138
|
+
* @param {string} [params.timeInForce] "GTC", "IOC", or "PO"
|
|
139
|
+
* @param {float} [params.stopLossPrice] The price at which a stop loss order is triggered at
|
|
140
|
+
* @param {float} [params.takeProfitPrice] The price at which a take profit order is triggered at
|
|
141
|
+
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
|
|
142
|
+
* @param {int} [params.iceberg] Amount to display for the iceberg order, Null or 0 for normal orders, Set to -1 to hide the order completely
|
|
143
|
+
* @param {string} [params.text] User defined information
|
|
144
|
+
* @param {string} [params.account] *spot and margin only* "spot", "margin" or "cross_margin"
|
|
145
|
+
* @param {bool} [params.auto_borrow] *margin only* Used in margin or cross margin trading to allow automatic loan of insufficient amount if balance is not enough
|
|
146
|
+
* @param {string} [params.settle] *contract only* Unified Currency Code for settle currency
|
|
147
|
+
* @param {bool} [params.reduceOnly] *contract only* Indicates if this order is to reduce the size of a position
|
|
148
|
+
* @param {bool} [params.close] *contract only* Set as true to close the position, with size set to 0
|
|
149
|
+
* @param {bool} [params.auto_size] *contract only* Set side to close dual-mode position, close_long closes the long side, while close_short the short one, size also needs to be set to 0
|
|
150
|
+
* @param {int} [params.price_type] *contract only* 0 latest deal price, 1 mark price, 2 index price
|
|
151
|
+
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
152
|
+
* @returns {object|undefined} [An order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
153
|
+
*/
|
|
154
|
+
await this.loadMarkets();
|
|
155
|
+
const market = this.market(symbol);
|
|
156
|
+
symbol = market['symbol'];
|
|
157
|
+
const messageType = this.getTypeByMarket(market);
|
|
158
|
+
const channel = messageType + '.order_place';
|
|
159
|
+
const url = this.getUrlByMarket(market);
|
|
160
|
+
params['textIsRequired'] = true;
|
|
161
|
+
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
162
|
+
await this.authenticate(url, messageType);
|
|
163
|
+
const rawOrder = await this.requestPrivate(url, request, channel);
|
|
164
|
+
const order = this.parseOrder(rawOrder, market);
|
|
165
|
+
return order;
|
|
166
|
+
}
|
|
167
|
+
async createOrdersWs(orders, params = {}) {
|
|
168
|
+
/**
|
|
169
|
+
* @method
|
|
170
|
+
* @name gate#createOrdersWs
|
|
171
|
+
* @description create a list of trade orders
|
|
172
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-batch-place
|
|
173
|
+
* @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
|
|
174
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
175
|
+
*/
|
|
176
|
+
await this.loadMarkets();
|
|
177
|
+
const request = this.createOrdersRequest(orders, params);
|
|
178
|
+
const firstOrder = orders[0];
|
|
179
|
+
const market = this.market(firstOrder['symbol']);
|
|
180
|
+
if (market['swap'] !== true) {
|
|
181
|
+
throw new NotSupported(this.id + ' createOrdersWs is not supported for swap markets');
|
|
182
|
+
}
|
|
183
|
+
const messageType = this.getTypeByMarket(market);
|
|
184
|
+
const channel = messageType + '.order_batch_place';
|
|
185
|
+
const url = this.getUrlByMarket(market);
|
|
186
|
+
await this.authenticate(url, messageType);
|
|
187
|
+
const rawOrders = await this.requestPrivate(url, request, channel);
|
|
188
|
+
return this.parseOrders(rawOrders, market);
|
|
189
|
+
}
|
|
190
|
+
async cancelAllOrdersWs(symbol = undefined, params = {}) {
|
|
191
|
+
/**
|
|
192
|
+
* @method
|
|
193
|
+
* @name gate#cancelAllOrdersWs
|
|
194
|
+
* @description cancel all open orders
|
|
195
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#cancel-all-open-orders-matched
|
|
196
|
+
* @see https://www.gate.io/docs/developers/apiv4/ws/en/#order-cancel-all-with-specified-currency-pair
|
|
197
|
+
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
198
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
199
|
+
* @param {string} [params.channel] the channel to use, defaults to spot.order_cancel_cp or futures.order_cancel_cp
|
|
200
|
+
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
201
|
+
*/
|
|
202
|
+
await this.loadMarkets();
|
|
203
|
+
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
204
|
+
const stop = this.safeBool2(params, 'stop', 'trigger');
|
|
205
|
+
const messageType = this.getTypeByMarket(market);
|
|
206
|
+
let channel = messageType + '.order_cancel_cp';
|
|
207
|
+
[channel, params] = this.handleOptionAndParams(params, 'cancelAllOrdersWs', 'channel', channel);
|
|
208
|
+
const url = this.getUrlByMarket(market);
|
|
209
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
210
|
+
const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
|
|
211
|
+
const [request, requestParams] = (type === 'spot') ? this.multiOrderSpotPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
|
|
212
|
+
await this.authenticate(url, messageType);
|
|
213
|
+
const rawOrders = await this.requestPrivate(url, this.extend(request, requestParams), channel);
|
|
214
|
+
return this.parseOrders(rawOrders, market);
|
|
215
|
+
}
|
|
216
|
+
async cancelOrderWs(id, symbol = undefined, params = {}) {
|
|
217
|
+
/**
|
|
218
|
+
* @method
|
|
219
|
+
* @name gate#cancelOrderWs
|
|
220
|
+
* @description Cancels an open order
|
|
221
|
+
* @see https://www.gate.io/docs/developers/apiv4/ws/en/#order-cancel
|
|
222
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-cancel
|
|
223
|
+
* @param {string} id Order id
|
|
224
|
+
* @param {string} symbol Unified market symbol
|
|
225
|
+
* @param {object} [params] Parameters specified by the exchange api
|
|
226
|
+
* @param {bool} [params.stop] True if the order to be cancelled is a trigger order
|
|
227
|
+
* @returns An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
228
|
+
*/
|
|
229
|
+
await this.loadMarkets();
|
|
230
|
+
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
231
|
+
const stop = this.safeValue2(params, 'is_stop_order', 'stop', false);
|
|
232
|
+
params = this.omit(params, ['is_stop_order', 'stop']);
|
|
233
|
+
const [type, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
|
|
234
|
+
const [request, requestParams] = (type === 'spot' || type === 'margin') ? this.spotOrderPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
|
|
235
|
+
const messageType = this.getTypeByMarket(market);
|
|
236
|
+
const channel = messageType + '.order_cancel';
|
|
237
|
+
const url = this.getUrlByMarket(market);
|
|
238
|
+
await this.authenticate(url, messageType);
|
|
239
|
+
request['order_id'] = id.toString();
|
|
240
|
+
const res = await this.requestPrivate(url, this.extend(request, requestParams), channel);
|
|
241
|
+
return this.parseOrder(res, market);
|
|
242
|
+
}
|
|
243
|
+
async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
244
|
+
/**
|
|
245
|
+
* @method
|
|
246
|
+
* @name gate#editOrderWs
|
|
247
|
+
* @description edit a trade order, gate currently only supports the modification of the price or amount fields
|
|
248
|
+
* @see https://www.gate.io/docs/developers/apiv4/ws/en/#order-amend
|
|
249
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-amend
|
|
250
|
+
* @param {string} id order id
|
|
251
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
252
|
+
* @param {string} type 'market' or 'limit'
|
|
253
|
+
* @param {string} side 'buy' or 'sell'
|
|
254
|
+
* @param {float} amount how much of the currency you want to trade in units of the base currency
|
|
255
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
|
|
256
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
257
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
258
|
+
*/
|
|
259
|
+
await this.loadMarkets();
|
|
260
|
+
const market = this.market(symbol);
|
|
261
|
+
const extendedRequest = this.editOrderRequest(id, symbol, type, side, amount, price, params);
|
|
262
|
+
const messageType = this.getTypeByMarket(market);
|
|
263
|
+
const channel = messageType + '.order_amend';
|
|
264
|
+
const url = this.getUrlByMarket(market);
|
|
265
|
+
await this.authenticate(url, messageType);
|
|
266
|
+
const rawOrder = await this.requestPrivate(url, extendedRequest, channel);
|
|
267
|
+
return this.parseOrder(rawOrder, market);
|
|
268
|
+
}
|
|
269
|
+
async fetchOrderWs(id, symbol = undefined, params = {}) {
|
|
270
|
+
/**
|
|
271
|
+
* @method
|
|
272
|
+
* @name gate#fetchOrderWs
|
|
273
|
+
* @description Retrieves information on an order
|
|
274
|
+
* @see https://www.gate.io/docs/developers/apiv4/ws/en/#order-status
|
|
275
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-status
|
|
276
|
+
* @param {string} id Order id
|
|
277
|
+
* @param {string} symbol Unified market symbol, *required for spot and margin*
|
|
278
|
+
* @param {object} [params] Parameters specified by the exchange api
|
|
279
|
+
* @param {bool} [params.stop] True if the order being fetched is a trigger order
|
|
280
|
+
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
|
|
281
|
+
* @param {string} [params.type] 'spot', 'swap', or 'future', if not provided this.options['defaultMarginMode'] is used
|
|
282
|
+
* @param {string} [params.settle] 'btc' or 'usdt' - settle currency for perpetual swap and future - market settle currency is used if symbol !== undefined, default="usdt" for swap and "btc" for future
|
|
283
|
+
* @returns An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
284
|
+
*/
|
|
285
|
+
await this.loadMarkets();
|
|
286
|
+
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
287
|
+
const [request, requestParams] = this.fetchOrderRequest(id, symbol, params);
|
|
288
|
+
const messageType = this.getTypeByMarket(market);
|
|
289
|
+
const channel = messageType + '.order_status';
|
|
290
|
+
const url = this.getUrlByMarket(market);
|
|
291
|
+
await this.authenticate(url, messageType);
|
|
292
|
+
const rawOrder = await this.requestPrivate(url, this.extend(request, requestParams), channel);
|
|
293
|
+
return this.parseOrder(rawOrder, market);
|
|
294
|
+
}
|
|
295
|
+
async fetchOpenOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
296
|
+
/**
|
|
297
|
+
* @method
|
|
298
|
+
* @name gate#fetchOpenOrdersWs
|
|
299
|
+
* @description fetch all unfilled currently open orders
|
|
300
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-list
|
|
301
|
+
* @param {string} symbol unified market symbol
|
|
302
|
+
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
303
|
+
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
304
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
305
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
306
|
+
*/
|
|
307
|
+
return await this.fetchOrdersByStatusWs('open', symbol, since, limit, params);
|
|
308
|
+
}
|
|
309
|
+
async fetchClosedOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
310
|
+
/**
|
|
311
|
+
* @method
|
|
312
|
+
* @name gate#fetchClosedOrdersWs
|
|
313
|
+
* @description fetches information on multiple closed orders made by the user
|
|
314
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-list
|
|
315
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
316
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
317
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
318
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
319
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
320
|
+
*/
|
|
321
|
+
return await this.fetchOrdersByStatusWs('finished', symbol, since, limit, params);
|
|
322
|
+
}
|
|
323
|
+
async fetchOrdersByStatusWs(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
324
|
+
/**
|
|
325
|
+
* @method
|
|
326
|
+
* @name gate#fetchOrdersWs
|
|
327
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-list
|
|
328
|
+
* @description fetches information on multiple orders made by the user by status
|
|
329
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
330
|
+
* @param {int|undefined} [since] the earliest time in ms to fetch orders for
|
|
331
|
+
* @param {int|undefined} [limit] the maximum number of order structures to retrieve
|
|
332
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
333
|
+
* @param {int} [params.orderId] order id to begin at
|
|
334
|
+
* @param {int} [params.limit] the maximum number of order structures to retrieve
|
|
335
|
+
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
336
|
+
*/
|
|
337
|
+
await this.loadMarkets();
|
|
338
|
+
let market = undefined;
|
|
339
|
+
if (symbol !== undefined) {
|
|
340
|
+
market = this.market(symbol);
|
|
341
|
+
symbol = market['symbol'];
|
|
342
|
+
if (market['swap'] !== true) {
|
|
343
|
+
throw new NotSupported(this.id + ' fetchOrdersByStatusWs is only supported by swap markets. Use rest API for other markets');
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const [request, requestParams] = this.fetchOrdersByStatusRequest(status, symbol, since, limit, params);
|
|
347
|
+
const newRequest = this.omit(request, ['settle']);
|
|
348
|
+
const messageType = this.getTypeByMarket(market);
|
|
349
|
+
const channel = messageType + '.order_list';
|
|
350
|
+
const url = this.getUrlByMarket(market);
|
|
351
|
+
await this.authenticate(url, messageType);
|
|
352
|
+
const rawOrders = await this.requestPrivate(url, this.extend(newRequest, requestParams), channel);
|
|
353
|
+
const orders = this.parseOrders(rawOrders, market);
|
|
354
|
+
return this.filterBySymbolSinceLimit(orders, symbol, since, limit);
|
|
355
|
+
}
|
|
101
356
|
async watchOrderBook(symbol, limit = undefined, params = {}) {
|
|
102
357
|
/**
|
|
103
358
|
* @method
|
|
@@ -1224,42 +1479,59 @@ export default class gate extends gateRest {
|
|
|
1224
1479
|
});
|
|
1225
1480
|
}
|
|
1226
1481
|
handleErrorMessage(client, message) {
|
|
1227
|
-
//
|
|
1228
|
-
//
|
|
1229
|
-
//
|
|
1230
|
-
//
|
|
1231
|
-
//
|
|
1232
|
-
// }
|
|
1233
|
-
//
|
|
1234
|
-
//
|
|
1235
|
-
//
|
|
1236
|
-
//
|
|
1237
|
-
//
|
|
1238
|
-
//
|
|
1239
|
-
//
|
|
1240
|
-
//
|
|
1241
|
-
//
|
|
1242
|
-
//
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1482
|
+
//
|
|
1483
|
+
// {
|
|
1484
|
+
// "time": 1647274664,
|
|
1485
|
+
// "channel": "futures.orders",
|
|
1486
|
+
// "event": "subscribe",
|
|
1487
|
+
// "error": { code: 2, message: "unknown contract BTC_USDT_20220318" },
|
|
1488
|
+
// }
|
|
1489
|
+
// {
|
|
1490
|
+
// "time": 1647276473,
|
|
1491
|
+
// "channel": "futures.orders",
|
|
1492
|
+
// "event": "subscribe",
|
|
1493
|
+
// "error": {
|
|
1494
|
+
// "code": 4,
|
|
1495
|
+
// "message": "{"label":"INVALID_KEY","message":"Invalid key provided"}\n"
|
|
1496
|
+
// },
|
|
1497
|
+
// "result": null
|
|
1498
|
+
// }
|
|
1499
|
+
// {
|
|
1500
|
+
// header: {
|
|
1501
|
+
// response_time: '1718551891329',
|
|
1502
|
+
// status: '400',
|
|
1503
|
+
// channel: 'spot.order_place',
|
|
1504
|
+
// event: 'api',
|
|
1505
|
+
// client_id: '81.34.68.6-0xc16375e2c0',
|
|
1506
|
+
// conn_id: '9539116e0e09678f'
|
|
1507
|
+
// },
|
|
1508
|
+
// data: { errs: { label: 'AUTHENTICATION_FAILED', message: 'Not login' } },
|
|
1509
|
+
// request_id: '10406147'
|
|
1510
|
+
// }
|
|
1511
|
+
//
|
|
1512
|
+
const data = this.safeDict(message, 'data');
|
|
1513
|
+
const errs = this.safeDict(data, 'errs');
|
|
1514
|
+
const error = this.safeDict(message, 'error', errs);
|
|
1515
|
+
const code = this.safeString2(error, 'code', 'label');
|
|
1516
|
+
const id = this.safeString2(message, 'id', 'requestId');
|
|
1517
|
+
if (error !== undefined) {
|
|
1250
1518
|
const messageHash = this.safeString(client.subscriptions, id);
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1519
|
+
try {
|
|
1520
|
+
this.throwExactlyMatchedException(this.exceptions['ws']['exact'], code, this.json(message));
|
|
1521
|
+
this.throwExactlyMatchedException(this.exceptions['exact'], code, this.json(errs));
|
|
1522
|
+
const errorMessage = this.safeString(error, 'message', this.safeString(errs, 'message'));
|
|
1523
|
+
this.throwBroadlyMatchedException(this.exceptions['ws']['broad'], errorMessage, this.json(message));
|
|
1524
|
+
throw new ExchangeError(this.json(message));
|
|
1525
|
+
}
|
|
1526
|
+
catch (e) {
|
|
1527
|
+
client.reject(e, messageHash);
|
|
1528
|
+
if ((messageHash !== undefined) && (messageHash in client.subscriptions)) {
|
|
1529
|
+
delete client.subscriptions[messageHash];
|
|
1260
1530
|
}
|
|
1261
1531
|
}
|
|
1262
|
-
|
|
1532
|
+
if (id !== undefined) {
|
|
1533
|
+
delete client.subscriptions[id];
|
|
1534
|
+
}
|
|
1263
1535
|
return true;
|
|
1264
1536
|
}
|
|
1265
1537
|
return false;
|
|
@@ -1402,6 +1674,20 @@ export default class gate extends gateRest {
|
|
|
1402
1674
|
if (method !== undefined) {
|
|
1403
1675
|
method.call(this, client, message);
|
|
1404
1676
|
}
|
|
1677
|
+
const requestId = this.safeString(message, 'request_id');
|
|
1678
|
+
if (requestId === 'authenticated') {
|
|
1679
|
+
this.handleAuthenticationMessage(client, message);
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
if (requestId !== undefined) {
|
|
1683
|
+
const data = this.safeDict(message, 'data');
|
|
1684
|
+
// use safeValue as result may be Array or an Object
|
|
1685
|
+
const result = this.safeValue(data, 'result');
|
|
1686
|
+
const ack = this.safeBool(message, 'ack');
|
|
1687
|
+
if (ack !== true) {
|
|
1688
|
+
client.resolve(result, requestId);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1405
1691
|
}
|
|
1406
1692
|
getUrlByMarket(market) {
|
|
1407
1693
|
const baseUrl = this.urls['api'][market['type']];
|
|
@@ -1488,6 +1774,51 @@ export default class gate extends gateRest {
|
|
|
1488
1774
|
const message = this.extend(request, params);
|
|
1489
1775
|
return await this.watchMultiple(url, messageHashes, message, messageHashes);
|
|
1490
1776
|
}
|
|
1777
|
+
async authenticate(url, messageType) {
|
|
1778
|
+
const channel = messageType + '.login';
|
|
1779
|
+
const client = this.client(url);
|
|
1780
|
+
const messageHash = 'authenticated';
|
|
1781
|
+
const future = client.future(messageHash);
|
|
1782
|
+
const authenticated = this.safeValue(client.subscriptions, messageHash);
|
|
1783
|
+
if (authenticated === undefined) {
|
|
1784
|
+
return await this.requestPrivate(url, {}, channel, messageHash);
|
|
1785
|
+
}
|
|
1786
|
+
return future;
|
|
1787
|
+
}
|
|
1788
|
+
handleAuthenticationMessage(client, message) {
|
|
1789
|
+
const messageHash = 'authenticated';
|
|
1790
|
+
const future = this.safeValue(client.futures, messageHash);
|
|
1791
|
+
future.resolve(true);
|
|
1792
|
+
}
|
|
1793
|
+
async requestPrivate(url, reqParams, channel, requestId = undefined) {
|
|
1794
|
+
this.checkRequiredCredentials();
|
|
1795
|
+
// uid is required for some subscriptions only so it's not a part of required credentials
|
|
1796
|
+
const event = 'api';
|
|
1797
|
+
if (requestId === undefined) {
|
|
1798
|
+
const reqId = this.requestId();
|
|
1799
|
+
requestId = reqId.toString();
|
|
1800
|
+
}
|
|
1801
|
+
const messageHash = requestId;
|
|
1802
|
+
const time = this.seconds();
|
|
1803
|
+
// unfortunately, PHP demands double quotes for the escaped newline symbol
|
|
1804
|
+
const signatureString = [event, channel, this.json(reqParams), time.toString()].join("\n"); // eslint-disable-line quotes
|
|
1805
|
+
const signature = this.hmac(this.encode(signatureString), this.encode(this.secret), sha512, 'hex');
|
|
1806
|
+
const payload = {
|
|
1807
|
+
'req_id': requestId,
|
|
1808
|
+
'timestamp': time.toString(),
|
|
1809
|
+
'api_key': this.apiKey,
|
|
1810
|
+
'signature': signature,
|
|
1811
|
+
'req_param': reqParams,
|
|
1812
|
+
};
|
|
1813
|
+
const request = {
|
|
1814
|
+
'id': requestId,
|
|
1815
|
+
'time': time,
|
|
1816
|
+
'channel': channel,
|
|
1817
|
+
'event': event,
|
|
1818
|
+
'payload': payload,
|
|
1819
|
+
};
|
|
1820
|
+
return await this.watch(url, messageHash, request, messageHash);
|
|
1821
|
+
}
|
|
1491
1822
|
async subscribePrivate(url, messageHash, payload, channel, params, requiresUid = false) {
|
|
1492
1823
|
this.checkRequiredCredentials();
|
|
1493
1824
|
// uid is required for some subscriptions only so it's not a part of required credentials
|
|
@@ -1517,7 +1848,7 @@ export default class gate extends gateRest {
|
|
|
1517
1848
|
'id': requestId,
|
|
1518
1849
|
'time': time,
|
|
1519
1850
|
'channel': channel,
|
|
1520
|
-
'event':
|
|
1851
|
+
'event': event,
|
|
1521
1852
|
'auth': auth,
|
|
1522
1853
|
};
|
|
1523
1854
|
if (payload !== undefined) {
|
package/js/src/woo.js
CHANGED
|
@@ -2537,6 +2537,12 @@ export default class woo extends Exchange {
|
|
|
2537
2537
|
url += '?' + this.urlencode(params);
|
|
2538
2538
|
}
|
|
2539
2539
|
}
|
|
2540
|
+
else if (access === 'pub') {
|
|
2541
|
+
url += pathWithParams;
|
|
2542
|
+
if (Object.keys(params).length) {
|
|
2543
|
+
url += '?' + this.urlencode(params);
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2540
2546
|
else {
|
|
2541
2547
|
this.checkRequiredCredentials();
|
|
2542
2548
|
if (method === 'POST' && (path === 'algo/order' || path === 'order')) {
|
package/package.json
CHANGED