ccxt 4.3.36 → 4.3.38
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 +5 -3
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/bingx.js +61 -31
- package/dist/cjs/src/bitbank.js +46 -1
- package/dist/cjs/src/bitmart.js +37 -37
- package/dist/cjs/src/bl3p.js +7 -1
- package/dist/cjs/src/btcalpha.js +7 -2
- package/dist/cjs/src/btcturk.js +11 -1
- package/dist/cjs/src/coinbase.js +2 -2
- package/dist/cjs/src/coincheck.js +8 -1
- package/dist/cjs/src/coinex.js +10 -7
- package/dist/cjs/src/htx.js +78 -3
- package/dist/cjs/src/kraken.js +5 -5
- package/dist/cjs/src/okx.js +3 -0
- package/dist/cjs/src/woofipro.js +3 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/okx.d.ts +3 -0
- package/js/src/bingx.d.ts +2 -2
- package/js/src/bingx.js +61 -31
- package/js/src/bitbank.d.ts +1 -1
- package/js/src/bitbank.js +46 -1
- package/js/src/bitmart.js +37 -37
- package/js/src/bl3p.d.ts +1 -1
- package/js/src/bl3p.js +7 -1
- package/js/src/btcalpha.d.ts +1 -1
- package/js/src/btcalpha.js +7 -2
- package/js/src/btcturk.d.ts +1 -1
- package/js/src/btcturk.js +11 -1
- package/js/src/coinbase.js +2 -2
- package/js/src/coincheck.d.ts +1 -1
- package/js/src/coincheck.js +8 -1
- package/js/src/coinex.d.ts +1 -1
- package/js/src/coinex.js +10 -7
- package/js/src/htx.d.ts +1 -0
- package/js/src/htx.js +78 -3
- package/js/src/kraken.js +5 -5
- package/js/src/okx.js +3 -0
- package/js/src/woofipro.js +3 -1
- package/package.json +1 -1
package/js/src/htx.js
CHANGED
|
@@ -41,6 +41,8 @@ export default class htx extends Exchange {
|
|
|
41
41
|
'cancelAllOrdersAfter': true,
|
|
42
42
|
'cancelOrder': true,
|
|
43
43
|
'cancelOrders': true,
|
|
44
|
+
'closeAllPositions': false,
|
|
45
|
+
'closePosition': true,
|
|
44
46
|
'createDepositAddress': undefined,
|
|
45
47
|
'createMarketBuyOrderWithCost': true,
|
|
46
48
|
'createMarketOrderWithCost': false,
|
|
@@ -5389,7 +5391,7 @@ export default class htx extends Exchange {
|
|
|
5389
5391
|
* @param {float} [params.stopLossPrice] *contract only* the price a stop-loss order is triggered at
|
|
5390
5392
|
* @param {float} [params.takeProfitPrice] *contract only* the price a take-profit order is triggered at
|
|
5391
5393
|
* @param {string} [params.operator] *spot and margin only* gte or lte, trigger price condition
|
|
5392
|
-
* @param {string} [params.offset] *contract only* '
|
|
5394
|
+
* @param {string} [params.offset] *contract only* 'both' (linear only), 'open', or 'close', required in hedge mode and for inverse markets
|
|
5393
5395
|
* @param {bool} [params.postOnly] *contract only* true or false
|
|
5394
5396
|
* @param {int} [params.leverRate] *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement
|
|
5395
5397
|
* @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
|
|
@@ -5452,6 +5454,10 @@ export default class htx extends Exchange {
|
|
|
5452
5454
|
}
|
|
5453
5455
|
}
|
|
5454
5456
|
else if (market['inverse']) {
|
|
5457
|
+
const offset = this.safeString(params, 'offset');
|
|
5458
|
+
if (offset === undefined) {
|
|
5459
|
+
throw new ArgumentsRequired(this.id + ' createOrder () requires an extra parameter params["offset"] to be set to "open" or "close" when placing orders in inverse markets');
|
|
5460
|
+
}
|
|
5455
5461
|
if (market['swap']) {
|
|
5456
5462
|
if (isStop) {
|
|
5457
5463
|
response = await this.contractPrivatePostSwapApiV1SwapTriggerOrder(contractRequest);
|
|
@@ -7598,14 +7604,20 @@ export default class htx extends Exchange {
|
|
|
7598
7604
|
* @description fetch all open positions
|
|
7599
7605
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
7600
7606
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7607
|
+
* @param {string} [params.subType] 'linear' or 'inverse'
|
|
7608
|
+
* @param {string} [params.type] *inverse only* 'future', or 'swap'
|
|
7609
|
+
* @param {string} [params.marginMode] *linear only* 'cross' or 'isolated'
|
|
7601
7610
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
7602
7611
|
*/
|
|
7603
7612
|
await this.loadMarkets();
|
|
7604
7613
|
symbols = this.marketSymbols(symbols);
|
|
7605
7614
|
let market = undefined;
|
|
7606
7615
|
if (symbols !== undefined) {
|
|
7607
|
-
const
|
|
7608
|
-
|
|
7616
|
+
const symbolsLength = symbols.length;
|
|
7617
|
+
if (symbolsLength > 0) {
|
|
7618
|
+
const first = this.safeString(symbols, 0);
|
|
7619
|
+
market = this.market(first);
|
|
7620
|
+
}
|
|
7609
7621
|
}
|
|
7610
7622
|
let marginMode = undefined;
|
|
7611
7623
|
[marginMode, params] = this.handleMarginModeAndParams('fetchPositions', params, 'cross');
|
|
@@ -9146,6 +9158,69 @@ export default class htx extends Exchange {
|
|
|
9146
9158
|
'datetime': this.iso8601(timestamp),
|
|
9147
9159
|
});
|
|
9148
9160
|
}
|
|
9161
|
+
async closePosition(symbol, side = undefined, params = {}) {
|
|
9162
|
+
/**
|
|
9163
|
+
* @method
|
|
9164
|
+
* @name htx#closePositions
|
|
9165
|
+
* @description closes open positions for a contract market, requires 'amount' in params, unlike other exchanges
|
|
9166
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-lightning-close-order // USDT-M (isolated)
|
|
9167
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-lightning-close-position // USDT-M (cross)
|
|
9168
|
+
* @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-lightning-close-order // Coin-M swap
|
|
9169
|
+
* @see https://huobiapi.github.io/docs/dm/v1/en/#place-flash-close-order // Coin-M futures
|
|
9170
|
+
* @param {string} symbol unified CCXT market symbol
|
|
9171
|
+
* @param {string} side 'buy' or 'sell', the side of the closing order, opposite side as position side
|
|
9172
|
+
* @param {object} [params] extra parameters specific to the okx api endpoint
|
|
9173
|
+
* @param {string} [params.clientOrderId] client needs to provide unique API and have to maintain the API themselves afterwards. [1, 9223372036854775807]
|
|
9174
|
+
* @param {object} [params.marginMode] 'cross' or 'isolated', required for linear markets
|
|
9175
|
+
*
|
|
9176
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
|
9177
|
+
* @param {number} [params.amount] order quantity
|
|
9178
|
+
* @param {string} [params.order_price_type] 'lightning' by default, 'lightning_fok': lightning fok type, 'lightning_ioc': lightning ioc type 'market' by default, 'market': market order type, 'lightning_fok': lightning
|
|
9179
|
+
* @returns {object} [an order structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
9180
|
+
*/
|
|
9181
|
+
await this.loadMarkets();
|
|
9182
|
+
const market = this.market(symbol);
|
|
9183
|
+
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
9184
|
+
if (!market['contract']) {
|
|
9185
|
+
throw new BadRequest(this.id + ' closePosition() symbol supports contract markets only');
|
|
9186
|
+
}
|
|
9187
|
+
this.checkRequiredArgument('closePosition', side, 'side');
|
|
9188
|
+
const request = {
|
|
9189
|
+
'contract_code': market['id'],
|
|
9190
|
+
'direction': side,
|
|
9191
|
+
};
|
|
9192
|
+
if (clientOrderId !== undefined) {
|
|
9193
|
+
request['client_order_id'] = clientOrderId;
|
|
9194
|
+
}
|
|
9195
|
+
if (market['inverse']) {
|
|
9196
|
+
const amount = this.safeString2(params, 'volume', 'amount');
|
|
9197
|
+
if (amount === undefined) {
|
|
9198
|
+
throw new ArgumentsRequired(this.id + ' closePosition () requires an extra argument params["amount"] for inverse markets');
|
|
9199
|
+
}
|
|
9200
|
+
request['volume'] = this.amountToPrecision(symbol, amount);
|
|
9201
|
+
}
|
|
9202
|
+
params = this.omit(params, ['clientOrderId', 'volume', 'amount']);
|
|
9203
|
+
let response = undefined;
|
|
9204
|
+
if (market['inverse']) { // Coin-M
|
|
9205
|
+
if (market['swap']) {
|
|
9206
|
+
response = await this.contractPrivatePostSwapApiV1SwapLightningClosePosition(this.extend(request, params));
|
|
9207
|
+
}
|
|
9208
|
+
else { // future
|
|
9209
|
+
response = await this.contractPrivatePostApiV1LightningClosePosition(this.extend(request, params));
|
|
9210
|
+
}
|
|
9211
|
+
}
|
|
9212
|
+
else { // USDT-M
|
|
9213
|
+
let marginMode = undefined;
|
|
9214
|
+
[marginMode, params] = this.handleMarginModeAndParams('closePosition', params, 'cross');
|
|
9215
|
+
if (marginMode === 'cross') {
|
|
9216
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossLightningClosePosition(this.extend(request, params));
|
|
9217
|
+
}
|
|
9218
|
+
else { // isolated
|
|
9219
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapLightningClosePosition(this.extend(request, params));
|
|
9220
|
+
}
|
|
9221
|
+
}
|
|
9222
|
+
return this.parseOrder(response, market);
|
|
9223
|
+
}
|
|
9149
9224
|
async setPositionMode(hedged, symbol = undefined, params = {}) {
|
|
9150
9225
|
/**
|
|
9151
9226
|
* @method
|
package/js/src/kraken.js
CHANGED
|
@@ -164,13 +164,13 @@ export default class kraken extends Exchange {
|
|
|
164
164
|
// rate-limits explained in comment in the top of this file
|
|
165
165
|
'Assets': 1,
|
|
166
166
|
'AssetPairs': 1,
|
|
167
|
-
'Depth': 1,
|
|
168
|
-
'OHLC': 1,
|
|
167
|
+
'Depth': 1.2,
|
|
168
|
+
'OHLC': 1.2,
|
|
169
169
|
'Spread': 1,
|
|
170
170
|
'SystemStatus': 1,
|
|
171
171
|
'Ticker': 1,
|
|
172
172
|
'Time': 1,
|
|
173
|
-
'Trades': 1,
|
|
173
|
+
'Trades': 1.2,
|
|
174
174
|
},
|
|
175
175
|
},
|
|
176
176
|
'private': {
|
|
@@ -761,8 +761,8 @@ export default class kraken extends Exchange {
|
|
|
761
761
|
return {
|
|
762
762
|
'info': response,
|
|
763
763
|
'symbol': market['symbol'],
|
|
764
|
-
'maker': this.
|
|
765
|
-
'taker': this.
|
|
764
|
+
'maker': this.parseNumber(Precise.stringDiv(this.safeString(symbolMakerFee, 'fee'), '100')),
|
|
765
|
+
'taker': this.parseNumber(Precise.stringDiv(this.safeString(symbolTakerFee, 'fee'), '100')),
|
|
766
766
|
'percentage': true,
|
|
767
767
|
'tierBased': true,
|
|
768
768
|
};
|
package/js/src/okx.js
CHANGED
|
@@ -258,6 +258,9 @@ export default class okx extends Exchange {
|
|
|
258
258
|
'finance/staking-defi/eth/apy-history': 5 / 3,
|
|
259
259
|
'finance/savings/lending-rate-summary': 5 / 3,
|
|
260
260
|
'finance/savings/lending-rate-history': 5 / 3,
|
|
261
|
+
'finance/fixed-loan/lending-offers': 10 / 3,
|
|
262
|
+
'finance/fixed-loan/lending-apy-history': 10 / 3,
|
|
263
|
+
'finance/fixed-loan/pending-lending-volume': 10 / 3,
|
|
261
264
|
// public broker
|
|
262
265
|
'finance/sfp/dcd/products': 2 / 3,
|
|
263
266
|
// copytrading
|
package/js/src/woofipro.js
CHANGED
|
@@ -2280,8 +2280,10 @@ export default class woofipro extends Exchange {
|
|
|
2280
2280
|
}
|
|
2281
2281
|
signHash(hash, privateKey) {
|
|
2282
2282
|
const signature = ecdsa(hash.slice(-64), privateKey.slice(-64), secp256k1, undefined);
|
|
2283
|
+
const r = signature['r'];
|
|
2284
|
+
const s = signature['s'];
|
|
2283
2285
|
const v = this.intToBase16(this.sum(27, signature['v']));
|
|
2284
|
-
return '0x' +
|
|
2286
|
+
return '0x' + r.padStart(64, '0') + s.padStart(64, '0') + v;
|
|
2285
2287
|
}
|
|
2286
2288
|
signMessage(message, privateKey) {
|
|
2287
2289
|
return this.signHash(this.hashMessage(message), privateKey.slice(-64));
|
package/package.json
CHANGED