ccxt 4.4.20 → 4.4.22
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 +4 -4
- package/dist/ccxt.browser.min.js +5 -5
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +1 -0
- package/dist/cjs/src/base/Exchange.js +34 -0
- package/dist/cjs/src/base/ws/Future.js +3 -1
- package/dist/cjs/src/bigone.js +3 -0
- package/dist/cjs/src/binance.js +103 -10
- package/dist/cjs/src/bingx.js +6 -1
- package/dist/cjs/src/bitflyer.js +57 -0
- package/dist/cjs/src/bitget.js +77 -0
- package/dist/cjs/src/bybit.js +143 -3
- package/dist/cjs/src/cex.js +1307 -1385
- package/dist/cjs/src/cryptocom.js +1 -1
- package/dist/cjs/src/gate.js +103 -3
- package/dist/cjs/src/htx.js +29 -7
- package/dist/cjs/src/hyperliquid.js +15 -12
- package/dist/cjs/src/kucoin.js +43 -95
- package/dist/cjs/src/kucoinfutures.js +2 -2
- package/dist/cjs/src/okx.js +82 -10
- package/dist/cjs/src/paradex.js +1 -2
- package/dist/cjs/src/static_dependencies/noble-hashes/_sha2.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-hashes/hmac.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-hashes/sha3.js +1 -1
- package/dist/cjs/src/static_dependencies/watchable/src/unpromise.js +298 -0
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bitflyer.d.ts +1 -0
- package/js/src/abstract/bitget.d.ts +3 -0
- package/js/src/abstract/bybit.d.ts +1 -0
- package/js/src/abstract/cex.d.ts +28 -29
- package/js/src/abstract/gate.d.ts +5 -0
- package/js/src/abstract/gateio.d.ts +5 -0
- package/js/src/abstract/kucoin.d.ts +2 -0
- package/js/src/abstract/kucoinfutures.d.ts +2 -0
- package/js/src/abstract/okx.d.ts +4 -0
- package/js/src/alpaca.js +1 -0
- package/js/src/base/Exchange.d.ts +11 -3
- package/js/src/base/Exchange.js +34 -0
- package/js/src/base/types.d.ts +8 -0
- package/js/src/base/ws/Future.js +2 -1
- package/js/src/bigone.js +3 -0
- package/js/src/binance.d.ts +3 -2
- package/js/src/binance.js +103 -10
- package/js/src/bingx.js +6 -1
- package/js/src/bitflyer.d.ts +3 -1
- package/js/src/bitflyer.js +57 -0
- package/js/src/bitget.d.ts +3 -1
- package/js/src/bitget.js +77 -0
- package/js/src/bybit.d.ts +4 -1
- package/js/src/bybit.js +143 -3
- package/js/src/cex.d.ts +34 -20
- package/js/src/cex.js +1308 -1386
- package/js/src/cryptocom.js +1 -1
- package/js/src/gate.d.ts +2 -0
- package/js/src/gate.js +103 -3
- package/js/src/htx.d.ts +2 -2
- package/js/src/htx.js +29 -7
- package/js/src/hyperliquid.js +15 -12
- package/js/src/kucoin.d.ts +0 -2
- package/js/src/kucoin.js +43 -95
- package/js/src/kucoinfutures.js +2 -2
- package/js/src/okx.d.ts +3 -2
- package/js/src/okx.js +83 -11
- package/js/src/paradex.js +1 -1
- package/js/src/static_dependencies/noble-hashes/_blake2.js +1 -1
- package/js/src/static_dependencies/noble-hashes/_sha2.js +1 -1
- package/js/src/static_dependencies/noble-hashes/hmac.js +1 -1
- package/js/src/static_dependencies/noble-hashes/sha3-addons.js +5 -5
- package/js/src/static_dependencies/noble-hashes/sha3.js +1 -1
- package/js/src/static_dependencies/watchable/src/index.d.ts +2 -0
- package/js/src/static_dependencies/watchable/src/index.js +7 -0
- package/js/src/static_dependencies/watchable/src/types.d.ts +28 -0
- package/js/src/static_dependencies/watchable/src/types.js +8 -0
- package/js/src/static_dependencies/watchable/src/unpromise.d.ts +120 -0
- package/js/src/static_dependencies/watchable/src/unpromise.js +297 -0
- package/package.json +1 -1
package/js/src/cryptocom.js
CHANGED
|
@@ -1618,7 +1618,7 @@ export default class cryptocom extends Exchange {
|
|
|
1618
1618
|
let paginate = false;
|
|
1619
1619
|
[paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
|
|
1620
1620
|
if (paginate) {
|
|
1621
|
-
return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
|
|
1621
|
+
return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params, 100);
|
|
1622
1622
|
}
|
|
1623
1623
|
const request = {};
|
|
1624
1624
|
let market = undefined;
|
package/js/src/gate.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ import type { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenI
|
|
|
7
7
|
export default class gate extends Exchange {
|
|
8
8
|
describe(): any;
|
|
9
9
|
setSandboxMode(enable: boolean): void;
|
|
10
|
+
loadUnifiedStatus(params?: {}): Promise<void>;
|
|
11
|
+
upgradeUnifiedTradeAccount(params?: {}): Promise<any>;
|
|
10
12
|
createExpiredOptionMarket(symbol: string): MarketInterface;
|
|
11
13
|
safeMarket(marketId?: Str, market?: Market, delimiter?: Str, marketType?: Str): MarketInterface;
|
|
12
14
|
fetchMarkets(params?: {}): Promise<Market[]>;
|
package/js/src/gate.js
CHANGED
|
@@ -324,10 +324,17 @@ export default class gate extends Exchange {
|
|
|
324
324
|
'interest_records': 20 / 15,
|
|
325
325
|
'estimate_rate': 20 / 15,
|
|
326
326
|
'currency_discount_tiers': 20 / 15,
|
|
327
|
+
'risk_units': 20 / 15,
|
|
328
|
+
'unified_mode': 20 / 15,
|
|
329
|
+
'loan_margin_tiers': 20 / 15,
|
|
327
330
|
},
|
|
328
331
|
'post': {
|
|
329
332
|
'account_mode': 20 / 15,
|
|
330
|
-
'loans': 200 / 15,
|
|
333
|
+
'loans': 200 / 15,
|
|
334
|
+
'portfolio_calculator': 20 / 15,
|
|
335
|
+
},
|
|
336
|
+
'put': {
|
|
337
|
+
'unified_mode': 20 / 15,
|
|
331
338
|
},
|
|
332
339
|
},
|
|
333
340
|
'spot': {
|
|
@@ -629,6 +636,7 @@ export default class gate extends Exchange {
|
|
|
629
636
|
},
|
|
630
637
|
'options': {
|
|
631
638
|
'sandboxMode': false,
|
|
639
|
+
'unifiedAccount': undefined,
|
|
632
640
|
'createOrder': {
|
|
633
641
|
'expiration': 86400, // for conditional orders
|
|
634
642
|
},
|
|
@@ -890,6 +898,37 @@ export default class gate extends Exchange {
|
|
|
890
898
|
super.setSandboxMode(enable);
|
|
891
899
|
this.options['sandboxMode'] = enable;
|
|
892
900
|
}
|
|
901
|
+
async loadUnifiedStatus(params = {}) {
|
|
902
|
+
/**
|
|
903
|
+
* @method
|
|
904
|
+
* @name gate#isUnifiedEnabled
|
|
905
|
+
* @description returns unifiedAccount so the user can check if the unified account is enabled
|
|
906
|
+
* @see https://www.gate.io/docs/developers/apiv4/#get-account-detail
|
|
907
|
+
* @returns {boolean} true or false if the enabled unified account is enabled or not and sets the unifiedAccount option if it is undefined
|
|
908
|
+
*/
|
|
909
|
+
const unifiedAccount = this.safeBool(this.options, 'unifiedAccount');
|
|
910
|
+
if (unifiedAccount === undefined) {
|
|
911
|
+
const response = await this.privateAccountGetDetail(params);
|
|
912
|
+
//
|
|
913
|
+
// {
|
|
914
|
+
// "user_id": 10406147,
|
|
915
|
+
// "ip_whitelist": [],
|
|
916
|
+
// "currency_pairs": [],
|
|
917
|
+
// "key": {
|
|
918
|
+
// "mode": 1
|
|
919
|
+
// },
|
|
920
|
+
// "tier": 0,
|
|
921
|
+
// "tier_expire_time": "0001-01-01T00:00:00Z",
|
|
922
|
+
// "copy_trading_role": 0
|
|
923
|
+
// }
|
|
924
|
+
//
|
|
925
|
+
const result = this.safeDict(response, 'key', {});
|
|
926
|
+
this.options['unifiedAccount'] = this.safeInteger(result, 'mode') === 2;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
async upgradeUnifiedTradeAccount(params = {}) {
|
|
930
|
+
return await this.privateUnifiedPutUnifiedMode(params);
|
|
931
|
+
}
|
|
893
932
|
createExpiredOptionMarket(symbol) {
|
|
894
933
|
// support expired option contracts
|
|
895
934
|
const quote = 'USDT';
|
|
@@ -1579,6 +1618,9 @@ export default class gate extends Exchange {
|
|
|
1579
1618
|
if (apiBackup !== undefined) {
|
|
1580
1619
|
return undefined;
|
|
1581
1620
|
}
|
|
1621
|
+
if (this.checkRequiredCredentials(false)) {
|
|
1622
|
+
await this.loadUnifiedStatus();
|
|
1623
|
+
}
|
|
1582
1624
|
const response = await this.publicSpotGetCurrencies(params);
|
|
1583
1625
|
//
|
|
1584
1626
|
// {
|
|
@@ -2681,10 +2723,14 @@ export default class gate extends Exchange {
|
|
|
2681
2723
|
* @param {string} [params.settle] 'btc' or 'usdt' - settle currency for perpetual swap and future - default="usdt" for swap and "btc" for future
|
|
2682
2724
|
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
|
|
2683
2725
|
* @param {string} [params.symbol] margin only - unified ccxt symbol
|
|
2726
|
+
* @param {boolean} [params.unifiedAccount] default false, set to true for fetching the unified account balance
|
|
2684
2727
|
*/
|
|
2685
2728
|
await this.loadMarkets();
|
|
2729
|
+
await this.loadUnifiedStatus();
|
|
2686
2730
|
const symbol = this.safeString(params, 'symbol');
|
|
2687
2731
|
params = this.omit(params, 'symbol');
|
|
2732
|
+
let isUnifiedAccount = false;
|
|
2733
|
+
[isUnifiedAccount, params] = this.handleOptionAndParams(params, 'fetchBalance', 'unifiedAccount');
|
|
2688
2734
|
const [type, query] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
2689
2735
|
const [request, requestParams] = this.prepareRequest(undefined, type, query);
|
|
2690
2736
|
const [marginMode, requestQuery] = this.getMarginMode(false, requestParams);
|
|
@@ -2693,7 +2739,10 @@ export default class gate extends Exchange {
|
|
|
2693
2739
|
request['currency_pair'] = market['id'];
|
|
2694
2740
|
}
|
|
2695
2741
|
let response = undefined;
|
|
2696
|
-
if (
|
|
2742
|
+
if (isUnifiedAccount) {
|
|
2743
|
+
response = await this.privateUnifiedGetAccounts(this.extend(request, params));
|
|
2744
|
+
}
|
|
2745
|
+
else if (type === 'spot') {
|
|
2697
2746
|
if (marginMode === 'spot') {
|
|
2698
2747
|
response = await this.privateSpotGetAccounts(this.extend(request, requestQuery));
|
|
2699
2748
|
}
|
|
@@ -2867,12 +2916,63 @@ export default class gate extends Exchange {
|
|
|
2867
2916
|
// "orders_limit": 10
|
|
2868
2917
|
// }
|
|
2869
2918
|
//
|
|
2919
|
+
// unified
|
|
2920
|
+
//
|
|
2921
|
+
// {
|
|
2922
|
+
// "user_id": 10001,
|
|
2923
|
+
// "locked": false,
|
|
2924
|
+
// "balances": {
|
|
2925
|
+
// "ETH": {
|
|
2926
|
+
// "available": "0",
|
|
2927
|
+
// "freeze": "0",
|
|
2928
|
+
// "borrowed": "0.075393666654",
|
|
2929
|
+
// "negative_liab": "0",
|
|
2930
|
+
// "futures_pos_liab": "0",
|
|
2931
|
+
// "equity": "1016.1",
|
|
2932
|
+
// "total_freeze": "0",
|
|
2933
|
+
// "total_liab": "0"
|
|
2934
|
+
// },
|
|
2935
|
+
// "POINT": {
|
|
2936
|
+
// "available": "9999999999.017023138734",
|
|
2937
|
+
// "freeze": "0",
|
|
2938
|
+
// "borrowed": "0",
|
|
2939
|
+
// "negative_liab": "0",
|
|
2940
|
+
// "futures_pos_liab": "0",
|
|
2941
|
+
// "equity": "12016.1",
|
|
2942
|
+
// "total_freeze": "0",
|
|
2943
|
+
// "total_liab": "0"
|
|
2944
|
+
// },
|
|
2945
|
+
// "USDT": {
|
|
2946
|
+
// "available": "0.00000062023",
|
|
2947
|
+
// "freeze": "0",
|
|
2948
|
+
// "borrowed": "0",
|
|
2949
|
+
// "negative_liab": "0",
|
|
2950
|
+
// "futures_pos_liab": "0",
|
|
2951
|
+
// "equity": "16.1",
|
|
2952
|
+
// "total_freeze": "0",
|
|
2953
|
+
// "total_liab": "0"
|
|
2954
|
+
// }
|
|
2955
|
+
// },
|
|
2956
|
+
// "total": "230.94621713",
|
|
2957
|
+
// "borrowed": "161.66395521",
|
|
2958
|
+
// "total_initial_margin": "1025.0524665088",
|
|
2959
|
+
// "total_margin_balance": "3382495.944473949183",
|
|
2960
|
+
// "total_maintenance_margin": "205.01049330176",
|
|
2961
|
+
// "total_initial_margin_rate": "3299.827135672679",
|
|
2962
|
+
// "total_maintenance_margin_rate": "16499.135678363399",
|
|
2963
|
+
// "total_available_margin": "3381470.892007440383",
|
|
2964
|
+
// "unified_account_total": "3381470.892007440383",
|
|
2965
|
+
// "unified_account_total_liab": "0",
|
|
2966
|
+
// "unified_account_total_equity": "100016.1",
|
|
2967
|
+
// "leverage": "2"
|
|
2968
|
+
// }
|
|
2969
|
+
//
|
|
2870
2970
|
const result = {
|
|
2871
2971
|
'info': response,
|
|
2872
2972
|
};
|
|
2873
2973
|
const isolated = marginMode === 'margin';
|
|
2874
2974
|
let data = response;
|
|
2875
|
-
if ('balances' in data) { // True for cross_margin
|
|
2975
|
+
if ('balances' in data) { // True for cross_margin and unified
|
|
2876
2976
|
const flatBalances = [];
|
|
2877
2977
|
const balances = this.safeValue(data, 'balances', []);
|
|
2878
2978
|
// inject currency and create an artificial balance object
|
package/js/src/htx.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export default class htx extends Exchange {
|
|
|
37
37
|
};
|
|
38
38
|
costToPrecision(symbol: any, cost: any): string;
|
|
39
39
|
fetchMarkets(params?: {}): Promise<Market[]>;
|
|
40
|
-
fetchMarketsByTypeAndSubType(type:
|
|
40
|
+
fetchMarketsByTypeAndSubType(type: Str, subType: Str, params?: {}): Promise<any[]>;
|
|
41
41
|
tryGetSymbolFromFutureMarkets(symbolOrMarketId: string): any;
|
|
42
42
|
parseTicker(ticker: Dict, market?: Market): Ticker;
|
|
43
43
|
fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
@@ -66,7 +66,7 @@ export default class htx extends Exchange {
|
|
|
66
66
|
type: any;
|
|
67
67
|
code: any;
|
|
68
68
|
};
|
|
69
|
-
fetchAccountIdByType(type:
|
|
69
|
+
fetchAccountIdByType(type: string, marginMode?: Str, symbol?: Str, params?: {}): Promise<any>;
|
|
70
70
|
fetchCurrencies(params?: {}): Promise<Currencies>;
|
|
71
71
|
networkIdToCode(networkId?: Str, currencyCode?: Str): string;
|
|
72
72
|
networkCodeToId(networkCode: string, currencyCode?: Str): any;
|
package/js/src/htx.js
CHANGED
|
@@ -1639,6 +1639,10 @@ export default class htx extends Exchange {
|
|
|
1639
1639
|
* @method
|
|
1640
1640
|
* @name htx#fetchMarkets
|
|
1641
1641
|
* @description retrieves data on all markets for huobi
|
|
1642
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-trading-symbol-v1-deprecated
|
|
1643
|
+
* @see https://huobiapi.github.io/docs/dm/v1/en/#get-contract-info
|
|
1644
|
+
* @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-swap-info
|
|
1645
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-swap-info
|
|
1642
1646
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1643
1647
|
* @returns {object[]} an array of objects representing market data
|
|
1644
1648
|
*/
|
|
@@ -1669,6 +1673,20 @@ export default class htx extends Exchange {
|
|
|
1669
1673
|
return allMarkets;
|
|
1670
1674
|
}
|
|
1671
1675
|
async fetchMarketsByTypeAndSubType(type, subType, params = {}) {
|
|
1676
|
+
/**
|
|
1677
|
+
* @ignore
|
|
1678
|
+
* @method
|
|
1679
|
+
* @name htx#fetchMarketsByTypeAndSubType
|
|
1680
|
+
* @description retrieves data on all markets of a certain type and/or subtype
|
|
1681
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-trading-symbol-v1-deprecated
|
|
1682
|
+
* @see https://huobiapi.github.io/docs/dm/v1/en/#get-contract-info
|
|
1683
|
+
* @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-swap-info
|
|
1684
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-swap-info
|
|
1685
|
+
* @param {string} [type] 'spot', 'swap' or 'future'
|
|
1686
|
+
* @param {string} [subType] 'linear' or 'inverse'
|
|
1687
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1688
|
+
* @returns {object[]} an array of objects representing market data
|
|
1689
|
+
*/
|
|
1672
1690
|
const isSpot = (type === 'spot');
|
|
1673
1691
|
const request = {};
|
|
1674
1692
|
let response = undefined;
|
|
@@ -3191,6 +3209,16 @@ export default class htx extends Exchange {
|
|
|
3191
3209
|
};
|
|
3192
3210
|
}
|
|
3193
3211
|
async fetchAccountIdByType(type, marginMode = undefined, symbol = undefined, params = {}) {
|
|
3212
|
+
/**
|
|
3213
|
+
* @method
|
|
3214
|
+
* @name htx#fetchAccountIdByType
|
|
3215
|
+
* @description fetch all the accounts by a type and marginModeassociated with a profile
|
|
3216
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user
|
|
3217
|
+
* @param {string} type 'spot', 'swap' or 'future
|
|
3218
|
+
* @param {string} [marginMode] 'cross' or 'isolated'
|
|
3219
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3220
|
+
* @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
|
|
3221
|
+
*/
|
|
3194
3222
|
const accounts = await this.loadAccounts();
|
|
3195
3223
|
const accountId = this.safeValue2(params, 'accountId', 'account-id');
|
|
3196
3224
|
if (accountId !== undefined) {
|
|
@@ -5088,13 +5116,7 @@ export default class htx extends Exchange {
|
|
|
5088
5116
|
let cost = undefined;
|
|
5089
5117
|
let amount = undefined;
|
|
5090
5118
|
if ((type !== undefined) && (type.indexOf('market') >= 0)) {
|
|
5091
|
-
|
|
5092
|
-
if (side === 'sell') {
|
|
5093
|
-
cost = this.safeString(order, 'field-cash-amount');
|
|
5094
|
-
}
|
|
5095
|
-
else {
|
|
5096
|
-
cost = this.safeString(order, 'amount');
|
|
5097
|
-
}
|
|
5119
|
+
cost = this.safeString(order, 'field-cash-amount');
|
|
5098
5120
|
}
|
|
5099
5121
|
else {
|
|
5100
5122
|
amount = this.safeString2(order, 'volume', 'amount');
|
package/js/src/hyperliquid.js
CHANGED
|
@@ -645,9 +645,9 @@ export default class hyperliquid extends Exchange {
|
|
|
645
645
|
const code = this.safeCurrencyCode(this.safeString(balance, 'coin'));
|
|
646
646
|
const account = this.account();
|
|
647
647
|
const total = this.safeString(balance, 'total');
|
|
648
|
-
const
|
|
648
|
+
const used = this.safeString(balance, 'hold');
|
|
649
649
|
account['total'] = total;
|
|
650
|
-
account['used'] =
|
|
650
|
+
account['used'] = used;
|
|
651
651
|
spotBalances[code] = account;
|
|
652
652
|
}
|
|
653
653
|
return this.safeBalance(spotBalances);
|
|
@@ -656,8 +656,8 @@ export default class hyperliquid extends Exchange {
|
|
|
656
656
|
const result = {
|
|
657
657
|
'info': response,
|
|
658
658
|
'USDC': {
|
|
659
|
-
'total': this.
|
|
660
|
-
'
|
|
659
|
+
'total': this.safeNumber(data, 'accountValue'),
|
|
660
|
+
'free': this.safeNumber(response, 'withdrawable'),
|
|
661
661
|
},
|
|
662
662
|
};
|
|
663
663
|
const timestamp = this.safeInteger(response, 'time');
|
|
@@ -2230,14 +2230,17 @@ export default class hyperliquid extends Exchange {
|
|
|
2230
2230
|
const leverage = this.safeDict(entry, 'leverage', {});
|
|
2231
2231
|
const marginMode = this.safeString(leverage, 'type');
|
|
2232
2232
|
const isIsolated = (marginMode === 'isolated');
|
|
2233
|
-
const
|
|
2233
|
+
const rawSize = this.safeString(entry, 'szi');
|
|
2234
|
+
let size = rawSize;
|
|
2234
2235
|
let side = undefined;
|
|
2235
2236
|
if (size !== undefined) {
|
|
2236
|
-
side = (
|
|
2237
|
+
side = Precise.stringGt(rawSize, '0') ? 'long' : 'short';
|
|
2238
|
+
size = Precise.stringAbs(size);
|
|
2237
2239
|
}
|
|
2238
|
-
const
|
|
2239
|
-
const
|
|
2240
|
-
const
|
|
2240
|
+
const rawUnrealizedPnl = this.safeString(entry, 'unrealizedPnl');
|
|
2241
|
+
const absRawUnrealizedPnl = Precise.stringAbs(rawUnrealizedPnl);
|
|
2242
|
+
const initialMargin = this.safeString(entry, 'marginUsed');
|
|
2243
|
+
const percentage = Precise.stringMul(Precise.stringDiv(absRawUnrealizedPnl, initialMargin), '100');
|
|
2241
2244
|
return this.safePosition({
|
|
2242
2245
|
'info': position,
|
|
2243
2246
|
'id': undefined,
|
|
@@ -2247,7 +2250,7 @@ export default class hyperliquid extends Exchange {
|
|
|
2247
2250
|
'isolated': isIsolated,
|
|
2248
2251
|
'hedged': undefined,
|
|
2249
2252
|
'side': side,
|
|
2250
|
-
'contracts': size,
|
|
2253
|
+
'contracts': this.parseNumber(size),
|
|
2251
2254
|
'contractSize': undefined,
|
|
2252
2255
|
'entryPrice': this.safeNumber(entry, 'entryPx'),
|
|
2253
2256
|
'markPrice': undefined,
|
|
@@ -2258,10 +2261,10 @@ export default class hyperliquid extends Exchange {
|
|
|
2258
2261
|
'maintenanceMargin': undefined,
|
|
2259
2262
|
'initialMarginPercentage': undefined,
|
|
2260
2263
|
'maintenanceMarginPercentage': undefined,
|
|
2261
|
-
'unrealizedPnl':
|
|
2264
|
+
'unrealizedPnl': this.parseNumber(rawUnrealizedPnl),
|
|
2262
2265
|
'liquidationPrice': this.safeNumber(entry, 'liquidationPx'),
|
|
2263
2266
|
'marginMode': marginMode,
|
|
2264
|
-
'percentage': percentage,
|
|
2267
|
+
'percentage': this.parseNumber(percentage),
|
|
2265
2268
|
});
|
|
2266
2269
|
}
|
|
2267
2270
|
async setMarginMode(marginMode, symbol = undefined, params = {}) {
|
package/js/src/kucoin.d.ts
CHANGED
|
@@ -62,7 +62,6 @@ export default class kucoin extends Exchange {
|
|
|
62
62
|
parseTrade(trade: Dict, market?: Market): Trade;
|
|
63
63
|
fetchTradingFee(symbol: string, params?: {}): Promise<TradingFeeInterface>;
|
|
64
64
|
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
65
|
-
loadCurrencyPrecision(currency: any, networkCode?: Str): Promise<void>;
|
|
66
65
|
parseTransactionStatus(status: Str): string;
|
|
67
66
|
parseTransaction(transaction: Dict, currency?: Currency): Transaction;
|
|
68
67
|
fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
@@ -76,7 +75,6 @@ export default class kucoin extends Exchange {
|
|
|
76
75
|
parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
|
|
77
76
|
fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
|
|
78
77
|
calculateRateLimiterCost(api: any, method: any, path: any, params: any, config?: {}): any;
|
|
79
|
-
parseBorrowRateHistory(response: any, code: any, since: any, limit: any): any;
|
|
80
78
|
parseBorrowRate(info: any, currency?: Currency): {
|
|
81
79
|
currency: string;
|
|
82
80
|
rate: number;
|
package/js/src/kucoin.js
CHANGED
|
@@ -166,7 +166,8 @@ export default class kucoin extends Exchange {
|
|
|
166
166
|
// margin trading
|
|
167
167
|
'mark-price/{symbol}/current': 3,
|
|
168
168
|
'mark-price/all-symbols': 3,
|
|
169
|
-
'margin/config': 25,
|
|
169
|
+
'margin/config': 25,
|
|
170
|
+
'announcements': 20, // 20W
|
|
170
171
|
},
|
|
171
172
|
'post': {
|
|
172
173
|
// ws
|
|
@@ -290,6 +291,7 @@ export default class kucoin extends Exchange {
|
|
|
290
291
|
// ws
|
|
291
292
|
'bullet-private': 10,
|
|
292
293
|
'position/update-user-leverage': 5,
|
|
294
|
+
'deposit-address/create': 20,
|
|
293
295
|
},
|
|
294
296
|
'delete': {
|
|
295
297
|
// account
|
|
@@ -456,6 +458,7 @@ export default class kucoin extends Exchange {
|
|
|
456
458
|
'precisionMode': TICK_SIZE,
|
|
457
459
|
'exceptions': {
|
|
458
460
|
'exact': {
|
|
461
|
+
'The order does not exist.': OrderNotFound,
|
|
459
462
|
'order not exist': OrderNotFound,
|
|
460
463
|
'order not exist.': OrderNotFound,
|
|
461
464
|
'order_not_exist': OrderNotFound,
|
|
@@ -656,6 +659,7 @@ export default class kucoin extends Exchange {
|
|
|
656
659
|
'currencies/{currency}': 'v3',
|
|
657
660
|
'symbols': 'v2',
|
|
658
661
|
'mark-price/all-symbols': 'v3',
|
|
662
|
+
'announcements': 'v3',
|
|
659
663
|
},
|
|
660
664
|
},
|
|
661
665
|
'private': {
|
|
@@ -707,6 +711,7 @@ export default class kucoin extends Exchange {
|
|
|
707
711
|
'accounts/sub-transfer': 'v2',
|
|
708
712
|
'accounts/inner-transfer': 'v2',
|
|
709
713
|
'transfer-out': 'v3',
|
|
714
|
+
'deposit-address/create': 'v3',
|
|
710
715
|
// spot trading
|
|
711
716
|
'oco/order': 'v3',
|
|
712
717
|
// margin trading
|
|
@@ -718,6 +723,7 @@ export default class kucoin extends Exchange {
|
|
|
718
723
|
'redeem': 'v3',
|
|
719
724
|
'lend/purchase/update': 'v3',
|
|
720
725
|
'position/update-user-leverage': 'v3',
|
|
726
|
+
'withdrawals': 'v3',
|
|
721
727
|
},
|
|
722
728
|
'DELETE': {
|
|
723
729
|
// account
|
|
@@ -783,7 +789,7 @@ export default class kucoin extends Exchange {
|
|
|
783
789
|
'TLOS': 'tlos',
|
|
784
790
|
'CFX': 'cfx',
|
|
785
791
|
'ACA': 'aca',
|
|
786
|
-
'
|
|
792
|
+
'OP': 'optimism',
|
|
787
793
|
'ONT': 'ont',
|
|
788
794
|
'GLMR': 'glmr',
|
|
789
795
|
'CSPR': 'cspr',
|
|
@@ -1544,41 +1550,28 @@ export default class kucoin extends Exchange {
|
|
|
1544
1550
|
// "chain": "ERC20"
|
|
1545
1551
|
// }
|
|
1546
1552
|
//
|
|
1553
|
+
const minWithdrawFee = this.safeNumber(fee, 'withdrawMinFee');
|
|
1547
1554
|
const result = {
|
|
1548
1555
|
'info': fee,
|
|
1549
1556
|
'withdraw': {
|
|
1557
|
+
'fee': minWithdrawFee,
|
|
1558
|
+
'percentage': false,
|
|
1559
|
+
},
|
|
1560
|
+
'deposit': {
|
|
1550
1561
|
'fee': undefined,
|
|
1551
1562
|
'percentage': undefined,
|
|
1552
1563
|
},
|
|
1564
|
+
'networks': {},
|
|
1565
|
+
};
|
|
1566
|
+
const networkId = this.safeString(fee, 'chain');
|
|
1567
|
+
const networkCode = this.networkIdToCode(networkId, this.safeString(currency, 'code'));
|
|
1568
|
+
result['networks'][networkCode] = {
|
|
1569
|
+
'withdraw': minWithdrawFee,
|
|
1553
1570
|
'deposit': {
|
|
1554
1571
|
'fee': undefined,
|
|
1555
1572
|
'percentage': undefined,
|
|
1556
1573
|
},
|
|
1557
|
-
'networks': {},
|
|
1558
1574
|
};
|
|
1559
|
-
const isWithdrawEnabled = this.safeBool(fee, 'isWithdrawEnabled', true);
|
|
1560
|
-
let minFee = undefined;
|
|
1561
|
-
if (isWithdrawEnabled) {
|
|
1562
|
-
result['withdraw']['percentage'] = false;
|
|
1563
|
-
const chains = this.safeList(fee, 'chains', []);
|
|
1564
|
-
for (let i = 0; i < chains.length; i++) {
|
|
1565
|
-
const chain = chains[i];
|
|
1566
|
-
const networkId = this.safeString(chain, 'chainId');
|
|
1567
|
-
const networkCode = this.networkIdToCode(networkId, this.safeString(currency, 'code'));
|
|
1568
|
-
const withdrawFee = this.safeString(chain, 'withdrawalMinFee');
|
|
1569
|
-
if (minFee === undefined || (Precise.stringLt(withdrawFee, minFee))) {
|
|
1570
|
-
minFee = withdrawFee;
|
|
1571
|
-
}
|
|
1572
|
-
result['networks'][networkCode] = {
|
|
1573
|
-
'withdraw': this.parseNumber(withdrawFee),
|
|
1574
|
-
'deposit': {
|
|
1575
|
-
'fee': undefined,
|
|
1576
|
-
'percentage': undefined,
|
|
1577
|
-
},
|
|
1578
|
-
};
|
|
1579
|
-
}
|
|
1580
|
-
result['withdraw']['fee'] = this.parseNumber(minFee);
|
|
1581
|
-
}
|
|
1582
1575
|
return result;
|
|
1583
1576
|
}
|
|
1584
1577
|
isFuturesMethod(methodName, params) {
|
|
@@ -1907,7 +1900,7 @@ export default class kucoin extends Exchange {
|
|
|
1907
1900
|
/**
|
|
1908
1901
|
* @method
|
|
1909
1902
|
* @name kucoin#createDepositAddress
|
|
1910
|
-
* @see https://
|
|
1903
|
+
* @see https://www.kucoin.com/docs/rest/funding/deposit/create-deposit-address-v3-
|
|
1911
1904
|
* @description create a currency deposit address
|
|
1912
1905
|
* @param {string} code unified currency code of the currency for the deposit address
|
|
1913
1906
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -1922,12 +1915,24 @@ export default class kucoin extends Exchange {
|
|
|
1922
1915
|
let networkCode = undefined;
|
|
1923
1916
|
[networkCode, params] = this.handleNetworkCodeAndParams(params);
|
|
1924
1917
|
if (networkCode !== undefined) {
|
|
1925
|
-
request['chain'] = this.networkCodeToId(networkCode)
|
|
1918
|
+
request['chain'] = this.networkCodeToId(networkCode); // docs mention "chain-name", but seems "chain-id" is used, like in "fetchDepositAddress"
|
|
1926
1919
|
}
|
|
1927
|
-
const response = await this.
|
|
1920
|
+
const response = await this.privatePostDepositAddressCreate(this.extend(request, params));
|
|
1928
1921
|
// {"code":"260000","msg":"Deposit address already exists."}
|
|
1929
|
-
//
|
|
1930
|
-
//
|
|
1922
|
+
//
|
|
1923
|
+
// {
|
|
1924
|
+
// "code": "200000",
|
|
1925
|
+
// "data": {
|
|
1926
|
+
// "address": "0x2336d1834faab10b2dac44e468f2627138417431",
|
|
1927
|
+
// "memo": null,
|
|
1928
|
+
// "chainId": "bsc",
|
|
1929
|
+
// "to": "MAIN",
|
|
1930
|
+
// "expirationDate": 0,
|
|
1931
|
+
// "currency": "BNB",
|
|
1932
|
+
// "chainName": "BEP20"
|
|
1933
|
+
// }
|
|
1934
|
+
// }
|
|
1935
|
+
//
|
|
1931
1936
|
const data = this.safeDict(response, 'data', {});
|
|
1932
1937
|
return this.parseDepositAddress(data, currency);
|
|
1933
1938
|
}
|
|
@@ -1984,7 +1989,7 @@ export default class kucoin extends Exchange {
|
|
|
1984
1989
|
return {
|
|
1985
1990
|
'info': depositAddress,
|
|
1986
1991
|
'currency': code,
|
|
1987
|
-
'network': this.networkIdToCode(this.safeString(depositAddress, '
|
|
1992
|
+
'network': this.networkIdToCode(this.safeString(depositAddress, 'chainId')),
|
|
1988
1993
|
'address': address,
|
|
1989
1994
|
'tag': this.safeString(depositAddress, 'memo'),
|
|
1990
1995
|
};
|
|
@@ -3094,7 +3099,7 @@ export default class kucoin extends Exchange {
|
|
|
3094
3099
|
},
|
|
3095
3100
|
'status': status,
|
|
3096
3101
|
'lastTradeTimestamp': undefined,
|
|
3097
|
-
'average':
|
|
3102
|
+
'average': this.safeString(order, 'avgDealPrice'),
|
|
3098
3103
|
'trades': undefined,
|
|
3099
3104
|
}, market);
|
|
3100
3105
|
}
|
|
@@ -3446,7 +3451,7 @@ export default class kucoin extends Exchange {
|
|
|
3446
3451
|
* @method
|
|
3447
3452
|
* @name kucoin#withdraw
|
|
3448
3453
|
* @description make a withdrawal
|
|
3449
|
-
* @see https://www.kucoin.com/docs/rest/funding/withdrawals/apply-withdraw
|
|
3454
|
+
* @see https://www.kucoin.com/docs/rest/funding/withdrawals/apply-withdraw-v3-
|
|
3450
3455
|
* @param {string} code unified currency code
|
|
3451
3456
|
* @param {float} amount the amount to withdraw
|
|
3452
3457
|
* @param {string} address the address to withdraw to
|
|
@@ -3460,7 +3465,8 @@ export default class kucoin extends Exchange {
|
|
|
3460
3465
|
const currency = this.currency(code);
|
|
3461
3466
|
const request = {
|
|
3462
3467
|
'currency': currency['id'],
|
|
3463
|
-
'
|
|
3468
|
+
'toAddress': address,
|
|
3469
|
+
'withdrawType': 'ADDRESS',
|
|
3464
3470
|
// 'memo': tag,
|
|
3465
3471
|
// 'isInner': false, // internal transfer or external withdrawal
|
|
3466
3472
|
// 'remark': 'optional',
|
|
@@ -3474,8 +3480,7 @@ export default class kucoin extends Exchange {
|
|
|
3474
3480
|
if (networkCode !== undefined) {
|
|
3475
3481
|
request['chain'] = this.networkCodeToId(networkCode).toLowerCase();
|
|
3476
3482
|
}
|
|
3477
|
-
|
|
3478
|
-
request['amount'] = this.currencyToPrecision(code, amount, networkCode);
|
|
3483
|
+
request['amount'] = parseFloat(this.currencyToPrecision(code, amount, networkCode));
|
|
3479
3484
|
let includeFee = undefined;
|
|
3480
3485
|
[includeFee, params] = this.handleOptionAndParams(params, 'withdraw', 'includeFee', false);
|
|
3481
3486
|
if (includeFee) {
|
|
@@ -3483,7 +3488,7 @@ export default class kucoin extends Exchange {
|
|
|
3483
3488
|
}
|
|
3484
3489
|
const response = await this.privatePostWithdrawals(this.extend(request, params));
|
|
3485
3490
|
//
|
|
3486
|
-
//
|
|
3491
|
+
// the id is inside "data"
|
|
3487
3492
|
//
|
|
3488
3493
|
// {
|
|
3489
3494
|
// "code": 200000,
|
|
@@ -3495,53 +3500,6 @@ export default class kucoin extends Exchange {
|
|
|
3495
3500
|
const data = this.safeDict(response, 'data', {});
|
|
3496
3501
|
return this.parseTransaction(data, currency);
|
|
3497
3502
|
}
|
|
3498
|
-
async loadCurrencyPrecision(currency, networkCode = undefined) {
|
|
3499
|
-
// as kucoin might not have network specific precisions defined in fetchCurrencies (because of webapi failure)
|
|
3500
|
-
// we should check and refetch precision once-per-instance for that specific currency & network
|
|
3501
|
-
// so avoids thorwing exceptions and burden to users
|
|
3502
|
-
// Note: this needs to be executed only if networkCode was provided
|
|
3503
|
-
if (networkCode !== undefined) {
|
|
3504
|
-
const networks = currency['networks'];
|
|
3505
|
-
const network = this.safeDict(networks, networkCode);
|
|
3506
|
-
if (this.safeNumber(network, 'precision') !== undefined) {
|
|
3507
|
-
// if precision exists, no need to refetch
|
|
3508
|
-
return;
|
|
3509
|
-
}
|
|
3510
|
-
// otherwise try to fetch and store in instance
|
|
3511
|
-
const request = {
|
|
3512
|
-
'currency': currency['id'],
|
|
3513
|
-
'chain': this.networkCodeToId(networkCode).toLowerCase(),
|
|
3514
|
-
};
|
|
3515
|
-
const response = await this.privateGetWithdrawalsQuotas(request);
|
|
3516
|
-
//
|
|
3517
|
-
// {
|
|
3518
|
-
// "code": "200000",
|
|
3519
|
-
// "data": {
|
|
3520
|
-
// "currency": "USDT",
|
|
3521
|
-
// "limitBTCAmount": "14.24094850",
|
|
3522
|
-
// "usedBTCAmount": "0.00000000",
|
|
3523
|
-
// "quotaCurrency": "USDT",
|
|
3524
|
-
// "limitQuotaCurrencyAmount": "999999.00000000",
|
|
3525
|
-
// "usedQuotaCurrencyAmount": "0",
|
|
3526
|
-
// "remainAmount": "999999.0000",
|
|
3527
|
-
// "availableAmount": "10.77545071",
|
|
3528
|
-
// "withdrawMinFee": "1",
|
|
3529
|
-
// "innerWithdrawMinFee": "0",
|
|
3530
|
-
// "withdrawMinSize": "10",
|
|
3531
|
-
// "isWithdrawEnabled": true,
|
|
3532
|
-
// "precision": 4,
|
|
3533
|
-
// "chain": "EOS",
|
|
3534
|
-
// "reason": null,
|
|
3535
|
-
// "lockedAmount": "0"
|
|
3536
|
-
// }
|
|
3537
|
-
// }
|
|
3538
|
-
//
|
|
3539
|
-
const data = this.safeDict(response, 'data', {});
|
|
3540
|
-
const precision = this.parseNumber(this.parsePrecision(this.safeString(data, 'precision')));
|
|
3541
|
-
const code = currency['code'];
|
|
3542
|
-
this.currencies[code]['networks'][networkCode]['precision'] = precision;
|
|
3543
|
-
}
|
|
3544
|
-
}
|
|
3545
3503
|
parseTransactionStatus(status) {
|
|
3546
3504
|
const statuses = {
|
|
3547
3505
|
'SUCCESS': 'ok',
|
|
@@ -4429,16 +4387,6 @@ export default class kucoin extends Exchange {
|
|
|
4429
4387
|
}
|
|
4430
4388
|
return this.safeValue(config, 'cost', 1);
|
|
4431
4389
|
}
|
|
4432
|
-
parseBorrowRateHistory(response, code, since, limit) {
|
|
4433
|
-
const result = [];
|
|
4434
|
-
for (let i = 0; i < response.length; i++) {
|
|
4435
|
-
const item = response[i];
|
|
4436
|
-
const borrowRate = this.parseBorrowRate(item);
|
|
4437
|
-
result.push(borrowRate);
|
|
4438
|
-
}
|
|
4439
|
-
const sorted = this.sortBy(result, 'timestamp');
|
|
4440
|
-
return this.filterByCurrencySinceLimit(sorted, code, since, limit);
|
|
4441
|
-
}
|
|
4442
4390
|
parseBorrowRate(info, currency = undefined) {
|
|
4443
4391
|
//
|
|
4444
4392
|
// {
|
package/js/src/kucoinfutures.js
CHANGED
|
@@ -2220,8 +2220,8 @@ export default class kucoinfutures extends kucoin {
|
|
|
2220
2220
|
const amount = this.safeString(order, 'size');
|
|
2221
2221
|
const filled = this.safeString(order, 'filledSize');
|
|
2222
2222
|
const cost = this.safeString(order, 'filledValue');
|
|
2223
|
-
let average =
|
|
2224
|
-
if (Precise.stringGt(filled, '0')) {
|
|
2223
|
+
let average = this.safeString(order, 'avgDealPrice');
|
|
2224
|
+
if ((average === undefined) && Precise.stringGt(filled, '0')) {
|
|
2225
2225
|
const contractSize = this.safeString(market, 'contractSize');
|
|
2226
2226
|
if (market['linear']) {
|
|
2227
2227
|
average = Precise.stringDiv(cost, Precise.stringMul(contractSize, filled));
|