ccxt 4.4.68 → 4.4.69
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 +1 -1
- package/dist/cjs/src/binance.js +19 -2
- package/dist/cjs/src/bitstamp.js +2 -3
- package/dist/cjs/src/coinbase.js +1 -5
- package/dist/cjs/src/cryptomus.js +214 -116
- package/dist/cjs/src/hyperliquid.js +1 -1
- package/dist/cjs/src/paradex.js +172 -4
- package/dist/cjs/src/phemex.js +2 -2
- package/dist/cjs/src/tradeogre.js +12 -7
- package/dist/cjs/src/whitebit.js +211 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/paradex.d.ts +23 -0
- package/js/src/abstract/tradeogre.d.ts +1 -0
- package/js/src/binance.js +19 -2
- package/js/src/bitstamp.js +2 -3
- package/js/src/coinbase.d.ts +0 -5
- package/js/src/coinbase.js +1 -5
- package/js/src/cryptomus.d.ts +127 -1
- package/js/src/cryptomus.js +214 -116
- package/js/src/hyperliquid.js +1 -1
- package/js/src/paradex.d.ts +48 -1
- package/js/src/paradex.js +172 -4
- package/js/src/phemex.d.ts +1 -1
- package/js/src/phemex.js +2 -2
- package/js/src/tradeogre.js +12 -7
- package/js/src/whitebit.d.ts +35 -1
- package/js/src/whitebit.js +211 -1
- package/package.json +1 -1
package/dist/cjs/src/paradex.js
CHANGED
|
@@ -76,10 +76,10 @@ class paradex extends paradex$1 {
|
|
|
76
76
|
'fetchIsolatedBorrowRate': false,
|
|
77
77
|
'fetchIsolatedBorrowRates': false,
|
|
78
78
|
'fetchLedger': false,
|
|
79
|
-
'fetchLeverage':
|
|
79
|
+
'fetchLeverage': true,
|
|
80
80
|
'fetchLeverageTiers': false,
|
|
81
81
|
'fetchLiquidations': true,
|
|
82
|
-
'fetchMarginMode':
|
|
82
|
+
'fetchMarginMode': true,
|
|
83
83
|
'fetchMarketLeverageTiers': false,
|
|
84
84
|
'fetchMarkets': true,
|
|
85
85
|
'fetchMarkOHLCV': false,
|
|
@@ -113,8 +113,8 @@ class paradex extends paradex$1 {
|
|
|
113
113
|
'repayCrossMargin': false,
|
|
114
114
|
'repayIsolatedMargin': false,
|
|
115
115
|
'sandbox': true,
|
|
116
|
-
'setLeverage':
|
|
117
|
-
'setMarginMode':
|
|
116
|
+
'setLeverage': true,
|
|
117
|
+
'setMarginMode': true,
|
|
118
118
|
'setPositionMode': false,
|
|
119
119
|
'transfer': false,
|
|
120
120
|
'withdraw': false,
|
|
@@ -156,12 +156,23 @@ class paradex extends paradex$1 {
|
|
|
156
156
|
'system/state': 1,
|
|
157
157
|
'system/time': 1,
|
|
158
158
|
'trades': 1,
|
|
159
|
+
'vaults': 1,
|
|
160
|
+
'vaults/balance': 1,
|
|
161
|
+
'vaults/config': 1,
|
|
162
|
+
'vaults/history': 1,
|
|
163
|
+
'vaults/positions': 1,
|
|
164
|
+
'vaults/summary': 1,
|
|
165
|
+
'vaults/transfers': 1,
|
|
159
166
|
},
|
|
160
167
|
},
|
|
161
168
|
'private': {
|
|
162
169
|
'get': {
|
|
163
170
|
'account': 1,
|
|
171
|
+
'account/info': 1,
|
|
172
|
+
'account/history': 1,
|
|
173
|
+
'account/margin': 1,
|
|
164
174
|
'account/profile': 1,
|
|
175
|
+
'account/subaccounts': 1,
|
|
165
176
|
'balance': 1,
|
|
166
177
|
'fills': 1,
|
|
167
178
|
'funding/payments': 1,
|
|
@@ -174,20 +185,34 @@ class paradex extends paradex$1 {
|
|
|
174
185
|
'orders/by_client_id/{client_id}': 1,
|
|
175
186
|
'orders/{order_id}': 1,
|
|
176
187
|
'points_data/{market}/{program}': 1,
|
|
188
|
+
'referrals/qr-code': 1,
|
|
177
189
|
'referrals/summary': 1,
|
|
178
190
|
'transfers': 1,
|
|
191
|
+
'algo/orders': 1,
|
|
192
|
+
'algo/orders-history': 1,
|
|
193
|
+
'algo/orders/{algo_id}': 1,
|
|
194
|
+
'vaults/account-summary': 1,
|
|
179
195
|
},
|
|
180
196
|
'post': {
|
|
197
|
+
'account/margin/{market}': 1,
|
|
198
|
+
'account/profile/max_slippage': 1,
|
|
181
199
|
'account/profile/referral_code': 1,
|
|
182
200
|
'account/profile/username': 1,
|
|
183
201
|
'auth': 1,
|
|
184
202
|
'onboarding': 1,
|
|
185
203
|
'orders': 1,
|
|
204
|
+
'orders/batch': 1,
|
|
205
|
+
'algo/orders': 1,
|
|
206
|
+
'vaults': 1,
|
|
207
|
+
},
|
|
208
|
+
'put': {
|
|
209
|
+
'orders/{order_id}': 1,
|
|
186
210
|
},
|
|
187
211
|
'delete': {
|
|
188
212
|
'orders': 1,
|
|
189
213
|
'orders/by_client_id/{client_id}': 1,
|
|
190
214
|
'orders/{order_id}': 1,
|
|
215
|
+
'algo/orders/{algo_id}': 1,
|
|
191
216
|
},
|
|
192
217
|
},
|
|
193
218
|
},
|
|
@@ -2126,6 +2151,149 @@ class paradex extends paradex$1 {
|
|
|
2126
2151
|
};
|
|
2127
2152
|
return this.safeString(statuses, status, status);
|
|
2128
2153
|
}
|
|
2154
|
+
/**
|
|
2155
|
+
* @method
|
|
2156
|
+
* @name paradex#fetchMarginMode
|
|
2157
|
+
* @description fetches the margin mode of a specific symbol
|
|
2158
|
+
* @see https://docs.api.testnet.paradex.trade/#get-account-margin-configuration
|
|
2159
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
2160
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2161
|
+
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
2162
|
+
*/
|
|
2163
|
+
async fetchMarginMode(symbol, params = {}) {
|
|
2164
|
+
await this.authenticateRest();
|
|
2165
|
+
await this.loadMarkets();
|
|
2166
|
+
const market = this.market(symbol);
|
|
2167
|
+
const request = {
|
|
2168
|
+
'market': market['id'],
|
|
2169
|
+
};
|
|
2170
|
+
const response = await this.privateGetAccountMargin(this.extend(request, params));
|
|
2171
|
+
//
|
|
2172
|
+
// {
|
|
2173
|
+
// "account": "0x6343248026a845b39a8a73fbe9c7ef0a841db31ed5c61ec1446aa9d25e54dbc",
|
|
2174
|
+
// "configs": [
|
|
2175
|
+
// {
|
|
2176
|
+
// "market": "SOL-USD-PERP",
|
|
2177
|
+
// "leverage": 50,
|
|
2178
|
+
// "margin_type": "CROSS"
|
|
2179
|
+
// }
|
|
2180
|
+
// ]
|
|
2181
|
+
// }
|
|
2182
|
+
//
|
|
2183
|
+
const configs = this.safeList(response, 'configs');
|
|
2184
|
+
return this.parseMarginMode(this.safeDict(configs, 0), market);
|
|
2185
|
+
}
|
|
2186
|
+
parseMarginMode(rawMarginMode, market = undefined) {
|
|
2187
|
+
const marketId = this.safeString(rawMarginMode, 'market');
|
|
2188
|
+
market = this.safeMarket(marketId, market);
|
|
2189
|
+
const marginMode = this.safeStringLower(rawMarginMode, 'margin_type');
|
|
2190
|
+
return {
|
|
2191
|
+
'info': rawMarginMode,
|
|
2192
|
+
'symbol': market['symbol'],
|
|
2193
|
+
'marginMode': marginMode,
|
|
2194
|
+
};
|
|
2195
|
+
}
|
|
2196
|
+
/**
|
|
2197
|
+
* @method
|
|
2198
|
+
* @name paradex#setMarginMode
|
|
2199
|
+
* @description set margin mode to 'cross' or 'isolated'
|
|
2200
|
+
* @see https://docs.api.testnet.paradex.trade/#set-margin-configuration
|
|
2201
|
+
* @param {string} marginMode 'cross' or 'isolated'
|
|
2202
|
+
* @param {string} symbol unified market symbol
|
|
2203
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2204
|
+
* @param {float} [params.leverage] the rate of leverage
|
|
2205
|
+
* @returns {object} response from the exchange
|
|
2206
|
+
*/
|
|
2207
|
+
async setMarginMode(marginMode, symbol = undefined, params = {}) {
|
|
2208
|
+
this.checkRequiredArgument('setMarginMode', symbol, 'symbol');
|
|
2209
|
+
await this.authenticateRest();
|
|
2210
|
+
await this.loadMarkets();
|
|
2211
|
+
const market = this.market(symbol);
|
|
2212
|
+
let leverage = undefined;
|
|
2213
|
+
[leverage, params] = this.handleOptionAndParams(params, 'setMarginMode', 'leverage', 1);
|
|
2214
|
+
const request = {
|
|
2215
|
+
'market': market['id'],
|
|
2216
|
+
'leverage': leverage,
|
|
2217
|
+
'margin_type': this.encodeMarginMode(marginMode),
|
|
2218
|
+
};
|
|
2219
|
+
return await this.privatePostAccountMarginMarket(this.extend(request, params));
|
|
2220
|
+
}
|
|
2221
|
+
/**
|
|
2222
|
+
* @method
|
|
2223
|
+
* @name paradex#fetchLeverage
|
|
2224
|
+
* @description fetch the set leverage for a market
|
|
2225
|
+
* @see https://docs.api.testnet.paradex.trade/#get-account-margin-configuration
|
|
2226
|
+
* @param {string} symbol unified market symbol
|
|
2227
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2228
|
+
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
2229
|
+
*/
|
|
2230
|
+
async fetchLeverage(symbol, params = {}) {
|
|
2231
|
+
await this.authenticateRest();
|
|
2232
|
+
await this.loadMarkets();
|
|
2233
|
+
const market = this.market(symbol);
|
|
2234
|
+
const request = {
|
|
2235
|
+
'market': market['id'],
|
|
2236
|
+
};
|
|
2237
|
+
const response = await this.privateGetAccountMargin(this.extend(request, params));
|
|
2238
|
+
//
|
|
2239
|
+
// {
|
|
2240
|
+
// "account": "0x6343248026a845b39a8a73fbe9c7ef0a841db31ed5c61ec1446aa9d25e54dbc",
|
|
2241
|
+
// "configs": [
|
|
2242
|
+
// {
|
|
2243
|
+
// "market": "SOL-USD-PERP",
|
|
2244
|
+
// "leverage": 50,
|
|
2245
|
+
// "margin_type": "CROSS"
|
|
2246
|
+
// }
|
|
2247
|
+
// ]
|
|
2248
|
+
// }
|
|
2249
|
+
//
|
|
2250
|
+
const configs = this.safeList(response, 'configs');
|
|
2251
|
+
return this.parseLeverage(this.safeDict(configs, 0), market);
|
|
2252
|
+
}
|
|
2253
|
+
parseLeverage(leverage, market = undefined) {
|
|
2254
|
+
const marketId = this.safeString(leverage, 'market');
|
|
2255
|
+
market = this.safeMarket(marketId, market);
|
|
2256
|
+
const marginMode = this.safeStringLower(leverage, 'margin_type');
|
|
2257
|
+
return {
|
|
2258
|
+
'info': leverage,
|
|
2259
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
2260
|
+
'marginMode': marginMode,
|
|
2261
|
+
'longLeverage': this.safeInteger(leverage, 'leverage'),
|
|
2262
|
+
'shortLeverage': this.safeInteger(leverage, 'leverage'),
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
encodeMarginMode(mode) {
|
|
2266
|
+
const modes = {
|
|
2267
|
+
'cross': 'CROSS',
|
|
2268
|
+
'isolated': 'ISOLATED',
|
|
2269
|
+
};
|
|
2270
|
+
return this.safeString(modes, mode, mode);
|
|
2271
|
+
}
|
|
2272
|
+
/**
|
|
2273
|
+
* @method
|
|
2274
|
+
* @name paradex#setLeverage
|
|
2275
|
+
* @description set the level of leverage for a market
|
|
2276
|
+
* @see https://docs.api.testnet.paradex.trade/#set-margin-configuration
|
|
2277
|
+
* @param {float} leverage the rate of leverage
|
|
2278
|
+
* @param {string} [symbol] unified market symbol (is mandatory for swap markets)
|
|
2279
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2280
|
+
* @param {string} [params.marginMode] 'cross' or 'isolated'
|
|
2281
|
+
* @returns {object} response from the exchange
|
|
2282
|
+
*/
|
|
2283
|
+
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
2284
|
+
this.checkRequiredArgument('setLeverage', symbol, 'symbol');
|
|
2285
|
+
await this.authenticateRest();
|
|
2286
|
+
await this.loadMarkets();
|
|
2287
|
+
const market = this.market(symbol);
|
|
2288
|
+
let marginMode = undefined;
|
|
2289
|
+
[marginMode, params] = this.handleMarginModeAndParams('setLeverage', params, 'cross');
|
|
2290
|
+
const request = {
|
|
2291
|
+
'market': market['id'],
|
|
2292
|
+
'leverage': leverage,
|
|
2293
|
+
'margin_type': this.encodeMarginMode(marginMode),
|
|
2294
|
+
};
|
|
2295
|
+
return await this.privatePostAccountMarginMarket(this.extend(request, params));
|
|
2296
|
+
}
|
|
2129
2297
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
2130
2298
|
let url = this.implodeHostname(this.urls['api'][this.version]) + '/' + this.implodeParams(path, params);
|
|
2131
2299
|
const query = this.omit(params, this.extractParams(path));
|
package/dist/cjs/src/phemex.js
CHANGED
|
@@ -3801,7 +3801,7 @@ class phemex extends phemex$1 {
|
|
|
3801
3801
|
* @see https://phemex-docs.github.io/#query-account-positions-with-unrealized-pnl
|
|
3802
3802
|
* @param {string[]} [symbols] list of unified market symbols
|
|
3803
3803
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3804
|
-
* @param {string} [params.code] the currency code to fetch positions for, USD, BTC or USDT,
|
|
3804
|
+
* @param {string} [params.code] the currency code to fetch positions for, USD, BTC or USDT, USDT is the default
|
|
3805
3805
|
* @param {string} [params.method] *USDT contracts only* 'privateGetGAccountsAccountPositions' or 'privateGetAccountsPositions' default is 'privateGetGAccountsAccountPositions'
|
|
3806
3806
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
3807
3807
|
*/
|
|
@@ -3809,7 +3809,7 @@ class phemex extends phemex$1 {
|
|
|
3809
3809
|
await this.loadMarkets();
|
|
3810
3810
|
symbols = this.marketSymbols(symbols);
|
|
3811
3811
|
let subType = undefined;
|
|
3812
|
-
let code = this.safeString2(params, 'currency', 'code', '
|
|
3812
|
+
let code = this.safeString2(params, 'currency', 'code', 'USDT');
|
|
3813
3813
|
params = this.omit(params, ['currency', 'code']);
|
|
3814
3814
|
let settle = undefined;
|
|
3815
3815
|
let market = undefined;
|
|
@@ -128,6 +128,7 @@ class tradeogre extends tradeogre$1 {
|
|
|
128
128
|
'orders/{market}': 1,
|
|
129
129
|
'ticker/{market}': 1,
|
|
130
130
|
'history/{market}': 1,
|
|
131
|
+
'chart/{interval}/{market}/{timestamp}': 1,
|
|
131
132
|
'chart/{interval}/{market}': 1,
|
|
132
133
|
},
|
|
133
134
|
},
|
|
@@ -420,15 +421,15 @@ class tradeogre extends tradeogre$1 {
|
|
|
420
421
|
'ask': this.safeString(ticker, 'ask'),
|
|
421
422
|
'askVolume': undefined,
|
|
422
423
|
'vwap': undefined,
|
|
423
|
-
'open': this.safeString(ticker, '
|
|
424
|
-
'close':
|
|
424
|
+
'open': this.safeString(ticker, 'initialprice'),
|
|
425
|
+
'close': this.safeString(ticker, 'price'),
|
|
425
426
|
'last': undefined,
|
|
426
427
|
'previousClose': undefined,
|
|
427
428
|
'change': undefined,
|
|
428
429
|
'percentage': undefined,
|
|
429
430
|
'average': undefined,
|
|
430
|
-
'baseVolume':
|
|
431
|
-
'quoteVolume':
|
|
431
|
+
'baseVolume': undefined,
|
|
432
|
+
'quoteVolume': this.safeString(ticker, 'volume'),
|
|
432
433
|
'info': ticker,
|
|
433
434
|
}, market);
|
|
434
435
|
}
|
|
@@ -451,12 +452,16 @@ class tradeogre extends tradeogre$1 {
|
|
|
451
452
|
'market': market['id'],
|
|
452
453
|
'interval': this.safeString(this.timeframes, timeframe, timeframe),
|
|
453
454
|
};
|
|
455
|
+
let response = undefined;
|
|
454
456
|
const until = this.safeInteger(params, 'until');
|
|
455
457
|
if (until !== undefined) {
|
|
456
458
|
params = this.omit(params, 'until');
|
|
457
|
-
request['timestamp'] = until;
|
|
459
|
+
request['timestamp'] = this.parseToInt(until / 1000);
|
|
460
|
+
response = await this.publicGetChartIntervalMarketTimestamp(this.extend(request, params));
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
response = await this.publicGetChartIntervalMarket(this.extend(request, params));
|
|
458
464
|
}
|
|
459
|
-
const response = await this.publicGetChartIntervalMarket(this.extend(request, params));
|
|
460
465
|
//
|
|
461
466
|
// [
|
|
462
467
|
// [
|
|
@@ -485,9 +490,9 @@ class tradeogre extends tradeogre$1 {
|
|
|
485
490
|
return [
|
|
486
491
|
this.safeTimestamp(ohlcv, 0),
|
|
487
492
|
this.safeNumber(ohlcv, 1),
|
|
493
|
+
this.safeNumber(ohlcv, 2),
|
|
488
494
|
this.safeNumber(ohlcv, 3),
|
|
489
495
|
this.safeNumber(ohlcv, 4),
|
|
490
|
-
this.safeNumber(ohlcv, 2),
|
|
491
496
|
this.safeNumber(ohlcv, 5),
|
|
492
497
|
];
|
|
493
498
|
}
|
package/dist/cjs/src/whitebit.js
CHANGED
|
@@ -25,7 +25,7 @@ class whitebit extends whitebit$1 {
|
|
|
25
25
|
'CORS': undefined,
|
|
26
26
|
'spot': true,
|
|
27
27
|
'margin': true,
|
|
28
|
-
'swap':
|
|
28
|
+
'swap': true,
|
|
29
29
|
'future': false,
|
|
30
30
|
'option': false,
|
|
31
31
|
'cancelAllOrders': true,
|
|
@@ -75,7 +75,10 @@ class whitebit extends whitebit$1 {
|
|
|
75
75
|
'fetchOpenOrders': true,
|
|
76
76
|
'fetchOrderBook': true,
|
|
77
77
|
'fetchOrderTrades': true,
|
|
78
|
+
'fetchPosition': true,
|
|
79
|
+
'fetchPositionHistory': true,
|
|
78
80
|
'fetchPositionMode': false,
|
|
81
|
+
'fetchPositions': true,
|
|
79
82
|
'fetchPremiumIndexOHLCV': false,
|
|
80
83
|
'fetchStatus': true,
|
|
81
84
|
'fetchTicker': true,
|
|
@@ -2961,6 +2964,213 @@ class whitebit extends whitebit$1 {
|
|
|
2961
2964
|
'fee': undefined,
|
|
2962
2965
|
};
|
|
2963
2966
|
}
|
|
2967
|
+
/**
|
|
2968
|
+
* @method
|
|
2969
|
+
* @name whitebit#fetchPositionHistory
|
|
2970
|
+
* @description fetches historical positions
|
|
2971
|
+
* @see https://docs.whitebit.com/private/http-trade-v4/#positions-history
|
|
2972
|
+
* @param {string} symbol unified contract symbol
|
|
2973
|
+
* @param {int} [since] the earliest time in ms to fetch positions for
|
|
2974
|
+
* @param {int} [limit] the maximum amount of records to fetch
|
|
2975
|
+
* @param {object} [params] extra parameters specific to the exchange api endpoint
|
|
2976
|
+
* @param {int} [params.positionId] the id of the requested position
|
|
2977
|
+
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
2978
|
+
*/
|
|
2979
|
+
async fetchPositionHistory(symbol, since = undefined, limit = undefined, params = {}) {
|
|
2980
|
+
await this.loadMarkets();
|
|
2981
|
+
const market = this.market(symbol);
|
|
2982
|
+
let request = {
|
|
2983
|
+
'market': market['id'],
|
|
2984
|
+
};
|
|
2985
|
+
if (since !== undefined) {
|
|
2986
|
+
request['startDate'] = since;
|
|
2987
|
+
}
|
|
2988
|
+
if (limit !== undefined) {
|
|
2989
|
+
request['limit'] = since;
|
|
2990
|
+
}
|
|
2991
|
+
[request, params] = this.handleUntilOption('endDate', request, params);
|
|
2992
|
+
const response = await this.v4PrivatePostCollateralAccountPositionsHistory(this.extend(request, params));
|
|
2993
|
+
//
|
|
2994
|
+
// [
|
|
2995
|
+
// {
|
|
2996
|
+
// "positionId": 479975679,
|
|
2997
|
+
// "market": "BTC_PERP",
|
|
2998
|
+
// "openDate": 1741941025.309887,
|
|
2999
|
+
// "modifyDate": 1741941025.309887,
|
|
3000
|
+
// "amount": "0.001",
|
|
3001
|
+
// "basePrice": "82498.7",
|
|
3002
|
+
// "realizedFunding": "0",
|
|
3003
|
+
// "liquidationPrice": "0",
|
|
3004
|
+
// "liquidationState": null,
|
|
3005
|
+
// "orderDetail": {
|
|
3006
|
+
// "id": 1224727949521,
|
|
3007
|
+
// "tradeAmount": "0.001",
|
|
3008
|
+
// "price": "82498.7",
|
|
3009
|
+
// "tradeFee": "0.028874545",
|
|
3010
|
+
// "fundingFee": "0",
|
|
3011
|
+
// "realizedPnl": "-0.028874545"
|
|
3012
|
+
// }
|
|
3013
|
+
// }
|
|
3014
|
+
// ]
|
|
3015
|
+
//
|
|
3016
|
+
const positions = this.parsePositions(response);
|
|
3017
|
+
return this.filterBySymbolSinceLimit(positions, symbol, since, limit);
|
|
3018
|
+
}
|
|
3019
|
+
/**
|
|
3020
|
+
* @method
|
|
3021
|
+
* @name whitebit#fetchPositions
|
|
3022
|
+
* @description fetch all open positions
|
|
3023
|
+
* @see https://docs.whitebit.com/private/http-trade-v4/#open-positions
|
|
3024
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
3025
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3026
|
+
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
3027
|
+
*/
|
|
3028
|
+
async fetchPositions(symbols = undefined, params = {}) {
|
|
3029
|
+
await this.loadMarkets();
|
|
3030
|
+
symbols = this.marketSymbols(symbols);
|
|
3031
|
+
const response = await this.v4PrivatePostCollateralAccountPositionsOpen(params);
|
|
3032
|
+
//
|
|
3033
|
+
// [
|
|
3034
|
+
// {
|
|
3035
|
+
// "positionId": 479975679,
|
|
3036
|
+
// "market": "BTC_PERP",
|
|
3037
|
+
// "openDate": 1741941025.3098869,
|
|
3038
|
+
// "modifyDate": 1741941025.3098869,
|
|
3039
|
+
// "amount": "0.001",
|
|
3040
|
+
// "basePrice": "82498.7",
|
|
3041
|
+
// "liquidationPrice": "70177.2",
|
|
3042
|
+
// "pnl": "0",
|
|
3043
|
+
// "pnlPercent": "0.00",
|
|
3044
|
+
// "margin": "4.2",
|
|
3045
|
+
// "freeMargin": "9.9",
|
|
3046
|
+
// "funding": "0",
|
|
3047
|
+
// "unrealizedFunding": "0",
|
|
3048
|
+
// "liquidationState": null,
|
|
3049
|
+
// "tpsl": null
|
|
3050
|
+
// }
|
|
3051
|
+
// ]
|
|
3052
|
+
//
|
|
3053
|
+
return this.parsePositions(response, symbols);
|
|
3054
|
+
}
|
|
3055
|
+
/**
|
|
3056
|
+
* @method
|
|
3057
|
+
* @name whitebit#fetchPosition
|
|
3058
|
+
* @description fetch data on a single open contract trade position
|
|
3059
|
+
* @see https://docs.whitebit.com/private/http-trade-v4/#open-positions
|
|
3060
|
+
* @param {string} symbol unified market symbol of the market the position is held in
|
|
3061
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3062
|
+
* @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
3063
|
+
*/
|
|
3064
|
+
async fetchPosition(symbol, params = {}) {
|
|
3065
|
+
await this.loadMarkets();
|
|
3066
|
+
const market = this.market(symbol);
|
|
3067
|
+
const request = {
|
|
3068
|
+
'symbol': market['id'],
|
|
3069
|
+
};
|
|
3070
|
+
const response = await this.v4PrivatePostCollateralAccountPositionsOpen(this.extend(request, params));
|
|
3071
|
+
//
|
|
3072
|
+
// [
|
|
3073
|
+
// {
|
|
3074
|
+
// "positionId": 479975679,
|
|
3075
|
+
// "market": "BTC_PERP",
|
|
3076
|
+
// "openDate": 1741941025.3098869,
|
|
3077
|
+
// "modifyDate": 1741941025.3098869,
|
|
3078
|
+
// "amount": "0.001",
|
|
3079
|
+
// "basePrice": "82498.7",
|
|
3080
|
+
// "liquidationPrice": "70177.2",
|
|
3081
|
+
// "pnl": "0",
|
|
3082
|
+
// "pnlPercent": "0.00",
|
|
3083
|
+
// "margin": "4.2",
|
|
3084
|
+
// "freeMargin": "9.9",
|
|
3085
|
+
// "funding": "0",
|
|
3086
|
+
// "unrealizedFunding": "0",
|
|
3087
|
+
// "liquidationState": null,
|
|
3088
|
+
// "tpsl": null
|
|
3089
|
+
// }
|
|
3090
|
+
// ]
|
|
3091
|
+
//
|
|
3092
|
+
const data = this.safeDict(response, 0, {});
|
|
3093
|
+
return this.parsePosition(data, market);
|
|
3094
|
+
}
|
|
3095
|
+
parsePosition(position, market = undefined) {
|
|
3096
|
+
//
|
|
3097
|
+
// fetchPosition, fetchPositions
|
|
3098
|
+
//
|
|
3099
|
+
// {
|
|
3100
|
+
// "positionId": 479975679,
|
|
3101
|
+
// "market": "BTC_PERP",
|
|
3102
|
+
// "openDate": 1741941025.3098869,
|
|
3103
|
+
// "modifyDate": 1741941025.3098869,
|
|
3104
|
+
// "amount": "0.001",
|
|
3105
|
+
// "basePrice": "82498.7",
|
|
3106
|
+
// "liquidationPrice": "70177.2",
|
|
3107
|
+
// "pnl": "0",
|
|
3108
|
+
// "pnlPercent": "0.00",
|
|
3109
|
+
// "margin": "4.2",
|
|
3110
|
+
// "freeMargin": "9.9",
|
|
3111
|
+
// "funding": "0",
|
|
3112
|
+
// "unrealizedFunding": "0",
|
|
3113
|
+
// "liquidationState": null,
|
|
3114
|
+
// "tpsl": null
|
|
3115
|
+
// }
|
|
3116
|
+
//
|
|
3117
|
+
// fetchPositionHistory
|
|
3118
|
+
//
|
|
3119
|
+
// {
|
|
3120
|
+
// "positionId": 479975679,
|
|
3121
|
+
// "market": "BTC_PERP",
|
|
3122
|
+
// "openDate": 1741941025.309887,
|
|
3123
|
+
// "modifyDate": 1741941025.309887,
|
|
3124
|
+
// "amount": "0.001",
|
|
3125
|
+
// "basePrice": "82498.7",
|
|
3126
|
+
// "realizedFunding": "0",
|
|
3127
|
+
// "liquidationPrice": "0",
|
|
3128
|
+
// "liquidationState": null,
|
|
3129
|
+
// "orderDetail": {
|
|
3130
|
+
// "id": 1224727949521,
|
|
3131
|
+
// "tradeAmount": "0.001",
|
|
3132
|
+
// "price": "82498.7",
|
|
3133
|
+
// "tradeFee": "0.028874545",
|
|
3134
|
+
// "fundingFee": "0",
|
|
3135
|
+
// "realizedPnl": "-0.028874545"
|
|
3136
|
+
// }
|
|
3137
|
+
// }
|
|
3138
|
+
//
|
|
3139
|
+
const marketId = this.safeString(position, 'market');
|
|
3140
|
+
const timestamp = this.safeTimestamp(position, 'openDate');
|
|
3141
|
+
const tpsl = this.safeDict(position, 'tpsl', {});
|
|
3142
|
+
const orderDetail = this.safeDict(position, 'orderDetail', {});
|
|
3143
|
+
return this.safePosition({
|
|
3144
|
+
'info': position,
|
|
3145
|
+
'id': this.safeString(position, 'positionId'),
|
|
3146
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
3147
|
+
'notional': undefined,
|
|
3148
|
+
'marginMode': undefined,
|
|
3149
|
+
'liquidationPrice': this.safeNumber(position, 'liquidationPrice'),
|
|
3150
|
+
'entryPrice': this.safeNumber(position, 'basePrice'),
|
|
3151
|
+
'unrealizedPnl': this.safeNumber(position, 'pnl'),
|
|
3152
|
+
'realizedPnl': this.safeNumber(orderDetail, 'realizedPnl'),
|
|
3153
|
+
'percentage': this.safeNumber(position, 'pnlPercent'),
|
|
3154
|
+
'contracts': undefined,
|
|
3155
|
+
'contractSize': undefined,
|
|
3156
|
+
'markPrice': undefined,
|
|
3157
|
+
'lastPrice': undefined,
|
|
3158
|
+
'side': undefined,
|
|
3159
|
+
'hedged': undefined,
|
|
3160
|
+
'timestamp': timestamp,
|
|
3161
|
+
'datetime': this.iso8601(timestamp),
|
|
3162
|
+
'lastUpdateTimestamp': this.safeTimestamp(position, 'modifyDate'),
|
|
3163
|
+
'maintenanceMargin': undefined,
|
|
3164
|
+
'maintenanceMarginPercentage': undefined,
|
|
3165
|
+
'collateral': this.safeNumber(position, 'margin'),
|
|
3166
|
+
'initialMargin': undefined,
|
|
3167
|
+
'initialMarginPercentage': undefined,
|
|
3168
|
+
'leverage': undefined,
|
|
3169
|
+
'marginRatio': undefined,
|
|
3170
|
+
'stopLossPrice': this.safeNumber(tpsl, 'stopLoss'),
|
|
3171
|
+
'takeProfitPrice': this.safeNumber(tpsl, 'takeProfit'),
|
|
3172
|
+
});
|
|
3173
|
+
}
|
|
2964
3174
|
isFiat(currency) {
|
|
2965
3175
|
const fiatCurrencies = this.safeValue(this.options, 'fiatCurrencies', []);
|
|
2966
3176
|
return this.inArray(currency, fiatCurrencies);
|
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 { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, LongShortRatio, OrderBooks, OpenInterests } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.4.
|
|
7
|
+
declare const version = "4.4.68";
|
|
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
|
@@ -32,7 +32,7 @@ import * as errors from './src/base/errors.js';
|
|
|
32
32
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
|
|
33
33
|
//-----------------------------------------------------------------------------
|
|
34
34
|
// this is updated by vss.js when building
|
|
35
|
-
const version = '4.4.
|
|
35
|
+
const version = '4.4.69';
|
|
36
36
|
Exchange.ccxtVersion = version;
|
|
37
37
|
//-----------------------------------------------------------------------------
|
|
38
38
|
import ace from './src/ace.js';
|
|
@@ -13,8 +13,19 @@ interface Exchange {
|
|
|
13
13
|
publicGetSystemState(params?: {}): Promise<implicitReturnType>;
|
|
14
14
|
publicGetSystemTime(params?: {}): Promise<implicitReturnType>;
|
|
15
15
|
publicGetTrades(params?: {}): Promise<implicitReturnType>;
|
|
16
|
+
publicGetVaults(params?: {}): Promise<implicitReturnType>;
|
|
17
|
+
publicGetVaultsBalance(params?: {}): Promise<implicitReturnType>;
|
|
18
|
+
publicGetVaultsConfig(params?: {}): Promise<implicitReturnType>;
|
|
19
|
+
publicGetVaultsHistory(params?: {}): Promise<implicitReturnType>;
|
|
20
|
+
publicGetVaultsPositions(params?: {}): Promise<implicitReturnType>;
|
|
21
|
+
publicGetVaultsSummary(params?: {}): Promise<implicitReturnType>;
|
|
22
|
+
publicGetVaultsTransfers(params?: {}): Promise<implicitReturnType>;
|
|
16
23
|
privateGetAccount(params?: {}): Promise<implicitReturnType>;
|
|
24
|
+
privateGetAccountInfo(params?: {}): Promise<implicitReturnType>;
|
|
25
|
+
privateGetAccountHistory(params?: {}): Promise<implicitReturnType>;
|
|
26
|
+
privateGetAccountMargin(params?: {}): Promise<implicitReturnType>;
|
|
17
27
|
privateGetAccountProfile(params?: {}): Promise<implicitReturnType>;
|
|
28
|
+
privateGetAccountSubaccounts(params?: {}): Promise<implicitReturnType>;
|
|
18
29
|
privateGetBalance(params?: {}): Promise<implicitReturnType>;
|
|
19
30
|
privateGetFills(params?: {}): Promise<implicitReturnType>;
|
|
20
31
|
privateGetFundingPayments(params?: {}): Promise<implicitReturnType>;
|
|
@@ -27,16 +38,28 @@ interface Exchange {
|
|
|
27
38
|
privateGetOrdersByClientIdClientId(params?: {}): Promise<implicitReturnType>;
|
|
28
39
|
privateGetOrdersOrderId(params?: {}): Promise<implicitReturnType>;
|
|
29
40
|
privateGetPointsDataMarketProgram(params?: {}): Promise<implicitReturnType>;
|
|
41
|
+
privateGetReferralsQrCode(params?: {}): Promise<implicitReturnType>;
|
|
30
42
|
privateGetReferralsSummary(params?: {}): Promise<implicitReturnType>;
|
|
31
43
|
privateGetTransfers(params?: {}): Promise<implicitReturnType>;
|
|
44
|
+
privateGetAlgoOrders(params?: {}): Promise<implicitReturnType>;
|
|
45
|
+
privateGetAlgoOrdersHistory(params?: {}): Promise<implicitReturnType>;
|
|
46
|
+
privateGetAlgoOrdersAlgoId(params?: {}): Promise<implicitReturnType>;
|
|
47
|
+
privateGetVaultsAccountSummary(params?: {}): Promise<implicitReturnType>;
|
|
48
|
+
privatePostAccountMarginMarket(params?: {}): Promise<implicitReturnType>;
|
|
49
|
+
privatePostAccountProfileMaxSlippage(params?: {}): Promise<implicitReturnType>;
|
|
32
50
|
privatePostAccountProfileReferralCode(params?: {}): Promise<implicitReturnType>;
|
|
33
51
|
privatePostAccountProfileUsername(params?: {}): Promise<implicitReturnType>;
|
|
34
52
|
privatePostAuth(params?: {}): Promise<implicitReturnType>;
|
|
35
53
|
privatePostOnboarding(params?: {}): Promise<implicitReturnType>;
|
|
36
54
|
privatePostOrders(params?: {}): Promise<implicitReturnType>;
|
|
55
|
+
privatePostOrdersBatch(params?: {}): Promise<implicitReturnType>;
|
|
56
|
+
privatePostAlgoOrders(params?: {}): Promise<implicitReturnType>;
|
|
57
|
+
privatePostVaults(params?: {}): Promise<implicitReturnType>;
|
|
58
|
+
privatePutOrdersOrderId(params?: {}): Promise<implicitReturnType>;
|
|
37
59
|
privateDeleteOrders(params?: {}): Promise<implicitReturnType>;
|
|
38
60
|
privateDeleteOrdersByClientIdClientId(params?: {}): Promise<implicitReturnType>;
|
|
39
61
|
privateDeleteOrdersOrderId(params?: {}): Promise<implicitReturnType>;
|
|
62
|
+
privateDeleteAlgoOrdersAlgoId(params?: {}): Promise<implicitReturnType>;
|
|
40
63
|
}
|
|
41
64
|
declare abstract class Exchange extends _Exchange {
|
|
42
65
|
}
|
|
@@ -5,6 +5,7 @@ interface Exchange {
|
|
|
5
5
|
publicGetOrdersMarket(params?: {}): Promise<implicitReturnType>;
|
|
6
6
|
publicGetTickerMarket(params?: {}): Promise<implicitReturnType>;
|
|
7
7
|
publicGetHistoryMarket(params?: {}): Promise<implicitReturnType>;
|
|
8
|
+
publicGetChartIntervalMarketTimestamp(params?: {}): Promise<implicitReturnType>;
|
|
8
9
|
publicGetChartIntervalMarket(params?: {}): Promise<implicitReturnType>;
|
|
9
10
|
privateGetAccountBalance(params?: {}): Promise<implicitReturnType>;
|
|
10
11
|
privateGetAccountBalances(params?: {}): Promise<implicitReturnType>;
|
package/js/src/binance.js
CHANGED
|
@@ -12113,8 +12113,25 @@ export default class binance extends Exchange {
|
|
|
12113
12113
|
let query = undefined;
|
|
12114
12114
|
// handle batchOrders
|
|
12115
12115
|
if ((path === 'batchOrders') && ((method === 'POST') || (method === 'PUT'))) {
|
|
12116
|
-
const batchOrders = this.
|
|
12117
|
-
|
|
12116
|
+
const batchOrders = this.safeList(params, 'batchOrders');
|
|
12117
|
+
let checkedBatchOrders = batchOrders;
|
|
12118
|
+
if (method === 'POST' && api === 'fapiPrivate') {
|
|
12119
|
+
// check broker id if batchOrders are called with fapiPrivatePostBatchOrders
|
|
12120
|
+
checkedBatchOrders = [];
|
|
12121
|
+
for (let i = 0; i < batchOrders.length; i++) {
|
|
12122
|
+
const batchOrder = batchOrders[i];
|
|
12123
|
+
let newClientOrderId = this.safeString(batchOrder, 'newClientOrderId');
|
|
12124
|
+
if (newClientOrderId === undefined) {
|
|
12125
|
+
const defaultId = 'x-xcKtGhcu'; // batchOrders can not be spot or margin
|
|
12126
|
+
const broker = this.safeDict(this.options, 'broker', {});
|
|
12127
|
+
const brokerId = this.safeString(broker, 'future', defaultId);
|
|
12128
|
+
newClientOrderId = brokerId + this.uuid22();
|
|
12129
|
+
batchOrder['newClientOrderId'] = newClientOrderId;
|
|
12130
|
+
}
|
|
12131
|
+
checkedBatchOrders.push(batchOrder);
|
|
12132
|
+
}
|
|
12133
|
+
}
|
|
12134
|
+
const queryBatch = (this.json(checkedBatchOrders));
|
|
12118
12135
|
params['batchOrders'] = queryBatch;
|
|
12119
12136
|
}
|
|
12120
12137
|
const defaultRecvWindow = this.safeInteger(this.options, 'recvWindow');
|