ccxt 4.3.46 → 4.3.48
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/base/functions/number.js +2 -2
- package/dist/cjs/src/binance.js +6 -3
- package/dist/cjs/src/bitget.js +1 -1
- package/dist/cjs/src/bitmart.js +1 -1
- package/dist/cjs/src/gate.js +103 -54
- package/dist/cjs/src/hyperliquid.js +27 -0
- package/dist/cjs/src/krakenfutures.js +5 -1
- package/dist/cjs/src/pro/bingx.js +5 -5
- package/dist/cjs/src/pro/coinex.js +3 -2
- 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/base/functions/number.js +2 -2
- package/js/src/binance.d.ts +1 -1
- package/js/src/binance.js +6 -3
- package/js/src/bitget.js +1 -1
- package/js/src/bitmart.js +1 -1
- package/js/src/gate.d.ts +4 -0
- package/js/src/gate.js +103 -54
- package/js/src/hyperliquid.d.ts +2 -1
- package/js/src/hyperliquid.js +27 -0
- package/js/src/krakenfutures.js +5 -1
- package/js/src/pro/bingx.js +5 -5
- package/js/src/pro/coinex.js +3 -2
- 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/dist/cjs/src/pro/gate.js
CHANGED
|
@@ -13,6 +13,27 @@ class gate extends gate$1 {
|
|
|
13
13
|
return this.deepExtend(super.describe(), {
|
|
14
14
|
'has': {
|
|
15
15
|
'ws': true,
|
|
16
|
+
'cancelAllOrdersWs': true,
|
|
17
|
+
'cancelOrderWs': true,
|
|
18
|
+
'createMarketBuyOrderWithCostWs': true,
|
|
19
|
+
'createMarketOrderWs': true,
|
|
20
|
+
'createMarketOrderWithCostWs': false,
|
|
21
|
+
'createMarketSellOrderWithCostWs': false,
|
|
22
|
+
'createOrderWs': true,
|
|
23
|
+
'createOrdersWs': true,
|
|
24
|
+
'createPostOnlyOrderWs': true,
|
|
25
|
+
'createReduceOnlyOrderWs': true,
|
|
26
|
+
'createStopLimitOrderWs': true,
|
|
27
|
+
'createStopLossOrderWs': true,
|
|
28
|
+
'createStopMarketOrderWs': false,
|
|
29
|
+
'createStopOrderWs': true,
|
|
30
|
+
'createTakeProfitOrderWs': true,
|
|
31
|
+
'createTriggerOrderWs': true,
|
|
32
|
+
'editOrderWs': true,
|
|
33
|
+
'fetchOrderWs': true,
|
|
34
|
+
'fetchOrdersWs': false,
|
|
35
|
+
'fetchOpenOrdersWs': true,
|
|
36
|
+
'fetchClosedOrdersWs': true,
|
|
16
37
|
'watchOrderBook': true,
|
|
17
38
|
'watchTicker': true,
|
|
18
39
|
'watchTickers': true,
|
|
@@ -86,15 +107,249 @@ class gate extends gate$1 {
|
|
|
86
107
|
'exceptions': {
|
|
87
108
|
'ws': {
|
|
88
109
|
'exact': {
|
|
110
|
+
'1': errors.BadRequest,
|
|
89
111
|
'2': errors.BadRequest,
|
|
90
112
|
'4': errors.AuthenticationError,
|
|
91
113
|
'6': errors.AuthenticationError,
|
|
92
114
|
'11': errors.AuthenticationError,
|
|
93
115
|
},
|
|
116
|
+
'broad': {},
|
|
94
117
|
},
|
|
95
118
|
},
|
|
96
119
|
});
|
|
97
120
|
}
|
|
121
|
+
async createOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
|
|
122
|
+
/**
|
|
123
|
+
* @method
|
|
124
|
+
* @name gate#createOrderWs
|
|
125
|
+
* @see https://www.gate.io/docs/developers/apiv4/ws/en/#order-place
|
|
126
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-place
|
|
127
|
+
* @description Create an order on the exchange
|
|
128
|
+
* @param {string} symbol Unified CCXT market symbol
|
|
129
|
+
* @param {string} type 'limit' or 'market' *"market" is contract only*
|
|
130
|
+
* @param {string} side 'buy' or 'sell'
|
|
131
|
+
* @param {float} amount the amount of currency to trade
|
|
132
|
+
* @param {float} [price] *ignored in "market" orders* the price at which the order is to be fullfilled at in units of the quote currency
|
|
133
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
134
|
+
* @param {float} [params.stopPrice] The price at which a trigger order is triggered at
|
|
135
|
+
* @param {string} [params.timeInForce] "GTC", "IOC", or "PO"
|
|
136
|
+
* @param {float} [params.stopLossPrice] The price at which a stop loss order is triggered at
|
|
137
|
+
* @param {float} [params.takeProfitPrice] The price at which a take profit order is triggered at
|
|
138
|
+
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
|
|
139
|
+
* @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
|
|
140
|
+
* @param {string} [params.text] User defined information
|
|
141
|
+
* @param {string} [params.account] *spot and margin only* "spot", "margin" or "cross_margin"
|
|
142
|
+
* @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
|
|
143
|
+
* @param {string} [params.settle] *contract only* Unified Currency Code for settle currency
|
|
144
|
+
* @param {bool} [params.reduceOnly] *contract only* Indicates if this order is to reduce the size of a position
|
|
145
|
+
* @param {bool} [params.close] *contract only* Set as true to close the position, with size set to 0
|
|
146
|
+
* @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
|
|
147
|
+
* @param {int} [params.price_type] *contract only* 0 latest deal price, 1 mark price, 2 index price
|
|
148
|
+
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
149
|
+
* @returns {object|undefined} [An order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
150
|
+
*/
|
|
151
|
+
await this.loadMarkets();
|
|
152
|
+
const market = this.market(symbol);
|
|
153
|
+
symbol = market['symbol'];
|
|
154
|
+
const messageType = this.getTypeByMarket(market);
|
|
155
|
+
const channel = messageType + '.order_place';
|
|
156
|
+
const url = this.getUrlByMarket(market);
|
|
157
|
+
params['textIsRequired'] = true;
|
|
158
|
+
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
159
|
+
await this.authenticate(url, messageType);
|
|
160
|
+
const rawOrder = await this.requestPrivate(url, request, channel);
|
|
161
|
+
const order = this.parseOrder(rawOrder, market);
|
|
162
|
+
return order;
|
|
163
|
+
}
|
|
164
|
+
async createOrdersWs(orders, params = {}) {
|
|
165
|
+
/**
|
|
166
|
+
* @method
|
|
167
|
+
* @name gate#createOrdersWs
|
|
168
|
+
* @description create a list of trade orders
|
|
169
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-batch-place
|
|
170
|
+
* @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
|
|
171
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
172
|
+
*/
|
|
173
|
+
await this.loadMarkets();
|
|
174
|
+
const request = this.createOrdersRequest(orders, params);
|
|
175
|
+
const firstOrder = orders[0];
|
|
176
|
+
const market = this.market(firstOrder['symbol']);
|
|
177
|
+
if (market['swap'] !== true) {
|
|
178
|
+
throw new errors.NotSupported(this.id + ' createOrdersWs is not supported for swap markets');
|
|
179
|
+
}
|
|
180
|
+
const messageType = this.getTypeByMarket(market);
|
|
181
|
+
const channel = messageType + '.order_batch_place';
|
|
182
|
+
const url = this.getUrlByMarket(market);
|
|
183
|
+
await this.authenticate(url, messageType);
|
|
184
|
+
const rawOrders = await this.requestPrivate(url, request, channel);
|
|
185
|
+
return this.parseOrders(rawOrders, market);
|
|
186
|
+
}
|
|
187
|
+
async cancelAllOrdersWs(symbol = undefined, params = {}) {
|
|
188
|
+
/**
|
|
189
|
+
* @method
|
|
190
|
+
* @name gate#cancelAllOrdersWs
|
|
191
|
+
* @description cancel all open orders
|
|
192
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#cancel-all-open-orders-matched
|
|
193
|
+
* @see https://www.gate.io/docs/developers/apiv4/ws/en/#order-cancel-all-with-specified-currency-pair
|
|
194
|
+
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
195
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
196
|
+
* @param {string} [params.channel] the channel to use, defaults to spot.order_cancel_cp or futures.order_cancel_cp
|
|
197
|
+
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
198
|
+
*/
|
|
199
|
+
await this.loadMarkets();
|
|
200
|
+
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
201
|
+
const stop = this.safeBool2(params, 'stop', 'trigger');
|
|
202
|
+
const messageType = this.getTypeByMarket(market);
|
|
203
|
+
let channel = messageType + '.order_cancel_cp';
|
|
204
|
+
[channel, params] = this.handleOptionAndParams(params, 'cancelAllOrdersWs', 'channel', channel);
|
|
205
|
+
const url = this.getUrlByMarket(market);
|
|
206
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
207
|
+
const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
|
|
208
|
+
const [request, requestParams] = (type === 'spot') ? this.multiOrderSpotPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
|
|
209
|
+
await this.authenticate(url, messageType);
|
|
210
|
+
const rawOrders = await this.requestPrivate(url, this.extend(request, requestParams), channel);
|
|
211
|
+
return this.parseOrders(rawOrders, market);
|
|
212
|
+
}
|
|
213
|
+
async cancelOrderWs(id, symbol = undefined, params = {}) {
|
|
214
|
+
/**
|
|
215
|
+
* @method
|
|
216
|
+
* @name gate#cancelOrderWs
|
|
217
|
+
* @description Cancels an open order
|
|
218
|
+
* @see https://www.gate.io/docs/developers/apiv4/ws/en/#order-cancel
|
|
219
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-cancel
|
|
220
|
+
* @param {string} id Order id
|
|
221
|
+
* @param {string} symbol Unified market symbol
|
|
222
|
+
* @param {object} [params] Parameters specified by the exchange api
|
|
223
|
+
* @param {bool} [params.stop] True if the order to be cancelled is a trigger order
|
|
224
|
+
* @returns An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
225
|
+
*/
|
|
226
|
+
await this.loadMarkets();
|
|
227
|
+
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
228
|
+
const stop = this.safeValue2(params, 'is_stop_order', 'stop', false);
|
|
229
|
+
params = this.omit(params, ['is_stop_order', 'stop']);
|
|
230
|
+
const [type, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
|
|
231
|
+
const [request, requestParams] = (type === 'spot' || type === 'margin') ? this.spotOrderPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
|
|
232
|
+
const messageType = this.getTypeByMarket(market);
|
|
233
|
+
const channel = messageType + '.order_cancel';
|
|
234
|
+
const url = this.getUrlByMarket(market);
|
|
235
|
+
await this.authenticate(url, messageType);
|
|
236
|
+
request['order_id'] = id.toString();
|
|
237
|
+
const res = await this.requestPrivate(url, this.extend(request, requestParams), channel);
|
|
238
|
+
return this.parseOrder(res, market);
|
|
239
|
+
}
|
|
240
|
+
async editOrderWs(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
241
|
+
/**
|
|
242
|
+
* @method
|
|
243
|
+
* @name gate#editOrderWs
|
|
244
|
+
* @description edit a trade order, gate currently only supports the modification of the price or amount fields
|
|
245
|
+
* @see https://www.gate.io/docs/developers/apiv4/ws/en/#order-amend
|
|
246
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-amend
|
|
247
|
+
* @param {string} id order id
|
|
248
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
249
|
+
* @param {string} type 'market' or 'limit'
|
|
250
|
+
* @param {string} side 'buy' or 'sell'
|
|
251
|
+
* @param {float} amount how much of the currency you want to trade in units of the base currency
|
|
252
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
|
|
253
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
254
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
255
|
+
*/
|
|
256
|
+
await this.loadMarkets();
|
|
257
|
+
const market = this.market(symbol);
|
|
258
|
+
const extendedRequest = this.editOrderRequest(id, symbol, type, side, amount, price, params);
|
|
259
|
+
const messageType = this.getTypeByMarket(market);
|
|
260
|
+
const channel = messageType + '.order_amend';
|
|
261
|
+
const url = this.getUrlByMarket(market);
|
|
262
|
+
await this.authenticate(url, messageType);
|
|
263
|
+
const rawOrder = await this.requestPrivate(url, extendedRequest, channel);
|
|
264
|
+
return this.parseOrder(rawOrder, market);
|
|
265
|
+
}
|
|
266
|
+
async fetchOrderWs(id, symbol = undefined, params = {}) {
|
|
267
|
+
/**
|
|
268
|
+
* @method
|
|
269
|
+
* @name gate#fetchOrderWs
|
|
270
|
+
* @description Retrieves information on an order
|
|
271
|
+
* @see https://www.gate.io/docs/developers/apiv4/ws/en/#order-status
|
|
272
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-status
|
|
273
|
+
* @param {string} id Order id
|
|
274
|
+
* @param {string} symbol Unified market symbol, *required for spot and margin*
|
|
275
|
+
* @param {object} [params] Parameters specified by the exchange api
|
|
276
|
+
* @param {bool} [params.stop] True if the order being fetched is a trigger order
|
|
277
|
+
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
|
|
278
|
+
* @param {string} [params.type] 'spot', 'swap', or 'future', if not provided this.options['defaultMarginMode'] is used
|
|
279
|
+
* @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
|
|
280
|
+
* @returns An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
281
|
+
*/
|
|
282
|
+
await this.loadMarkets();
|
|
283
|
+
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
284
|
+
const [request, requestParams] = this.fetchOrderRequest(id, symbol, params);
|
|
285
|
+
const messageType = this.getTypeByMarket(market);
|
|
286
|
+
const channel = messageType + '.order_status';
|
|
287
|
+
const url = this.getUrlByMarket(market);
|
|
288
|
+
await this.authenticate(url, messageType);
|
|
289
|
+
const rawOrder = await this.requestPrivate(url, this.extend(request, requestParams), channel);
|
|
290
|
+
return this.parseOrder(rawOrder, market);
|
|
291
|
+
}
|
|
292
|
+
async fetchOpenOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
293
|
+
/**
|
|
294
|
+
* @method
|
|
295
|
+
* @name gate#fetchOpenOrdersWs
|
|
296
|
+
* @description fetch all unfilled currently open orders
|
|
297
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-list
|
|
298
|
+
* @param {string} symbol unified market symbol
|
|
299
|
+
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
300
|
+
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
301
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
302
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
303
|
+
*/
|
|
304
|
+
return await this.fetchOrdersByStatusWs('open', symbol, since, limit, params);
|
|
305
|
+
}
|
|
306
|
+
async fetchClosedOrdersWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
307
|
+
/**
|
|
308
|
+
* @method
|
|
309
|
+
* @name gate#fetchClosedOrdersWs
|
|
310
|
+
* @description fetches information on multiple closed orders made by the user
|
|
311
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-list
|
|
312
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
313
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
314
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
315
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
316
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
317
|
+
*/
|
|
318
|
+
return await this.fetchOrdersByStatusWs('finished', symbol, since, limit, params);
|
|
319
|
+
}
|
|
320
|
+
async fetchOrdersByStatusWs(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
321
|
+
/**
|
|
322
|
+
* @method
|
|
323
|
+
* @name gate#fetchOrdersWs
|
|
324
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#order-list
|
|
325
|
+
* @description fetches information on multiple orders made by the user by status
|
|
326
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
327
|
+
* @param {int|undefined} [since] the earliest time in ms to fetch orders for
|
|
328
|
+
* @param {int|undefined} [limit] the maximum number of order structures to retrieve
|
|
329
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
330
|
+
* @param {int} [params.orderId] order id to begin at
|
|
331
|
+
* @param {int} [params.limit] the maximum number of order structures to retrieve
|
|
332
|
+
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
333
|
+
*/
|
|
334
|
+
await this.loadMarkets();
|
|
335
|
+
let market = undefined;
|
|
336
|
+
if (symbol !== undefined) {
|
|
337
|
+
market = this.market(symbol);
|
|
338
|
+
symbol = market['symbol'];
|
|
339
|
+
if (market['swap'] !== true) {
|
|
340
|
+
throw new errors.NotSupported(this.id + ' fetchOrdersByStatusWs is only supported by swap markets. Use rest API for other markets');
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const [request, requestParams] = this.fetchOrdersByStatusRequest(status, symbol, since, limit, params);
|
|
344
|
+
const newRequest = this.omit(request, ['settle']);
|
|
345
|
+
const messageType = this.getTypeByMarket(market);
|
|
346
|
+
const channel = messageType + '.order_list';
|
|
347
|
+
const url = this.getUrlByMarket(market);
|
|
348
|
+
await this.authenticate(url, messageType);
|
|
349
|
+
const rawOrders = await this.requestPrivate(url, this.extend(newRequest, requestParams), channel);
|
|
350
|
+
const orders = this.parseOrders(rawOrders, market);
|
|
351
|
+
return this.filterBySymbolSinceLimit(orders, symbol, since, limit);
|
|
352
|
+
}
|
|
98
353
|
async watchOrderBook(symbol, limit = undefined, params = {}) {
|
|
99
354
|
/**
|
|
100
355
|
* @method
|
|
@@ -1221,42 +1476,59 @@ class gate extends gate$1 {
|
|
|
1221
1476
|
});
|
|
1222
1477
|
}
|
|
1223
1478
|
handleErrorMessage(client, message) {
|
|
1224
|
-
//
|
|
1225
|
-
//
|
|
1226
|
-
//
|
|
1227
|
-
//
|
|
1228
|
-
//
|
|
1229
|
-
// }
|
|
1230
|
-
//
|
|
1231
|
-
//
|
|
1232
|
-
//
|
|
1233
|
-
//
|
|
1234
|
-
//
|
|
1235
|
-
//
|
|
1236
|
-
//
|
|
1237
|
-
//
|
|
1238
|
-
//
|
|
1239
|
-
//
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1479
|
+
//
|
|
1480
|
+
// {
|
|
1481
|
+
// "time": 1647274664,
|
|
1482
|
+
// "channel": "futures.orders",
|
|
1483
|
+
// "event": "subscribe",
|
|
1484
|
+
// "error": { code: 2, message: "unknown contract BTC_USDT_20220318" },
|
|
1485
|
+
// }
|
|
1486
|
+
// {
|
|
1487
|
+
// "time": 1647276473,
|
|
1488
|
+
// "channel": "futures.orders",
|
|
1489
|
+
// "event": "subscribe",
|
|
1490
|
+
// "error": {
|
|
1491
|
+
// "code": 4,
|
|
1492
|
+
// "message": "{"label":"INVALID_KEY","message":"Invalid key provided"}\n"
|
|
1493
|
+
// },
|
|
1494
|
+
// "result": null
|
|
1495
|
+
// }
|
|
1496
|
+
// {
|
|
1497
|
+
// header: {
|
|
1498
|
+
// response_time: '1718551891329',
|
|
1499
|
+
// status: '400',
|
|
1500
|
+
// channel: 'spot.order_place',
|
|
1501
|
+
// event: 'api',
|
|
1502
|
+
// client_id: '81.34.68.6-0xc16375e2c0',
|
|
1503
|
+
// conn_id: '9539116e0e09678f'
|
|
1504
|
+
// },
|
|
1505
|
+
// data: { errs: { label: 'AUTHENTICATION_FAILED', message: 'Not login' } },
|
|
1506
|
+
// request_id: '10406147'
|
|
1507
|
+
// }
|
|
1508
|
+
//
|
|
1509
|
+
const data = this.safeDict(message, 'data');
|
|
1510
|
+
const errs = this.safeDict(data, 'errs');
|
|
1511
|
+
const error = this.safeDict(message, 'error', errs);
|
|
1512
|
+
const code = this.safeString2(error, 'code', 'label');
|
|
1513
|
+
const id = this.safeString2(message, 'id', 'requestId');
|
|
1514
|
+
if (error !== undefined) {
|
|
1247
1515
|
const messageHash = this.safeString(client.subscriptions, id);
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1516
|
+
try {
|
|
1517
|
+
this.throwExactlyMatchedException(this.exceptions['ws']['exact'], code, this.json(message));
|
|
1518
|
+
this.throwExactlyMatchedException(this.exceptions['exact'], code, this.json(errs));
|
|
1519
|
+
const errorMessage = this.safeString(error, 'message', this.safeString(errs, 'message'));
|
|
1520
|
+
this.throwBroadlyMatchedException(this.exceptions['ws']['broad'], errorMessage, this.json(message));
|
|
1521
|
+
throw new errors.ExchangeError(this.json(message));
|
|
1522
|
+
}
|
|
1523
|
+
catch (e) {
|
|
1524
|
+
client.reject(e, messageHash);
|
|
1525
|
+
if ((messageHash !== undefined) && (messageHash in client.subscriptions)) {
|
|
1526
|
+
delete client.subscriptions[messageHash];
|
|
1257
1527
|
}
|
|
1258
1528
|
}
|
|
1259
|
-
|
|
1529
|
+
if (id !== undefined) {
|
|
1530
|
+
delete client.subscriptions[id];
|
|
1531
|
+
}
|
|
1260
1532
|
return true;
|
|
1261
1533
|
}
|
|
1262
1534
|
return false;
|
|
@@ -1399,6 +1671,20 @@ class gate extends gate$1 {
|
|
|
1399
1671
|
if (method !== undefined) {
|
|
1400
1672
|
method.call(this, client, message);
|
|
1401
1673
|
}
|
|
1674
|
+
const requestId = this.safeString(message, 'request_id');
|
|
1675
|
+
if (requestId === 'authenticated') {
|
|
1676
|
+
this.handleAuthenticationMessage(client, message);
|
|
1677
|
+
return;
|
|
1678
|
+
}
|
|
1679
|
+
if (requestId !== undefined) {
|
|
1680
|
+
const data = this.safeDict(message, 'data');
|
|
1681
|
+
// use safeValue as result may be Array or an Object
|
|
1682
|
+
const result = this.safeValue(data, 'result');
|
|
1683
|
+
const ack = this.safeBool(message, 'ack');
|
|
1684
|
+
if (ack !== true) {
|
|
1685
|
+
client.resolve(result, requestId);
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1402
1688
|
}
|
|
1403
1689
|
getUrlByMarket(market) {
|
|
1404
1690
|
const baseUrl = this.urls['api'][market['type']];
|
|
@@ -1485,6 +1771,51 @@ class gate extends gate$1 {
|
|
|
1485
1771
|
const message = this.extend(request, params);
|
|
1486
1772
|
return await this.watchMultiple(url, messageHashes, message, messageHashes);
|
|
1487
1773
|
}
|
|
1774
|
+
async authenticate(url, messageType) {
|
|
1775
|
+
const channel = messageType + '.login';
|
|
1776
|
+
const client = this.client(url);
|
|
1777
|
+
const messageHash = 'authenticated';
|
|
1778
|
+
const future = client.future(messageHash);
|
|
1779
|
+
const authenticated = this.safeValue(client.subscriptions, messageHash);
|
|
1780
|
+
if (authenticated === undefined) {
|
|
1781
|
+
return await this.requestPrivate(url, {}, channel, messageHash);
|
|
1782
|
+
}
|
|
1783
|
+
return future;
|
|
1784
|
+
}
|
|
1785
|
+
handleAuthenticationMessage(client, message) {
|
|
1786
|
+
const messageHash = 'authenticated';
|
|
1787
|
+
const future = this.safeValue(client.futures, messageHash);
|
|
1788
|
+
future.resolve(true);
|
|
1789
|
+
}
|
|
1790
|
+
async requestPrivate(url, reqParams, channel, requestId = undefined) {
|
|
1791
|
+
this.checkRequiredCredentials();
|
|
1792
|
+
// uid is required for some subscriptions only so it's not a part of required credentials
|
|
1793
|
+
const event = 'api';
|
|
1794
|
+
if (requestId === undefined) {
|
|
1795
|
+
const reqId = this.requestId();
|
|
1796
|
+
requestId = reqId.toString();
|
|
1797
|
+
}
|
|
1798
|
+
const messageHash = requestId;
|
|
1799
|
+
const time = this.seconds();
|
|
1800
|
+
// unfortunately, PHP demands double quotes for the escaped newline symbol
|
|
1801
|
+
const signatureString = [event, channel, this.json(reqParams), time.toString()].join("\n"); // eslint-disable-line quotes
|
|
1802
|
+
const signature = this.hmac(this.encode(signatureString), this.encode(this.secret), sha512.sha512, 'hex');
|
|
1803
|
+
const payload = {
|
|
1804
|
+
'req_id': requestId,
|
|
1805
|
+
'timestamp': time.toString(),
|
|
1806
|
+
'api_key': this.apiKey,
|
|
1807
|
+
'signature': signature,
|
|
1808
|
+
'req_param': reqParams,
|
|
1809
|
+
};
|
|
1810
|
+
const request = {
|
|
1811
|
+
'id': requestId,
|
|
1812
|
+
'time': time,
|
|
1813
|
+
'channel': channel,
|
|
1814
|
+
'event': event,
|
|
1815
|
+
'payload': payload,
|
|
1816
|
+
};
|
|
1817
|
+
return await this.watch(url, messageHash, request, messageHash);
|
|
1818
|
+
}
|
|
1488
1819
|
async subscribePrivate(url, messageHash, payload, channel, params, requiresUid = false) {
|
|
1489
1820
|
this.checkRequiredCredentials();
|
|
1490
1821
|
// uid is required for some subscriptions only so it's not a part of required credentials
|
|
@@ -1514,7 +1845,7 @@ class gate extends gate$1 {
|
|
|
1514
1845
|
'id': requestId,
|
|
1515
1846
|
'time': time,
|
|
1516
1847
|
'channel': channel,
|
|
1517
|
-
'event':
|
|
1848
|
+
'event': event,
|
|
1518
1849
|
'auth': auth,
|
|
1519
1850
|
};
|
|
1520
1851
|
if (payload !== undefined) {
|
package/dist/cjs/src/woo.js
CHANGED
|
@@ -2534,6 +2534,12 @@ class woo extends woo$1 {
|
|
|
2534
2534
|
url += '?' + this.urlencode(params);
|
|
2535
2535
|
}
|
|
2536
2536
|
}
|
|
2537
|
+
else if (access === 'pub') {
|
|
2538
|
+
url += pathWithParams;
|
|
2539
|
+
if (Object.keys(params).length) {
|
|
2540
|
+
url += '?' + this.urlencode(params);
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2537
2543
|
else {
|
|
2538
2544
|
this.checkRequiredCredentials();
|
|
2539
2545
|
if (method === 'POST' && (path === 'algo/order' || path === 'order')) {
|
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 { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, TransferEntries, LeverageTiers } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, 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
|
+
declare const version = "4.3.47";
|
|
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, MarketClosed, 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.
|
|
41
|
+
const version = '4.3.48';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -17,6 +17,8 @@ interface Exchange {
|
|
|
17
17
|
privateGetTransfers(params?: {}): Promise<implicitReturnType>;
|
|
18
18
|
privateGetLeveragepreferences(params?: {}): Promise<implicitReturnType>;
|
|
19
19
|
privateGetPnlpreferences(params?: {}): Promise<implicitReturnType>;
|
|
20
|
+
privateGetAssignmentprogramCurrent(params?: {}): Promise<implicitReturnType>;
|
|
21
|
+
privateGetAssignmentprogramHistory(params?: {}): Promise<implicitReturnType>;
|
|
20
22
|
privatePostSendorder(params?: {}): Promise<implicitReturnType>;
|
|
21
23
|
privatePostEditorder(params?: {}): Promise<implicitReturnType>;
|
|
22
24
|
privatePostCancelorder(params?: {}): Promise<implicitReturnType>;
|
|
@@ -25,6 +27,8 @@ interface Exchange {
|
|
|
25
27
|
privatePostCancelallorders(params?: {}): Promise<implicitReturnType>;
|
|
26
28
|
privatePostCancelallordersafter(params?: {}): Promise<implicitReturnType>;
|
|
27
29
|
privatePostWithdrawal(params?: {}): Promise<implicitReturnType>;
|
|
30
|
+
privatePostAssignmentprogramAdd(params?: {}): Promise<implicitReturnType>;
|
|
31
|
+
privatePostAssignmentprogramDelete(params?: {}): Promise<implicitReturnType>;
|
|
28
32
|
privatePutLeveragepreferences(params?: {}): Promise<implicitReturnType>;
|
|
29
33
|
privatePutPnlpreferences(params?: {}): Promise<implicitReturnType>;
|
|
30
34
|
chartsGetPriceTypeSymbolInterval(params?: {}): Promise<implicitReturnType>;
|
|
@@ -84,8 +84,8 @@ const truncate_to_string = (num, precision = 0) => {
|
|
|
84
84
|
const truncate = (num, precision = 0) => parseFloat(truncate_to_string(num, precision));
|
|
85
85
|
function precisionFromString(str) {
|
|
86
86
|
// support string formats like '1e-4'
|
|
87
|
-
if (str.indexOf('e') > -1) {
|
|
88
|
-
const numStr = str.replace(/\
|
|
87
|
+
if (str.indexOf('e') > -1 || str.indexOf('E') > -1) {
|
|
88
|
+
const numStr = str.replace(/\d\.?\d*[eE]/, '');
|
|
89
89
|
return parseInt(numStr) * -1;
|
|
90
90
|
}
|
|
91
91
|
// support integer formats (without dot) like '1', '10' etc [Note: bug in decimalToPrecision, so this should not be used atm]
|
package/js/src/binance.d.ts
CHANGED
|
@@ -93,7 +93,7 @@ export default class binance extends Exchange {
|
|
|
93
93
|
};
|
|
94
94
|
fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
95
95
|
fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
96
|
-
parseTransactionStatusByType(status: any, type?: any):
|
|
96
|
+
parseTransactionStatusByType(status: any, type?: any): any;
|
|
97
97
|
parseTransaction(transaction: Dict, currency?: Currency): Transaction;
|
|
98
98
|
parseTransferStatus(status: Str): Str;
|
|
99
99
|
parseTransfer(transfer: Dict, currency?: Currency): TransferEntry;
|
package/js/src/binance.js
CHANGED
|
@@ -6169,7 +6169,7 @@ export default class binance extends Exchange {
|
|
|
6169
6169
|
if (!market['spot']) {
|
|
6170
6170
|
throw new NotSupported(this.id + ' createMarketOrderWithCost() supports spot orders only');
|
|
6171
6171
|
}
|
|
6172
|
-
params['
|
|
6172
|
+
params['cost'] = cost;
|
|
6173
6173
|
return await this.createOrder(symbol, 'market', side, cost, undefined, params);
|
|
6174
6174
|
}
|
|
6175
6175
|
async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
|
|
@@ -6188,7 +6188,7 @@ export default class binance extends Exchange {
|
|
|
6188
6188
|
if (!market['spot']) {
|
|
6189
6189
|
throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
6190
6190
|
}
|
|
6191
|
-
params['
|
|
6191
|
+
params['cost'] = cost;
|
|
6192
6192
|
return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
|
|
6193
6193
|
}
|
|
6194
6194
|
async createMarketSellOrderWithCost(symbol, cost, params = {}) {
|
|
@@ -7923,6 +7923,9 @@ export default class binance extends Exchange {
|
|
|
7923
7923
|
return this.parseTransactions(response, currency, since, limit);
|
|
7924
7924
|
}
|
|
7925
7925
|
parseTransactionStatusByType(status, type = undefined) {
|
|
7926
|
+
if (type === undefined) {
|
|
7927
|
+
return status;
|
|
7928
|
+
}
|
|
7926
7929
|
const statusesByType = {
|
|
7927
7930
|
'deposit': {
|
|
7928
7931
|
'0': 'pending',
|
|
@@ -8809,7 +8812,7 @@ export default class binance extends Exchange {
|
|
|
8809
8812
|
const request = {
|
|
8810
8813
|
'coin': currency['id'],
|
|
8811
8814
|
'address': address,
|
|
8812
|
-
'amount': amount,
|
|
8815
|
+
'amount': this.currencyToPrecision(code, amount),
|
|
8813
8816
|
// https://binance-docs.github.io/apidocs/spot/en/#withdraw-sapi
|
|
8814
8817
|
// issue sapiGetCapitalConfigGetall () to get networks for withdrawing USDT ERC20 vs USDT Omni
|
|
8815
8818
|
// 'network': 'ETH', // 'BTC', 'TRX', etc, optional
|
package/js/src/bitget.js
CHANGED
|
@@ -4414,7 +4414,7 @@ export default class bitget extends Exchange {
|
|
|
4414
4414
|
}
|
|
4415
4415
|
if (marginMode !== undefined) {
|
|
4416
4416
|
request['loanType'] = 'normal';
|
|
4417
|
-
if (
|
|
4417
|
+
if (isMarketOrder && (side === 'buy')) {
|
|
4418
4418
|
request['quoteSize'] = quantity;
|
|
4419
4419
|
}
|
|
4420
4420
|
else {
|
package/js/src/bitmart.js
CHANGED
|
@@ -2333,7 +2333,7 @@ export default class bitmart extends Exchange {
|
|
|
2333
2333
|
const trailingActivationPrice = this.safeNumber(order, 'activation_price');
|
|
2334
2334
|
return this.safeOrder({
|
|
2335
2335
|
'id': id,
|
|
2336
|
-
'clientOrderId': this.
|
|
2336
|
+
'clientOrderId': this.safeString2(order, 'client_order_id', 'clientOrderId'),
|
|
2337
2337
|
'info': order,
|
|
2338
2338
|
'timestamp': timestamp,
|
|
2339
2339
|
'datetime': this.iso8601(timestamp),
|
package/js/src/gate.d.ts
CHANGED
|
@@ -165,15 +165,19 @@ export default class gate extends Exchange {
|
|
|
165
165
|
parseTransactionType(type: any): string;
|
|
166
166
|
parseTransaction(transaction: Dict, currency?: Currency): Transaction;
|
|
167
167
|
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
|
|
168
|
+
createOrdersRequest(orders: OrderRequest[], params?: {}): any[];
|
|
168
169
|
createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
|
|
169
170
|
createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): any;
|
|
170
171
|
createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
|
|
172
|
+
editOrderRequest(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): any;
|
|
171
173
|
editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
|
|
172
174
|
parseOrderStatus(status: Str): string;
|
|
173
175
|
parseOrder(order: Dict, market?: Market): Order;
|
|
176
|
+
fetchOrderRequest(id: string, symbol?: Str, params?: {}): any[];
|
|
174
177
|
fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
175
178
|
fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
176
179
|
fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
180
|
+
fetchOrdersByStatusRequest(status: any, symbol?: Str, since?: Int, limit?: Int, params?: {}): any[];
|
|
177
181
|
fetchOrdersByStatus(status: any, symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
178
182
|
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
179
183
|
cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
|