ccxt 4.3.40 → 4.3.41
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/binance.js +3 -0
- package/dist/cjs/src/bitfinex2.js +1 -1
- package/dist/cjs/src/bithumb.js +9 -1
- package/dist/cjs/src/bitstamp.js +38 -2
- package/dist/cjs/src/coinlist.js +20 -1
- package/dist/cjs/src/coinmate.js +19 -3
- package/dist/cjs/src/coinone.js +1 -1
- package/dist/cjs/src/coinspot.js +13 -2
- package/dist/cjs/src/independentreserve.js +33 -1
- package/dist/cjs/src/indodax.js +43 -2
- package/dist/cjs/src/okx.js +7 -0
- package/dist/cjs/src/pro/alpaca.js +5 -5
- package/dist/cjs/src/pro/ascendex.js +3 -3
- package/dist/cjs/src/pro/bingx.js +293 -47
- package/dist/cjs/src/pro/bitget.js +6 -5
- package/dist/cjs/src/pro/bitrue.js +3 -4
- package/dist/cjs/src/pro/currencycom.js +6 -5
- package/dist/cjs/src/pro/exmo.js +5 -6
- package/dist/cjs/src/pro/gemini.js +4 -3
- package/dist/cjs/src/pro/independentreserve.js +7 -7
- package/dist/cjs/src/pro/lbank.js +4 -4
- package/dist/cjs/src/pro/phemex.js +5 -5
- package/dist/cjs/src/pro/probit.js +4 -4
- package/dist/cjs/src/pro/upbit.js +318 -2
- package/dist/cjs/src/pro/wazirx.js +12 -12
- package/dist/cjs/src/upbit.js +17 -9
- package/dist/cjs/src/woo.js +6 -2
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +2 -0
- package/js/src/abstract/binancecoinm.d.ts +2 -0
- package/js/src/abstract/binanceus.d.ts +2 -0
- package/js/src/abstract/binanceusdm.d.ts +2 -0
- package/js/src/abstract/okx.d.ts +7 -0
- package/js/src/binance.js +3 -0
- package/js/src/bitfinex2.js +1 -1
- package/js/src/bithumb.d.ts +2 -2
- package/js/src/bithumb.js +9 -1
- package/js/src/bitstamp.d.ts +2 -2
- package/js/src/bitstamp.js +38 -2
- package/js/src/coinlist.d.ts +1 -1
- package/js/src/coinlist.js +20 -1
- package/js/src/coinmate.d.ts +1 -3
- package/js/src/coinmate.js +19 -3
- package/js/src/coinone.d.ts +1 -1
- package/js/src/coinone.js +1 -1
- package/js/src/coinspot.d.ts +1 -1
- package/js/src/coinspot.js +13 -2
- package/js/src/independentreserve.d.ts +1 -1
- package/js/src/independentreserve.js +33 -1
- package/js/src/indodax.d.ts +1 -1
- package/js/src/indodax.js +43 -2
- package/js/src/okx.js +7 -0
- package/js/src/pro/alpaca.js +5 -5
- package/js/src/pro/ascendex.js +3 -3
- package/js/src/pro/bingx.d.ts +6 -1
- package/js/src/pro/bingx.js +294 -48
- package/js/src/pro/bitget.js +6 -5
- package/js/src/pro/bitrue.js +3 -4
- package/js/src/pro/currencycom.js +6 -5
- package/js/src/pro/exmo.js +5 -6
- package/js/src/pro/gemini.js +4 -3
- package/js/src/pro/independentreserve.js +7 -7
- package/js/src/pro/lbank.js +4 -4
- package/js/src/pro/phemex.js +5 -5
- package/js/src/pro/probit.js +4 -4
- package/js/src/pro/upbit.d.ts +13 -1
- package/js/src/pro/upbit.js +319 -3
- package/js/src/pro/wazirx.js +12 -12
- package/js/src/upbit.js +17 -9
- package/js/src/woo.d.ts +1 -1
- package/js/src/woo.js +6 -2
- package/package.json +1 -1
package/js/src/pro/phemex.js
CHANGED
|
@@ -709,11 +709,11 @@ export default class phemex extends phemexRest {
|
|
|
709
709
|
client.resolve(orderbook, messageHash);
|
|
710
710
|
}
|
|
711
711
|
else {
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
const changes = this.
|
|
715
|
-
const asks = this.
|
|
716
|
-
const bids = this.
|
|
712
|
+
if (symbol in this.orderbooks) {
|
|
713
|
+
const orderbook = this.orderbooks[symbol];
|
|
714
|
+
const changes = this.safeDict2(message, 'book', 'orderbook_p', {});
|
|
715
|
+
const asks = this.safeList(changes, 'asks', []);
|
|
716
|
+
const bids = this.safeList(changes, 'bids', []);
|
|
717
717
|
this.customHandleDeltas(orderbook['asks'], asks, market);
|
|
718
718
|
this.customHandleDeltas(orderbook['bids'], bids, market);
|
|
719
719
|
orderbook['nonce'] = nonce;
|
package/js/src/pro/probit.js
CHANGED
|
@@ -453,11 +453,11 @@ export default class probit extends probitRest {
|
|
|
453
453
|
const symbol = this.safeSymbol(marketId);
|
|
454
454
|
const dataBySide = this.groupBy(orderBook, 'side');
|
|
455
455
|
const messageHash = 'orderbook:' + symbol;
|
|
456
|
-
let orderbook = this.safeValue(this.orderbooks, symbol);
|
|
457
|
-
if (
|
|
458
|
-
|
|
459
|
-
this.orderbooks[symbol] = orderbook;
|
|
456
|
+
// let orderbook = this.safeValue (this.orderbooks, symbol);
|
|
457
|
+
if (!(symbol in this.orderbooks)) {
|
|
458
|
+
this.orderbooks[symbol] = this.orderBook({});
|
|
460
459
|
}
|
|
460
|
+
const orderbook = this.orderbooks[symbol];
|
|
461
461
|
const reset = this.safeBool(message, 'reset', false);
|
|
462
462
|
if (reset) {
|
|
463
463
|
const snapshot = this.parseOrderBook(dataBySide, symbol, undefined, 'buy', 'sell', 'price', 'quantity');
|
package/js/src/pro/upbit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import upbitRest from '../upbit.js';
|
|
2
|
-
import type { Int, OrderBook, Trade, Ticker } from '../base/types.js';
|
|
2
|
+
import type { Int, Str, Order, OrderBook, Trade, Ticker, Balances } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class upbit extends upbitRest {
|
|
5
5
|
describe(): any;
|
|
@@ -10,5 +10,17 @@ export default class upbit extends upbitRest {
|
|
|
10
10
|
handleTicker(client: Client, message: any): void;
|
|
11
11
|
handleOrderBook(client: Client, message: any): void;
|
|
12
12
|
handleTrades(client: Client, message: any): void;
|
|
13
|
+
authenticate(params?: {}): Promise<import("../base/ws/WsClient.js").default>;
|
|
14
|
+
watchPrivate(symbol: any, channel: any, messageHash: any, params?: {}): Promise<any>;
|
|
15
|
+
watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
16
|
+
watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
17
|
+
parseWsOrderStatus(status: Str): string;
|
|
18
|
+
parseWsOrder(order: any, market?: any): Order;
|
|
19
|
+
parseWsTrade(trade: any, market?: any): Trade;
|
|
20
|
+
handleMyOrder(client: Client, message: any): void;
|
|
21
|
+
handleMyTrade(client: Client, message: any): void;
|
|
22
|
+
handleOrder(client: Client, message: any): void;
|
|
23
|
+
watchBalance(params?: {}): Promise<Balances>;
|
|
24
|
+
handleBalance(client: Client, message: any): void;
|
|
13
25
|
handleMessage(client: Client, message: any): void;
|
|
14
26
|
}
|
package/js/src/pro/upbit.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import upbitRest from '../upbit.js';
|
|
9
|
-
import { ArrayCache } from '../base/ws/Cache.js';
|
|
9
|
+
import { ArrayCache, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
|
|
10
|
+
import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
|
|
11
|
+
import { jwt } from '../base/functions/rsa.js';
|
|
10
12
|
// ---------------------------------------------------------------------------
|
|
11
13
|
export default class upbit extends upbitRest {
|
|
12
14
|
describe() {
|
|
@@ -16,10 +18,13 @@ export default class upbit extends upbitRest {
|
|
|
16
18
|
'watchOrderBook': true,
|
|
17
19
|
'watchTicker': true,
|
|
18
20
|
'watchTrades': true,
|
|
21
|
+
'watchOrders': true,
|
|
22
|
+
'watchMyTrades': true,
|
|
23
|
+
'watchBalance': true,
|
|
19
24
|
},
|
|
20
25
|
'urls': {
|
|
21
26
|
'api': {
|
|
22
|
-
'ws': 'wss://
|
|
27
|
+
'ws': 'wss://{hostname}/websocket/v1',
|
|
23
28
|
},
|
|
24
29
|
},
|
|
25
30
|
'options': {
|
|
@@ -32,7 +37,9 @@ export default class upbit extends upbitRest {
|
|
|
32
37
|
const market = this.market(symbol);
|
|
33
38
|
symbol = market['symbol'];
|
|
34
39
|
const marketId = market['id'];
|
|
35
|
-
const url = this.urls['api']['ws']
|
|
40
|
+
const url = this.implodeParams(this.urls['api']['ws'], {
|
|
41
|
+
'hostname': this.hostname,
|
|
42
|
+
});
|
|
36
43
|
this.options[channel] = this.safeValue(this.options, channel, {});
|
|
37
44
|
this.options[channel][symbol] = true;
|
|
38
45
|
const symbols = Object.keys(this.options[channel]);
|
|
@@ -56,6 +63,7 @@ export default class upbit extends upbitRest {
|
|
|
56
63
|
* @method
|
|
57
64
|
* @name upbit#watchTicker
|
|
58
65
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
66
|
+
* @see https://global-docs.upbit.com/reference/websocket-ticker
|
|
59
67
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
60
68
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
61
69
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -67,6 +75,7 @@ export default class upbit extends upbitRest {
|
|
|
67
75
|
* @method
|
|
68
76
|
* @name upbit#watchTrades
|
|
69
77
|
* @description get the list of most recent trades for a particular symbol
|
|
78
|
+
* @see https://global-docs.upbit.com/reference/websocket-trade
|
|
70
79
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
71
80
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
72
81
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -86,6 +95,7 @@ export default class upbit extends upbitRest {
|
|
|
86
95
|
* @method
|
|
87
96
|
* @name upbit#watchOrderBook
|
|
88
97
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
98
|
+
* @see https://global-docs.upbit.com/reference/websocket-orderbook
|
|
89
99
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
90
100
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
91
101
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -220,11 +230,317 @@ export default class upbit extends upbitRest {
|
|
|
220
230
|
const messageHash = 'trade:' + marketId;
|
|
221
231
|
client.resolve(stored, messageHash);
|
|
222
232
|
}
|
|
233
|
+
async authenticate(params = {}) {
|
|
234
|
+
this.checkRequiredCredentials();
|
|
235
|
+
const authenticated = this.options['ws']['token'];
|
|
236
|
+
if (authenticated === undefined) {
|
|
237
|
+
const auth = {
|
|
238
|
+
'access_key': this.apiKey,
|
|
239
|
+
'nonce': this.uuid(),
|
|
240
|
+
};
|
|
241
|
+
const token = jwt(auth, this.encode(this.secret), sha256, false);
|
|
242
|
+
this.options['ws']['token'] = token;
|
|
243
|
+
this.options['ws']['options']['headers'] = {
|
|
244
|
+
'authorization': 'Bearer ' + token,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
const url = this.urls['api']['ws'] + '/private';
|
|
248
|
+
const client = this.client(url);
|
|
249
|
+
return client;
|
|
250
|
+
}
|
|
251
|
+
async watchPrivate(symbol, channel, messageHash, params = {}) {
|
|
252
|
+
await this.authenticate();
|
|
253
|
+
const request = {
|
|
254
|
+
'type': channel,
|
|
255
|
+
};
|
|
256
|
+
if (symbol !== undefined) {
|
|
257
|
+
await this.loadMarkets();
|
|
258
|
+
const market = this.market(symbol);
|
|
259
|
+
symbol = market['symbol'];
|
|
260
|
+
const symbols = [symbol];
|
|
261
|
+
const marketIds = this.marketIds(symbols);
|
|
262
|
+
request['codes'] = marketIds;
|
|
263
|
+
messageHash = messageHash + ':' + symbol;
|
|
264
|
+
}
|
|
265
|
+
let url = this.implodeParams(this.urls['api']['ws'], {
|
|
266
|
+
'hostname': this.hostname,
|
|
267
|
+
});
|
|
268
|
+
url += '/private';
|
|
269
|
+
const message = [
|
|
270
|
+
{
|
|
271
|
+
'ticket': this.uuid(),
|
|
272
|
+
},
|
|
273
|
+
request,
|
|
274
|
+
];
|
|
275
|
+
return await this.watch(url, messageHash, message, messageHash);
|
|
276
|
+
}
|
|
277
|
+
async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
278
|
+
/**
|
|
279
|
+
* @method
|
|
280
|
+
* @name upbit#watchOrders
|
|
281
|
+
* @description watches information on multiple orders made by the user
|
|
282
|
+
* @see https://global-docs.upbit.com/reference/websocket-myorder
|
|
283
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
284
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
285
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
286
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
287
|
+
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
288
|
+
*/
|
|
289
|
+
await this.loadMarkets();
|
|
290
|
+
const channel = 'myOrder';
|
|
291
|
+
const messageHash = 'myOrder';
|
|
292
|
+
const orders = await this.watchPrivate(symbol, channel, messageHash);
|
|
293
|
+
if (this.newUpdates) {
|
|
294
|
+
limit = orders.getLimit(symbol, limit);
|
|
295
|
+
}
|
|
296
|
+
return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
|
|
297
|
+
}
|
|
298
|
+
async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
299
|
+
/**
|
|
300
|
+
* @method
|
|
301
|
+
* @name upbit#watchMyTrades
|
|
302
|
+
* @description watches information on multiple trades made by the user
|
|
303
|
+
* @see https://global-docs.upbit.com/reference/websocket-myorder
|
|
304
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
305
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
306
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
307
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
308
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
|
|
309
|
+
*/
|
|
310
|
+
await this.loadMarkets();
|
|
311
|
+
const channel = 'myOrder';
|
|
312
|
+
const messageHash = 'myTrades';
|
|
313
|
+
const trades = await this.watchPrivate(symbol, channel, messageHash);
|
|
314
|
+
if (this.newUpdates) {
|
|
315
|
+
limit = trades.getLimit(symbol, limit);
|
|
316
|
+
}
|
|
317
|
+
return this.filterBySymbolSinceLimit(trades, symbol, since, limit, true);
|
|
318
|
+
}
|
|
319
|
+
parseWsOrderStatus(status) {
|
|
320
|
+
const statuses = {
|
|
321
|
+
'wait': 'open',
|
|
322
|
+
'done': 'closed',
|
|
323
|
+
'cancel': 'canceled',
|
|
324
|
+
'watch': 'open',
|
|
325
|
+
'trade': 'open',
|
|
326
|
+
};
|
|
327
|
+
return this.safeString(statuses, status, status);
|
|
328
|
+
}
|
|
329
|
+
parseWsOrder(order, market = undefined) {
|
|
330
|
+
//
|
|
331
|
+
// {
|
|
332
|
+
// "type": "myOrder",
|
|
333
|
+
// "code": "SGD-XRP",
|
|
334
|
+
// "uuid": "ac2dc2a3-fce9-40a2-a4f6-5987c25c438f",
|
|
335
|
+
// "ask_bid": "BID",
|
|
336
|
+
// "order_type": "limit",
|
|
337
|
+
// "state": "trade",
|
|
338
|
+
// "price": 0.001453,
|
|
339
|
+
// "avg_price": 0.00145372,
|
|
340
|
+
// "volume": 30925891.29839369,
|
|
341
|
+
// "remaining_volume": 29968038.09235948,
|
|
342
|
+
// "executed_volume": 30925891.29839369,
|
|
343
|
+
// "trades_count": 1,
|
|
344
|
+
// "reserved_fee": 44.23943970238218,
|
|
345
|
+
// "remaining_fee": 21.77177967409916,
|
|
346
|
+
// "paid_fee": 22.467660028283017,
|
|
347
|
+
// "locked": 43565.33112787242,
|
|
348
|
+
// "executed_funds": 44935.32005656603,
|
|
349
|
+
// "order_timestamp": 1710751590000,
|
|
350
|
+
// "timestamp": 1710751597500,
|
|
351
|
+
// "stream_type": "REALTIME"
|
|
352
|
+
// }
|
|
353
|
+
//
|
|
354
|
+
const id = this.safeString(order, 'uuid');
|
|
355
|
+
let side = this.safeStringLower(order, 'ask_bid');
|
|
356
|
+
if (side === 'bid') {
|
|
357
|
+
side = 'buy';
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
side = 'sell';
|
|
361
|
+
}
|
|
362
|
+
const timestamp = this.parse8601(this.safeString(order, 'order_timestamp'));
|
|
363
|
+
const status = this.parseWsOrderStatus(this.safeString(order, 'state'));
|
|
364
|
+
const marketId = this.safeString(order, 'code');
|
|
365
|
+
market = this.safeMarket(marketId, market);
|
|
366
|
+
let fee = undefined;
|
|
367
|
+
const feeCost = this.safeString(order, 'paid_fee');
|
|
368
|
+
if (feeCost !== undefined) {
|
|
369
|
+
fee = {
|
|
370
|
+
'currency': market['quote'],
|
|
371
|
+
'cost': feeCost,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
return this.safeOrder({
|
|
375
|
+
'info': order,
|
|
376
|
+
'id': id,
|
|
377
|
+
'clientOrderId': undefined,
|
|
378
|
+
'timestamp': timestamp,
|
|
379
|
+
'datetime': this.iso8601(timestamp),
|
|
380
|
+
'lastTradeTimestamp': this.safeString(order, 'trade_timestamp'),
|
|
381
|
+
'symbol': market['symbol'],
|
|
382
|
+
'type': this.safeString(order, 'order_type'),
|
|
383
|
+
'timeInForce': this.safeString(order, 'time_in_force'),
|
|
384
|
+
'postOnly': undefined,
|
|
385
|
+
'side': side,
|
|
386
|
+
'price': this.safeString(order, 'price'),
|
|
387
|
+
'stopPrice': undefined,
|
|
388
|
+
'triggerPrice': undefined,
|
|
389
|
+
'cost': this.safeString(order, 'executed_funds'),
|
|
390
|
+
'average': this.safeString(order, 'avg_price'),
|
|
391
|
+
'amount': this.safeString(order, 'volume'),
|
|
392
|
+
'filled': this.safeString(order, 'executed_volume'),
|
|
393
|
+
'remaining': this.safeString(order, 'remaining_volume'),
|
|
394
|
+
'status': status,
|
|
395
|
+
'fee': fee,
|
|
396
|
+
'trades': undefined,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
parseWsTrade(trade, market = undefined) {
|
|
400
|
+
// see: parseWsOrder
|
|
401
|
+
let side = this.safeStringLower(trade, 'ask_bid');
|
|
402
|
+
if (side === 'bid') {
|
|
403
|
+
side = 'buy';
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
side = 'sell';
|
|
407
|
+
}
|
|
408
|
+
const timestamp = this.parse8601(this.safeString(trade, 'trade_timestamp'));
|
|
409
|
+
const marketId = this.safeString(trade, 'code');
|
|
410
|
+
market = this.safeMarket(marketId, market);
|
|
411
|
+
let fee = undefined;
|
|
412
|
+
const feeCost = this.safeString(trade, 'paid_fee');
|
|
413
|
+
if (feeCost !== undefined) {
|
|
414
|
+
fee = {
|
|
415
|
+
'currency': market['quote'],
|
|
416
|
+
'cost': feeCost,
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
return this.safeTrade({
|
|
420
|
+
'id': this.safeString(trade, 'trade_uuid'),
|
|
421
|
+
'timestamp': timestamp,
|
|
422
|
+
'datetime': this.iso8601(timestamp),
|
|
423
|
+
'symbol': market['symbol'],
|
|
424
|
+
'side': side,
|
|
425
|
+
'price': this.safeString(trade, 'price'),
|
|
426
|
+
'amount': this.safeString(trade, 'volume'),
|
|
427
|
+
'cost': this.safeString(trade, 'executed_funds'),
|
|
428
|
+
'order': this.safeString(trade, 'uuid'),
|
|
429
|
+
'takerOrMaker': undefined,
|
|
430
|
+
'type': this.safeString(trade, 'order_type'),
|
|
431
|
+
'fee': fee,
|
|
432
|
+
'info': trade,
|
|
433
|
+
}, market);
|
|
434
|
+
}
|
|
435
|
+
handleMyOrder(client, message) {
|
|
436
|
+
// see: parseWsOrder
|
|
437
|
+
const tradeId = this.safeString(message, 'trade_uuid');
|
|
438
|
+
if (tradeId !== undefined) {
|
|
439
|
+
this.handleMyTrade(client, message);
|
|
440
|
+
}
|
|
441
|
+
this.handleOrder(client, message);
|
|
442
|
+
}
|
|
443
|
+
handleMyTrade(client, message) {
|
|
444
|
+
// see: parseWsOrder
|
|
445
|
+
let myTrades = this.myTrades;
|
|
446
|
+
if (myTrades === undefined) {
|
|
447
|
+
const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
448
|
+
myTrades = new ArrayCacheBySymbolById(limit);
|
|
449
|
+
}
|
|
450
|
+
const trade = this.parseWsTrade(message);
|
|
451
|
+
myTrades.append(trade);
|
|
452
|
+
let messageHash = 'myTrades';
|
|
453
|
+
client.resolve(myTrades, messageHash);
|
|
454
|
+
messageHash = 'myTrades:' + trade['symbol'];
|
|
455
|
+
client.resolve(myTrades, messageHash);
|
|
456
|
+
}
|
|
457
|
+
handleOrder(client, message) {
|
|
458
|
+
const parsed = this.parseWsOrder(message);
|
|
459
|
+
const symbol = this.safeString(parsed, 'symbol');
|
|
460
|
+
const orderId = this.safeString(parsed, 'id');
|
|
461
|
+
if (this.orders === undefined) {
|
|
462
|
+
const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
|
|
463
|
+
this.orders = new ArrayCacheBySymbolById(limit);
|
|
464
|
+
}
|
|
465
|
+
const cachedOrders = this.orders;
|
|
466
|
+
const orders = this.safeValue(cachedOrders.hashmap, symbol, {});
|
|
467
|
+
const order = this.safeValue(orders, orderId);
|
|
468
|
+
if (order !== undefined) {
|
|
469
|
+
const fee = this.safeValue(order, 'fee');
|
|
470
|
+
if (fee !== undefined) {
|
|
471
|
+
parsed['fee'] = fee;
|
|
472
|
+
}
|
|
473
|
+
const fees = this.safeValue(order, 'fees');
|
|
474
|
+
if (fees !== undefined) {
|
|
475
|
+
parsed['fees'] = fees;
|
|
476
|
+
}
|
|
477
|
+
parsed['trades'] = this.safeValue(order, 'trades');
|
|
478
|
+
parsed['timestamp'] = this.safeInteger(order, 'timestamp');
|
|
479
|
+
parsed['datetime'] = this.safeString(order, 'datetime');
|
|
480
|
+
}
|
|
481
|
+
cachedOrders.append(parsed);
|
|
482
|
+
let messageHash = 'myOrder';
|
|
483
|
+
client.resolve(this.orders, messageHash);
|
|
484
|
+
messageHash = messageHash + ':' + symbol;
|
|
485
|
+
client.resolve(this.orders, messageHash);
|
|
486
|
+
}
|
|
487
|
+
async watchBalance(params = {}) {
|
|
488
|
+
/**
|
|
489
|
+
* @method
|
|
490
|
+
* @name upbit#watchBalance
|
|
491
|
+
* @see https://global-docs.upbit.com/reference/websocket-myasset
|
|
492
|
+
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
493
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
494
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
495
|
+
*/
|
|
496
|
+
await this.loadMarkets();
|
|
497
|
+
const channel = 'myAsset';
|
|
498
|
+
const messageHash = 'myAsset';
|
|
499
|
+
return await this.watchPrivate(undefined, channel, messageHash);
|
|
500
|
+
}
|
|
501
|
+
handleBalance(client, message) {
|
|
502
|
+
//
|
|
503
|
+
// {
|
|
504
|
+
// "type": "myAsset",
|
|
505
|
+
// "asset_uuid": "e635f223-1609-4969-8fb6-4376937baad6",
|
|
506
|
+
// "assets": [
|
|
507
|
+
// {
|
|
508
|
+
// "currency": "SGD",
|
|
509
|
+
// "balance": 1386929.37231066771348207123,
|
|
510
|
+
// "locked": 10329.670127489597585685
|
|
511
|
+
// }
|
|
512
|
+
// ],
|
|
513
|
+
// "asset_timestamp": 1710146517259,
|
|
514
|
+
// "timestamp": 1710146517267,
|
|
515
|
+
// "stream_type": "REALTIME"
|
|
516
|
+
// }
|
|
517
|
+
//
|
|
518
|
+
const data = this.safeList(message, 'assets', []);
|
|
519
|
+
const timestamp = this.safeInteger(message, 'timestamp');
|
|
520
|
+
this.balance['timestamp'] = timestamp;
|
|
521
|
+
this.balance['datetime'] = this.iso8601(timestamp);
|
|
522
|
+
for (let i = 0; i < data.length; i++) {
|
|
523
|
+
const balance = data[i];
|
|
524
|
+
const currencyId = this.safeString(balance, 'currency');
|
|
525
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
526
|
+
const available = this.safeString(balance, 'balance');
|
|
527
|
+
const frozen = this.safeString(balance, 'locked');
|
|
528
|
+
const account = this.account();
|
|
529
|
+
account['free'] = available;
|
|
530
|
+
account['used'] = frozen;
|
|
531
|
+
this.balance[code] = account;
|
|
532
|
+
this.balance = this.safeBalance(this.balance);
|
|
533
|
+
}
|
|
534
|
+
const messageHash = this.safeString(message, 'type');
|
|
535
|
+
client.resolve(this.balance, messageHash);
|
|
536
|
+
}
|
|
223
537
|
handleMessage(client, message) {
|
|
224
538
|
const methods = {
|
|
225
539
|
'ticker': this.handleTicker,
|
|
226
540
|
'orderbook': this.handleOrderBook,
|
|
227
541
|
'trade': this.handleTrades,
|
|
542
|
+
'myOrder': this.handleMyOrder,
|
|
543
|
+
'myAsset': this.handleBalance,
|
|
228
544
|
};
|
|
229
545
|
const methodName = this.safeString(message, 'type');
|
|
230
546
|
const method = this.safeValue(methods, methodName);
|
package/js/src/pro/wazirx.js
CHANGED
|
@@ -523,21 +523,21 @@ export default class wazirx extends wazirxRest {
|
|
|
523
523
|
const market = this.safeMarket(marketId);
|
|
524
524
|
const symbol = market['symbol'];
|
|
525
525
|
const messageHash = 'orderbook:' + symbol;
|
|
526
|
-
const currentOrderBook = this.safeValue(this.orderbooks, symbol);
|
|
527
|
-
if (
|
|
526
|
+
// const currentOrderBook = this.safeValue (this.orderbooks, symbol);
|
|
527
|
+
if (!(symbol in this.orderbooks)) {
|
|
528
528
|
const snapshot = this.parseOrderBook(data, symbol, timestamp, 'b', 'a');
|
|
529
|
-
|
|
530
|
-
this.orderbooks[symbol] = orderBook;
|
|
529
|
+
this.orderbooks[symbol] = this.orderBook(snapshot);
|
|
531
530
|
}
|
|
532
531
|
else {
|
|
533
|
-
const
|
|
534
|
-
const
|
|
535
|
-
this.
|
|
536
|
-
this.handleDeltas(
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
532
|
+
const orderbook = this.orderbooks[symbol];
|
|
533
|
+
const asks = this.safeList(data, 'a', []);
|
|
534
|
+
const bids = this.safeList(data, 'b', []);
|
|
535
|
+
this.handleDeltas(orderbook['asks'], asks);
|
|
536
|
+
this.handleDeltas(orderbook['bids'], bids);
|
|
537
|
+
orderbook['nonce'] = timestamp;
|
|
538
|
+
orderbook['timestamp'] = timestamp;
|
|
539
|
+
orderbook['datetime'] = this.iso8601(timestamp);
|
|
540
|
+
this.orderbooks[symbol] = orderbook;
|
|
541
541
|
}
|
|
542
542
|
client.resolve(this.orderbooks[symbol], messageHash);
|
|
543
543
|
}
|
package/js/src/upbit.js
CHANGED
|
@@ -1887,25 +1887,33 @@ export default class upbit extends Exchange {
|
|
|
1887
1887
|
}
|
|
1888
1888
|
if (api === 'private') {
|
|
1889
1889
|
this.checkRequiredCredentials();
|
|
1890
|
+
headers = {};
|
|
1890
1891
|
const nonce = this.uuid();
|
|
1891
1892
|
const request = {
|
|
1892
1893
|
'access_key': this.apiKey,
|
|
1893
1894
|
'nonce': nonce,
|
|
1894
1895
|
};
|
|
1895
|
-
|
|
1896
|
-
|
|
1896
|
+
const hasQuery = Object.keys(query).length;
|
|
1897
|
+
let auth = undefined;
|
|
1898
|
+
if ((method !== 'GET') && (method !== 'DELETE')) {
|
|
1899
|
+
body = this.json(params);
|
|
1900
|
+
headers['Content-Type'] = 'application/json';
|
|
1901
|
+
if (hasQuery) {
|
|
1902
|
+
auth = this.urlencode(query);
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
else {
|
|
1906
|
+
if (hasQuery) {
|
|
1907
|
+
auth = this.urlencode(this.keysort(query));
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
if (auth !== undefined) {
|
|
1897
1911
|
const hash = this.hash(this.encode(auth), sha512);
|
|
1898
1912
|
request['query_hash'] = hash;
|
|
1899
1913
|
request['query_hash_alg'] = 'SHA512';
|
|
1900
1914
|
}
|
|
1901
1915
|
const token = jwt(request, this.encode(this.secret), sha256);
|
|
1902
|
-
headers =
|
|
1903
|
-
'Authorization': 'Bearer ' + token,
|
|
1904
|
-
};
|
|
1905
|
-
if ((method !== 'GET') && (method !== 'DELETE')) {
|
|
1906
|
-
body = this.json(params);
|
|
1907
|
-
headers['Content-Type'] = 'application/json';
|
|
1908
|
-
}
|
|
1916
|
+
headers['Authorization'] = 'Bearer ' + token;
|
|
1909
1917
|
}
|
|
1910
1918
|
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
1911
1919
|
}
|
package/js/src/woo.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export default class woo extends Exchange {
|
|
|
28
28
|
editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
|
|
29
29
|
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
|
|
30
30
|
cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
|
|
31
|
-
cancelAllOrdersAfter(timeout: Int, params?: {}): Promise<
|
|
31
|
+
cancelAllOrdersAfter(timeout: Int, params?: {}): Promise<Order[]>;
|
|
32
32
|
fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
33
33
|
fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
34
34
|
fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
package/js/src/woo.js
CHANGED
|
@@ -1300,7 +1300,9 @@ export default class woo extends Exchange {
|
|
|
1300
1300
|
// "status":"CANCEL_ALL_SENT"
|
|
1301
1301
|
// }
|
|
1302
1302
|
//
|
|
1303
|
-
return
|
|
1303
|
+
return [
|
|
1304
|
+
this.safeOrder(response),
|
|
1305
|
+
];
|
|
1304
1306
|
}
|
|
1305
1307
|
async cancelAllOrdersAfter(timeout, params = {}) {
|
|
1306
1308
|
/**
|
|
@@ -1327,7 +1329,9 @@ export default class woo extends Exchange {
|
|
|
1327
1329
|
// "timestamp": 1711534302943
|
|
1328
1330
|
// }
|
|
1329
1331
|
//
|
|
1330
|
-
return
|
|
1332
|
+
return [
|
|
1333
|
+
this.safeOrder(response),
|
|
1334
|
+
];
|
|
1331
1335
|
}
|
|
1332
1336
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
1333
1337
|
/**
|
package/package.json
CHANGED