ccxt 4.3.33 → 4.3.34
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 +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +26 -0
- package/dist/cjs/src/binance.js +1 -0
- package/dist/cjs/src/coinbase.js +106 -53
- package/dist/cjs/src/pro/binance.js +352 -0
- package/dist/cjs/src/pro/bitmex.js +108 -0
- package/dist/cjs/src/pro/bybit.js +85 -0
- package/dist/cjs/src/pro/gate.js +183 -0
- package/dist/cjs/src/pro/kucoinfutures.js +4 -0
- package/dist/cjs/src/pro/okx.js +259 -1
- 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/ace.d.ts +3 -3
- package/js/src/alpaca.d.ts +2 -2
- package/js/src/ascendex.d.ts +3 -3
- package/js/src/base/Exchange.d.ts +13 -3
- package/js/src/base/Exchange.js +26 -0
- package/js/src/base/types.d.ts +1 -0
- package/js/src/bigone.d.ts +3 -3
- package/js/src/binance.d.ts +4 -4
- package/js/src/binance.js +1 -0
- package/js/src/bingx.d.ts +3 -3
- package/js/src/bit2c.d.ts +2 -2
- package/js/src/bitbank.d.ts +2 -2
- package/js/src/bitbns.d.ts +2 -2
- package/js/src/bitfinex.d.ts +3 -3
- package/js/src/bitfinex2.d.ts +1 -1
- package/js/src/bitflyer.d.ts +2 -2
- package/js/src/bitget.d.ts +4 -4
- package/js/src/bithumb.d.ts +2 -2
- package/js/src/bitmart.d.ts +3 -3
- package/js/src/bitmex.d.ts +4 -4
- package/js/src/bitopro.d.ts +4 -4
- package/js/src/bitrue.d.ts +3 -3
- package/js/src/bitso.d.ts +3 -3
- package/js/src/bitstamp.d.ts +3 -3
- package/js/src/bitteam.d.ts +4 -4
- package/js/src/bitvavo.d.ts +3 -3
- package/js/src/blockchaincom.d.ts +2 -2
- package/js/src/blofin.d.ts +4 -4
- package/js/src/btcalpha.d.ts +4 -4
- package/js/src/btcbox.d.ts +2 -2
- package/js/src/btcmarkets.d.ts +4 -4
- package/js/src/btcturk.d.ts +2 -2
- package/js/src/bybit.d.ts +3 -3
- package/js/src/cex.d.ts +2 -2
- package/js/src/coinbase.d.ts +3 -3
- package/js/src/coinbase.js +106 -53
- package/js/src/coinbaseexchange.d.ts +2 -2
- package/js/src/coinbaseinternational.d.ts +4 -4
- package/js/src/coincheck.d.ts +3 -3
- package/js/src/coinex.d.ts +3 -3
- package/js/src/coinlist.d.ts +3 -3
- package/js/src/coinmate.d.ts +3 -3
- package/js/src/coinmetro.d.ts +3 -3
- package/js/src/coinone.d.ts +2 -2
- package/js/src/coinsph.d.ts +3 -3
- package/js/src/cryptocom.d.ts +2 -2
- package/js/src/currencycom.d.ts +3 -3
- package/js/src/delta.d.ts +2 -2
- package/js/src/deribit.d.ts +3 -3
- package/js/src/digifinex.d.ts +3 -3
- package/js/src/exmo.d.ts +3 -3
- package/js/src/gate.d.ts +3 -3
- package/js/src/gemini.d.ts +3 -3
- package/js/src/hitbtc.d.ts +3 -3
- package/js/src/hollaex.d.ts +2 -2
- package/js/src/htx.d.ts +3 -3
- package/js/src/huobijp.d.ts +3 -3
- package/js/src/hyperliquid.d.ts +3 -3
- package/js/src/idex.d.ts +3 -3
- package/js/src/indodax.d.ts +3 -3
- package/js/src/kraken.d.ts +3 -3
- package/js/src/krakenfutures.d.ts +2 -2
- package/js/src/kucoin.d.ts +3 -3
- package/js/src/kuna.d.ts +3 -3
- package/js/src/latoken.d.ts +3 -3
- package/js/src/lbank.d.ts +2 -2
- package/js/src/luno.d.ts +2 -2
- package/js/src/lykke.d.ts +2 -2
- package/js/src/mercado.d.ts +2 -2
- package/js/src/mexc.d.ts +2 -2
- package/js/src/ndax.d.ts +3 -3
- package/js/src/novadax.d.ts +4 -4
- package/js/src/oceanex.d.ts +3 -3
- package/js/src/okcoin.d.ts +4 -4
- package/js/src/okx.d.ts +4 -4
- package/js/src/onetrading.d.ts +3 -3
- package/js/src/p2b.d.ts +3 -3
- package/js/src/paymium.d.ts +2 -2
- package/js/src/phemex.d.ts +5 -5
- package/js/src/poloniex.d.ts +4 -4
- package/js/src/poloniexfutures.d.ts +3 -3
- package/js/src/pro/binance.d.ts +9 -2
- package/js/src/pro/binance.js +352 -0
- package/js/src/pro/bitmex.d.ts +4 -1
- package/js/src/pro/bitmex.js +108 -0
- package/js/src/pro/bybit.d.ts +4 -1
- package/js/src/pro/bybit.js +85 -0
- package/js/src/pro/gate.d.ts +5 -1
- package/js/src/pro/gate.js +183 -0
- package/js/src/pro/kucoinfutures.js +4 -0
- package/js/src/pro/okx.d.ts +8 -1
- package/js/src/pro/okx.js +259 -1
- package/js/src/probit.d.ts +4 -4
- package/js/src/timex.d.ts +3 -3
- package/js/src/tokocrypto.d.ts +2 -2
- package/js/src/tradeogre.d.ts +2 -2
- package/js/src/upbit.d.ts +4 -4
- package/js/src/wavesexchange.d.ts +2 -2
- package/js/src/wazirx.d.ts +4 -4
- package/js/src/whitebit.d.ts +4 -4
- package/js/src/woo.d.ts +4 -4
- package/js/src/woofipro.d.ts +4 -4
- package/js/src/yobit.d.ts +2 -2
- package/js/src/zaif.d.ts +3 -3
- package/js/src/zonda.d.ts +2 -2
- package/package.json +1 -1
package/dist/cjs/src/pro/gate.js
CHANGED
|
@@ -4,6 +4,7 @@ var gate$1 = require('../gate.js');
|
|
|
4
4
|
var errors = require('../base/errors.js');
|
|
5
5
|
var Cache = require('../base/ws/Cache.js');
|
|
6
6
|
var sha512 = require('../static_dependencies/noble-hashes/sha512.js');
|
|
7
|
+
var Precise = require('../base/Precise.js');
|
|
7
8
|
|
|
8
9
|
// ---------------------------------------------------------------------------
|
|
9
10
|
// ---------------------------------------------------------------------------
|
|
@@ -21,6 +22,10 @@ class gate extends gate$1 {
|
|
|
21
22
|
'watchOHLCV': true,
|
|
22
23
|
'watchBalance': true,
|
|
23
24
|
'watchOrders': true,
|
|
25
|
+
'watchLiquidations': false,
|
|
26
|
+
'watchLiquidationsForSymbols': false,
|
|
27
|
+
'watchMyLiquidations': true,
|
|
28
|
+
'watchMyLiquidationsForSymbols': true,
|
|
24
29
|
'watchPositions': true,
|
|
25
30
|
},
|
|
26
31
|
'urls': {
|
|
@@ -1038,6 +1043,183 @@ class gate extends gate$1 {
|
|
|
1038
1043
|
}
|
|
1039
1044
|
client.resolve(this.orders, 'orders');
|
|
1040
1045
|
}
|
|
1046
|
+
async watchMyLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
|
|
1047
|
+
/**
|
|
1048
|
+
* @method
|
|
1049
|
+
* @name gate#watchMyLiquidations
|
|
1050
|
+
* @description watch the public liquidations of a trading pair
|
|
1051
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#liquidates-api
|
|
1052
|
+
* @see https://www.gate.io/docs/developers/delivery/ws/en/#liquidates-api
|
|
1053
|
+
* @see https://www.gate.io/docs/developers/options/ws/en/#liquidates-channel
|
|
1054
|
+
* @param {string} symbol unified CCXT market symbol
|
|
1055
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
1056
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
1057
|
+
* @param {object} [params] exchange specific parameters for the bitmex api endpoint
|
|
1058
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
1059
|
+
*/
|
|
1060
|
+
return this.watchMyLiquidationsForSymbols([symbol], since, limit, params);
|
|
1061
|
+
}
|
|
1062
|
+
async watchMyLiquidationsForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1063
|
+
/**
|
|
1064
|
+
* @method
|
|
1065
|
+
* @name gate#watchMyLiquidationsForSymbols
|
|
1066
|
+
* @description watch the private liquidations of a trading pair
|
|
1067
|
+
* @see https://www.gate.io/docs/developers/futures/ws/en/#liquidates-api
|
|
1068
|
+
* @see https://www.gate.io/docs/developers/delivery/ws/en/#liquidates-api
|
|
1069
|
+
* @see https://www.gate.io/docs/developers/options/ws/en/#liquidates-channel
|
|
1070
|
+
* @param {string} symbol unified CCXT market symbol
|
|
1071
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
1072
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
1073
|
+
* @param {object} [params] exchange specific parameters for the gate api endpoint
|
|
1074
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
1075
|
+
*/
|
|
1076
|
+
await this.loadMarkets();
|
|
1077
|
+
symbols = this.marketSymbols(symbols, undefined, true, true);
|
|
1078
|
+
const market = this.getMarketFromSymbols(symbols);
|
|
1079
|
+
let type = undefined;
|
|
1080
|
+
let query = undefined;
|
|
1081
|
+
[type, query] = this.handleMarketTypeAndParams('watchMyLiquidationsForSymbols', market, params);
|
|
1082
|
+
const typeId = this.getSupportedMapping(type, {
|
|
1083
|
+
'future': 'futures',
|
|
1084
|
+
'swap': 'futures',
|
|
1085
|
+
'option': 'options',
|
|
1086
|
+
});
|
|
1087
|
+
let subType = undefined;
|
|
1088
|
+
[subType, query] = this.handleSubTypeAndParams('watchMyLiquidationsForSymbols', market, query);
|
|
1089
|
+
const isInverse = (subType === 'inverse');
|
|
1090
|
+
const url = this.getUrlByMarketType(type, isInverse);
|
|
1091
|
+
const payload = [];
|
|
1092
|
+
let messageHash = '';
|
|
1093
|
+
if (this.isEmpty(symbols)) {
|
|
1094
|
+
if (typeId !== 'futures' && !isInverse) {
|
|
1095
|
+
throw new errors.BadRequest(this.id + ' watchMyLiquidationsForSymbols() does not support listening to all symbols, you must call watchMyLiquidations() instead for each symbol you wish to watch.');
|
|
1096
|
+
}
|
|
1097
|
+
messageHash = 'myLiquidations';
|
|
1098
|
+
payload.push('!all');
|
|
1099
|
+
}
|
|
1100
|
+
else {
|
|
1101
|
+
const symbolsLength = symbols.length;
|
|
1102
|
+
if (symbolsLength !== 1) {
|
|
1103
|
+
throw new errors.BadRequest(this.id + ' watchMyLiquidationsForSymbols() only allows one symbol at a time. To listen to several symbols call watchMyLiquidationsForSymbols() several times.');
|
|
1104
|
+
}
|
|
1105
|
+
messageHash = 'myLiquidations::' + symbols[0];
|
|
1106
|
+
payload.push(market['id']);
|
|
1107
|
+
}
|
|
1108
|
+
const channel = typeId + '.liquidates';
|
|
1109
|
+
const newLiquidations = await this.subscribePrivate(url, messageHash, payload, channel, query, true);
|
|
1110
|
+
if (this.newUpdates) {
|
|
1111
|
+
return newLiquidations;
|
|
1112
|
+
}
|
|
1113
|
+
return this.filterBySymbolsSinceLimit(this.liquidations, symbols, since, limit, true);
|
|
1114
|
+
}
|
|
1115
|
+
handleLiquidation(client, message) {
|
|
1116
|
+
//
|
|
1117
|
+
// future / delivery
|
|
1118
|
+
// {
|
|
1119
|
+
// "channel":"futures.liquidates",
|
|
1120
|
+
// "event":"update",
|
|
1121
|
+
// "time":1541505434,
|
|
1122
|
+
// "time_ms":1541505434123,
|
|
1123
|
+
// "result":[
|
|
1124
|
+
// {
|
|
1125
|
+
// "entry_price":209,
|
|
1126
|
+
// "fill_price":215.1,
|
|
1127
|
+
// "left":0,
|
|
1128
|
+
// "leverage":0.0,
|
|
1129
|
+
// "liq_price":213,
|
|
1130
|
+
// "margin":0.007816722941,
|
|
1131
|
+
// "mark_price":213,
|
|
1132
|
+
// "order_id":4093362,
|
|
1133
|
+
// "order_price":215.1,
|
|
1134
|
+
// "size":-124,
|
|
1135
|
+
// "time":1541486601,
|
|
1136
|
+
// "time_ms":1541486601123,
|
|
1137
|
+
// "contract":"BTC_USD",
|
|
1138
|
+
// "user":"1040xxxx"
|
|
1139
|
+
// }
|
|
1140
|
+
// ]
|
|
1141
|
+
// }
|
|
1142
|
+
// option
|
|
1143
|
+
// {
|
|
1144
|
+
// "channel":"options.liquidates",
|
|
1145
|
+
// "event":"update",
|
|
1146
|
+
// "time":1630654851,
|
|
1147
|
+
// "result":[
|
|
1148
|
+
// {
|
|
1149
|
+
// "user":"1xxxx",
|
|
1150
|
+
// "init_margin":1190,
|
|
1151
|
+
// "maint_margin":1042.5,
|
|
1152
|
+
// "order_margin":0,
|
|
1153
|
+
// "time":1639051907,
|
|
1154
|
+
// "time_ms":1639051907000
|
|
1155
|
+
// }
|
|
1156
|
+
// ]
|
|
1157
|
+
// }
|
|
1158
|
+
//
|
|
1159
|
+
const rawLiquidations = this.safeList(message, 'result', []);
|
|
1160
|
+
const newLiquidations = [];
|
|
1161
|
+
for (let i = 0; i < rawLiquidations.length; i++) {
|
|
1162
|
+
const rawLiquidation = rawLiquidations[i];
|
|
1163
|
+
const liquidation = this.parseWsLiquidation(rawLiquidation);
|
|
1164
|
+
const symbol = this.safeString(liquidation, 'symbol');
|
|
1165
|
+
let liquidations = this.safeValue(this.liquidations, symbol);
|
|
1166
|
+
if (liquidations === undefined) {
|
|
1167
|
+
const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
|
|
1168
|
+
liquidations = new Cache.ArrayCache(limit);
|
|
1169
|
+
}
|
|
1170
|
+
liquidations.append(liquidation);
|
|
1171
|
+
this.liquidations[symbol] = liquidations;
|
|
1172
|
+
client.resolve(liquidations, 'myLiquidations::' + symbol);
|
|
1173
|
+
}
|
|
1174
|
+
client.resolve(newLiquidations, 'myLiquidations');
|
|
1175
|
+
}
|
|
1176
|
+
parseWsLiquidation(liquidation, market = undefined) {
|
|
1177
|
+
//
|
|
1178
|
+
// future / delivery
|
|
1179
|
+
// {
|
|
1180
|
+
// "entry_price": 209,
|
|
1181
|
+
// "fill_price": 215.1,
|
|
1182
|
+
// "left": 0,
|
|
1183
|
+
// "leverage": 0.0,
|
|
1184
|
+
// "liq_price": 213,
|
|
1185
|
+
// "margin": 0.007816722941,
|
|
1186
|
+
// "mark_price": 213,
|
|
1187
|
+
// "order_id": 4093362,
|
|
1188
|
+
// "order_price": 215.1,
|
|
1189
|
+
// "size": -124,
|
|
1190
|
+
// "time": 1541486601,
|
|
1191
|
+
// "time_ms": 1541486601123,
|
|
1192
|
+
// "contract": "BTC_USD",
|
|
1193
|
+
// "user": "1040xxxx"
|
|
1194
|
+
// }
|
|
1195
|
+
// option
|
|
1196
|
+
// {
|
|
1197
|
+
// "user": "1xxxx",
|
|
1198
|
+
// "init_margin": 1190,
|
|
1199
|
+
// "maint_margin": 1042.5,
|
|
1200
|
+
// "order_margin": 0,
|
|
1201
|
+
// "time": 1639051907,
|
|
1202
|
+
// "time_ms": 1639051907000
|
|
1203
|
+
// }
|
|
1204
|
+
//
|
|
1205
|
+
const marketId = this.safeString(liquidation, 'contract');
|
|
1206
|
+
market = this.safeMarket(marketId, market);
|
|
1207
|
+
const timestamp = this.safeInteger(liquidation, 'time_ms');
|
|
1208
|
+
const originalSize = this.safeString(liquidation, 'size');
|
|
1209
|
+
const left = this.safeString(liquidation, 'left');
|
|
1210
|
+
const amount = Precise["default"].stringAbs(Precise["default"].stringSub(originalSize, left));
|
|
1211
|
+
return this.safeLiquidation({
|
|
1212
|
+
'info': liquidation,
|
|
1213
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
1214
|
+
'contracts': this.parseNumber(amount),
|
|
1215
|
+
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
1216
|
+
'price': this.safeNumber(liquidation, 'fill_price'),
|
|
1217
|
+
'baseValue': undefined,
|
|
1218
|
+
'quoteValue': undefined,
|
|
1219
|
+
'timestamp': timestamp,
|
|
1220
|
+
'datetime': this.iso8601(timestamp),
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1041
1223
|
handleErrorMessage(client, message) {
|
|
1042
1224
|
// {
|
|
1043
1225
|
// "time": 1647274664,
|
|
@@ -1211,6 +1393,7 @@ class gate extends gate$1 {
|
|
|
1211
1393
|
'trades': this.handleTrades,
|
|
1212
1394
|
'order_book_update': this.handleOrderBook,
|
|
1213
1395
|
'balances': this.handleBalance,
|
|
1396
|
+
'liquidates': this.handleLiquidation,
|
|
1214
1397
|
};
|
|
1215
1398
|
const method = this.safeValue(v4Methods, channelType);
|
|
1216
1399
|
if (method !== undefined) {
|
|
@@ -11,6 +11,10 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
11
11
|
return this.deepExtend(super.describe(), {
|
|
12
12
|
'has': {
|
|
13
13
|
'ws': true,
|
|
14
|
+
'watchLiquidations': false,
|
|
15
|
+
'watchLiquidatinsForSymbols': false,
|
|
16
|
+
'watchMyLiquidations': undefined,
|
|
17
|
+
'watchMyLiquidationsForSymbols': undefined,
|
|
14
18
|
'watchTicker': true,
|
|
15
19
|
'watchTickers': true,
|
|
16
20
|
'watchBidsAsks': true,
|
package/dist/cjs/src/pro/okx.js
CHANGED
|
@@ -19,6 +19,10 @@ class okx extends okx$1 {
|
|
|
19
19
|
'watchTradesForSymbols': true,
|
|
20
20
|
'watchOrderBookForSymbols': true,
|
|
21
21
|
'watchBalance': true,
|
|
22
|
+
'watchLiquidations': 'emulated',
|
|
23
|
+
'watchLiquidationsForSymbols': true,
|
|
24
|
+
'watchMyLiquidations': 'emulated',
|
|
25
|
+
'watchMyLiquidationsForSymbols': true,
|
|
22
26
|
'watchOHLCV': true,
|
|
23
27
|
'watchOHLCVForSymbols': true,
|
|
24
28
|
'watchOrders': true,
|
|
@@ -155,7 +159,7 @@ class okx extends okx$1 {
|
|
|
155
159
|
this.deepExtend(firstArgument, params),
|
|
156
160
|
],
|
|
157
161
|
};
|
|
158
|
-
return
|
|
162
|
+
return this.watch(url, messageHash, request, messageHash);
|
|
159
163
|
}
|
|
160
164
|
async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
161
165
|
/**
|
|
@@ -419,6 +423,255 @@ class okx extends okx$1 {
|
|
|
419
423
|
}
|
|
420
424
|
return message;
|
|
421
425
|
}
|
|
426
|
+
async watchLiquidationsForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
427
|
+
/**
|
|
428
|
+
* @method
|
|
429
|
+
* @name okx#watchLiquidationsForSymbols
|
|
430
|
+
* @description watch the public liquidations of a trading pair
|
|
431
|
+
* @see https://www.okx.com/docs-v5/en/#public-data-websocket-liquidation-orders-channel
|
|
432
|
+
* @param {string} symbol unified CCXT market symbol
|
|
433
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
434
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
435
|
+
* @param {object} [params] exchange specific parameters for the okx api endpoint
|
|
436
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
437
|
+
*/
|
|
438
|
+
await this.loadMarkets();
|
|
439
|
+
symbols = this.marketSymbols(symbols, undefined, true, true);
|
|
440
|
+
let messageHash = 'liquidations';
|
|
441
|
+
if (symbols !== undefined) {
|
|
442
|
+
messageHash += '::' + symbols.join(',');
|
|
443
|
+
}
|
|
444
|
+
const market = this.getMarketFromSymbols(symbols);
|
|
445
|
+
let type = undefined;
|
|
446
|
+
[type, params] = this.handleMarketTypeAndParams('watchliquidationsForSymbols', market, params);
|
|
447
|
+
const channel = 'liquidation-orders';
|
|
448
|
+
if (type === 'spot') {
|
|
449
|
+
type = 'SWAP';
|
|
450
|
+
}
|
|
451
|
+
else if (type === 'future') {
|
|
452
|
+
type = 'futures';
|
|
453
|
+
}
|
|
454
|
+
const uppercaseType = type.toUpperCase();
|
|
455
|
+
const request = {
|
|
456
|
+
'instType': uppercaseType,
|
|
457
|
+
};
|
|
458
|
+
const newLiquidations = await this.subscribe('public', messageHash, channel, undefined, this.extend(request, params));
|
|
459
|
+
if (this.newUpdates) {
|
|
460
|
+
return newLiquidations;
|
|
461
|
+
}
|
|
462
|
+
return this.filterBySymbolsSinceLimit(this.liquidations, symbols, since, limit, true);
|
|
463
|
+
}
|
|
464
|
+
handleLiquidation(client, message) {
|
|
465
|
+
//
|
|
466
|
+
// {
|
|
467
|
+
// "arg": {
|
|
468
|
+
// "channel": "liquidation-orders",
|
|
469
|
+
// "instType": "SWAP"
|
|
470
|
+
// },
|
|
471
|
+
// "data": [
|
|
472
|
+
// {
|
|
473
|
+
// "details": [
|
|
474
|
+
// {
|
|
475
|
+
// "bkLoss": "0",
|
|
476
|
+
// "bkPx": "0.007831",
|
|
477
|
+
// "ccy": "",
|
|
478
|
+
// "posSide": "short",
|
|
479
|
+
// "side": "buy",
|
|
480
|
+
// "sz": "13",
|
|
481
|
+
// "ts": "1692266434010"
|
|
482
|
+
// }
|
|
483
|
+
// ],
|
|
484
|
+
// "instFamily": "IOST-USDT",
|
|
485
|
+
// "instId": "IOST-USDT-SWAP",
|
|
486
|
+
// "instType": "SWAP",
|
|
487
|
+
// "uly": "IOST-USDT"
|
|
488
|
+
// }
|
|
489
|
+
// ]
|
|
490
|
+
// }
|
|
491
|
+
//
|
|
492
|
+
const rawLiquidations = this.safeList(message, 'data', []);
|
|
493
|
+
for (let i = 0; i < rawLiquidations.length; i++) {
|
|
494
|
+
const rawLiquidation = rawLiquidations[i];
|
|
495
|
+
const liquidation = this.parseWsLiquidation(rawLiquidation);
|
|
496
|
+
const symbol = this.safeString(liquidation, 'symbol');
|
|
497
|
+
let liquidations = this.safeValue(this.liquidations, symbol);
|
|
498
|
+
if (liquidations === undefined) {
|
|
499
|
+
const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
|
|
500
|
+
liquidations = new Cache.ArrayCache(limit);
|
|
501
|
+
}
|
|
502
|
+
liquidations.append(liquidation);
|
|
503
|
+
this.liquidations[symbol] = liquidations;
|
|
504
|
+
client.resolve([liquidation], 'liquidations');
|
|
505
|
+
client.resolve([liquidation], 'liquidations::' + symbol);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
async watchMyLiquidationsForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
509
|
+
/**
|
|
510
|
+
* @method
|
|
511
|
+
* @name okx#watchMyLiquidationsForSymbols
|
|
512
|
+
* @description watch the private liquidations of a trading pair
|
|
513
|
+
* @see https://www.okx.com/docs-v5/en/#trading-account-websocket-balance-and-position-channel
|
|
514
|
+
* @param {string} symbol unified CCXT market symbol
|
|
515
|
+
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
516
|
+
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
517
|
+
* @param {object} [params] exchange specific parameters for the okx api endpoint
|
|
518
|
+
* @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
|
|
519
|
+
*/
|
|
520
|
+
await this.loadMarkets();
|
|
521
|
+
const isStop = this.safeValue2(params, 'stop', 'trigger', false);
|
|
522
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
523
|
+
await this.authenticate({ 'access': isStop ? 'business' : 'private' });
|
|
524
|
+
symbols = this.marketSymbols(symbols, undefined, true, true);
|
|
525
|
+
let messageHash = 'myLiquidations';
|
|
526
|
+
if (symbols !== undefined) {
|
|
527
|
+
messageHash += '::' + symbols.join(',');
|
|
528
|
+
}
|
|
529
|
+
const channel = 'balance_and_position';
|
|
530
|
+
const newLiquidations = await this.subscribe('private', messageHash, channel, undefined, params);
|
|
531
|
+
if (this.newUpdates) {
|
|
532
|
+
return newLiquidations;
|
|
533
|
+
}
|
|
534
|
+
return this.filterBySymbolsSinceLimit(this.liquidations, symbols, since, limit, true);
|
|
535
|
+
}
|
|
536
|
+
handleMyLiquidation(client, message) {
|
|
537
|
+
//
|
|
538
|
+
// {
|
|
539
|
+
// "arg": {
|
|
540
|
+
// "channel": "balance_and_position",
|
|
541
|
+
// "uid": "77982378738415879"
|
|
542
|
+
// },
|
|
543
|
+
// "data": [{
|
|
544
|
+
// "pTime": "1597026383085",
|
|
545
|
+
// "eventType": "snapshot",
|
|
546
|
+
// "balData": [{
|
|
547
|
+
// "ccy": "BTC",
|
|
548
|
+
// "cashBal": "1",
|
|
549
|
+
// "uTime": "1597026383085"
|
|
550
|
+
// }],
|
|
551
|
+
// "posData": [{
|
|
552
|
+
// "posId": "1111111111",
|
|
553
|
+
// "tradeId": "2",
|
|
554
|
+
// "instId": "BTC-USD-191018",
|
|
555
|
+
// "instType": "FUTURES",
|
|
556
|
+
// "mgnMode": "cross",
|
|
557
|
+
// "posSide": "long",
|
|
558
|
+
// "pos": "10",
|
|
559
|
+
// "ccy": "BTC",
|
|
560
|
+
// "posCcy": "",
|
|
561
|
+
// "avgPx": "3320",
|
|
562
|
+
// "uTIme": "1597026383085"
|
|
563
|
+
// }],
|
|
564
|
+
// "trades": [{
|
|
565
|
+
// "instId": "BTC-USD-191018",
|
|
566
|
+
// "tradeId": "2",
|
|
567
|
+
// }]
|
|
568
|
+
// }]
|
|
569
|
+
// }
|
|
570
|
+
//
|
|
571
|
+
const rawLiquidations = this.safeList(message, 'data', []);
|
|
572
|
+
for (let i = 0; i < rawLiquidations.length; i++) {
|
|
573
|
+
const rawLiquidation = rawLiquidations[i];
|
|
574
|
+
const eventType = this.safeString(rawLiquidation, 'eventType');
|
|
575
|
+
if (eventType !== 'liquidation') {
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
const liquidation = this.parseWsMyLiquidation(rawLiquidation);
|
|
579
|
+
const symbol = this.safeString(liquidation, 'symbol');
|
|
580
|
+
let liquidations = this.safeValue(this.liquidations, symbol);
|
|
581
|
+
if (liquidations === undefined) {
|
|
582
|
+
const limit = this.safeInteger(this.options, 'myLiquidationsLimit', 1000);
|
|
583
|
+
liquidations = new Cache.ArrayCache(limit);
|
|
584
|
+
}
|
|
585
|
+
liquidations.append(liquidation);
|
|
586
|
+
this.liquidations[symbol] = liquidations;
|
|
587
|
+
client.resolve([liquidation], 'myLiquidations');
|
|
588
|
+
client.resolve([liquidation], 'myLiquidations::' + symbol);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
parseWsMyLiquidation(liquidation, market = undefined) {
|
|
592
|
+
//
|
|
593
|
+
// {
|
|
594
|
+
// "pTime": "1597026383085",
|
|
595
|
+
// "eventType": "snapshot",
|
|
596
|
+
// "balData": [{
|
|
597
|
+
// "ccy": "BTC",
|
|
598
|
+
// "cashBal": "1",
|
|
599
|
+
// "uTime": "1597026383085"
|
|
600
|
+
// }],
|
|
601
|
+
// "posData": [{
|
|
602
|
+
// "posId": "1111111111",
|
|
603
|
+
// "tradeId": "2",
|
|
604
|
+
// "instId": "BTC-USD-191018",
|
|
605
|
+
// "instType": "FUTURES",
|
|
606
|
+
// "mgnMode": "cross",
|
|
607
|
+
// "posSide": "long",
|
|
608
|
+
// "pos": "10",
|
|
609
|
+
// "ccy": "BTC",
|
|
610
|
+
// "posCcy": "",
|
|
611
|
+
// "avgPx": "3320",
|
|
612
|
+
// "uTIme": "1597026383085"
|
|
613
|
+
// }],
|
|
614
|
+
// "trades": [{
|
|
615
|
+
// "instId": "BTC-USD-191018",
|
|
616
|
+
// "tradeId": "2",
|
|
617
|
+
// }]
|
|
618
|
+
// }
|
|
619
|
+
//
|
|
620
|
+
const posData = this.safeList(liquidation, 'posData', []);
|
|
621
|
+
const firstPosData = this.safeDict(posData, 0, {});
|
|
622
|
+
const marketId = this.safeString(firstPosData, 'instId');
|
|
623
|
+
market = this.safeMarket(marketId, market);
|
|
624
|
+
const timestamp = this.safeInteger(firstPosData, 'uTIme');
|
|
625
|
+
return this.safeLiquidation({
|
|
626
|
+
'info': liquidation,
|
|
627
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
628
|
+
'contracts': this.safeNumber(firstPosData, 'pos'),
|
|
629
|
+
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
630
|
+
'price': this.safeNumber(liquidation, 'avgPx'),
|
|
631
|
+
'baseValue': undefined,
|
|
632
|
+
'quoteValue': undefined,
|
|
633
|
+
'timestamp': timestamp,
|
|
634
|
+
'datetime': this.iso8601(timestamp),
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
parseWsLiquidation(liquidation, market = undefined) {
|
|
638
|
+
//
|
|
639
|
+
// public liquidation
|
|
640
|
+
// {
|
|
641
|
+
// "details": [
|
|
642
|
+
// {
|
|
643
|
+
// "bkLoss": "0",
|
|
644
|
+
// "bkPx": "0.007831",
|
|
645
|
+
// "ccy": "",
|
|
646
|
+
// "posSide": "short",
|
|
647
|
+
// "side": "buy",
|
|
648
|
+
// "sz": "13",
|
|
649
|
+
// "ts": "1692266434010"
|
|
650
|
+
// }
|
|
651
|
+
// ],
|
|
652
|
+
// "instFamily": "IOST-USDT",
|
|
653
|
+
// "instId": "IOST-USDT-SWAP",
|
|
654
|
+
// "instType": "SWAP",
|
|
655
|
+
// "uly": "IOST-USDT"
|
|
656
|
+
// }
|
|
657
|
+
//
|
|
658
|
+
const details = this.safeList(liquidation, 'details', []);
|
|
659
|
+
const liquidationDetails = this.safeDict(details, 0, {});
|
|
660
|
+
const marketId = this.safeString(liquidation, 'instId');
|
|
661
|
+
market = this.safeMarket(marketId, market);
|
|
662
|
+
const timestamp = this.safeInteger(liquidationDetails, 'ts');
|
|
663
|
+
return this.safeLiquidation({
|
|
664
|
+
'info': liquidation,
|
|
665
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
666
|
+
'contracts': this.safeNumber(liquidationDetails, 'sz'),
|
|
667
|
+
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
668
|
+
'price': this.safeNumber(liquidationDetails, 'bkPx'),
|
|
669
|
+
'baseValue': undefined,
|
|
670
|
+
'quoteValue': undefined,
|
|
671
|
+
'timestamp': timestamp,
|
|
672
|
+
'datetime': this.iso8601(timestamp),
|
|
673
|
+
});
|
|
674
|
+
}
|
|
422
675
|
async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
423
676
|
/**
|
|
424
677
|
* @method
|
|
@@ -878,6 +1131,9 @@ class okx extends okx$1 {
|
|
|
878
1131
|
await this.authenticate();
|
|
879
1132
|
return await this.subscribe('private', 'account', 'account', undefined, params);
|
|
880
1133
|
}
|
|
1134
|
+
handleBalanceAndPosition(client, message) {
|
|
1135
|
+
this.handleMyLiquidation(client, message);
|
|
1136
|
+
}
|
|
881
1137
|
handleBalance(client, message) {
|
|
882
1138
|
//
|
|
883
1139
|
// {
|
|
@@ -1721,6 +1977,8 @@ class okx extends okx$1 {
|
|
|
1721
1977
|
// 'margin_account': this.handleBalance,
|
|
1722
1978
|
'orders': this.handleOrders,
|
|
1723
1979
|
'orders-algo': this.handleOrders,
|
|
1980
|
+
'liquidation-orders': this.handleLiquidation,
|
|
1981
|
+
'balance_and_position': this.handleBalanceAndPosition,
|
|
1724
1982
|
};
|
|
1725
1983
|
const method = this.safeValue(methods, channel);
|
|
1726
1984
|
if (method === undefined) {
|
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 { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion } 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.33";
|
|
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.34';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -3,6 +3,7 @@ import { Exchange as _Exchange } from '../base/Exchange.js';
|
|
|
3
3
|
interface Exchange {
|
|
4
4
|
sapiGetSystemStatus(params?: {}): Promise<implicitReturnType>;
|
|
5
5
|
sapiGetAccountSnapshot(params?: {}): Promise<implicitReturnType>;
|
|
6
|
+
sapiGetAccountInfo(params?: {}): Promise<implicitReturnType>;
|
|
6
7
|
sapiGetMarginAsset(params?: {}): Promise<implicitReturnType>;
|
|
7
8
|
sapiGetMarginPair(params?: {}): Promise<implicitReturnType>;
|
|
8
9
|
sapiGetMarginAllAssets(params?: {}): Promise<implicitReturnType>;
|
|
@@ -3,6 +3,7 @@ import _binance from '../binance.js';
|
|
|
3
3
|
interface binance {
|
|
4
4
|
sapiGetSystemStatus(params?: {}): Promise<implicitReturnType>;
|
|
5
5
|
sapiGetAccountSnapshot(params?: {}): Promise<implicitReturnType>;
|
|
6
|
+
sapiGetAccountInfo(params?: {}): Promise<implicitReturnType>;
|
|
6
7
|
sapiGetMarginAsset(params?: {}): Promise<implicitReturnType>;
|
|
7
8
|
sapiGetMarginPair(params?: {}): Promise<implicitReturnType>;
|
|
8
9
|
sapiGetMarginAllAssets(params?: {}): Promise<implicitReturnType>;
|
|
@@ -3,6 +3,7 @@ import _binance from '../binance.js';
|
|
|
3
3
|
interface binance {
|
|
4
4
|
sapiGetSystemStatus(params?: {}): Promise<implicitReturnType>;
|
|
5
5
|
sapiGetAccountSnapshot(params?: {}): Promise<implicitReturnType>;
|
|
6
|
+
sapiGetAccountInfo(params?: {}): Promise<implicitReturnType>;
|
|
6
7
|
sapiGetMarginAsset(params?: {}): Promise<implicitReturnType>;
|
|
7
8
|
sapiGetMarginPair(params?: {}): Promise<implicitReturnType>;
|
|
8
9
|
sapiGetMarginAllAssets(params?: {}): Promise<implicitReturnType>;
|
|
@@ -3,6 +3,7 @@ import _binance from '../binance.js';
|
|
|
3
3
|
interface binance {
|
|
4
4
|
sapiGetSystemStatus(params?: {}): Promise<implicitReturnType>;
|
|
5
5
|
sapiGetAccountSnapshot(params?: {}): Promise<implicitReturnType>;
|
|
6
|
+
sapiGetAccountInfo(params?: {}): Promise<implicitReturnType>;
|
|
6
7
|
sapiGetMarginAsset(params?: {}): Promise<implicitReturnType>;
|
|
7
8
|
sapiGetMarginPair(params?: {}): Promise<implicitReturnType>;
|
|
8
9
|
sapiGetMarginAllAssets(params?: {}): Promise<implicitReturnType>;
|
package/js/src/ace.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/ace.js';
|
|
2
|
-
import type { Balances, Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade } from './base/types.js';
|
|
2
|
+
import type { Balances, Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, int } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class ace
|
|
5
5
|
* @augments Exchange
|
|
@@ -7,7 +7,7 @@ import type { Balances, Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSi
|
|
|
7
7
|
export default class ace extends Exchange {
|
|
8
8
|
describe(): any;
|
|
9
9
|
fetchMarkets(params?: {}): Promise<Market[]>;
|
|
10
|
-
parseMarket(market:
|
|
10
|
+
parseMarket(market: Dict): Market;
|
|
11
11
|
parseTicker(ticker: Dict, market?: Market): Ticker;
|
|
12
12
|
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
13
13
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
@@ -31,5 +31,5 @@ export default class ace extends Exchange {
|
|
|
31
31
|
body: any;
|
|
32
32
|
headers: any;
|
|
33
33
|
};
|
|
34
|
-
handleErrors(code:
|
|
34
|
+
handleErrors(code: int, reason: string, url: string, method: string, headers: Dict, body: string, response: any, requestHeaders: any, requestBody: any): any;
|
|
35
35
|
}
|
package/js/src/alpaca.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/alpaca.js';
|
|
2
|
-
import type { Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Trade } from './base/types.js';
|
|
2
|
+
import type { Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Trade, int } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class alpaca
|
|
5
5
|
* @augments Exchange
|
|
@@ -30,5 +30,5 @@ export default class alpaca extends Exchange {
|
|
|
30
30
|
body: any;
|
|
31
31
|
headers: any;
|
|
32
32
|
};
|
|
33
|
-
handleErrors(code:
|
|
33
|
+
handleErrors(code: int, reason: string, url: string, method: string, headers: Dict, body: string, response: any, requestHeaders: any, requestBody: any): any;
|
|
34
34
|
}
|
package/js/src/ascendex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/ascendex.js';
|
|
2
|
-
import type { TransferEntry, FundingHistory, Int, OHLCV, Order, OrderSide, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Strings, Num, Currency, Market, Leverage, Leverages, Account, MarginModes, MarginMode, MarginModification, Currencies, TradingFees, Dict, LeverageTier, LeverageTiers } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, FundingHistory, Int, OHLCV, Order, OrderSide, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Strings, Num, Currency, Market, Leverage, Leverages, Account, MarginModes, MarginMode, MarginModification, Currencies, TradingFees, Dict, LeverageTier, LeverageTiers, int } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class ascendex
|
|
5
5
|
* @augments Exchange
|
|
@@ -46,7 +46,7 @@ export default class ascendex extends Exchange {
|
|
|
46
46
|
fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
47
47
|
fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
48
48
|
fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
49
|
-
parseTransactionStatus(status:
|
|
49
|
+
parseTransactionStatus(status: Str): string;
|
|
50
50
|
parseTransaction(transaction: Dict, currency?: Currency): Transaction;
|
|
51
51
|
fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
|
|
52
52
|
parsePosition(position: Dict, market?: Market): import("./base/types.js").Position;
|
|
@@ -103,5 +103,5 @@ export default class ascendex extends Exchange {
|
|
|
103
103
|
body: any;
|
|
104
104
|
headers: any;
|
|
105
105
|
};
|
|
106
|
-
handleErrors(httpCode:
|
|
106
|
+
handleErrors(httpCode: int, reason: string, url: string, method: string, headers: Dict, body: string, response: any, requestHeaders: any, requestBody: any): any;
|
|
107
107
|
}
|