ccxt 4.3.9 → 4.3.10
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/base/Exchange.js +3 -3
- package/dist/cjs/src/bitget.js +1 -1
- package/dist/cjs/src/coinex.js +175 -148
- package/dist/cjs/src/kucoinfutures.js +159 -11
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/kucoinfutures.d.ts +2 -0
- package/js/src/base/Exchange.js +3 -3
- package/js/src/base/types.d.ts +2 -0
- package/js/src/bitget.js +1 -1
- package/js/src/coinex.js +175 -148
- package/js/src/kucoinfutures.d.ts +3 -1
- package/js/src/kucoinfutures.js +159 -11
- package/package.json +2 -1
|
@@ -81,13 +81,14 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
81
81
|
'fetchPositionHistory': false,
|
|
82
82
|
'fetchPositionMode': false,
|
|
83
83
|
'fetchPositions': true,
|
|
84
|
-
'fetchPositionsHistory':
|
|
84
|
+
'fetchPositionsHistory': true,
|
|
85
85
|
'fetchPremiumIndexOHLCV': false,
|
|
86
86
|
'fetchStatus': true,
|
|
87
87
|
'fetchTicker': true,
|
|
88
88
|
'fetchTickers': true,
|
|
89
89
|
'fetchTime': true,
|
|
90
90
|
'fetchTrades': true,
|
|
91
|
+
'fetchTradingFee': true,
|
|
91
92
|
'fetchTransactionFee': false,
|
|
92
93
|
'fetchWithdrawals': true,
|
|
93
94
|
'setLeverage': false,
|
|
@@ -164,6 +165,8 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
164
165
|
'funding-history': 4.44,
|
|
165
166
|
'sub/api-key': 1,
|
|
166
167
|
'trade-statistics': 1,
|
|
168
|
+
'trade-fees': 1,
|
|
169
|
+
'history-positions': 1,
|
|
167
170
|
},
|
|
168
171
|
'post': {
|
|
169
172
|
'withdrawals': 1,
|
|
@@ -1137,6 +1140,76 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
1137
1140
|
const data = this.safeList(response, 'data');
|
|
1138
1141
|
return this.parsePositions(data, symbols);
|
|
1139
1142
|
}
|
|
1143
|
+
async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1144
|
+
/**
|
|
1145
|
+
* @method
|
|
1146
|
+
* @name kucoinfutures#fetchPositionsHistory
|
|
1147
|
+
* @description fetches historical positions
|
|
1148
|
+
* @see https://www.kucoin.com/docs/rest/futures-trading/positions/get-positions-history
|
|
1149
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
1150
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1151
|
+
* @param {int} [params.until] closing end time
|
|
1152
|
+
* @param {int} [params.pageId] page id
|
|
1153
|
+
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
1154
|
+
*/
|
|
1155
|
+
await this.loadMarkets();
|
|
1156
|
+
if (limit === undefined) {
|
|
1157
|
+
limit = 200;
|
|
1158
|
+
}
|
|
1159
|
+
const request = {
|
|
1160
|
+
'limit': limit,
|
|
1161
|
+
};
|
|
1162
|
+
if (since !== undefined) {
|
|
1163
|
+
request['from'] = since;
|
|
1164
|
+
}
|
|
1165
|
+
const until = this.safeInteger(params, 'until');
|
|
1166
|
+
if (until !== undefined) {
|
|
1167
|
+
params = this.omit(params, 'until');
|
|
1168
|
+
request['to'] = until;
|
|
1169
|
+
}
|
|
1170
|
+
const response = await this.futuresPrivateGetHistoryPositions(this.extend(request, params));
|
|
1171
|
+
//
|
|
1172
|
+
// {
|
|
1173
|
+
// "success": true,
|
|
1174
|
+
// "code": "200",
|
|
1175
|
+
// "msg": "success",
|
|
1176
|
+
// "retry": false,
|
|
1177
|
+
// "data": {
|
|
1178
|
+
// "currentPage": 1,
|
|
1179
|
+
// "pageSize": 10,
|
|
1180
|
+
// "totalNum": 25,
|
|
1181
|
+
// "totalPage": 3,
|
|
1182
|
+
// "items": [
|
|
1183
|
+
// {
|
|
1184
|
+
// "closeId": "300000000000000030",
|
|
1185
|
+
// "positionId": "300000000000000009",
|
|
1186
|
+
// "uid": 99996908309485,
|
|
1187
|
+
// "userId": "6527d4fc8c7f3d0001f40f5f",
|
|
1188
|
+
// "symbol": "XBTUSDM",
|
|
1189
|
+
// "settleCurrency": "XBT",
|
|
1190
|
+
// "leverage": "0.0",
|
|
1191
|
+
// "type": "LIQUID_LONG",
|
|
1192
|
+
// "side": null,
|
|
1193
|
+
// "closeSize": null,
|
|
1194
|
+
// "pnl": "-1.0000003793999999",
|
|
1195
|
+
// "realisedGrossCost": "0.9993849748999999",
|
|
1196
|
+
// "withdrawPnl": "0.0",
|
|
1197
|
+
// "roe": null,
|
|
1198
|
+
// "tradeFee": "0.0006154045",
|
|
1199
|
+
// "fundingFee": "0.0",
|
|
1200
|
+
// "openTime": 1713785751181,
|
|
1201
|
+
// "closeTime": 1713785752784,
|
|
1202
|
+
// "openPrice": null,
|
|
1203
|
+
// "closePrice": null
|
|
1204
|
+
// }
|
|
1205
|
+
// ]
|
|
1206
|
+
// }
|
|
1207
|
+
// }
|
|
1208
|
+
//
|
|
1209
|
+
const data = this.safeDict(response, 'data');
|
|
1210
|
+
const items = this.safeList(data, 'items', []);
|
|
1211
|
+
return this.parsePositions(items, symbols);
|
|
1212
|
+
}
|
|
1140
1213
|
parsePosition(position, market = undefined) {
|
|
1141
1214
|
//
|
|
1142
1215
|
// {
|
|
@@ -1183,17 +1256,51 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
1183
1256
|
// }
|
|
1184
1257
|
// ]
|
|
1185
1258
|
// }
|
|
1259
|
+
// position history
|
|
1260
|
+
// {
|
|
1261
|
+
// "closeId": "300000000000000030",
|
|
1262
|
+
// "positionId": "300000000000000009",
|
|
1263
|
+
// "uid": 99996908309485,
|
|
1264
|
+
// "userId": "6527d4fc8c7f3d0001f40f5f",
|
|
1265
|
+
// "symbol": "XBTUSDM",
|
|
1266
|
+
// "settleCurrency": "XBT",
|
|
1267
|
+
// "leverage": "0.0",
|
|
1268
|
+
// "type": "LIQUID_LONG",
|
|
1269
|
+
// "side": null,
|
|
1270
|
+
// "closeSize": null,
|
|
1271
|
+
// "pnl": "-1.0000003793999999",
|
|
1272
|
+
// "realisedGrossCost": "0.9993849748999999",
|
|
1273
|
+
// "withdrawPnl": "0.0",
|
|
1274
|
+
// "roe": null,
|
|
1275
|
+
// "tradeFee": "0.0006154045",
|
|
1276
|
+
// "fundingFee": "0.0",
|
|
1277
|
+
// "openTime": 1713785751181,
|
|
1278
|
+
// "closeTime": 1713785752784,
|
|
1279
|
+
// "openPrice": null,
|
|
1280
|
+
// "closePrice": null
|
|
1281
|
+
// }
|
|
1186
1282
|
//
|
|
1187
1283
|
const symbol = this.safeString(position, 'symbol');
|
|
1188
1284
|
market = this.safeMarket(symbol, market);
|
|
1189
1285
|
const timestamp = this.safeInteger(position, 'currentTimestamp');
|
|
1190
1286
|
const size = this.safeString(position, 'currentQty');
|
|
1191
1287
|
let side = undefined;
|
|
1192
|
-
|
|
1193
|
-
|
|
1288
|
+
const type = this.safeStringLower(position, 'type');
|
|
1289
|
+
if (size !== undefined) {
|
|
1290
|
+
if (Precise["default"].stringGt(size, '0')) {
|
|
1291
|
+
side = 'long';
|
|
1292
|
+
}
|
|
1293
|
+
else if (Precise["default"].stringLt(size, '0')) {
|
|
1294
|
+
side = 'short';
|
|
1295
|
+
}
|
|
1194
1296
|
}
|
|
1195
|
-
else if (
|
|
1196
|
-
|
|
1297
|
+
else if (type !== undefined) {
|
|
1298
|
+
if (type.indexOf('long') > -1) {
|
|
1299
|
+
side = 'long';
|
|
1300
|
+
}
|
|
1301
|
+
else {
|
|
1302
|
+
side = 'short';
|
|
1303
|
+
}
|
|
1197
1304
|
}
|
|
1198
1305
|
const notional = Precise["default"].stringAbs(this.safeString(position, 'posCost'));
|
|
1199
1306
|
const initialMargin = this.safeString(position, 'posInit');
|
|
@@ -1202,25 +1309,28 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
1202
1309
|
const unrealisedPnl = this.safeString(position, 'unrealisedPnl');
|
|
1203
1310
|
const crossMode = this.safeValue(position, 'crossMode');
|
|
1204
1311
|
// currently crossMode is always set to false and only isolated positions are supported
|
|
1205
|
-
|
|
1312
|
+
let marginMode = undefined;
|
|
1313
|
+
if (crossMode !== undefined) {
|
|
1314
|
+
marginMode = crossMode ? 'cross' : 'isolated';
|
|
1315
|
+
}
|
|
1206
1316
|
return this.safePosition({
|
|
1207
1317
|
'info': position,
|
|
1208
|
-
'id': this.
|
|
1318
|
+
'id': this.safeString2(position, 'id', 'positionId'),
|
|
1209
1319
|
'symbol': this.safeString(market, 'symbol'),
|
|
1210
1320
|
'timestamp': timestamp,
|
|
1211
1321
|
'datetime': this.iso8601(timestamp),
|
|
1212
|
-
'lastUpdateTimestamp':
|
|
1322
|
+
'lastUpdateTimestamp': this.safeInteger(position, 'closeTime'),
|
|
1213
1323
|
'initialMargin': this.parseNumber(initialMargin),
|
|
1214
1324
|
'initialMarginPercentage': this.parseNumber(initialMarginPercentage),
|
|
1215
1325
|
'maintenanceMargin': this.safeNumber(position, 'posMaint'),
|
|
1216
1326
|
'maintenanceMarginPercentage': this.safeNumber(position, 'maintMarginReq'),
|
|
1217
|
-
'entryPrice': this.
|
|
1327
|
+
'entryPrice': this.safeNumber2(position, 'avgEntryPrice', 'openPrice'),
|
|
1218
1328
|
'notional': this.parseNumber(notional),
|
|
1219
|
-
'leverage': this.
|
|
1329
|
+
'leverage': this.safeNumber2(position, 'realLeverage', 'leverage'),
|
|
1220
1330
|
'unrealizedPnl': this.parseNumber(unrealisedPnl),
|
|
1221
1331
|
'contracts': this.parseNumber(Precise["default"].stringAbs(size)),
|
|
1222
1332
|
'contractSize': this.safeValue(market, 'contractSize'),
|
|
1223
|
-
'realizedPnl': this.
|
|
1333
|
+
'realizedPnl': this.safeNumber2(position, 'realisedPnl', 'pnl'),
|
|
1224
1334
|
'marginRatio': undefined,
|
|
1225
1335
|
'liquidationPrice': this.safeNumber(position, 'liquidationPrice'),
|
|
1226
1336
|
'markPrice': this.safeNumber(position, 'markPrice'),
|
|
@@ -2701,6 +2811,44 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
2701
2811
|
}
|
|
2702
2812
|
return this.parseOrder(response, market);
|
|
2703
2813
|
}
|
|
2814
|
+
async fetchTradingFee(symbol, params = {}) {
|
|
2815
|
+
/**
|
|
2816
|
+
* @method
|
|
2817
|
+
* @name kucoinfutures#fetchTradingFee
|
|
2818
|
+
* @description fetch the trading fees for a market
|
|
2819
|
+
* @see https://www.kucoin.com/docs/rest/funding/trade-fee/trading-pair-actual-fee-futures
|
|
2820
|
+
* @param {string} symbol unified market symbol
|
|
2821
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2822
|
+
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
2823
|
+
*/
|
|
2824
|
+
await this.loadMarkets();
|
|
2825
|
+
const market = this.market(symbol);
|
|
2826
|
+
const request = {
|
|
2827
|
+
'symbols': market['id'],
|
|
2828
|
+
};
|
|
2829
|
+
const response = await this.privateGetTradeFees(this.extend(request, params));
|
|
2830
|
+
//
|
|
2831
|
+
// {
|
|
2832
|
+
// "code": "200000",
|
|
2833
|
+
// "data": {
|
|
2834
|
+
// "symbol": "XBTUSDTM",
|
|
2835
|
+
// "takerFeeRate": "0.0006",
|
|
2836
|
+
// "makerFeeRate": "0.0002"
|
|
2837
|
+
// }
|
|
2838
|
+
// }
|
|
2839
|
+
//
|
|
2840
|
+
const data = this.safeList(response, 'data', []);
|
|
2841
|
+
const first = this.safeDict(data, 0);
|
|
2842
|
+
const marketId = this.safeString(first, 'symbol');
|
|
2843
|
+
return {
|
|
2844
|
+
'info': response,
|
|
2845
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
2846
|
+
'maker': this.safeNumber(first, 'makerFeeRate'),
|
|
2847
|
+
'taker': this.safeNumber(first, 'takerFeeRate'),
|
|
2848
|
+
'percentage': true,
|
|
2849
|
+
'tierBased': true,
|
|
2850
|
+
};
|
|
2851
|
+
}
|
|
2704
2852
|
}
|
|
2705
2853
|
|
|
2706
2854
|
module.exports = kucoinfutures;
|
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, 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.9";
|
|
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, 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.10';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -183,6 +183,8 @@ interface kucoin {
|
|
|
183
183
|
futuresPrivateGetWithdrawalList(params?: {}): Promise<implicitReturnType>;
|
|
184
184
|
futuresPrivateGetSubApiKey(params?: {}): Promise<implicitReturnType>;
|
|
185
185
|
futuresPrivateGetTradeStatistics(params?: {}): Promise<implicitReturnType>;
|
|
186
|
+
futuresPrivateGetTradeFees(params?: {}): Promise<implicitReturnType>;
|
|
187
|
+
futuresPrivateGetHistoryPositions(params?: {}): Promise<implicitReturnType>;
|
|
186
188
|
futuresPrivatePostTransferOut(params?: {}): Promise<implicitReturnType>;
|
|
187
189
|
futuresPrivatePostTransferIn(params?: {}): Promise<implicitReturnType>;
|
|
188
190
|
futuresPrivatePostOrders(params?: {}): Promise<implicitReturnType>;
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -6101,10 +6101,10 @@ export default class Exchange {
|
|
|
6101
6101
|
const fromId = this.safeString(entry, fromCurrencyKey);
|
|
6102
6102
|
const toId = this.safeString(entry, toCurrencyKey);
|
|
6103
6103
|
if (fromId !== undefined) {
|
|
6104
|
-
fromCurrency = this.
|
|
6104
|
+
fromCurrency = this.safeCurrency(fromId);
|
|
6105
6105
|
}
|
|
6106
6106
|
if (toId !== undefined) {
|
|
6107
|
-
toCurrency = this.
|
|
6107
|
+
toCurrency = this.safeCurrency(toId);
|
|
6108
6108
|
}
|
|
6109
6109
|
const conversion = this.extend(this.parseConversion(entry, fromCurrency, toCurrency), params);
|
|
6110
6110
|
result.push(conversion);
|
|
@@ -6112,7 +6112,7 @@ export default class Exchange {
|
|
|
6112
6112
|
const sorted = this.sortBy(result, 'timestamp');
|
|
6113
6113
|
let currency = undefined;
|
|
6114
6114
|
if (code !== undefined) {
|
|
6115
|
-
currency = this.
|
|
6115
|
+
currency = this.safeCurrency(code);
|
|
6116
6116
|
code = currency['code'];
|
|
6117
6117
|
}
|
|
6118
6118
|
if (code === undefined) {
|
package/js/src/base/types.d.ts
CHANGED
package/js/src/bitget.js
CHANGED
|
@@ -8458,7 +8458,7 @@ export default class bitget extends Exchange {
|
|
|
8458
8458
|
* @name bitget#fetchPositionsHistory
|
|
8459
8459
|
* @description fetches historical positions
|
|
8460
8460
|
* @see https://www.bitget.com/api-doc/contract/position/Get-History-Position
|
|
8461
|
-
* @param {string} [
|
|
8461
|
+
* @param {string[]} [symbols] unified contract symbols
|
|
8462
8462
|
* @param {int} [since] timestamp in ms of the earliest position to fetch, default=3 months ago, max range for params["until"] - since is 3 months
|
|
8463
8463
|
* @param {int} [limit] the maximum amount of records to fetch, default=20, max=100
|
|
8464
8464
|
* @param {object} params extra parameters specific to the exchange api endpoint
|