ccxt 4.1.25 → 4.1.26

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/dist/cjs/ccxt.js CHANGED
@@ -180,7 +180,7 @@ var woo$1 = require('./src/pro/woo.js');
180
180
 
181
181
  //-----------------------------------------------------------------------------
182
182
  // this is updated by vss.js when building
183
- const version = '4.1.25';
183
+ const version = '4.1.26';
184
184
  Exchange["default"].ccxtVersion = version;
185
185
  const exchanges = {
186
186
  'ace': ace,
@@ -40,7 +40,7 @@ class bitget extends bitget$1 {
40
40
  'editOrder': true,
41
41
  'fetchAccounts': false,
42
42
  'fetchBalance': true,
43
- 'fetchBorrowRate': false,
43
+ 'fetchBorrowRate': true,
44
44
  'fetchBorrowRateHistories': false,
45
45
  'fetchBorrowRateHistory': false,
46
46
  'fetchBorrowRates': false,
@@ -6179,6 +6179,201 @@ class bitget extends bitget$1 {
6179
6179
  'datetime': this.iso8601(timestamp),
6180
6180
  };
6181
6181
  }
6182
+ async fetchBorrowRate(code, params = {}) {
6183
+ /**
6184
+ * @method
6185
+ * @name bitget#fetchBorrowRate
6186
+ * @description fetch the rate of interest to borrow a currency for margin trading
6187
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-margin-interest-rate-and-max-borrowable-amount
6188
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-margin-interest-rate-and-borrowable
6189
+ * @param {string} code unified currency code
6190
+ * @param {object} [params] extra parameters specific to the bitget api endpoint
6191
+ * @param {string} [params.symbol] required for isolated margin
6192
+ * @returns {object} a [borrow rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure}
6193
+ */
6194
+ await this.loadMarkets();
6195
+ const currency = this.currency(code);
6196
+ let market = undefined;
6197
+ const symbol = this.safeString(params, 'symbol');
6198
+ params = this.omit(params, 'symbol');
6199
+ if (symbol !== undefined) {
6200
+ market = this.market(symbol);
6201
+ }
6202
+ const request = {};
6203
+ let response = undefined;
6204
+ let marginMode = undefined;
6205
+ [marginMode, params] = this.handleMarginModeAndParams('fetchBorrowRate', params, 'cross');
6206
+ if ((symbol !== undefined) || (marginMode === 'isolated')) {
6207
+ this.checkRequiredSymbol('fetchBorrowRate', symbol);
6208
+ request['symbol'] = market['info']['symbolName'];
6209
+ response = await this.publicMarginGetIsolatedPublicInterestRateAndLimit(this.extend(request, params));
6210
+ }
6211
+ else if (marginMode === 'cross') {
6212
+ request['coin'] = currency['code'];
6213
+ response = await this.publicMarginGetCrossPublicInterestRateAndLimit(this.extend(request, params));
6214
+ }
6215
+ //
6216
+ // isolated
6217
+ //
6218
+ // {
6219
+ // "code": "00000",
6220
+ // "msg": "success",
6221
+ // "requestTime": 1698208075332,
6222
+ // "data": [
6223
+ // {
6224
+ // "symbol": "BTCUSDT",
6225
+ // "leverage": "10",
6226
+ // "baseCoin": "BTC",
6227
+ // "baseTransferInAble": true,
6228
+ // "baseBorrowAble": true,
6229
+ // "baseDailyInterestRate": "0.00007",
6230
+ // "baseYearlyInterestRate": "0.02555",
6231
+ // "baseMaxBorrowableAmount": "35",
6232
+ // "baseVips": [
6233
+ // {
6234
+ // "level": "0",
6235
+ // "dailyInterestRate": "0.00007",
6236
+ // "yearlyInterestRate": "0.02555",
6237
+ // "discountRate": "1"
6238
+ // },
6239
+ // ],
6240
+ // "quoteCoin": "USDT",
6241
+ // "quoteTransferInAble": true,
6242
+ // "quoteBorrowAble": true,
6243
+ // "quoteDailyInterestRate": "0.00012627",
6244
+ // "quoteYearlyInterestRate": "0.04608855",
6245
+ // "quoteMaxBorrowableAmount": "300000",
6246
+ // "quoteVips": [
6247
+ // {
6248
+ // "level": "0",
6249
+ // "dailyInterestRate": "0.000126279",
6250
+ // "yearlyInterestRate": "0.046091835",
6251
+ // "discountRate": "1"
6252
+ // },
6253
+ // ]
6254
+ // }
6255
+ // ]
6256
+ // }
6257
+ //
6258
+ // cross
6259
+ //
6260
+ // {
6261
+ // "code": "00000",
6262
+ // "msg": "success",
6263
+ // "requestTime": 1698208150986,
6264
+ // "data": [
6265
+ // {
6266
+ // "coin": "BTC",
6267
+ // "leverage": "3",
6268
+ // "transferInAble": true,
6269
+ // "borrowAble": true,
6270
+ // "dailyInterestRate": "0.00007",
6271
+ // "yearlyInterestRate": "0.02555",
6272
+ // "maxBorrowableAmount": "26",
6273
+ // "vips": [
6274
+ // {
6275
+ // "level": "0",
6276
+ // "dailyInterestRate": "0.00007",
6277
+ // "yearlyInterestRate": "0.02555",
6278
+ // "discountRate": "1"
6279
+ // },
6280
+ // ]
6281
+ // }
6282
+ // ]
6283
+ // }
6284
+ //
6285
+ const timestamp = this.safeInteger(response, 'requestTime');
6286
+ const data = this.safeValue(response, 'data', []);
6287
+ const first = this.safeValue(data, 0, {});
6288
+ first['timestamp'] = timestamp;
6289
+ return this.parseBorrowRate(first, currency);
6290
+ }
6291
+ parseBorrowRate(info, currency = undefined) {
6292
+ //
6293
+ // isolated
6294
+ //
6295
+ // {
6296
+ // "symbol": "BTCUSDT",
6297
+ // "leverage": "10",
6298
+ // "baseCoin": "BTC",
6299
+ // "baseTransferInAble": true,
6300
+ // "baseBorrowAble": true,
6301
+ // "baseDailyInterestRate": "0.00007",
6302
+ // "baseYearlyInterestRate": "0.02555",
6303
+ // "baseMaxBorrowableAmount": "35",
6304
+ // "baseVips": [
6305
+ // {
6306
+ // "level": "0",
6307
+ // "dailyInterestRate": "0.00007",
6308
+ // "yearlyInterestRate": "0.02555",
6309
+ // "discountRate": "1"
6310
+ // },
6311
+ // ],
6312
+ // "quoteCoin": "USDT",
6313
+ // "quoteTransferInAble": true,
6314
+ // "quoteBorrowAble": true,
6315
+ // "quoteDailyInterestRate": "0.00012627",
6316
+ // "quoteYearlyInterestRate": "0.04608855",
6317
+ // "quoteMaxBorrowableAmount": "300000",
6318
+ // "quoteVips": [
6319
+ // {
6320
+ // "level": "0",
6321
+ // "dailyInterestRate": "0.000126279",
6322
+ // "yearlyInterestRate": "0.046091835",
6323
+ // "discountRate": "1"
6324
+ // },
6325
+ // ]
6326
+ // }
6327
+ //
6328
+ // cross
6329
+ //
6330
+ // {
6331
+ // "coin": "BTC",
6332
+ // "leverage": "3",
6333
+ // "transferInAble": true,
6334
+ // "borrowAble": true,
6335
+ // "dailyInterestRate": "0.00007",
6336
+ // "yearlyInterestRate": "0.02555",
6337
+ // "maxBorrowableAmount": "26",
6338
+ // "vips": [
6339
+ // {
6340
+ // "level": "0",
6341
+ // "dailyInterestRate": "0.00007",
6342
+ // "yearlyInterestRate": "0.02555",
6343
+ // "discountRate": "1"
6344
+ // },
6345
+ // ]
6346
+ // }
6347
+ //
6348
+ const code = currency['code'];
6349
+ const baseCoin = this.safeString(info, 'baseCoin');
6350
+ const quoteCoin = this.safeString(info, 'quoteCoin');
6351
+ let currencyId = undefined;
6352
+ let interestRate = undefined;
6353
+ if (baseCoin !== undefined) {
6354
+ if (code === baseCoin) {
6355
+ currencyId = baseCoin;
6356
+ interestRate = this.safeNumber(info, 'baseDailyInterestRate');
6357
+ }
6358
+ else if (code === quoteCoin) {
6359
+ currencyId = quoteCoin;
6360
+ interestRate = this.safeNumber(info, 'quoteDailyInterestRate');
6361
+ }
6362
+ }
6363
+ else {
6364
+ currencyId = this.safeString(info, 'coin');
6365
+ interestRate = this.safeNumber(info, 'dailyInterestRate');
6366
+ }
6367
+ const timestamp = this.safeInteger(info, 'timestamp');
6368
+ return {
6369
+ 'currency': this.safeCurrencyCode(currencyId, currency),
6370
+ 'rate': interestRate,
6371
+ 'period': 86400000,
6372
+ 'timestamp': timestamp,
6373
+ 'datetime': this.iso8601(timestamp),
6374
+ 'info': info,
6375
+ };
6376
+ }
6182
6377
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
6183
6378
  if (!response) {
6184
6379
  return undefined; // fallback to default error handler
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 { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.1.24";
7
+ declare const version = "4.1.25";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.1.25';
41
+ const version = '4.1.26';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -328,6 +328,22 @@ export default class bitget extends Exchange {
328
328
  timestamp: number;
329
329
  datetime: string;
330
330
  };
331
+ fetchBorrowRate(code: string, params?: {}): Promise<{
332
+ currency: any;
333
+ rate: any;
334
+ period: number;
335
+ timestamp: number;
336
+ datetime: string;
337
+ info: any;
338
+ }>;
339
+ parseBorrowRate(info: any, currency?: any): {
340
+ currency: any;
341
+ rate: any;
342
+ period: number;
343
+ timestamp: number;
344
+ datetime: string;
345
+ info: any;
346
+ };
331
347
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
332
348
  sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
333
349
  url: string;
package/js/src/bitget.js CHANGED
@@ -43,7 +43,7 @@ export default class bitget extends Exchange {
43
43
  'editOrder': true,
44
44
  'fetchAccounts': false,
45
45
  'fetchBalance': true,
46
- 'fetchBorrowRate': false,
46
+ 'fetchBorrowRate': true,
47
47
  'fetchBorrowRateHistories': false,
48
48
  'fetchBorrowRateHistory': false,
49
49
  'fetchBorrowRates': false,
@@ -6182,6 +6182,201 @@ export default class bitget extends Exchange {
6182
6182
  'datetime': this.iso8601(timestamp),
6183
6183
  };
6184
6184
  }
6185
+ async fetchBorrowRate(code, params = {}) {
6186
+ /**
6187
+ * @method
6188
+ * @name bitget#fetchBorrowRate
6189
+ * @description fetch the rate of interest to borrow a currency for margin trading
6190
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-margin-interest-rate-and-max-borrowable-amount
6191
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-margin-interest-rate-and-borrowable
6192
+ * @param {string} code unified currency code
6193
+ * @param {object} [params] extra parameters specific to the bitget api endpoint
6194
+ * @param {string} [params.symbol] required for isolated margin
6195
+ * @returns {object} a [borrow rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure}
6196
+ */
6197
+ await this.loadMarkets();
6198
+ const currency = this.currency(code);
6199
+ let market = undefined;
6200
+ const symbol = this.safeString(params, 'symbol');
6201
+ params = this.omit(params, 'symbol');
6202
+ if (symbol !== undefined) {
6203
+ market = this.market(symbol);
6204
+ }
6205
+ const request = {};
6206
+ let response = undefined;
6207
+ let marginMode = undefined;
6208
+ [marginMode, params] = this.handleMarginModeAndParams('fetchBorrowRate', params, 'cross');
6209
+ if ((symbol !== undefined) || (marginMode === 'isolated')) {
6210
+ this.checkRequiredSymbol('fetchBorrowRate', symbol);
6211
+ request['symbol'] = market['info']['symbolName'];
6212
+ response = await this.publicMarginGetIsolatedPublicInterestRateAndLimit(this.extend(request, params));
6213
+ }
6214
+ else if (marginMode === 'cross') {
6215
+ request['coin'] = currency['code'];
6216
+ response = await this.publicMarginGetCrossPublicInterestRateAndLimit(this.extend(request, params));
6217
+ }
6218
+ //
6219
+ // isolated
6220
+ //
6221
+ // {
6222
+ // "code": "00000",
6223
+ // "msg": "success",
6224
+ // "requestTime": 1698208075332,
6225
+ // "data": [
6226
+ // {
6227
+ // "symbol": "BTCUSDT",
6228
+ // "leverage": "10",
6229
+ // "baseCoin": "BTC",
6230
+ // "baseTransferInAble": true,
6231
+ // "baseBorrowAble": true,
6232
+ // "baseDailyInterestRate": "0.00007",
6233
+ // "baseYearlyInterestRate": "0.02555",
6234
+ // "baseMaxBorrowableAmount": "35",
6235
+ // "baseVips": [
6236
+ // {
6237
+ // "level": "0",
6238
+ // "dailyInterestRate": "0.00007",
6239
+ // "yearlyInterestRate": "0.02555",
6240
+ // "discountRate": "1"
6241
+ // },
6242
+ // ],
6243
+ // "quoteCoin": "USDT",
6244
+ // "quoteTransferInAble": true,
6245
+ // "quoteBorrowAble": true,
6246
+ // "quoteDailyInterestRate": "0.00012627",
6247
+ // "quoteYearlyInterestRate": "0.04608855",
6248
+ // "quoteMaxBorrowableAmount": "300000",
6249
+ // "quoteVips": [
6250
+ // {
6251
+ // "level": "0",
6252
+ // "dailyInterestRate": "0.000126279",
6253
+ // "yearlyInterestRate": "0.046091835",
6254
+ // "discountRate": "1"
6255
+ // },
6256
+ // ]
6257
+ // }
6258
+ // ]
6259
+ // }
6260
+ //
6261
+ // cross
6262
+ //
6263
+ // {
6264
+ // "code": "00000",
6265
+ // "msg": "success",
6266
+ // "requestTime": 1698208150986,
6267
+ // "data": [
6268
+ // {
6269
+ // "coin": "BTC",
6270
+ // "leverage": "3",
6271
+ // "transferInAble": true,
6272
+ // "borrowAble": true,
6273
+ // "dailyInterestRate": "0.00007",
6274
+ // "yearlyInterestRate": "0.02555",
6275
+ // "maxBorrowableAmount": "26",
6276
+ // "vips": [
6277
+ // {
6278
+ // "level": "0",
6279
+ // "dailyInterestRate": "0.00007",
6280
+ // "yearlyInterestRate": "0.02555",
6281
+ // "discountRate": "1"
6282
+ // },
6283
+ // ]
6284
+ // }
6285
+ // ]
6286
+ // }
6287
+ //
6288
+ const timestamp = this.safeInteger(response, 'requestTime');
6289
+ const data = this.safeValue(response, 'data', []);
6290
+ const first = this.safeValue(data, 0, {});
6291
+ first['timestamp'] = timestamp;
6292
+ return this.parseBorrowRate(first, currency);
6293
+ }
6294
+ parseBorrowRate(info, currency = undefined) {
6295
+ //
6296
+ // isolated
6297
+ //
6298
+ // {
6299
+ // "symbol": "BTCUSDT",
6300
+ // "leverage": "10",
6301
+ // "baseCoin": "BTC",
6302
+ // "baseTransferInAble": true,
6303
+ // "baseBorrowAble": true,
6304
+ // "baseDailyInterestRate": "0.00007",
6305
+ // "baseYearlyInterestRate": "0.02555",
6306
+ // "baseMaxBorrowableAmount": "35",
6307
+ // "baseVips": [
6308
+ // {
6309
+ // "level": "0",
6310
+ // "dailyInterestRate": "0.00007",
6311
+ // "yearlyInterestRate": "0.02555",
6312
+ // "discountRate": "1"
6313
+ // },
6314
+ // ],
6315
+ // "quoteCoin": "USDT",
6316
+ // "quoteTransferInAble": true,
6317
+ // "quoteBorrowAble": true,
6318
+ // "quoteDailyInterestRate": "0.00012627",
6319
+ // "quoteYearlyInterestRate": "0.04608855",
6320
+ // "quoteMaxBorrowableAmount": "300000",
6321
+ // "quoteVips": [
6322
+ // {
6323
+ // "level": "0",
6324
+ // "dailyInterestRate": "0.000126279",
6325
+ // "yearlyInterestRate": "0.046091835",
6326
+ // "discountRate": "1"
6327
+ // },
6328
+ // ]
6329
+ // }
6330
+ //
6331
+ // cross
6332
+ //
6333
+ // {
6334
+ // "coin": "BTC",
6335
+ // "leverage": "3",
6336
+ // "transferInAble": true,
6337
+ // "borrowAble": true,
6338
+ // "dailyInterestRate": "0.00007",
6339
+ // "yearlyInterestRate": "0.02555",
6340
+ // "maxBorrowableAmount": "26",
6341
+ // "vips": [
6342
+ // {
6343
+ // "level": "0",
6344
+ // "dailyInterestRate": "0.00007",
6345
+ // "yearlyInterestRate": "0.02555",
6346
+ // "discountRate": "1"
6347
+ // },
6348
+ // ]
6349
+ // }
6350
+ //
6351
+ const code = currency['code'];
6352
+ const baseCoin = this.safeString(info, 'baseCoin');
6353
+ const quoteCoin = this.safeString(info, 'quoteCoin');
6354
+ let currencyId = undefined;
6355
+ let interestRate = undefined;
6356
+ if (baseCoin !== undefined) {
6357
+ if (code === baseCoin) {
6358
+ currencyId = baseCoin;
6359
+ interestRate = this.safeNumber(info, 'baseDailyInterestRate');
6360
+ }
6361
+ else if (code === quoteCoin) {
6362
+ currencyId = quoteCoin;
6363
+ interestRate = this.safeNumber(info, 'quoteDailyInterestRate');
6364
+ }
6365
+ }
6366
+ else {
6367
+ currencyId = this.safeString(info, 'coin');
6368
+ interestRate = this.safeNumber(info, 'dailyInterestRate');
6369
+ }
6370
+ const timestamp = this.safeInteger(info, 'timestamp');
6371
+ return {
6372
+ 'currency': this.safeCurrencyCode(currencyId, currency),
6373
+ 'rate': interestRate,
6374
+ 'period': 86400000,
6375
+ 'timestamp': timestamp,
6376
+ 'datetime': this.iso8601(timestamp),
6377
+ 'info': info,
6378
+ };
6379
+ }
6185
6380
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
6186
6381
  if (!response) {
6187
6382
  return undefined; // fallback to default error handler
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.1.25",
3
+ "version": "4.1.26",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",