ccxt 4.2.27 → 4.2.28

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
@@ -175,7 +175,7 @@ var woo$1 = require('./src/pro/woo.js');
175
175
 
176
176
  //-----------------------------------------------------------------------------
177
177
  // this is updated by vss.js when building
178
- const version = '4.2.27';
178
+ const version = '4.2.28';
179
179
  Exchange["default"].ccxtVersion = version;
180
180
  const exchanges = {
181
181
  'ace': ace,
@@ -8,6 +8,10 @@ var number = require('./base/functions/number.js');
8
8
 
9
9
  // ---------------------------------------------------------------------------
10
10
  // ---------------------------------------------------------------------------
11
+ /**
12
+ * @class bingx
13
+ * @augments Exchange
14
+ */
11
15
  class bingx extends bingx$1 {
12
16
  describe() {
13
17
  return this.deepExtend(super.describe(), {
@@ -28,6 +28,7 @@ class bit2c extends bit2c$1 {
28
28
  'future': false,
29
29
  'option': false,
30
30
  'addMargin': false,
31
+ 'cancelAllOrders': false,
31
32
  'cancelOrder': true,
32
33
  'closeAllPositions': false,
33
34
  'closePosition': false,
@@ -26,6 +26,7 @@ class bitbank extends bitbank$1 {
26
26
  'future': false,
27
27
  'option': false,
28
28
  'addMargin': false,
29
+ 'cancelAllOrders': false,
29
30
  'cancelOrder': true,
30
31
  'closeAllPositions': false,
31
32
  'closePosition': false,
@@ -29,6 +29,7 @@ class bitbns extends bitbns$1 {
29
29
  'swap': false,
30
30
  'future': false,
31
31
  'option': undefined,
32
+ 'cancelAllOrders': false,
32
33
  'cancelOrder': true,
33
34
  'createOrder': true,
34
35
  'fetchBalance': true,
@@ -69,6 +69,7 @@ class bitfinex2 extends bitfinex2$1 {
69
69
  'fetchTradingFees': true,
70
70
  'fetchTransactionFees': undefined,
71
71
  'fetchTransactions': 'emulated',
72
+ 'setMargin': true,
72
73
  'withdraw': true,
73
74
  },
74
75
  'timeframes': {
@@ -819,6 +820,11 @@ class bitfinex2 extends bitfinex2$1 {
819
820
  const result = { 'info': response };
820
821
  for (let i = 0; i < response.length; i++) {
821
822
  const balance = response[i];
823
+ const account = this.account();
824
+ const interest = this.safeString(balance, 3);
825
+ if (interest !== '0') {
826
+ account['debt'] = interest;
827
+ }
822
828
  const type = this.safeString(balance, 0);
823
829
  const currencyId = this.safeStringLower(balance, 1, '');
824
830
  const start = currencyId.length - 2;
@@ -827,7 +833,6 @@ class bitfinex2 extends bitfinex2$1 {
827
833
  const derivativeCondition = (!isDerivative || isDerivativeCode);
828
834
  if ((accountType === type) && derivativeCondition) {
829
835
  const code = this.safeCurrencyCode(currencyId);
830
- const account = this.account();
831
836
  account['total'] = this.safeString(balance, 2);
832
837
  account['free'] = this.safeString(balance, 4);
833
838
  result[code] = account;
@@ -3262,6 +3267,49 @@ class bitfinex2 extends bitfinex2$1 {
3262
3267
  'datetime': this.iso8601(timestamp),
3263
3268
  });
3264
3269
  }
3270
+ async setMargin(symbol, amount, params = {}) {
3271
+ /**
3272
+ * @method
3273
+ * @name bitfinex2#setMargin
3274
+ * @description either adds or reduces margin in a swap position in order to set the margin to a specific value
3275
+ * @see https://docs.bitfinex.com/reference/rest-auth-deriv-pos-collateral-set
3276
+ * @param {string} symbol unified market symbol of the market to set margin in
3277
+ * @param {float} amount the amount to set the margin to
3278
+ * @param {object} [params] parameters specific to the exchange API endpoint
3279
+ * @returns {object} A [margin structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#add-margin-structure}
3280
+ */
3281
+ await this.loadMarkets();
3282
+ const market = this.market(symbol);
3283
+ if (!market['swap']) {
3284
+ throw new errors.NotSupported(this.id + ' setMargin() only support swap markets');
3285
+ }
3286
+ const request = {
3287
+ 'symbol': market['id'],
3288
+ 'collateral': this.parseToNumeric(amount),
3289
+ };
3290
+ const response = await this.privatePostAuthWDerivCollateralSet(this.extend(request, params));
3291
+ //
3292
+ // [
3293
+ // [
3294
+ // 1
3295
+ // ]
3296
+ // ]
3297
+ //
3298
+ const data = this.safeValue(response, 0);
3299
+ return this.parseMarginModification(data, market);
3300
+ }
3301
+ parseMarginModification(data, market = undefined) {
3302
+ const marginStatusRaw = data[0];
3303
+ const marginStatus = (marginStatusRaw === 1) ? 'ok' : 'failed';
3304
+ return {
3305
+ 'info': data,
3306
+ 'type': undefined,
3307
+ 'amount': undefined,
3308
+ 'code': undefined,
3309
+ 'symbol': market['symbol'],
3310
+ 'status': marginStatus,
3311
+ };
3312
+ }
3265
3313
  }
3266
3314
 
3267
3315
  module.exports = bitfinex2;
@@ -28,6 +28,7 @@ class bitflyer extends bitflyer$1 {
28
28
  'swap': undefined,
29
29
  'future': undefined,
30
30
  'option': false,
31
+ 'cancelAllOrders': undefined,
31
32
  'cancelOrder': true,
32
33
  'createOrder': true,
33
34
  'fetchBalance': true,
@@ -27,6 +27,7 @@ class bitforex extends bitforex$1 {
27
27
  'future': false,
28
28
  'option': false,
29
29
  'addMargin': false,
30
+ 'cancelAllOrders': true,
30
31
  'cancelOrder': true,
31
32
  'createOrder': true,
32
33
  'createReduceOnlyOrder': false,
@@ -680,6 +681,34 @@ class bitforex extends bitforex$1 {
680
681
  'trades': undefined,
681
682
  }, market);
682
683
  }
684
+ async cancelAllOrders(symbol = undefined, params = {}) {
685
+ /**
686
+ * @method
687
+ * @name bitforex#cancelAllOrders
688
+ * @see https://github.com/githubdev2020/API_Doc_en/wiki/Cancle-all-orders
689
+ * @description cancel all open orders in a market
690
+ * @param {string} symbol unified market symbol of the market to cancel orders in
691
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
692
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
693
+ */
694
+ if (symbol === undefined) {
695
+ throw new errors.ArgumentsRequired(this.id + ' cancelAllOrders () requires a symbol argument');
696
+ }
697
+ await this.loadMarkets();
698
+ const market = this.market(symbol);
699
+ const request = {
700
+ 'symbol': market['id'],
701
+ };
702
+ const response = await this.privatePostApiV1TradeCancelAllOrder(this.extend(request, params));
703
+ //
704
+ // {
705
+ // 'data': True,
706
+ // 'success': True,
707
+ // 'time': '1706542995252'
708
+ // }
709
+ //
710
+ return response;
711
+ }
683
712
  async fetchOrder(id, symbol = undefined, params = {}) {
684
713
  /**
685
714
  * @method
@@ -7,6 +7,10 @@ var kucoinfutures$1 = require('./abstract/kucoinfutures.js');
7
7
 
8
8
  // ---------------------------------------------------------------------------
9
9
  // ---------------------------------------------------------------------------
10
+ /**
11
+ * @class kucoinfutures
12
+ * @augments Exchange
13
+ */
10
14
  class kucoinfutures extends kucoinfutures$1 {
11
15
  describe() {
12
16
  return this.deepExtend(super.describe(), {
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } 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.2.26";
7
+ declare const version = "4.2.27";
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.2.27';
41
+ const version = '4.2.28';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
package/js/src/bingx.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import Exchange from './abstract/bingx.js';
2
2
  import type { Int, OrderSide, OHLCV, FundingRateHistory, Order, OrderType, OrderRequest, Str, Trade, Balances, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position } from './base/types.js';
3
+ /**
4
+ * @class bingx
5
+ * @augments Exchange
6
+ */
3
7
  export default class bingx extends Exchange {
4
8
  describe(): any;
5
9
  fetchTime(params?: {}): Promise<number>;
package/js/src/bingx.js CHANGED
@@ -11,6 +11,10 @@ import { Precise } from './base/Precise.js';
11
11
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
12
12
  import { DECIMAL_PLACES } from './base/functions/number.js';
13
13
  // ---------------------------------------------------------------------------
14
+ /**
15
+ * @class bingx
16
+ * @augments Exchange
17
+ */
14
18
  export default class bingx extends Exchange {
15
19
  describe() {
16
20
  return this.deepExtend(super.describe(), {
package/js/src/bit2c.js CHANGED
@@ -31,6 +31,7 @@ export default class bit2c extends Exchange {
31
31
  'future': false,
32
32
  'option': false,
33
33
  'addMargin': false,
34
+ 'cancelAllOrders': false,
34
35
  'cancelOrder': true,
35
36
  'closeAllPositions': false,
36
37
  'closePosition': false,
package/js/src/bitbank.js CHANGED
@@ -29,6 +29,7 @@ export default class bitbank extends Exchange {
29
29
  'future': false,
30
30
  'option': false,
31
31
  'addMargin': false,
32
+ 'cancelAllOrders': false,
32
33
  'cancelOrder': true,
33
34
  'closeAllPositions': false,
34
35
  'closePosition': false,
package/js/src/bitbns.js CHANGED
@@ -32,6 +32,7 @@ export default class bitbns extends Exchange {
32
32
  'swap': false,
33
33
  'future': false,
34
34
  'option': undefined,
35
+ 'cancelAllOrders': false,
35
36
  'cancelOrder': true,
36
37
  'createOrder': true,
37
38
  'fetchBalance': true,
@@ -161,4 +161,20 @@ export default class bitfinex2 extends Exchange {
161
161
  parseOpenInterest(interest: any, market?: Market): OpenInterest;
162
162
  fetchLiquidations(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
163
163
  parseLiquidation(liquidation: any, market?: Market): Liquidation;
164
+ setMargin(symbol: string, amount: any, params?: {}): Promise<{
165
+ info: any;
166
+ type: any;
167
+ amount: any;
168
+ code: any;
169
+ symbol: any;
170
+ status: string;
171
+ }>;
172
+ parseMarginModification(data: any, market?: any): {
173
+ info: any;
174
+ type: any;
175
+ amount: any;
176
+ code: any;
177
+ symbol: any;
178
+ status: string;
179
+ };
164
180
  }
@@ -72,6 +72,7 @@ export default class bitfinex2 extends Exchange {
72
72
  'fetchTradingFees': true,
73
73
  'fetchTransactionFees': undefined,
74
74
  'fetchTransactions': 'emulated',
75
+ 'setMargin': true,
75
76
  'withdraw': true,
76
77
  },
77
78
  'timeframes': {
@@ -822,6 +823,11 @@ export default class bitfinex2 extends Exchange {
822
823
  const result = { 'info': response };
823
824
  for (let i = 0; i < response.length; i++) {
824
825
  const balance = response[i];
826
+ const account = this.account();
827
+ const interest = this.safeString(balance, 3);
828
+ if (interest !== '0') {
829
+ account['debt'] = interest;
830
+ }
825
831
  const type = this.safeString(balance, 0);
826
832
  const currencyId = this.safeStringLower(balance, 1, '');
827
833
  const start = currencyId.length - 2;
@@ -830,7 +836,6 @@ export default class bitfinex2 extends Exchange {
830
836
  const derivativeCondition = (!isDerivative || isDerivativeCode);
831
837
  if ((accountType === type) && derivativeCondition) {
832
838
  const code = this.safeCurrencyCode(currencyId);
833
- const account = this.account();
834
839
  account['total'] = this.safeString(balance, 2);
835
840
  account['free'] = this.safeString(balance, 4);
836
841
  result[code] = account;
@@ -3265,4 +3270,47 @@ export default class bitfinex2 extends Exchange {
3265
3270
  'datetime': this.iso8601(timestamp),
3266
3271
  });
3267
3272
  }
3273
+ async setMargin(symbol, amount, params = {}) {
3274
+ /**
3275
+ * @method
3276
+ * @name bitfinex2#setMargin
3277
+ * @description either adds or reduces margin in a swap position in order to set the margin to a specific value
3278
+ * @see https://docs.bitfinex.com/reference/rest-auth-deriv-pos-collateral-set
3279
+ * @param {string} symbol unified market symbol of the market to set margin in
3280
+ * @param {float} amount the amount to set the margin to
3281
+ * @param {object} [params] parameters specific to the exchange API endpoint
3282
+ * @returns {object} A [margin structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#add-margin-structure}
3283
+ */
3284
+ await this.loadMarkets();
3285
+ const market = this.market(symbol);
3286
+ if (!market['swap']) {
3287
+ throw new NotSupported(this.id + ' setMargin() only support swap markets');
3288
+ }
3289
+ const request = {
3290
+ 'symbol': market['id'],
3291
+ 'collateral': this.parseToNumeric(amount),
3292
+ };
3293
+ const response = await this.privatePostAuthWDerivCollateralSet(this.extend(request, params));
3294
+ //
3295
+ // [
3296
+ // [
3297
+ // 1
3298
+ // ]
3299
+ // ]
3300
+ //
3301
+ const data = this.safeValue(response, 0);
3302
+ return this.parseMarginModification(data, market);
3303
+ }
3304
+ parseMarginModification(data, market = undefined) {
3305
+ const marginStatusRaw = data[0];
3306
+ const marginStatus = (marginStatusRaw === 1) ? 'ok' : 'failed';
3307
+ return {
3308
+ 'info': data,
3309
+ 'type': undefined,
3310
+ 'amount': undefined,
3311
+ 'code': undefined,
3312
+ 'symbol': market['symbol'],
3313
+ 'status': marginStatus,
3314
+ };
3315
+ }
3268
3316
  }
@@ -31,6 +31,7 @@ export default class bitflyer extends Exchange {
31
31
  'swap': undefined,
32
32
  'future': undefined,
33
33
  'option': false,
34
+ 'cancelAllOrders': undefined,
34
35
  'cancelOrder': true,
35
36
  'createOrder': true,
36
37
  'fetchBalance': true,
@@ -20,6 +20,7 @@ export default class bitforex extends Exchange {
20
20
  parseOrderStatus(status: any): any;
21
21
  parseSide(sideId: any): "buy" | "sell";
22
22
  parseOrder(order: any, market?: Market): Order;
23
+ cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
23
24
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
24
25
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
25
26
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
@@ -30,6 +30,7 @@ export default class bitforex extends Exchange {
30
30
  'future': false,
31
31
  'option': false,
32
32
  'addMargin': false,
33
+ 'cancelAllOrders': true,
33
34
  'cancelOrder': true,
34
35
  'createOrder': true,
35
36
  'createReduceOnlyOrder': false,
@@ -683,6 +684,34 @@ export default class bitforex extends Exchange {
683
684
  'trades': undefined,
684
685
  }, market);
685
686
  }
687
+ async cancelAllOrders(symbol = undefined, params = {}) {
688
+ /**
689
+ * @method
690
+ * @name bitforex#cancelAllOrders
691
+ * @see https://github.com/githubdev2020/API_Doc_en/wiki/Cancle-all-orders
692
+ * @description cancel all open orders in a market
693
+ * @param {string} symbol unified market symbol of the market to cancel orders in
694
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
695
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
696
+ */
697
+ if (symbol === undefined) {
698
+ throw new ArgumentsRequired(this.id + ' cancelAllOrders () requires a symbol argument');
699
+ }
700
+ await this.loadMarkets();
701
+ const market = this.market(symbol);
702
+ const request = {
703
+ 'symbol': market['id'],
704
+ };
705
+ const response = await this.privatePostApiV1TradeCancelAllOrder(this.extend(request, params));
706
+ //
707
+ // {
708
+ // 'data': True,
709
+ // 'success': True,
710
+ // 'time': '1706542995252'
711
+ // }
712
+ //
713
+ return response;
714
+ }
686
715
  async fetchOrder(id, symbol = undefined, params = {}) {
687
716
  /**
688
717
  * @method
@@ -1,5 +1,9 @@
1
1
  import kucoin from './abstract/kucoinfutures.js';
2
2
  import type { Int, OrderSide, OrderType, OHLCV, Order, Trade, FundingHistory, Balances, Str, Ticker, OrderBook, Transaction, Strings, Market, Currency, OrderRequest } from './base/types.js';
3
+ /**
4
+ * @class kucoinfutures
5
+ * @augments Exchange
6
+ */
3
7
  export default class kucoinfutures extends kucoin {
4
8
  describe(): any;
5
9
  fetchStatus(params?: {}): Promise<{
@@ -10,6 +10,10 @@ import { Precise } from './base/Precise.js';
10
10
  import { TICK_SIZE } from './base/functions/number.js';
11
11
  import kucoin from './abstract/kucoinfutures.js';
12
12
  // ---------------------------------------------------------------------------
13
+ /**
14
+ * @class kucoinfutures
15
+ * @augments Exchange
16
+ */
13
17
  export default class kucoinfutures extends kucoin {
14
18
  describe() {
15
19
  return this.deepExtend(super.describe(), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.2.27",
3
+ "version": "4.2.28",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",