ccxt 4.2.14 → 4.2.15
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.js +184 -30
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/js/ccxt.js +1 -1
- package/dist/cjs/js/src/binance.js +2 -2
- package/dist/cjs/js/src/bingx.js +4 -3
- package/dist/cjs/js/src/bitget.js +3 -3
- package/dist/cjs/js/src/bybit.js +3 -3
- package/dist/cjs/js/src/coinex.js +3 -3
- package/dist/cjs/js/src/gate.js +3 -3
- package/dist/cjs/js/src/htx.js +2 -2
- package/dist/cjs/js/src/kraken.js +24 -2
- package/dist/cjs/js/src/kucoin.js +1 -1
- package/dist/cjs/js/src/kucoinfutures.js +2 -2
- package/dist/cjs/js/src/okx.js +1 -1
- package/dist/cjs/js/src/pro/htx.js +6 -1
- package/dist/cjs/js/src/pro/woo.js +126 -0
- package/dist/cjs/js/src/woo.js +3 -3
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/binance.js +2 -2
- package/js/src/bingx.js +4 -3
- package/js/src/bitget.js +3 -3
- package/js/src/bybit.js +3 -3
- package/js/src/coinex.js +3 -3
- package/js/src/gate.js +3 -3
- package/js/src/htx.js +2 -2
- package/js/src/kraken.d.ts +1 -0
- package/js/src/kraken.js +24 -2
- package/js/src/kucoin.js +1 -1
- package/js/src/kucoinfutures.js +2 -2
- package/js/src/okx.js +1 -1
- package/js/src/pro/htx.js +6 -1
- package/js/src/pro/woo.d.ts +5 -1
- package/js/src/pro/woo.js +127 -1
- package/js/src/woo.js +3 -3
- package/package.json +1 -1
package/js/src/kucoin.js
CHANGED
|
@@ -49,8 +49,8 @@ export default class kucoin extends Exchange {
|
|
|
49
49
|
'createPostOnlyOrder': true,
|
|
50
50
|
'createStopLimitOrder': true,
|
|
51
51
|
'createStopMarketOrder': true,
|
|
52
|
-
'createTriggerOrder': true,
|
|
53
52
|
'createStopOrder': true,
|
|
53
|
+
'createTriggerOrder': true,
|
|
54
54
|
'editOrder': true,
|
|
55
55
|
'fetchAccounts': true,
|
|
56
56
|
'fetchBalance': true,
|
package/js/src/kucoinfutures.js
CHANGED
|
@@ -39,11 +39,11 @@ export default class kucoinfutures extends kucoin {
|
|
|
39
39
|
'createOrders': true,
|
|
40
40
|
'createReduceOnlyOrder': true,
|
|
41
41
|
'createStopLimitOrder': true,
|
|
42
|
+
'createStopLossOrder': true,
|
|
42
43
|
'createStopMarketOrder': true,
|
|
43
44
|
'createStopOrder': true,
|
|
44
|
-
'createTriggerOrder': true,
|
|
45
45
|
'createTakeProfitOrder': true,
|
|
46
|
-
'
|
|
46
|
+
'createTriggerOrder': true,
|
|
47
47
|
'fetchAccounts': true,
|
|
48
48
|
'fetchBalance': true,
|
|
49
49
|
'fetchBorrowRateHistories': false,
|
package/js/src/okx.js
CHANGED
|
@@ -46,8 +46,8 @@ export default class okx extends Exchange {
|
|
|
46
46
|
'createOrderWithTakeProfitAndStopLoss': true,
|
|
47
47
|
'createPostOnlyOrder': true,
|
|
48
48
|
'createReduceOnlyOrder': true,
|
|
49
|
-
'createStopLossOrder': true,
|
|
50
49
|
'createStopLimitOrder': true,
|
|
50
|
+
'createStopLossOrder': true,
|
|
51
51
|
'createStopMarketOrder': true,
|
|
52
52
|
'createStopOrder': true,
|
|
53
53
|
'createTakeProfitOrder': true,
|
package/js/src/pro/htx.js
CHANGED
|
@@ -933,11 +933,16 @@ export default class htx extends htxRest {
|
|
|
933
933
|
// inject trade in existing order by faking an order object
|
|
934
934
|
const orderId = this.safeString(parsedTrade, 'order');
|
|
935
935
|
const trades = [parsedTrade];
|
|
936
|
+
const status = this.parseOrderStatus(this.safeString2(data, 'orderStatus', 'status', 'closed'));
|
|
937
|
+
const filled = this.safeString(data, 'execAmt');
|
|
938
|
+
const remaining = this.safeString(data, 'remainAmt');
|
|
936
939
|
const order = {
|
|
937
940
|
'id': orderId,
|
|
938
941
|
'trades': trades,
|
|
939
|
-
'status':
|
|
942
|
+
'status': status,
|
|
940
943
|
'symbol': market['symbol'],
|
|
944
|
+
'filled': this.parseNumber(filled),
|
|
945
|
+
'remaining': this.parseNumber(remaining),
|
|
941
946
|
};
|
|
942
947
|
parsedOrder = order;
|
|
943
948
|
}
|
package/js/src/pro/woo.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import wooRest from '../woo.js';
|
|
2
|
-
import type { Int, Str, Strings, OrderBook, Order, Trade, Ticker, Tickers, OHLCV, Balances } from '../base/types.js';
|
|
2
|
+
import type { Int, Str, Strings, OrderBook, Order, Trade, Ticker, Tickers, OHLCV, Balances, Position } from '../base/types.js';
|
|
3
3
|
import Client from '../base/ws/Client.js';
|
|
4
4
|
export default class woo extends wooRest {
|
|
5
5
|
describe(): any;
|
|
@@ -24,6 +24,10 @@ export default class woo extends wooRest {
|
|
|
24
24
|
parseWsOrder(order: any, market?: any): Order;
|
|
25
25
|
handleOrderUpdate(client: Client, message: any): void;
|
|
26
26
|
handleOrder(client: Client, message: any): void;
|
|
27
|
+
watchPositions(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
|
|
28
|
+
setPositionsCache(client: Client, type: any, symbols?: Strings): void;
|
|
29
|
+
loadPositionsSnapshot(client: any, messageHash: any): Promise<void>;
|
|
30
|
+
handlePositions(client: any, message: any): void;
|
|
27
31
|
watchBalance(params?: {}): Promise<Balances>;
|
|
28
32
|
handleBalance(client: any, message: any): void;
|
|
29
33
|
handleMessage(client: Client, message: any): any;
|
package/js/src/pro/woo.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// ----------------------------------------------------------------------------
|
|
8
8
|
import wooRest from '../woo.js';
|
|
9
9
|
import { ExchangeError, AuthenticationError } from '../base/errors.js';
|
|
10
|
-
import { ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCache } from '../base/ws/Cache.js';
|
|
10
|
+
import { ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCache, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
|
|
11
11
|
import { Precise } from '../base/Precise.js';
|
|
12
12
|
import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
|
|
13
13
|
// ----------------------------------------------------------------------------
|
|
@@ -24,6 +24,7 @@ export default class woo extends wooRest {
|
|
|
24
24
|
'watchTicker': true,
|
|
25
25
|
'watchTickers': true,
|
|
26
26
|
'watchTrades': true,
|
|
27
|
+
'watchPositions': true,
|
|
27
28
|
},
|
|
28
29
|
'urls': {
|
|
29
30
|
'api': {
|
|
@@ -48,6 +49,10 @@ export default class woo extends wooRest {
|
|
|
48
49
|
'tradesLimit': 1000,
|
|
49
50
|
'ordersLimit': 1000,
|
|
50
51
|
'requestId': {},
|
|
52
|
+
'watchPositions': {
|
|
53
|
+
'fetchPositionsSnapshot': true,
|
|
54
|
+
'awaitPositionsSnapshot': true, // whether to wait for the positions snapshot before providing updates
|
|
55
|
+
},
|
|
51
56
|
},
|
|
52
57
|
'streaming': {
|
|
53
58
|
'ping': this.ping,
|
|
@@ -606,6 +611,126 @@ export default class woo extends wooRest {
|
|
|
606
611
|
client.resolve(this.orders, messageHashSymbol);
|
|
607
612
|
}
|
|
608
613
|
}
|
|
614
|
+
async watchPositions(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
615
|
+
/**
|
|
616
|
+
* @method
|
|
617
|
+
* @name woo#watchPositions
|
|
618
|
+
* @see https://docs.woo.org/#position-push
|
|
619
|
+
* @description watch all open positions
|
|
620
|
+
* @param {string[]|undefined} symbols list of unified market symbols
|
|
621
|
+
* @param {object} params extra parameters specific to the exchange API endpoint
|
|
622
|
+
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
|
|
623
|
+
*/
|
|
624
|
+
await this.loadMarkets();
|
|
625
|
+
let messageHash = '';
|
|
626
|
+
symbols = this.marketSymbols(symbols);
|
|
627
|
+
if (!this.isEmpty(symbols)) {
|
|
628
|
+
messageHash = '::' + symbols.join(',');
|
|
629
|
+
}
|
|
630
|
+
messageHash = 'positions' + messageHash;
|
|
631
|
+
const url = this.urls['api']['ws']['private'] + '/' + this.uid;
|
|
632
|
+
const client = this.client(url);
|
|
633
|
+
this.setPositionsCache(client, symbols);
|
|
634
|
+
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
635
|
+
const awaitPositionsSnapshot = this.safeValue('watchPositions', 'awaitPositionsSnapshot', true);
|
|
636
|
+
if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
|
|
637
|
+
const snapshot = await client.future('fetchPositionsSnapshot');
|
|
638
|
+
return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
|
|
639
|
+
}
|
|
640
|
+
const request = {
|
|
641
|
+
'event': 'subscribe',
|
|
642
|
+
'topic': 'position',
|
|
643
|
+
};
|
|
644
|
+
const newPositions = await this.watchPrivate(messageHash, request, params);
|
|
645
|
+
if (this.newUpdates) {
|
|
646
|
+
return newPositions;
|
|
647
|
+
}
|
|
648
|
+
return this.filterBySymbolsSinceLimit(this.positions, symbols, since, limit, true);
|
|
649
|
+
}
|
|
650
|
+
setPositionsCache(client, type, symbols = undefined) {
|
|
651
|
+
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', false);
|
|
652
|
+
if (fetchPositionsSnapshot) {
|
|
653
|
+
const messageHash = 'fetchPositionsSnapshot';
|
|
654
|
+
if (!(messageHash in client.futures)) {
|
|
655
|
+
client.future(messageHash);
|
|
656
|
+
this.spawn(this.loadPositionsSnapshot, client, messageHash);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
this.positions = new ArrayCacheBySymbolBySide();
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
async loadPositionsSnapshot(client, messageHash) {
|
|
664
|
+
const positions = await this.fetchPositions();
|
|
665
|
+
this.positions = new ArrayCacheBySymbolBySide();
|
|
666
|
+
const cache = this.positions;
|
|
667
|
+
for (let i = 0; i < positions.length; i++) {
|
|
668
|
+
const position = positions[i];
|
|
669
|
+
const contracts = this.safeNumber(position, 'contracts', 0);
|
|
670
|
+
if (contracts > 0) {
|
|
671
|
+
cache.append(position);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
// don't remove the future from the .futures cache
|
|
675
|
+
const future = client.futures[messageHash];
|
|
676
|
+
future.resolve(cache);
|
|
677
|
+
client.resolve(cache, 'positions');
|
|
678
|
+
}
|
|
679
|
+
handlePositions(client, message) {
|
|
680
|
+
//
|
|
681
|
+
// {
|
|
682
|
+
// "topic":"position",
|
|
683
|
+
// "ts":1705292345255,
|
|
684
|
+
// "data":{
|
|
685
|
+
// "positions":{
|
|
686
|
+
// "PERP_LTC_USDT":{
|
|
687
|
+
// "holding":1,
|
|
688
|
+
// "pendingLongQty":0,
|
|
689
|
+
// "pendingShortQty":0,
|
|
690
|
+
// "averageOpenPrice":71.53,
|
|
691
|
+
// "pnl24H":0,
|
|
692
|
+
// "fee24H":0.07153,
|
|
693
|
+
// "settlePrice":71.53,
|
|
694
|
+
// "markPrice":71.32098452065145,
|
|
695
|
+
// "version":7886,
|
|
696
|
+
// "openingTime":1705292304267,
|
|
697
|
+
// "pnl24HPercentage":0,
|
|
698
|
+
// "adlQuantile":1,
|
|
699
|
+
// "positionSide":"BOTH"
|
|
700
|
+
// }
|
|
701
|
+
// }
|
|
702
|
+
// }
|
|
703
|
+
// }
|
|
704
|
+
//
|
|
705
|
+
const data = this.safeValue(message, 'data', {});
|
|
706
|
+
const rawPositions = this.safeValue(data, 'positions', {});
|
|
707
|
+
const postitionsIds = Object.keys(rawPositions);
|
|
708
|
+
if (this.positions === undefined) {
|
|
709
|
+
this.positions = new ArrayCacheBySymbolBySide();
|
|
710
|
+
}
|
|
711
|
+
const cache = this.positions;
|
|
712
|
+
const newPositions = [];
|
|
713
|
+
for (let i = 0; i < postitionsIds.length; i++) {
|
|
714
|
+
const marketId = postitionsIds[i];
|
|
715
|
+
const market = this.safeMarket(marketId);
|
|
716
|
+
const rawPosition = rawPositions[marketId];
|
|
717
|
+
const position = this.parsePosition(rawPosition, market);
|
|
718
|
+
newPositions.push(position);
|
|
719
|
+
cache.append(position);
|
|
720
|
+
}
|
|
721
|
+
const messageHashes = this.findMessageHashes(client, 'positions::');
|
|
722
|
+
for (let i = 0; i < messageHashes.length; i++) {
|
|
723
|
+
const messageHash = messageHashes[i];
|
|
724
|
+
const parts = messageHash.split('::');
|
|
725
|
+
const symbolsString = parts[1];
|
|
726
|
+
const symbols = symbolsString.split(',');
|
|
727
|
+
const positions = this.filterByArray(newPositions, 'symbol', symbols, false);
|
|
728
|
+
if (!this.isEmpty(positions)) {
|
|
729
|
+
client.resolve(positions, messageHash);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
client.resolve(newPositions, 'positions');
|
|
733
|
+
}
|
|
609
734
|
async watchBalance(params = {}) {
|
|
610
735
|
/**
|
|
611
736
|
* @method
|
|
@@ -689,6 +814,7 @@ export default class woo extends wooRest {
|
|
|
689
814
|
'executionreport': this.handleOrderUpdate,
|
|
690
815
|
'trade': this.handleTrade,
|
|
691
816
|
'balance': this.handleBalance,
|
|
817
|
+
'position': this.handlePositions,
|
|
692
818
|
};
|
|
693
819
|
const event = this.safeString(message, 'event');
|
|
694
820
|
let method = this.safeValue(methods, event);
|
package/js/src/woo.js
CHANGED
|
@@ -45,16 +45,16 @@ export default class woo extends Exchange {
|
|
|
45
45
|
'createMarketOrderWithCost': false,
|
|
46
46
|
'createMarketSellOrderWithCost': false,
|
|
47
47
|
'createOrder': true,
|
|
48
|
+
'createOrderWithTakeProfitAndStopLoss': true,
|
|
48
49
|
'createReduceOnlyOrder': true,
|
|
49
50
|
'createStopLimitOrder': false,
|
|
51
|
+
'createStopLossOrder': true,
|
|
50
52
|
'createStopMarketOrder': false,
|
|
51
53
|
'createStopOrder': false,
|
|
54
|
+
'createTakeProfitOrder': true,
|
|
52
55
|
'createTrailingAmountOrder': true,
|
|
53
56
|
'createTrailingPercentOrder': true,
|
|
54
57
|
'createTriggerOrder': true,
|
|
55
|
-
'createTakeProfitOrder': true,
|
|
56
|
-
'createStopLossOrder': true,
|
|
57
|
-
'createOrderWithTakeProfitAndStopLoss': true,
|
|
58
58
|
'fetchAccounts': true,
|
|
59
59
|
'fetchBalance': true,
|
|
60
60
|
'fetchCanceledOrders': false,
|
package/package.json
CHANGED