ccxt 4.3.5 → 4.3.7
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/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ace.js +5 -0
- package/dist/cjs/src/alpaca.js +6 -0
- package/dist/cjs/src/base/Exchange.js +37 -0
- package/dist/cjs/src/binance.js +4 -0
- package/dist/cjs/src/bingx.js +47 -0
- package/dist/cjs/src/bitbank.js +3 -0
- package/dist/cjs/src/bitget.js +74 -1
- package/dist/cjs/src/bithumb.js +4 -0
- package/dist/cjs/src/bitmex.js +26 -0
- package/dist/cjs/src/bitopro.js +5 -0
- package/dist/cjs/src/bitso.js +3 -0
- package/dist/cjs/src/bitstamp.js +3 -0
- package/dist/cjs/src/bitteam.js +4 -0
- package/dist/cjs/src/bitvavo.js +3 -0
- package/dist/cjs/src/bl3p.js +3 -0
- package/dist/cjs/src/btcalpha.js +3 -0
- package/dist/cjs/src/btcbox.js +3 -0
- package/dist/cjs/src/btcmarkets.js +3 -0
- package/dist/cjs/src/btcturk.js +3 -0
- package/dist/cjs/src/bybit.js +209 -12
- package/dist/cjs/src/cex.js +6 -0
- package/dist/cjs/src/coinbase.js +100 -21
- package/dist/cjs/src/coinbaseinternational.js +2 -0
- package/dist/cjs/src/coinbasepro.js +6 -0
- package/dist/cjs/src/coincheck.js +3 -0
- package/dist/cjs/src/coinex.js +180 -75
- package/dist/cjs/src/coinlist.js +4 -0
- package/dist/cjs/src/coinmate.js +3 -0
- package/dist/cjs/src/coinone.js +3 -0
- package/dist/cjs/src/coinsph.js +4 -0
- package/dist/cjs/src/coinspot.js +3 -0
- package/dist/cjs/src/cryptocom.js +34 -0
- package/dist/cjs/src/exmo.js +5 -0
- package/dist/cjs/src/gate.js +124 -22
- package/dist/cjs/src/hitbtc.js +4 -3
- package/dist/cjs/src/htx.js +30 -0
- package/dist/cjs/src/hyperliquid.js +40 -0
- package/dist/cjs/src/idex.js +3 -0
- package/dist/cjs/src/independentreserve.js +3 -0
- package/dist/cjs/src/indodax.js +3 -0
- package/dist/cjs/src/kraken.js +30 -0
- package/dist/cjs/src/krakenfutures.js +28 -0
- package/dist/cjs/src/kucoin.js +2 -0
- package/dist/cjs/src/kucoinfutures.js +4 -2
- package/dist/cjs/src/latoken.js +6 -0
- package/dist/cjs/src/luno.js +3 -0
- package/dist/cjs/src/lykke.js +5 -0
- package/dist/cjs/src/mercado.js +3 -0
- package/dist/cjs/src/mexc.js +111 -0
- package/dist/cjs/src/ndax.js +4 -0
- package/dist/cjs/src/novadax.js +4 -0
- package/dist/cjs/src/okx.js +196 -0
- package/dist/cjs/src/onetrading.js +3 -0
- package/dist/cjs/src/p2b.js +3 -0
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bybit.js +1 -1
- package/dist/cjs/src/pro/coinbase.js +30 -29
- package/dist/cjs/src/probit.js +3 -0
- package/dist/cjs/src/timex.js +3 -0
- package/dist/cjs/src/tradeogre.js +3 -0
- package/dist/cjs/src/wavesexchange.js +3 -0
- package/dist/cjs/src/wazirx.js +3 -0
- package/dist/cjs/src/whitebit.js +42 -0
- package/dist/cjs/src/woo.js +31 -0
- package/dist/cjs/src/yobit.js +3 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +1 -0
- package/js/src/abstract/binancecoinm.d.ts +1 -0
- package/js/src/abstract/binanceus.d.ts +1 -0
- package/js/src/abstract/binanceusdm.d.ts +1 -0
- package/js/src/abstract/bingx.d.ts +1 -0
- package/js/src/abstract/coinbase.d.ts +5 -0
- package/js/src/abstract/woo.d.ts +1 -0
- package/js/src/ace.js +5 -0
- package/js/src/alpaca.js +6 -0
- package/js/src/ascendex.d.ts +2 -2
- package/js/src/base/Exchange.d.ts +5 -0
- package/js/src/base/Exchange.js +37 -0
- package/js/src/bigone.d.ts +1 -1
- package/js/src/binance.d.ts +3 -3
- package/js/src/binance.js +4 -0
- package/js/src/bingx.d.ts +2 -1
- package/js/src/bingx.js +47 -0
- package/js/src/bitbank.d.ts +1 -1
- package/js/src/bitbank.js +3 -0
- package/js/src/bitfinex.d.ts +1 -1
- package/js/src/bitfinex2.d.ts +1 -1
- package/js/src/bitflyer.d.ts +1 -1
- package/js/src/bitget.d.ts +4 -3
- package/js/src/bitget.js +74 -1
- package/js/src/bithumb.d.ts +1 -1
- package/js/src/bithumb.js +4 -0
- package/js/src/bitmart.d.ts +1 -1
- package/js/src/bitmex.d.ts +2 -1
- package/js/src/bitmex.js +26 -0
- package/js/src/bitopro.d.ts +1 -1
- package/js/src/bitopro.js +5 -0
- package/js/src/bitrue.d.ts +1 -1
- package/js/src/bitso.d.ts +1 -1
- package/js/src/bitso.js +3 -0
- package/js/src/bitstamp.d.ts +1 -1
- package/js/src/bitstamp.js +3 -0
- package/js/src/bitteam.js +4 -0
- package/js/src/bitvavo.d.ts +1 -1
- package/js/src/bitvavo.js +3 -0
- package/js/src/bl3p.js +3 -0
- package/js/src/blockchaincom.d.ts +1 -1
- package/js/src/btcalpha.js +3 -0
- package/js/src/btcbox.js +3 -0
- package/js/src/btcmarkets.d.ts +1 -1
- package/js/src/btcmarkets.js +3 -0
- package/js/src/btcturk.js +3 -0
- package/js/src/bybit.d.ts +8 -6
- package/js/src/bybit.js +209 -12
- package/js/src/cex.js +6 -0
- package/js/src/coinbase.d.ts +1 -1
- package/js/src/coinbase.js +100 -21
- package/js/src/coinbaseinternational.d.ts +1 -1
- package/js/src/coinbaseinternational.js +2 -0
- package/js/src/coinbasepro.d.ts +1 -1
- package/js/src/coinbasepro.js +6 -0
- package/js/src/coincheck.js +3 -0
- package/js/src/coinex.d.ts +8 -7
- package/js/src/coinex.js +180 -75
- package/js/src/coinlist.d.ts +1 -1
- package/js/src/coinlist.js +4 -0
- package/js/src/coinmate.d.ts +1 -1
- package/js/src/coinmate.js +3 -0
- package/js/src/coinone.js +3 -0
- package/js/src/coinsph.d.ts +1 -1
- package/js/src/coinsph.js +4 -0
- package/js/src/coinspot.js +3 -0
- package/js/src/cryptocom.d.ts +3 -2
- package/js/src/cryptocom.js +34 -0
- package/js/src/delta.d.ts +2 -2
- package/js/src/deribit.d.ts +1 -1
- package/js/src/digifinex.d.ts +3 -3
- package/js/src/exmo.d.ts +3 -3
- package/js/src/exmo.js +5 -0
- package/js/src/gate.d.ts +8 -7
- package/js/src/gate.js +124 -22
- package/js/src/gemini.d.ts +1 -1
- package/js/src/hitbtc.d.ts +3 -3
- package/js/src/hitbtc.js +4 -3
- package/js/src/hollaex.d.ts +1 -1
- package/js/src/htx.d.ts +2 -1
- package/js/src/htx.js +30 -0
- package/js/src/huobijp.d.ts +1 -1
- package/js/src/hyperliquid.d.ts +3 -2
- package/js/src/hyperliquid.js +40 -0
- package/js/src/idex.d.ts +1 -1
- package/js/src/idex.js +3 -0
- package/js/src/independentreserve.js +3 -0
- package/js/src/indodax.d.ts +1 -1
- package/js/src/indodax.js +3 -0
- package/js/src/kraken.d.ts +2 -1
- package/js/src/kraken.js +30 -0
- package/js/src/krakenfutures.d.ts +1 -0
- package/js/src/krakenfutures.js +28 -0
- package/js/src/kucoin.d.ts +1 -1
- package/js/src/kucoin.js +2 -0
- package/js/src/kucoinfutures.d.ts +1 -1
- package/js/src/kucoinfutures.js +4 -2
- package/js/src/kuna.d.ts +1 -1
- package/js/src/latoken.js +6 -0
- package/js/src/lbank.d.ts +1 -1
- package/js/src/luno.js +3 -0
- package/js/src/lykke.d.ts +1 -1
- package/js/src/lykke.js +5 -0
- package/js/src/mercado.d.ts +1 -1
- package/js/src/mercado.js +3 -0
- package/js/src/mexc.d.ts +4 -3
- package/js/src/mexc.js +111 -0
- package/js/src/ndax.d.ts +1 -1
- package/js/src/ndax.js +4 -0
- package/js/src/novadax.d.ts +1 -1
- package/js/src/novadax.js +4 -0
- package/js/src/okcoin.d.ts +1 -1
- package/js/src/okx.d.ts +11 -8
- package/js/src/okx.js +196 -0
- package/js/src/onetrading.d.ts +1 -1
- package/js/src/onetrading.js +3 -0
- package/js/src/p2b.js +3 -0
- package/js/src/phemex.d.ts +1 -1
- package/js/src/poloniex.d.ts +1 -1
- package/js/src/pro/bitget.d.ts +1 -1
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bybit.js +1 -1
- package/js/src/pro/coinbase.d.ts +2 -2
- package/js/src/pro/coinbase.js +30 -29
- package/js/src/probit.d.ts +1 -1
- package/js/src/probit.js +3 -0
- package/js/src/timex.js +3 -0
- package/js/src/tokocrypto.d.ts +1 -1
- package/js/src/tradeogre.js +3 -0
- package/js/src/upbit.d.ts +1 -1
- package/js/src/wavesexchange.d.ts +1 -1
- package/js/src/wavesexchange.js +3 -0
- package/js/src/wazirx.js +3 -0
- package/js/src/whitebit.d.ts +2 -1
- package/js/src/whitebit.js +42 -0
- package/js/src/woo.d.ts +3 -2
- package/js/src/woo.js +31 -0
- package/js/src/yobit.d.ts +1 -1
- package/js/src/yobit.js +3 -0
- package/js/src/zaif.d.ts +1 -1
- package/js/src/zonda.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/src/mexc.js
CHANGED
|
@@ -90,8 +90,10 @@ class mexc extends mexc$1 {
|
|
|
90
90
|
'fetchOrders': true,
|
|
91
91
|
'fetchOrderTrades': true,
|
|
92
92
|
'fetchPosition': true,
|
|
93
|
+
'fetchPositionHistory': 'emulated',
|
|
93
94
|
'fetchPositionMode': true,
|
|
94
95
|
'fetchPositions': true,
|
|
96
|
+
'fetchPositionsHistory': true,
|
|
95
97
|
'fetchPositionsRisk': undefined,
|
|
96
98
|
'fetchPremiumIndexOHLCV': false,
|
|
97
99
|
'fetchStatus': true,
|
|
@@ -4863,6 +4865,8 @@ class mexc extends mexc$1 {
|
|
|
4863
4865
|
return this.parsePositions(data, symbols);
|
|
4864
4866
|
}
|
|
4865
4867
|
parsePosition(position, market = undefined) {
|
|
4868
|
+
//
|
|
4869
|
+
// fetchPositions
|
|
4866
4870
|
//
|
|
4867
4871
|
// {
|
|
4868
4872
|
// "positionId": 1394650,
|
|
@@ -4887,6 +4891,40 @@ class mexc extends mexc$1 {
|
|
|
4887
4891
|
// "autoAddIm": false
|
|
4888
4892
|
// }
|
|
4889
4893
|
//
|
|
4894
|
+
// fetchPositionsHistory
|
|
4895
|
+
//
|
|
4896
|
+
// {
|
|
4897
|
+
// positionId: '390281084',
|
|
4898
|
+
// symbol: 'RVN_USDT',
|
|
4899
|
+
// positionType: '1',
|
|
4900
|
+
// openType: '2',
|
|
4901
|
+
// state: '3',
|
|
4902
|
+
// holdVol: '0',
|
|
4903
|
+
// frozenVol: '0',
|
|
4904
|
+
// closeVol: '1141',
|
|
4905
|
+
// holdAvgPrice: '0.03491',
|
|
4906
|
+
// holdAvgPriceFullyScale: '0.03491',
|
|
4907
|
+
// openAvgPrice: '0.03491',
|
|
4908
|
+
// openAvgPriceFullyScale: '0.03491',
|
|
4909
|
+
// closeAvgPrice: '0.03494',
|
|
4910
|
+
// liquidatePrice: '0.03433',
|
|
4911
|
+
// oim: '0',
|
|
4912
|
+
// im: '0',
|
|
4913
|
+
// holdFee: '0',
|
|
4914
|
+
// realised: '0.1829',
|
|
4915
|
+
// leverage: '50',
|
|
4916
|
+
// createTime: '1711512408000',
|
|
4917
|
+
// updateTime: '1711512553000',
|
|
4918
|
+
// autoAddIm: false,
|
|
4919
|
+
// version: '4',
|
|
4920
|
+
// profitRatio: '0.0227',
|
|
4921
|
+
// newOpenAvgPrice: '0.03491',
|
|
4922
|
+
// newCloseAvgPrice: '0.03494',
|
|
4923
|
+
// closeProfitLoss: '0.3423',
|
|
4924
|
+
// fee: '0.1593977',
|
|
4925
|
+
// positionShowStatus: 'CLOSED'
|
|
4926
|
+
// }
|
|
4927
|
+
//
|
|
4890
4928
|
market = this.safeMarket(this.safeString(position, 'symbol'), market);
|
|
4891
4929
|
const symbol = market['symbol'];
|
|
4892
4930
|
const contracts = this.safeString(position, 'holdVol');
|
|
@@ -5524,6 +5562,79 @@ class mexc extends mexc$1 {
|
|
|
5524
5562
|
}
|
|
5525
5563
|
return [marginMode, params];
|
|
5526
5564
|
}
|
|
5565
|
+
async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
5566
|
+
/**
|
|
5567
|
+
* @method
|
|
5568
|
+
* @name mexc#fetchPositionsHistory
|
|
5569
|
+
* @description fetches historical positions
|
|
5570
|
+
* @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
|
|
5571
|
+
* @param {string[]} [symbols] unified contract symbols
|
|
5572
|
+
* @param {int} [since] not used by mexc fetchPositionsHistory
|
|
5573
|
+
* @param {int} [limit] the maximum amount of candles to fetch, default=1000
|
|
5574
|
+
* @param {object} params extra parameters specific to the exchange api endpoint
|
|
5575
|
+
*
|
|
5576
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
|
5577
|
+
* @param {int} type position type,1: long, 2: short
|
|
5578
|
+
* @param {int} page_num current page number, default is 1
|
|
5579
|
+
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
5580
|
+
*/
|
|
5581
|
+
await this.loadMarkets();
|
|
5582
|
+
const request = {};
|
|
5583
|
+
if (symbols !== undefined) {
|
|
5584
|
+
const symbolsLength = symbols.length;
|
|
5585
|
+
if (symbolsLength === 1) {
|
|
5586
|
+
const market = this.market(symbols[0]);
|
|
5587
|
+
request['symbol'] = market['id'];
|
|
5588
|
+
}
|
|
5589
|
+
}
|
|
5590
|
+
if (limit !== undefined) {
|
|
5591
|
+
request['page_size'] = limit;
|
|
5592
|
+
}
|
|
5593
|
+
const response = await this.contractPrivateGetPositionListHistoryPositions(this.extend(request, params));
|
|
5594
|
+
//
|
|
5595
|
+
// {
|
|
5596
|
+
// success: true,
|
|
5597
|
+
// code: '0',
|
|
5598
|
+
// data: [
|
|
5599
|
+
// {
|
|
5600
|
+
// positionId: '390281084',
|
|
5601
|
+
// symbol: 'RVN_USDT',
|
|
5602
|
+
// positionType: '1',
|
|
5603
|
+
// openType: '2',
|
|
5604
|
+
// state: '3',
|
|
5605
|
+
// holdVol: '0',
|
|
5606
|
+
// frozenVol: '0',
|
|
5607
|
+
// closeVol: '1141',
|
|
5608
|
+
// holdAvgPrice: '0.03491',
|
|
5609
|
+
// holdAvgPriceFullyScale: '0.03491',
|
|
5610
|
+
// openAvgPrice: '0.03491',
|
|
5611
|
+
// openAvgPriceFullyScale: '0.03491',
|
|
5612
|
+
// closeAvgPrice: '0.03494',
|
|
5613
|
+
// liquidatePrice: '0.03433',
|
|
5614
|
+
// oim: '0',
|
|
5615
|
+
// im: '0',
|
|
5616
|
+
// holdFee: '0',
|
|
5617
|
+
// realised: '0.1829',
|
|
5618
|
+
// leverage: '50',
|
|
5619
|
+
// createTime: '1711512408000',
|
|
5620
|
+
// updateTime: '1711512553000',
|
|
5621
|
+
// autoAddIm: false,
|
|
5622
|
+
// version: '4',
|
|
5623
|
+
// profitRatio: '0.0227',
|
|
5624
|
+
// newOpenAvgPrice: '0.03491',
|
|
5625
|
+
// newCloseAvgPrice: '0.03494',
|
|
5626
|
+
// closeProfitLoss: '0.3423',
|
|
5627
|
+
// fee: '0.1593977',
|
|
5628
|
+
// positionShowStatus: 'CLOSED'
|
|
5629
|
+
// },
|
|
5630
|
+
// ...
|
|
5631
|
+
// ]
|
|
5632
|
+
// }
|
|
5633
|
+
//
|
|
5634
|
+
const data = this.safeList(response, 'data');
|
|
5635
|
+
const positions = this.parsePositions(data, symbols, params);
|
|
5636
|
+
return this.filterBySinceLimit(positions, since, limit);
|
|
5637
|
+
}
|
|
5527
5638
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
5528
5639
|
const section = this.safeString(api, 0);
|
|
5529
5640
|
const access = this.safeString(api, 1);
|
package/dist/cjs/src/ndax.js
CHANGED
|
@@ -70,7 +70,11 @@ class ndax extends ndax$1 {
|
|
|
70
70
|
'fetchOrders': true,
|
|
71
71
|
'fetchOrderTrades': true,
|
|
72
72
|
'fetchPosition': false,
|
|
73
|
+
'fetchPositionHistory': false,
|
|
74
|
+
'fetchPositionMode': false,
|
|
73
75
|
'fetchPositions': false,
|
|
76
|
+
'fetchPositionsForSymbol': false,
|
|
77
|
+
'fetchPositionsHistory': false,
|
|
74
78
|
'fetchPositionsRisk': false,
|
|
75
79
|
'fetchPremiumIndexOHLCV': false,
|
|
76
80
|
'fetchTicker': true,
|
package/dist/cjs/src/novadax.js
CHANGED
|
@@ -75,7 +75,11 @@ class novadax extends novadax$1 {
|
|
|
75
75
|
'fetchOrders': true,
|
|
76
76
|
'fetchOrderTrades': true,
|
|
77
77
|
'fetchPosition': false,
|
|
78
|
+
'fetchPositionHistory': false,
|
|
79
|
+
'fetchPositionMode': false,
|
|
78
80
|
'fetchPositions': false,
|
|
81
|
+
'fetchPositionsForSymbol': false,
|
|
82
|
+
'fetchPositionsHistory': false,
|
|
79
83
|
'fetchPositionsRisk': false,
|
|
80
84
|
'fetchPremiumIndexOHLCV': false,
|
|
81
85
|
'fetchTicker': true,
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -31,8 +31,10 @@ class okx extends okx$1 {
|
|
|
31
31
|
'option': true,
|
|
32
32
|
'addMargin': true,
|
|
33
33
|
'cancelAllOrders': false,
|
|
34
|
+
'cancelAllOrdersAfter': true,
|
|
34
35
|
'cancelOrder': true,
|
|
35
36
|
'cancelOrders': true,
|
|
37
|
+
'cancelOrdersForSymbols': true,
|
|
36
38
|
'closeAllPositions': false,
|
|
37
39
|
'closePosition': true,
|
|
38
40
|
'createConvertTrade': true,
|
|
@@ -109,8 +111,10 @@ class okx extends okx$1 {
|
|
|
109
111
|
'fetchOrderTrades': true,
|
|
110
112
|
'fetchPermissions': undefined,
|
|
111
113
|
'fetchPosition': true,
|
|
114
|
+
'fetchPositionHistory': 'emulated',
|
|
112
115
|
'fetchPositions': true,
|
|
113
116
|
'fetchPositionsForSymbol': true,
|
|
117
|
+
'fetchPositionsHistory': true,
|
|
114
118
|
'fetchPositionsRisk': false,
|
|
115
119
|
'fetchPremiumIndexOHLCV': false,
|
|
116
120
|
'fetchSettlementHistory': true,
|
|
@@ -3282,6 +3286,117 @@ class okx extends okx$1 {
|
|
|
3282
3286
|
const ordersData = this.safeList(response, 'data', []);
|
|
3283
3287
|
return this.parseOrders(ordersData, market, undefined, undefined, params);
|
|
3284
3288
|
}
|
|
3289
|
+
async cancelOrdersForSymbols(orders, params = {}) {
|
|
3290
|
+
/**
|
|
3291
|
+
* @method
|
|
3292
|
+
* @name okx#cancelOrdersForSymbols
|
|
3293
|
+
* @description cancel multiple orders for multiple symbols
|
|
3294
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-multiple-orders
|
|
3295
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-post-cancel-algo-order
|
|
3296
|
+
* @param {CancellationRequest[]} orders each order should contain the parameters required by cancelOrder namely id and symbol
|
|
3297
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3298
|
+
* @param {boolean} [params.trigger] whether the order is a stop/trigger order
|
|
3299
|
+
* @param {boolean} [params.trailing] set to true if you want to cancel trailing orders
|
|
3300
|
+
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3301
|
+
*/
|
|
3302
|
+
await this.loadMarkets();
|
|
3303
|
+
const request = [];
|
|
3304
|
+
const options = this.safeDict(this.options, 'cancelOrders', {});
|
|
3305
|
+
const defaultMethod = this.safeString(options, 'method', 'privatePostTradeCancelBatchOrders');
|
|
3306
|
+
let method = this.safeString(params, 'method', defaultMethod);
|
|
3307
|
+
const stop = this.safeBool2(params, 'stop', 'trigger');
|
|
3308
|
+
const trailing = this.safeBool(params, 'trailing', false);
|
|
3309
|
+
const isStopOrTrailing = stop || trailing;
|
|
3310
|
+
if (isStopOrTrailing) {
|
|
3311
|
+
method = 'privatePostTradeCancelAlgos';
|
|
3312
|
+
}
|
|
3313
|
+
for (let i = 0; i < orders.length; i++) {
|
|
3314
|
+
const order = orders[i];
|
|
3315
|
+
const id = this.safeString(order, 'id');
|
|
3316
|
+
const clientOrderId = this.safeString2(order, 'clOrdId', 'clientOrderId');
|
|
3317
|
+
const symbol = this.safeString(order, 'symbol');
|
|
3318
|
+
const market = this.market(symbol);
|
|
3319
|
+
let idKey = 'ordId';
|
|
3320
|
+
if (isStopOrTrailing) {
|
|
3321
|
+
idKey = 'algoId';
|
|
3322
|
+
}
|
|
3323
|
+
else if (clientOrderId !== undefined) {
|
|
3324
|
+
idKey = 'clOrdId';
|
|
3325
|
+
}
|
|
3326
|
+
const requestItem = {
|
|
3327
|
+
'instId': market['id'],
|
|
3328
|
+
};
|
|
3329
|
+
requestItem[idKey] = (clientOrderId !== undefined) ? clientOrderId : id;
|
|
3330
|
+
request.push(requestItem);
|
|
3331
|
+
}
|
|
3332
|
+
let response = undefined;
|
|
3333
|
+
if (method === 'privatePostTradeCancelAlgos') {
|
|
3334
|
+
response = await this.privatePostTradeCancelAlgos(request); // * dont extend with params, otherwise ARRAY will be turned into OBJECT
|
|
3335
|
+
}
|
|
3336
|
+
else {
|
|
3337
|
+
response = await this.privatePostTradeCancelBatchOrders(request); // * dont extend with params, otherwise ARRAY will be turned into OBJECT
|
|
3338
|
+
}
|
|
3339
|
+
//
|
|
3340
|
+
// {
|
|
3341
|
+
// "code": "0",
|
|
3342
|
+
// "data": [
|
|
3343
|
+
// {
|
|
3344
|
+
// "clOrdId": "e123456789ec4dBC1123456ba123b45e",
|
|
3345
|
+
// "ordId": "405071912345641543",
|
|
3346
|
+
// "sCode": "0",
|
|
3347
|
+
// "sMsg": ""
|
|
3348
|
+
// },
|
|
3349
|
+
// ...
|
|
3350
|
+
// ],
|
|
3351
|
+
// "msg": ""
|
|
3352
|
+
// }
|
|
3353
|
+
//
|
|
3354
|
+
// Algo order
|
|
3355
|
+
//
|
|
3356
|
+
// {
|
|
3357
|
+
// "code": "0",
|
|
3358
|
+
// "data": [
|
|
3359
|
+
// {
|
|
3360
|
+
// "algoId": "431375349042380800",
|
|
3361
|
+
// "sCode": "0",
|
|
3362
|
+
// "sMsg": ""
|
|
3363
|
+
// }
|
|
3364
|
+
// ],
|
|
3365
|
+
// "msg": ""
|
|
3366
|
+
// }
|
|
3367
|
+
//
|
|
3368
|
+
const ordersData = this.safeList(response, 'data', []);
|
|
3369
|
+
return this.parseOrders(ordersData, undefined, undefined, undefined, params);
|
|
3370
|
+
}
|
|
3371
|
+
async cancelAllOrdersAfter(timeout, params = {}) {
|
|
3372
|
+
/**
|
|
3373
|
+
* @method
|
|
3374
|
+
* @name okx#cancelAllOrdersAfter
|
|
3375
|
+
* @description dead man's switch, cancel all orders after the given timeout
|
|
3376
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-all-after
|
|
3377
|
+
* @param {number} timeout time in milliseconds, 0 represents cancel the timer
|
|
3378
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3379
|
+
* @returns {object} the api result
|
|
3380
|
+
*/
|
|
3381
|
+
await this.loadMarkets();
|
|
3382
|
+
const request = {
|
|
3383
|
+
'timeOut': (timeout > 0) ? this.parseToInt(timeout / 1000) : 0,
|
|
3384
|
+
};
|
|
3385
|
+
const response = await this.privatePostTradeCancelAllAfter(this.extend(request, params));
|
|
3386
|
+
//
|
|
3387
|
+
// {
|
|
3388
|
+
// "code":"0",
|
|
3389
|
+
// "msg":"",
|
|
3390
|
+
// "data":[
|
|
3391
|
+
// {
|
|
3392
|
+
// "triggerTime":"1587971460",
|
|
3393
|
+
// "ts":"1587971400"
|
|
3394
|
+
// }
|
|
3395
|
+
// ]
|
|
3396
|
+
// }
|
|
3397
|
+
//
|
|
3398
|
+
return response;
|
|
3399
|
+
}
|
|
3285
3400
|
parseOrderStatus(status) {
|
|
3286
3401
|
const statuses = {
|
|
3287
3402
|
'canceled': 'canceled',
|
|
@@ -8086,6 +8201,87 @@ class okx extends okx$1 {
|
|
|
8086
8201
|
const modifications = this.parseMarginModifications(data);
|
|
8087
8202
|
return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
|
|
8088
8203
|
}
|
|
8204
|
+
async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
8205
|
+
/**
|
|
8206
|
+
* @method
|
|
8207
|
+
* @name okx#fetchPositionsHistory
|
|
8208
|
+
* @description fetches historical positions
|
|
8209
|
+
* @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions-history
|
|
8210
|
+
* @param {string} [symbols] unified market symbols
|
|
8211
|
+
* @param {int} [since] timestamp in ms of the earliest position to fetch
|
|
8212
|
+
* @param {int} [limit] the maximum amount of records to fetch, default=100, max=100
|
|
8213
|
+
* @param {object} params extra parameters specific to the exchange api endpoint
|
|
8214
|
+
* @param {string} [params.marginMode] "cross" or "isolated"
|
|
8215
|
+
*
|
|
8216
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
|
8217
|
+
* @param {string} [params.instType] margin, swap, futures or option
|
|
8218
|
+
* @param {string} [params.type] the type of latest close position 1: close position partially, 2:close all, 3:liquidation, 4:partial liquidation; 5:adl, is it is the latest type if there are several types for the same position
|
|
8219
|
+
* @param {string} [params.posId] position id, there is attribute expiration, the posid will be expired if it is more than 30 days after the last full close position, then position will use new posid
|
|
8220
|
+
* @param {string} [params.before] timestamp in ms of the earliest position to fetch based on the last update time of the position
|
|
8221
|
+
* @param {string} [params.after] timestamp in ms of the latest position to fetch based on the last update time of the position
|
|
8222
|
+
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
8223
|
+
*/
|
|
8224
|
+
await this.loadMarkets();
|
|
8225
|
+
const marginMode = this.safeString(params, 'marginMode');
|
|
8226
|
+
const instType = this.safeStringUpper(params, 'instType');
|
|
8227
|
+
params = this.omit(params, ['until', 'marginMode', 'instType']);
|
|
8228
|
+
if (limit === undefined) {
|
|
8229
|
+
limit = 100;
|
|
8230
|
+
}
|
|
8231
|
+
const request = {
|
|
8232
|
+
'limit': limit,
|
|
8233
|
+
};
|
|
8234
|
+
if (symbols !== undefined) {
|
|
8235
|
+
const symbolsLength = symbols.length;
|
|
8236
|
+
if (symbolsLength === 1) {
|
|
8237
|
+
const market = this.market(symbols[0]);
|
|
8238
|
+
request['instId'] = market['id'];
|
|
8239
|
+
}
|
|
8240
|
+
}
|
|
8241
|
+
if (marginMode !== undefined) {
|
|
8242
|
+
request['mgnMode'] = marginMode;
|
|
8243
|
+
}
|
|
8244
|
+
if (instType !== undefined) {
|
|
8245
|
+
request['instType'] = instType;
|
|
8246
|
+
}
|
|
8247
|
+
const response = await this.privateGetAccountPositionsHistory(this.extend(request, params));
|
|
8248
|
+
//
|
|
8249
|
+
// {
|
|
8250
|
+
// code: '0',
|
|
8251
|
+
// data: [
|
|
8252
|
+
// {
|
|
8253
|
+
// cTime: '1708735940395',
|
|
8254
|
+
// ccy: 'USDT',
|
|
8255
|
+
// closeAvgPx: '0.6330444444444444',
|
|
8256
|
+
// closeTotalPos: '27',
|
|
8257
|
+
// direction: 'long',
|
|
8258
|
+
// fee: '-1.69566',
|
|
8259
|
+
// fundingFee: '-11.870404179341788',
|
|
8260
|
+
// instId: 'XRP-USDT-SWAP',
|
|
8261
|
+
// instType: 'SWAP',
|
|
8262
|
+
// lever: '3.0',
|
|
8263
|
+
// liqPenalty: '0',
|
|
8264
|
+
// mgnMode: 'cross',
|
|
8265
|
+
// openAvgPx: '0.623',
|
|
8266
|
+
// openMaxPos: '15',
|
|
8267
|
+
// pnl: '27.11999999999988',
|
|
8268
|
+
// pnlRatio: '0.0241732402722634',
|
|
8269
|
+
// posId: '681423155054862336',
|
|
8270
|
+
// realizedPnl: '13.553935820658092',
|
|
8271
|
+
// triggerPx: '',
|
|
8272
|
+
// type: '2',
|
|
8273
|
+
// uTime: '1711088748170',
|
|
8274
|
+
// uly: 'XRP-USDT'
|
|
8275
|
+
// },
|
|
8276
|
+
// ...
|
|
8277
|
+
// ],
|
|
8278
|
+
// msg: ''
|
|
8279
|
+
// }
|
|
8280
|
+
//
|
|
8281
|
+
const data = this.safeList(response, 'data');
|
|
8282
|
+
const positions = this.parsePositions(data, symbols, params);
|
|
8283
|
+
return this.filterBySinceLimit(positions, since, limit);
|
|
8284
|
+
}
|
|
8089
8285
|
}
|
|
8090
8286
|
|
|
8091
8287
|
module.exports = okx;
|
|
@@ -74,8 +74,11 @@ class onetrading extends onetrading$1 {
|
|
|
74
74
|
'fetchOrders': false,
|
|
75
75
|
'fetchOrderTrades': true,
|
|
76
76
|
'fetchPosition': false,
|
|
77
|
+
'fetchPositionHistory': false,
|
|
77
78
|
'fetchPositionMode': false,
|
|
78
79
|
'fetchPositions': false,
|
|
80
|
+
'fetchPositionsForSymbol': false,
|
|
81
|
+
'fetchPositionsHistory': false,
|
|
79
82
|
'fetchPositionsRisk': false,
|
|
80
83
|
'fetchPremiumIndexOHLCV': false,
|
|
81
84
|
'fetchTicker': true,
|
package/dist/cjs/src/p2b.js
CHANGED
|
@@ -79,8 +79,11 @@ class p2b extends p2b$1 {
|
|
|
79
79
|
'fetchOrderTrades': true,
|
|
80
80
|
'fetchPermissions': false,
|
|
81
81
|
'fetchPosition': false,
|
|
82
|
+
'fetchPositionHistory': false,
|
|
83
|
+
'fetchPositionMode': false,
|
|
82
84
|
'fetchPositions': false,
|
|
83
85
|
'fetchPositionsForSymbol': false,
|
|
86
|
+
'fetchPositionsHistory': false,
|
|
84
87
|
'fetchPositionsRisk': false,
|
|
85
88
|
'fetchPremiumIndexOHLCV': false,
|
|
86
89
|
'fetchTicker': true,
|
|
@@ -1004,7 +1004,7 @@ class bitget extends bitget$1 {
|
|
|
1004
1004
|
}
|
|
1005
1005
|
return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
|
|
1006
1006
|
}
|
|
1007
|
-
handleOrder(client, message
|
|
1007
|
+
handleOrder(client, message) {
|
|
1008
1008
|
//
|
|
1009
1009
|
// spot
|
|
1010
1010
|
//
|
|
@@ -46,7 +46,7 @@ class coinbase extends coinbase$1 {
|
|
|
46
46
|
},
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
async subscribe(name, symbol = undefined, params = {}) {
|
|
49
|
+
async subscribe(name, isPrivate, symbol = undefined, params = {}) {
|
|
50
50
|
/**
|
|
51
51
|
* @ignore
|
|
52
52
|
* @method
|
|
@@ -58,7 +58,6 @@ class coinbase extends coinbase$1 {
|
|
|
58
58
|
* @returns {object} subscription to a websocket channel
|
|
59
59
|
*/
|
|
60
60
|
await this.loadMarkets();
|
|
61
|
-
this.checkRequiredCredentials();
|
|
62
61
|
let market = undefined;
|
|
63
62
|
let messageHash = name;
|
|
64
63
|
let productIds = [];
|
|
@@ -75,8 +74,6 @@ class coinbase extends coinbase$1 {
|
|
|
75
74
|
}
|
|
76
75
|
const url = this.urls['api']['ws'];
|
|
77
76
|
const timestamp = this.numberToString(this.seconds());
|
|
78
|
-
const isCloudAPiKey = (this.apiKey.indexOf('organizations/') >= 0) || (this.secret.startsWith('-----BEGIN'));
|
|
79
|
-
const auth = timestamp + name + productIds.join(',');
|
|
80
77
|
const subscribe = {
|
|
81
78
|
'type': 'subscribe',
|
|
82
79
|
'product_ids': productIds,
|
|
@@ -85,25 +82,30 @@ class coinbase extends coinbase$1 {
|
|
|
85
82
|
// 'timestamp': timestamp,
|
|
86
83
|
// 'signature': this.hmac (this.encode (auth), this.encode (this.secret), sha256),
|
|
87
84
|
};
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
85
|
+
if (isPrivate) {
|
|
86
|
+
this.checkRequiredCredentials();
|
|
87
|
+
const isCloudAPiKey = (this.apiKey.indexOf('organizations/') >= 0) || (this.secret.startsWith('-----BEGIN'));
|
|
88
|
+
const auth = timestamp + name + productIds.join(',');
|
|
89
|
+
if (!isCloudAPiKey) {
|
|
90
|
+
subscribe['api_key'] = this.apiKey;
|
|
91
|
+
subscribe['timestamp'] = timestamp;
|
|
92
|
+
subscribe['signature'] = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
|
|
96
93
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
94
|
+
else {
|
|
95
|
+
if (this.apiKey.startsWith('-----BEGIN')) {
|
|
96
|
+
throw new errors.ArgumentsRequired(this.id + ' apiKey should contain the name (eg: organizations/3b910e93....) and not the public key');
|
|
97
|
+
}
|
|
98
|
+
const currentToken = this.safeString(this.options, 'wsToken');
|
|
99
|
+
const tokenTimestamp = this.safeInteger(this.options, 'wsTokenTimestamp', 0);
|
|
100
|
+
const seconds = this.seconds();
|
|
101
|
+
if (currentToken === undefined || tokenTimestamp + 120 < seconds) {
|
|
102
|
+
// we should generate new token
|
|
103
|
+
const token = this.createAuthToken(seconds);
|
|
104
|
+
this.options['wsToken'] = token;
|
|
105
|
+
this.options['wsTokenTimestamp'] = seconds;
|
|
106
|
+
}
|
|
107
|
+
subscribe['jwt'] = this.safeString(this.options, 'wsToken');
|
|
105
108
|
}
|
|
106
|
-
subscribe['jwt'] = this.safeString(this.options, 'wsToken');
|
|
107
109
|
}
|
|
108
110
|
return await this.watch(url, messageHash, subscribe, messageHash);
|
|
109
111
|
}
|
|
@@ -118,7 +120,7 @@ class coinbase extends coinbase$1 {
|
|
|
118
120
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
119
121
|
*/
|
|
120
122
|
const name = 'ticker';
|
|
121
|
-
return await this.subscribe(name, symbol, params);
|
|
123
|
+
return await this.subscribe(name, false, symbol, params);
|
|
122
124
|
}
|
|
123
125
|
async watchTickers(symbols = undefined, params = {}) {
|
|
124
126
|
/**
|
|
@@ -134,7 +136,7 @@ class coinbase extends coinbase$1 {
|
|
|
134
136
|
symbols = this.symbols;
|
|
135
137
|
}
|
|
136
138
|
const name = 'ticker_batch';
|
|
137
|
-
const tickers = await this.subscribe(name, symbols, params);
|
|
139
|
+
const tickers = await this.subscribe(name, false, symbols, params);
|
|
138
140
|
if (this.newUpdates) {
|
|
139
141
|
return tickers;
|
|
140
142
|
}
|
|
@@ -298,7 +300,7 @@ class coinbase extends coinbase$1 {
|
|
|
298
300
|
await this.loadMarkets();
|
|
299
301
|
symbol = this.symbol(symbol);
|
|
300
302
|
const name = 'market_trades';
|
|
301
|
-
const trades = await this.subscribe(name, symbol, params);
|
|
303
|
+
const trades = await this.subscribe(name, false, symbol, params);
|
|
302
304
|
if (this.newUpdates) {
|
|
303
305
|
limit = trades.getLimit(symbol, limit);
|
|
304
306
|
}
|
|
@@ -318,7 +320,7 @@ class coinbase extends coinbase$1 {
|
|
|
318
320
|
*/
|
|
319
321
|
await this.loadMarkets();
|
|
320
322
|
const name = 'user';
|
|
321
|
-
const orders = await this.subscribe(name, symbol, params);
|
|
323
|
+
const orders = await this.subscribe(name, true, symbol, params);
|
|
322
324
|
if (this.newUpdates) {
|
|
323
325
|
limit = orders.getLimit(symbol, limit);
|
|
324
326
|
}
|
|
@@ -339,7 +341,7 @@ class coinbase extends coinbase$1 {
|
|
|
339
341
|
const name = 'level2';
|
|
340
342
|
const market = this.market(symbol);
|
|
341
343
|
symbol = market['symbol'];
|
|
342
|
-
const orderbook = await this.subscribe(name, symbol, params);
|
|
344
|
+
const orderbook = await this.subscribe(name, false, symbol, params);
|
|
343
345
|
return orderbook.limit();
|
|
344
346
|
}
|
|
345
347
|
handleTrade(client, message) {
|
|
@@ -557,8 +559,8 @@ class coinbase extends coinbase$1 {
|
|
|
557
559
|
this.orderbooks[symbol] = this.orderBook({}, limit);
|
|
558
560
|
const orderbook = this.orderbooks[symbol];
|
|
559
561
|
this.handleOrderBookHelper(orderbook, updates);
|
|
560
|
-
orderbook['timestamp'] =
|
|
561
|
-
orderbook['datetime'] =
|
|
562
|
+
orderbook['timestamp'] = this.parse8601(datetime);
|
|
563
|
+
orderbook['datetime'] = datetime;
|
|
562
564
|
orderbook['symbol'] = symbol;
|
|
563
565
|
client.resolve(orderbook, messageHash);
|
|
564
566
|
if (messageHash.endsWith('USD')) {
|
|
@@ -577,7 +579,6 @@ class coinbase extends coinbase$1 {
|
|
|
577
579
|
}
|
|
578
580
|
}
|
|
579
581
|
}
|
|
580
|
-
return message;
|
|
581
582
|
}
|
|
582
583
|
handleSubscriptionStatus(client, message) {
|
|
583
584
|
//
|
package/dist/cjs/src/probit.js
CHANGED
|
@@ -67,8 +67,11 @@ class probit extends probit$1 {
|
|
|
67
67
|
'fetchOrder': true,
|
|
68
68
|
'fetchOrderBook': true,
|
|
69
69
|
'fetchPosition': false,
|
|
70
|
+
'fetchPositionHistory': false,
|
|
70
71
|
'fetchPositionMode': false,
|
|
71
72
|
'fetchPositions': false,
|
|
73
|
+
'fetchPositionsForSymbol': false,
|
|
74
|
+
'fetchPositionsHistory': false,
|
|
72
75
|
'fetchPositionsRisk': false,
|
|
73
76
|
'fetchPremiumIndexOHLCV': false,
|
|
74
77
|
'fetchTicker': true,
|
package/dist/cjs/src/timex.js
CHANGED
|
@@ -64,8 +64,11 @@ class timex extends timex$1 {
|
|
|
64
64
|
'fetchOrder': true,
|
|
65
65
|
'fetchOrderBook': true,
|
|
66
66
|
'fetchPosition': false,
|
|
67
|
+
'fetchPositionHistory': false,
|
|
67
68
|
'fetchPositionMode': false,
|
|
68
69
|
'fetchPositions': false,
|
|
70
|
+
'fetchPositionsForSymbol': false,
|
|
71
|
+
'fetchPositionsHistory': false,
|
|
69
72
|
'fetchPositionsRisk': false,
|
|
70
73
|
'fetchPremiumIndexOHLCV': false,
|
|
71
74
|
'fetchTicker': true,
|
|
@@ -79,8 +79,11 @@ class tradeogre extends tradeogre$1 {
|
|
|
79
79
|
'fetchOrderTrades': false,
|
|
80
80
|
'fetchPermissions': false,
|
|
81
81
|
'fetchPosition': false,
|
|
82
|
+
'fetchPositionHistory': false,
|
|
83
|
+
'fetchPositionMode': false,
|
|
82
84
|
'fetchPositions': false,
|
|
83
85
|
'fetchPositionsForSymbol': false,
|
|
86
|
+
'fetchPositionsHistory': false,
|
|
84
87
|
'fetchPositionsRisk': false,
|
|
85
88
|
'fetchPremiumIndexOHLCV': false,
|
|
86
89
|
'fetchTicker': true,
|
|
@@ -66,8 +66,11 @@ class wavesexchange extends wavesexchange$1 {
|
|
|
66
66
|
'fetchOrderBook': true,
|
|
67
67
|
'fetchOrders': true,
|
|
68
68
|
'fetchPosition': false,
|
|
69
|
+
'fetchPositionHistory': false,
|
|
69
70
|
'fetchPositionMode': false,
|
|
70
71
|
'fetchPositions': false,
|
|
72
|
+
'fetchPositionsForSymbol': false,
|
|
73
|
+
'fetchPositionsHistory': false,
|
|
71
74
|
'fetchPositionsRisk': false,
|
|
72
75
|
'fetchPremiumIndexOHLCV': false,
|
|
73
76
|
'fetchTicker': true,
|
package/dist/cjs/src/wazirx.js
CHANGED
|
@@ -71,8 +71,11 @@ class wazirx extends wazirx$1 {
|
|
|
71
71
|
'fetchOrderBook': true,
|
|
72
72
|
'fetchOrders': true,
|
|
73
73
|
'fetchPosition': false,
|
|
74
|
+
'fetchPositionHistory': false,
|
|
74
75
|
'fetchPositionMode': false,
|
|
75
76
|
'fetchPositions': false,
|
|
77
|
+
'fetchPositionsForSymbol': false,
|
|
78
|
+
'fetchPositionsHistory': false,
|
|
76
79
|
'fetchPositionsRisk': false,
|
|
77
80
|
'fetchPremiumIndexOHLCV': false,
|
|
78
81
|
'fetchStatus': true,
|