ccxt 4.3.62 → 4.3.63
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 +3 -3
- package/dist/cjs/ccxt.js +2 -1
- package/dist/cjs/src/ace.js +34 -15
- package/dist/cjs/src/base/Exchange.js +8 -1
- package/dist/cjs/src/base/errors.js +8 -1
- package/dist/cjs/src/binance.js +6 -9
- package/dist/cjs/src/bingx.js +466 -151
- package/dist/cjs/src/cryptocom.js +18 -2
- package/dist/cjs/src/mercado.js +5 -1
- package/dist/cjs/src/pro/binance.js +58 -34
- package/dist/cjs/src/pro/bitfinex2.js +6 -3
- package/dist/cjs/src/pro/bitget.js +4 -1
- package/dist/cjs/src/pro/bitvavo.js +1 -1
- package/dist/cjs/src/pro/bybit.js +44 -18
- package/dist/cjs/src/pro/cryptocom.js +7 -1
- package/dist/cjs/src/pro/gate.js +6 -2
- package/dist/cjs/src/pro/htx.js +5 -1
- package/dist/cjs/src/pro/independentreserve.js +5 -3
- package/dist/cjs/src/pro/kraken.js +82 -4
- package/dist/cjs/src/pro/okx.js +3 -3
- package/dist/cjs/src/pro/poloniexfutures.js +5 -1
- package/dist/cjs/src/pro/woofipro.js +1 -1
- package/dist/cjs/src/woo.js +313 -81
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +3 -3
- package/js/src/abstract/cryptocom.d.ts +11 -0
- package/js/src/abstract/woo.d.ts +3 -0
- package/js/src/ace.js +34 -15
- package/js/src/base/Exchange.d.ts +1 -0
- package/js/src/base/Exchange.js +8 -1
- package/js/src/base/errorHierarchy.d.ts +3 -1
- package/js/src/base/errorHierarchy.js +3 -1
- package/js/src/base/errors.d.ts +5 -1
- package/js/src/base/errors.js +8 -2
- package/js/src/binance.js +6 -9
- package/js/src/bingx.d.ts +1 -0
- package/js/src/bingx.js +466 -151
- package/js/src/coinbaseinternational.d.ts +1 -1
- package/js/src/cryptocom.js +18 -2
- package/js/src/mercado.js +5 -1
- package/js/src/pro/binance.d.ts +1 -0
- package/js/src/pro/binance.js +59 -35
- package/js/src/pro/bitfinex2.js +7 -4
- package/js/src/pro/bitget.js +5 -2
- package/js/src/pro/bitvavo.js +1 -1
- package/js/src/pro/bybit.d.ts +1 -0
- package/js/src/pro/bybit.js +44 -18
- package/js/src/pro/cryptocom.js +8 -2
- package/js/src/pro/gate.js +7 -3
- package/js/src/pro/htx.js +6 -2
- package/js/src/pro/independentreserve.js +6 -4
- package/js/src/pro/kraken.d.ts +3 -1
- package/js/src/pro/kraken.js +83 -5
- package/js/src/pro/okx.js +4 -4
- package/js/src/pro/poloniexfutures.js +6 -2
- package/js/src/pro/woofipro.js +1 -1
- package/js/src/woo.d.ts +5 -1
- package/js/src/woo.js +313 -81
- package/js/src/xt.d.ts +3 -3
- package/package.json +1 -1
package/js/src/woo.js
CHANGED
|
@@ -33,7 +33,7 @@ export default class woo extends Exchange {
|
|
|
33
33
|
'swap': true,
|
|
34
34
|
'future': false,
|
|
35
35
|
'option': false,
|
|
36
|
-
'addMargin':
|
|
36
|
+
'addMargin': true,
|
|
37
37
|
'cancelAllOrders': true,
|
|
38
38
|
'cancelAllOrdersAfter': true,
|
|
39
39
|
'cancelOrder': true,
|
|
@@ -203,6 +203,7 @@ export default class woo extends Exchange {
|
|
|
203
203
|
'positions': 3.33,
|
|
204
204
|
'position/{symbol}': 3.33,
|
|
205
205
|
'client/transaction_history': 60,
|
|
206
|
+
'client/futures_leverage': 60,
|
|
206
207
|
},
|
|
207
208
|
'post': {
|
|
208
209
|
'order': 5,
|
|
@@ -215,6 +216,8 @@ export default class woo extends Exchange {
|
|
|
215
216
|
'client/account_mode': 120,
|
|
216
217
|
'client/position_mode': 5,
|
|
217
218
|
'client/leverage': 120,
|
|
219
|
+
'client/futures_leverage': 30,
|
|
220
|
+
'client/isolated_margin': 30,
|
|
218
221
|
},
|
|
219
222
|
'delete': {
|
|
220
223
|
'order': 1,
|
|
@@ -938,16 +941,18 @@ export default class woo extends Exchange {
|
|
|
938
941
|
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
939
942
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
940
943
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
944
|
+
* @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated', default 'cross'
|
|
941
945
|
* @param {float} [params.triggerPrice] The price a trigger order is triggered at
|
|
942
946
|
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
|
|
943
947
|
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
944
948
|
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
|
|
945
949
|
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
946
|
-
* @param {float} [params.algoType] 'STOP'or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
|
|
950
|
+
* @param {float} [params.algoType] 'STOP' or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
|
|
947
951
|
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
948
952
|
* @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
949
953
|
* @param {string} [params.trailingPercent] the percent to trail away from the current market price
|
|
950
954
|
* @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
|
|
955
|
+
* @param {string} [params.position_side] 'SHORT' or 'LONG' - if position mode is HEDGE_MODE and the trading involves futures, then is required, otherwise this parameter is not required
|
|
951
956
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
952
957
|
*/
|
|
953
958
|
const reduceOnly = this.safeBool2(params, 'reduceOnly', 'reduce_only');
|
|
@@ -960,6 +965,11 @@ export default class woo extends Exchange {
|
|
|
960
965
|
'symbol': market['id'],
|
|
961
966
|
'side': orderSide,
|
|
962
967
|
};
|
|
968
|
+
let marginMode = undefined;
|
|
969
|
+
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
|
|
970
|
+
if (marginMode !== undefined) {
|
|
971
|
+
request['margin_mode'] = this.encodeMarginMode(marginMode);
|
|
972
|
+
}
|
|
963
973
|
const stopPrice = this.safeNumber2(params, 'triggerPrice', 'stopPrice');
|
|
964
974
|
const stopLoss = this.safeValue(params, 'stopLoss');
|
|
965
975
|
const takeProfit = this.safeValue(params, 'takeProfit');
|
|
@@ -1121,6 +1131,13 @@ export default class woo extends Exchange {
|
|
|
1121
1131
|
order['type'] = type;
|
|
1122
1132
|
return order;
|
|
1123
1133
|
}
|
|
1134
|
+
encodeMarginMode(mode) {
|
|
1135
|
+
const modes = {
|
|
1136
|
+
'cross': 'CROSS',
|
|
1137
|
+
'isolated': 'ISOLATED',
|
|
1138
|
+
};
|
|
1139
|
+
return this.safeString(modes, mode, mode);
|
|
1140
|
+
}
|
|
1124
1141
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
1125
1142
|
/**
|
|
1126
1143
|
* @method
|
|
@@ -2882,61 +2899,204 @@ export default class woo extends Exchange {
|
|
|
2882
2899
|
* @see https://docs.woo.org/#get-account-information-new
|
|
2883
2900
|
* @param {string} symbol unified market symbol
|
|
2884
2901
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2902
|
+
* @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated'
|
|
2903
|
+
* @param {string} [params.position_mode] *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE'
|
|
2885
2904
|
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
2886
2905
|
*/
|
|
2887
2906
|
await this.loadMarkets();
|
|
2888
2907
|
const market = this.market(symbol);
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2908
|
+
let response = undefined;
|
|
2909
|
+
if (market['spot']) {
|
|
2910
|
+
response = await this.v3PrivateGetAccountinfo(params);
|
|
2911
|
+
//
|
|
2912
|
+
// {
|
|
2913
|
+
// "success": true,
|
|
2914
|
+
// "data": {
|
|
2915
|
+
// "applicationId": "dsa",
|
|
2916
|
+
// "account": "dsa",
|
|
2917
|
+
// "alias": "haha",
|
|
2918
|
+
// "accountMode": "MARGIN",
|
|
2919
|
+
// "leverage": 1,
|
|
2920
|
+
// "takerFeeRate": 1,
|
|
2921
|
+
// "makerFeeRate": 1,
|
|
2922
|
+
// "interestRate": 1,
|
|
2923
|
+
// "futuresTakerFeeRate": 1,
|
|
2924
|
+
// "futuresMakerFeeRate": 1,
|
|
2925
|
+
// "otpauth": true,
|
|
2926
|
+
// "marginRatio": 1,
|
|
2927
|
+
// "openMarginRatio": 1,
|
|
2928
|
+
// "initialMarginRatio": 1,
|
|
2929
|
+
// "maintenanceMarginRatio": 1,
|
|
2930
|
+
// "totalCollateral": 1,
|
|
2931
|
+
// "freeCollateral": 1,
|
|
2932
|
+
// "totalAccountValue": 1,
|
|
2933
|
+
// "totalVaultValue": 1,
|
|
2934
|
+
// "totalStakingValue": 1
|
|
2935
|
+
// },
|
|
2936
|
+
// "timestamp": 1673323685109
|
|
2937
|
+
// }
|
|
2938
|
+
//
|
|
2939
|
+
}
|
|
2940
|
+
else if (market['swap']) {
|
|
2941
|
+
const request = {
|
|
2942
|
+
'symbol': market['id'],
|
|
2943
|
+
};
|
|
2944
|
+
let marginMode = undefined;
|
|
2945
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchLeverage', params, 'cross');
|
|
2946
|
+
request['margin_mode'] = this.encodeMarginMode(marginMode);
|
|
2947
|
+
response = await this.v1PrivateGetClientFuturesLeverage(this.extend(request, params));
|
|
2948
|
+
//
|
|
2949
|
+
// HEDGE_MODE
|
|
2950
|
+
// {
|
|
2951
|
+
// "success": true,
|
|
2952
|
+
// "data":
|
|
2953
|
+
// {
|
|
2954
|
+
// "symbol": "PERP_ETH_USDT",
|
|
2955
|
+
// "default_margin_mode": "CROSS",
|
|
2956
|
+
// "position_mode": "HEDGE_MODE",
|
|
2957
|
+
// "details": [
|
|
2958
|
+
// {
|
|
2959
|
+
// "position_side": "LONG",
|
|
2960
|
+
// "leverage": 10
|
|
2961
|
+
// },
|
|
2962
|
+
// {
|
|
2963
|
+
// "position_side": "SHORT",
|
|
2964
|
+
// "leverage": 10
|
|
2965
|
+
// }
|
|
2966
|
+
// ]
|
|
2967
|
+
// },
|
|
2968
|
+
// "timestamp": 1720886470482
|
|
2969
|
+
// }
|
|
2970
|
+
//
|
|
2971
|
+
// ONE_WAY
|
|
2972
|
+
// {
|
|
2973
|
+
// "success": true,
|
|
2974
|
+
// "data": {
|
|
2975
|
+
// "symbol": "PERP_ETH_USDT",
|
|
2976
|
+
// "default_margin_mode": "ISOLATED",
|
|
2977
|
+
// "position_mode": "ONE_WAY",
|
|
2978
|
+
// "details": [
|
|
2979
|
+
// {
|
|
2980
|
+
// "position_side": "BOTH",
|
|
2981
|
+
// "leverage": 10
|
|
2982
|
+
// }
|
|
2983
|
+
// ]
|
|
2984
|
+
// },
|
|
2985
|
+
// "timestamp": 1720886810317
|
|
2986
|
+
// }
|
|
2987
|
+
//
|
|
2988
|
+
}
|
|
2989
|
+
else {
|
|
2990
|
+
throw new NotSupported(this.id + ' fetchLeverage() is not supported for ' + market['type'] + ' markets');
|
|
2991
|
+
}
|
|
2918
2992
|
const data = this.safeDict(response, 'data', {});
|
|
2919
2993
|
return this.parseLeverage(data, market);
|
|
2920
2994
|
}
|
|
2921
2995
|
parseLeverage(leverage, market = undefined) {
|
|
2922
|
-
const
|
|
2996
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
2997
|
+
market = this.safeMarket(marketId, market);
|
|
2998
|
+
const marginMode = this.safeStringLower(leverage, 'default_margin_mode');
|
|
2999
|
+
const spotLeverage = this.safeInteger(leverage, 'leverage');
|
|
3000
|
+
let longLeverage = spotLeverage;
|
|
3001
|
+
let shortLeverage = spotLeverage;
|
|
3002
|
+
const details = this.safeList(leverage, 'details', []);
|
|
3003
|
+
for (let i = 0; i < details.length; i++) {
|
|
3004
|
+
const position = this.safeDict(details, i, {});
|
|
3005
|
+
const positionLeverage = this.safeInteger(position, 'leverage');
|
|
3006
|
+
const side = this.safeString(position, 'position_side');
|
|
3007
|
+
if (side === 'BOTH') {
|
|
3008
|
+
longLeverage = positionLeverage;
|
|
3009
|
+
shortLeverage = positionLeverage;
|
|
3010
|
+
}
|
|
3011
|
+
else if (side === 'LONG') {
|
|
3012
|
+
longLeverage = positionLeverage;
|
|
3013
|
+
}
|
|
3014
|
+
else if (side === 'SHORT') {
|
|
3015
|
+
shortLeverage = positionLeverage;
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
2923
3018
|
return {
|
|
2924
3019
|
'info': leverage,
|
|
2925
3020
|
'symbol': market['symbol'],
|
|
2926
|
-
'marginMode':
|
|
2927
|
-
'longLeverage':
|
|
2928
|
-
'shortLeverage':
|
|
3021
|
+
'marginMode': marginMode,
|
|
3022
|
+
'longLeverage': longLeverage,
|
|
3023
|
+
'shortLeverage': shortLeverage,
|
|
2929
3024
|
};
|
|
2930
3025
|
}
|
|
2931
3026
|
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
3027
|
+
/**
|
|
3028
|
+
* @method
|
|
3029
|
+
* @name woo#setLeverage
|
|
3030
|
+
* @description set the level of leverage for a market
|
|
3031
|
+
* @see https://docs.woo.org/#update-leverage-setting
|
|
3032
|
+
* @see https://docs.woo.org/#update-futures-leverage-setting
|
|
3033
|
+
* @param {float} leverage the rate of leverage (1, 2, 3, 4 or 5 for spot markets, 1, 2, 3, 4, 5, 10, 15, 20 for swap markets)
|
|
3034
|
+
* @param {string} [symbo] unified market symbol (is mandatory for swap markets)
|
|
3035
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3036
|
+
* @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated'
|
|
3037
|
+
* @param {string} [params.position_side] *for swap markets only* 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode.
|
|
3038
|
+
* @returns {object} response from the exchange
|
|
3039
|
+
*/
|
|
2932
3040
|
await this.loadMarkets();
|
|
2933
|
-
if ((leverage < 1) || (leverage > 20)) {
|
|
2934
|
-
throw new BadRequest(this.id + ' leverage should be between 1 and 20');
|
|
2935
|
-
}
|
|
2936
3041
|
const request = {
|
|
2937
3042
|
'leverage': leverage,
|
|
2938
3043
|
};
|
|
2939
|
-
|
|
3044
|
+
let market = undefined;
|
|
3045
|
+
if (symbol !== undefined) {
|
|
3046
|
+
market = this.market(symbol);
|
|
3047
|
+
}
|
|
3048
|
+
if ((symbol === undefined) || market['spot']) {
|
|
3049
|
+
return await this.v1PrivatePostClientLeverage(this.extend(request, params));
|
|
3050
|
+
}
|
|
3051
|
+
else if (market['swap']) {
|
|
3052
|
+
request['symbol'] = market['id'];
|
|
3053
|
+
let marginMode = undefined;
|
|
3054
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchLeverage', params, 'cross');
|
|
3055
|
+
request['margin_mode'] = this.encodeMarginMode(marginMode);
|
|
3056
|
+
return await this.v1PrivatePostClientFuturesLeverage(this.extend(request, params));
|
|
3057
|
+
}
|
|
3058
|
+
else {
|
|
3059
|
+
throw new NotSupported(this.id + ' fetchLeverage() is not supported for ' + market['type'] + ' markets');
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
async addMargin(symbol, amount, params = {}) {
|
|
3063
|
+
/**
|
|
3064
|
+
* @method
|
|
3065
|
+
* @name woo#addMargin
|
|
3066
|
+
* @description add margin
|
|
3067
|
+
* @see https://docs.woo.org/#update-isolated-margin-setting
|
|
3068
|
+
* @param {string} symbol unified market symbol
|
|
3069
|
+
* @param {float} amount amount of margin to add
|
|
3070
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3071
|
+
* @param {string} [params.position_side] 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode
|
|
3072
|
+
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
|
|
3073
|
+
*/
|
|
3074
|
+
return await this.modifyMarginHelper(symbol, amount, 'ADD', params);
|
|
3075
|
+
}
|
|
3076
|
+
async reduceMargin(symbol, amount, params = {}) {
|
|
3077
|
+
/**
|
|
3078
|
+
* @method
|
|
3079
|
+
* @name woo#reduceMargin
|
|
3080
|
+
* @description remove margin from a position
|
|
3081
|
+
* @see https://docs.woo.org/#update-isolated-margin-setting
|
|
3082
|
+
* @param {string} symbol unified market symbol
|
|
3083
|
+
* @param {float} amount amount of margin to remove
|
|
3084
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3085
|
+
* @param {string} [params.position_side] 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode
|
|
3086
|
+
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure}
|
|
3087
|
+
*/
|
|
3088
|
+
return await this.modifyMarginHelper(symbol, amount, 'REDUCE', params);
|
|
3089
|
+
}
|
|
3090
|
+
async modifyMarginHelper(symbol, amount, type, params = {}) {
|
|
3091
|
+
await this.loadMarkets();
|
|
3092
|
+
const market = this.market(symbol);
|
|
3093
|
+
const request = {
|
|
3094
|
+
'symbol': market['id'],
|
|
3095
|
+
'adjust_token': 'USDT',
|
|
3096
|
+
'adjust_amount': amount,
|
|
3097
|
+
'action': type,
|
|
3098
|
+
};
|
|
3099
|
+
return await this.v1PrivatePostClientIsolatedMargin(this.extend(request, params));
|
|
2940
3100
|
}
|
|
2941
3101
|
async fetchPosition(symbol = undefined, params = {}) {
|
|
2942
3102
|
await this.loadMarkets();
|
|
@@ -2947,17 +3107,26 @@ export default class woo extends Exchange {
|
|
|
2947
3107
|
const response = await this.v1PrivateGetPositionSymbol(this.extend(request, params));
|
|
2948
3108
|
//
|
|
2949
3109
|
// {
|
|
2950
|
-
// "symbol":"
|
|
2951
|
-
// "
|
|
2952
|
-
// "
|
|
2953
|
-
// "
|
|
2954
|
-
// "average_open_price":
|
|
2955
|
-
// "
|
|
2956
|
-
// "
|
|
2957
|
-
// "
|
|
2958
|
-
// "
|
|
2959
|
-
// "
|
|
2960
|
-
// "
|
|
3110
|
+
// "symbol": "PERP_ETH_USDT",
|
|
3111
|
+
// "position_side": "BOTH",
|
|
3112
|
+
// "leverage": 10,
|
|
3113
|
+
// "margin_mode": "CROSS",
|
|
3114
|
+
// "average_open_price": 3139.9,
|
|
3115
|
+
// "isolated_margin_amount": 0.0,
|
|
3116
|
+
// "isolated_margin_token": "",
|
|
3117
|
+
// "opening_time": "1720627963.094",
|
|
3118
|
+
// "mark_price": 3155.19169891,
|
|
3119
|
+
// "pending_short_qty": 0.0,
|
|
3120
|
+
// "pending_long_qty": 0.0,
|
|
3121
|
+
// "holding": -0.7,
|
|
3122
|
+
// "pnl_24_h": 0.0,
|
|
3123
|
+
// "est_liq_price": 9107.40055552,
|
|
3124
|
+
// "settle_price": 3151.0319904,
|
|
3125
|
+
// "success": true,
|
|
3126
|
+
// "fee_24_h": 0.0,
|
|
3127
|
+
// "isolated_frozen_long": 0.0,
|
|
3128
|
+
// "isolated_frozen_short": 0.0,
|
|
3129
|
+
// "timestamp": "1720867502.544"
|
|
2961
3130
|
// }
|
|
2962
3131
|
//
|
|
2963
3132
|
return this.parsePosition(response, market);
|
|
@@ -2968,24 +3137,54 @@ export default class woo extends Exchange {
|
|
|
2968
3137
|
//
|
|
2969
3138
|
// {
|
|
2970
3139
|
// "success": true,
|
|
2971
|
-
// "data":
|
|
3140
|
+
// "data":
|
|
3141
|
+
// {
|
|
2972
3142
|
// "positions": [
|
|
2973
3143
|
// {
|
|
2974
|
-
// "symbol": "
|
|
2975
|
-
// "holding": 1,
|
|
2976
|
-
// "pendingLongQty": 0,
|
|
2977
|
-
// "pendingShortQty":
|
|
2978
|
-
// "settlePrice":
|
|
2979
|
-
// "averageOpenPrice":
|
|
2980
|
-
// "pnl24H":
|
|
2981
|
-
// "fee24H": 1,
|
|
2982
|
-
// "markPrice":
|
|
2983
|
-
// "estLiqPrice":
|
|
2984
|
-
// "timestamp":
|
|
3144
|
+
// "symbol": "PERP_ETH_USDT",
|
|
3145
|
+
// "holding": -1.0,
|
|
3146
|
+
// "pendingLongQty": 0.0,
|
|
3147
|
+
// "pendingShortQty": 0.0,
|
|
3148
|
+
// "settlePrice": 3143.2,
|
|
3149
|
+
// "averageOpenPrice": 3143.2,
|
|
3150
|
+
// "pnl24H": 0.0,
|
|
3151
|
+
// "fee24H": 1.5716,
|
|
3152
|
+
// "markPrice": 3134.97984158,
|
|
3153
|
+
// "estLiqPrice": 3436.176349,
|
|
3154
|
+
// "timestamp": 1720628031.463,
|
|
3155
|
+
// "adlQuantile": 5,
|
|
3156
|
+
// "positionSide": "BOTH",
|
|
3157
|
+
// "marginMode": "ISOLATED",
|
|
3158
|
+
// "isolatedMarginToken": "USDT",
|
|
3159
|
+
// "isolatedMarginAmount": 314.62426,
|
|
3160
|
+
// "isolatedFrozenLong": 0.0,
|
|
3161
|
+
// "isolatedFrozenShort": 0.0,
|
|
3162
|
+
// "leverage": 10
|
|
3163
|
+
// },
|
|
3164
|
+
// {
|
|
3165
|
+
// "symbol": "PERP_SOL_USDT",
|
|
3166
|
+
// "holding": -1.0,
|
|
3167
|
+
// "pendingLongQty": 0.0,
|
|
3168
|
+
// "pendingShortQty": 0.0,
|
|
3169
|
+
// "settlePrice": 141.89933923,
|
|
3170
|
+
// "averageOpenPrice": 171.38,
|
|
3171
|
+
// "pnl24H": 0.0,
|
|
3172
|
+
// "fee24H": 0.0,
|
|
3173
|
+
// "markPrice": 141.65155427,
|
|
3174
|
+
// "estLiqPrice": 4242.73548551,
|
|
3175
|
+
// "timestamp": 1720616702.68,
|
|
3176
|
+
// "adlQuantile": 5,
|
|
3177
|
+
// "positionSide": "BOTH",
|
|
3178
|
+
// "marginMode": "CROSS",
|
|
3179
|
+
// "isolatedMarginToken": "",
|
|
3180
|
+
// "isolatedMarginAmount": 0.0,
|
|
3181
|
+
// "isolatedFrozenLong": 0.0,
|
|
3182
|
+
// "isolatedFrozenShort": 0.0,
|
|
3183
|
+
// "leverage": 10
|
|
2985
3184
|
// }
|
|
2986
3185
|
// ]
|
|
2987
3186
|
// },
|
|
2988
|
-
// "timestamp":
|
|
3187
|
+
// "timestamp": 1720628675078
|
|
2989
3188
|
// }
|
|
2990
3189
|
//
|
|
2991
3190
|
const result = this.safeDict(response, 'data', {});
|
|
@@ -2994,18 +3193,51 @@ export default class woo extends Exchange {
|
|
|
2994
3193
|
}
|
|
2995
3194
|
parsePosition(position, market = undefined) {
|
|
2996
3195
|
//
|
|
3196
|
+
// v1PrivateGetPositionSymbol
|
|
3197
|
+
// {
|
|
3198
|
+
// "symbol": "PERP_ETH_USDT",
|
|
3199
|
+
// "position_side": "BOTH",
|
|
3200
|
+
// "leverage": 10,
|
|
3201
|
+
// "margin_mode": "CROSS",
|
|
3202
|
+
// "average_open_price": 3139.9,
|
|
3203
|
+
// "isolated_margin_amount": 0.0,
|
|
3204
|
+
// "isolated_margin_token": "",
|
|
3205
|
+
// "opening_time": "1720627963.094",
|
|
3206
|
+
// "mark_price": 3155.19169891,
|
|
3207
|
+
// "pending_short_qty": 0.0,
|
|
3208
|
+
// "pending_long_qty": 0.0,
|
|
3209
|
+
// "holding": -0.7,
|
|
3210
|
+
// "pnl_24_h": 0.0,
|
|
3211
|
+
// "est_liq_price": 9107.40055552,
|
|
3212
|
+
// "settle_price": 3151.0319904,
|
|
3213
|
+
// "success": true,
|
|
3214
|
+
// "fee_24_h": 0.0,
|
|
3215
|
+
// "isolated_frozen_long": 0.0,
|
|
3216
|
+
// "isolated_frozen_short": 0.0,
|
|
3217
|
+
// "timestamp": "1720867502.544"
|
|
3218
|
+
// }
|
|
3219
|
+
//
|
|
3220
|
+
// v3PrivateGetPositions
|
|
2997
3221
|
// {
|
|
2998
|
-
// "symbol": "
|
|
2999
|
-
// "holding": 1,
|
|
3000
|
-
// "pendingLongQty": 0,
|
|
3001
|
-
// "pendingShortQty":
|
|
3002
|
-
// "settlePrice":
|
|
3003
|
-
// "averageOpenPrice":
|
|
3004
|
-
// "pnl24H":
|
|
3005
|
-
// "fee24H": 1,
|
|
3006
|
-
// "markPrice":
|
|
3007
|
-
// "estLiqPrice":
|
|
3008
|
-
// "timestamp":
|
|
3222
|
+
// "symbol": "PERP_ETH_USDT",
|
|
3223
|
+
// "holding": -1.0,
|
|
3224
|
+
// "pendingLongQty": 0.0, // todo: check
|
|
3225
|
+
// "pendingShortQty": 0.0, // todo: check
|
|
3226
|
+
// "settlePrice": 3143.2,
|
|
3227
|
+
// "averageOpenPrice": 3143.2,
|
|
3228
|
+
// "pnl24H": 0.0, // todo: check
|
|
3229
|
+
// "fee24H": 1.5716, // todo: check
|
|
3230
|
+
// "markPrice": 3134.97984158,
|
|
3231
|
+
// "estLiqPrice": 3436.176349,
|
|
3232
|
+
// "timestamp": 1720628031.463,
|
|
3233
|
+
// "adlQuantile": 5,
|
|
3234
|
+
// "positionSide": "BOTH",
|
|
3235
|
+
// "marginMode": "ISOLATED",
|
|
3236
|
+
// "isolatedMarginToken": "USDT", // todo: check
|
|
3237
|
+
// "isolatedMarginAmount": 314.62426, // todo: check
|
|
3238
|
+
// "isolatedFrozenLong": 0.0, // todo: check
|
|
3239
|
+
// "isolatedFrozenShort": 0.0, // todo: check
|
|
3240
|
+
// "leverage": 10
|
|
3009
3241
|
// }
|
|
3010
3242
|
//
|
|
3011
3243
|
const contract = this.safeString(position, 'symbol');
|
|
@@ -3019,13 +3251,14 @@ export default class woo extends Exchange {
|
|
|
3019
3251
|
side = 'short';
|
|
3020
3252
|
}
|
|
3021
3253
|
const contractSize = this.safeString(market, 'contractSize');
|
|
3022
|
-
const markPrice = this.
|
|
3254
|
+
const markPrice = this.safeString2(position, 'markPrice', 'mark_price');
|
|
3023
3255
|
const timestamp = this.safeTimestamp(position, 'timestamp');
|
|
3024
|
-
const entryPrice = this.
|
|
3256
|
+
const entryPrice = this.safeString2(position, 'averageOpenPrice', 'average_open_price');
|
|
3025
3257
|
const priceDifference = Precise.stringSub(markPrice, entryPrice);
|
|
3026
3258
|
const unrealisedPnl = Precise.stringMul(priceDifference, size);
|
|
3027
3259
|
size = Precise.stringAbs(size);
|
|
3028
3260
|
const notional = Precise.stringMul(size, markPrice);
|
|
3261
|
+
const positionSide = this.safeString(position, 'positionSide'); // 'SHORT' or 'LONG' for hedged, 'BOTH' for non-hedged
|
|
3029
3262
|
return this.safePosition({
|
|
3030
3263
|
'info': position,
|
|
3031
3264
|
'id': undefined,
|
|
@@ -3039,20 +3272,19 @@ export default class woo extends Exchange {
|
|
|
3039
3272
|
'maintenanceMarginPercentage': undefined,
|
|
3040
3273
|
'entryPrice': this.parseNumber(entryPrice),
|
|
3041
3274
|
'notional': this.parseNumber(notional),
|
|
3042
|
-
'leverage':
|
|
3275
|
+
'leverage': this.safeNumber(position, 'leverage'),
|
|
3043
3276
|
'unrealizedPnl': this.parseNumber(unrealisedPnl),
|
|
3044
3277
|
'contracts': this.parseNumber(size),
|
|
3045
3278
|
'contractSize': this.parseNumber(contractSize),
|
|
3046
3279
|
'marginRatio': undefined,
|
|
3047
|
-
'liquidationPrice': this.
|
|
3280
|
+
'liquidationPrice': this.safeNumber2(position, 'estLiqPrice', 'est_liq_price'),
|
|
3048
3281
|
'markPrice': this.parseNumber(markPrice),
|
|
3049
3282
|
'lastPrice': undefined,
|
|
3050
3283
|
'collateral': undefined,
|
|
3051
|
-
'marginMode': '
|
|
3052
|
-
'marginType': undefined,
|
|
3284
|
+
'marginMode': this.safeStringLower2(position, 'marginMode', 'margin_mode'),
|
|
3053
3285
|
'side': side,
|
|
3054
3286
|
'percentage': undefined,
|
|
3055
|
-
'hedged':
|
|
3287
|
+
'hedged': positionSide !== 'BOTH',
|
|
3056
3288
|
'stopLossPrice': undefined,
|
|
3057
3289
|
'takeProfitPrice': undefined,
|
|
3058
3290
|
});
|
package/js/src/xt.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export default class xt extends Exchange {
|
|
|
37
37
|
cancelOrders(ids: string[], symbol?: string, params?: {}): Promise<Order[]>;
|
|
38
38
|
parseOrder(order: any, market?: any): Order;
|
|
39
39
|
parseOrderStatus(status: any): string;
|
|
40
|
-
fetchLedger(code?:
|
|
40
|
+
fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
41
41
|
parseLedgerEntry(item: any, currency?: any): {
|
|
42
42
|
id: string;
|
|
43
43
|
direction: string;
|
|
@@ -73,8 +73,8 @@ export default class xt extends Exchange {
|
|
|
73
73
|
network: any;
|
|
74
74
|
info: any;
|
|
75
75
|
};
|
|
76
|
-
fetchDeposits(code?:
|
|
77
|
-
fetchWithdrawals(code?:
|
|
76
|
+
fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
77
|
+
fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
78
78
|
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
79
79
|
parseTransaction(transaction: Dict, currency?: Currency): Transaction;
|
|
80
80
|
parseTransactionStatus(status: any): string;
|
package/package.json
CHANGED