ccxt 4.2.91 → 4.2.92

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
@@ -182,7 +182,7 @@ var woo$1 = require('./src/pro/woo.js');
182
182
 
183
183
  //-----------------------------------------------------------------------------
184
184
  // this is updated by vss.js when building
185
- const version = '4.2.91';
185
+ const version = '4.2.92';
186
186
  Exchange["default"].ccxtVersion = version;
187
187
  const exchanges = {
188
188
  'ace': ace,
@@ -5807,7 +5807,7 @@ class Exchange {
5807
5807
  return reconstructedDate;
5808
5808
  }
5809
5809
  convertMarketIdExpireDate(date) {
5810
- // parse 19JAN24 to 240119
5810
+ // parse 03JAN24 to 240103
5811
5811
  const monthMappping = {
5812
5812
  'JAN': '01',
5813
5813
  'FEB': '02',
@@ -5822,6 +5822,10 @@ class Exchange {
5822
5822
  'NOV': '11',
5823
5823
  'DEC': '12',
5824
5824
  };
5825
+ // if exchange omits first zero and provides i.e. '3JAN24' instead of '03JAN24'
5826
+ if (date.length === 6) {
5827
+ date = '0' + date;
5828
+ }
5825
5829
  const year = date.slice(0, 2);
5826
5830
  const monthName = date.slice(2, 5);
5827
5831
  const month = this.safeString(monthMappping, monthName);
@@ -370,6 +370,7 @@ class bybit extends bybit$1 {
370
370
  'v5/broker/earning-record': 5,
371
371
  'v5/broker/earnings-info': 5,
372
372
  'v5/broker/account-info': 5,
373
+ 'v5/broker/asset/query-sub-member-deposit-record': 10,
373
374
  },
374
375
  'post': {
375
376
  // Legacy option USDC
@@ -697,117 +697,130 @@ class deribit extends deribit$1 {
697
697
  * @name deribit#fetchMarkets
698
698
  * @description retrieves data on all markets for deribit
699
699
  * @see https://docs.deribit.com/#public-get_currencies
700
+ * @see https://docs.deribit.com/#public-get_instruments
700
701
  * @param {object} [params] extra parameters specific to the exchange API endpoint
701
702
  * @returns {object[]} an array of objects representing market data
702
703
  */
703
- const currenciesResponse = await this.publicGetGetCurrencies(params);
704
- //
705
- // {
706
- // "jsonrpc": "2.0",
707
- // "result": [
708
- // {
709
- // "withdrawal_priorities": [
710
- // { value: 0.15, name: "very_low" },
711
- // { value: 1.5, name: "very_high" },
712
- // ],
713
- // "withdrawal_fee": 0.0005,
714
- // "min_withdrawal_fee": 0.0005,
715
- // "min_confirmations": 1,
716
- // "fee_precision": 4,
717
- // "currency_long": "Bitcoin",
718
- // "currency": "BTC",
719
- // "coin_type": "BITCOIN"
720
- // }
721
- // ],
722
- // "usIn": 1583761588590479,
723
- // "usOut": 1583761588590544,
724
- // "usDiff": 65,
725
- // "testnet": false
726
- // }
727
- //
728
- const parsedMarkets = {};
729
- const currenciesResult = this.safeValue(currenciesResponse, 'result', []);
704
+ const instrumentsResponses = [];
730
705
  const result = [];
731
- for (let i = 0; i < currenciesResult.length; i++) {
732
- const currencyId = this.safeString(currenciesResult[i], 'currency');
733
- const request = {
734
- 'currency': currencyId,
735
- };
736
- const instrumentsResponse = await this.publicGetGetInstruments(this.extend(request, params));
706
+ const parsedMarkets = {};
707
+ let fetchAllMarkets = undefined;
708
+ [fetchAllMarkets, params] = this.handleOptionAndParams(params, 'fetchMarkets', 'fetchAllMarkets', true);
709
+ if (fetchAllMarkets) {
710
+ const instrumentsResponse = await this.publicGetGetInstruments(params);
711
+ instrumentsResponses.push(instrumentsResponse);
712
+ }
713
+ else {
714
+ const currenciesResponse = await this.publicGetGetCurrencies(params);
737
715
  //
738
716
  // {
739
- // "jsonrpc":"2.0",
740
- // "result":[
717
+ // "jsonrpc": "2.0",
718
+ // "result": [
741
719
  // {
742
- // "tick_size":0.0005,
743
- // "taker_commission":0.0003,
744
- // "strike":52000.0,
745
- // "settlement_period":"month",
746
- // "settlement_currency":"BTC",
747
- // "quote_currency":"BTC",
748
- // "option_type":"put", // put, call
749
- // "min_trade_amount":0.1,
750
- // "maker_commission":0.0003,
751
- // "kind":"option",
752
- // "is_active":true,
753
- // "instrument_name":"BTC-24JUN22-52000-P",
754
- // "expiration_timestamp":1656057600000,
755
- // "creation_timestamp":1648199543000,
756
- // "counter_currency":"USD",
757
- // "contract_size":1.0,
758
- // "block_trade_commission":0.0003,
759
- // "base_currency":"BTC"
760
- // },
761
- // {
762
- // "tick_size":0.5,
763
- // "taker_commission":0.0005,
764
- // "settlement_period":"month", // month, week
765
- // "settlement_currency":"BTC",
766
- // "quote_currency":"USD",
767
- // "min_trade_amount":10.0,
768
- // "max_liquidation_commission":0.0075,
769
- // "max_leverage":50,
770
- // "maker_commission":0.0,
771
- // "kind":"future",
772
- // "is_active":true,
773
- // "instrument_name":"BTC-27MAY22",
774
- // "future_type":"reversed",
775
- // "expiration_timestamp":1653638400000,
776
- // "creation_timestamp":1648195209000,
777
- // "counter_currency":"USD",
778
- // "contract_size":10.0,
779
- // "block_trade_commission":0.0001,
780
- // "base_currency":"BTC"
781
- // },
782
- // {
783
- // "tick_size":0.5,
784
- // "taker_commission":0.0005,
785
- // "settlement_period":"perpetual",
786
- // "settlement_currency":"BTC",
787
- // "quote_currency":"USD",
788
- // "min_trade_amount":10.0,
789
- // "max_liquidation_commission":0.0075,
790
- // "max_leverage":50,
791
- // "maker_commission":0.0,
792
- // "kind":"future",
793
- // "is_active":true,
794
- // "instrument_name":"BTC-PERPETUAL",
795
- // "future_type":"reversed",
796
- // "expiration_timestamp":32503708800000,
797
- // "creation_timestamp":1534242287000,
798
- // "counter_currency":"USD",
799
- // "contract_size":10.0,
800
- // "block_trade_commission":0.0001,
801
- // "base_currency":"BTC"
802
- // },
720
+ // "withdrawal_priorities": [
721
+ // { value: 0.15, name: "very_low" },
722
+ // { value: 1.5, name: "very_high" },
723
+ // ],
724
+ // "withdrawal_fee": 0.0005,
725
+ // "min_withdrawal_fee": 0.0005,
726
+ // "min_confirmations": 1,
727
+ // "fee_precision": 4,
728
+ // "currency_long": "Bitcoin",
729
+ // "currency": "BTC",
730
+ // "coin_type": "BITCOIN"
731
+ // }
803
732
  // ],
804
- // "usIn":1648691472831791,
805
- // "usOut":1648691472831896,
806
- // "usDiff":105,
807
- // "testnet":false
733
+ // "usIn": 1583761588590479,
734
+ // "usOut": 1583761588590544,
735
+ // "usDiff": 65,
736
+ // "testnet": false
808
737
  // }
809
738
  //
810
- const instrumentsResult = this.safeValue(instrumentsResponse, 'result', []);
739
+ const currenciesResult = this.safeValue(currenciesResponse, 'result', []);
740
+ for (let i = 0; i < currenciesResult.length; i++) {
741
+ const currencyId = this.safeString(currenciesResult[i], 'currency');
742
+ const request = {
743
+ 'currency': currencyId,
744
+ };
745
+ const instrumentsResponse = await this.publicGetGetInstruments(this.extend(request, params));
746
+ //
747
+ // {
748
+ // "jsonrpc":"2.0",
749
+ // "result":[
750
+ // {
751
+ // "tick_size":0.0005,
752
+ // "taker_commission":0.0003,
753
+ // "strike":52000.0,
754
+ // "settlement_period":"month",
755
+ // "settlement_currency":"BTC",
756
+ // "quote_currency":"BTC",
757
+ // "option_type":"put", // put, call
758
+ // "min_trade_amount":0.1,
759
+ // "maker_commission":0.0003,
760
+ // "kind":"option",
761
+ // "is_active":true,
762
+ // "instrument_name":"BTC-24JUN22-52000-P",
763
+ // "expiration_timestamp":1656057600000,
764
+ // "creation_timestamp":1648199543000,
765
+ // "counter_currency":"USD",
766
+ // "contract_size":1.0,
767
+ // "block_trade_commission":0.0003,
768
+ // "base_currency":"BTC"
769
+ // },
770
+ // {
771
+ // "tick_size":0.5,
772
+ // "taker_commission":0.0005,
773
+ // "settlement_period":"month", // month, week
774
+ // "settlement_currency":"BTC",
775
+ // "quote_currency":"USD",
776
+ // "min_trade_amount":10.0,
777
+ // "max_liquidation_commission":0.0075,
778
+ // "max_leverage":50,
779
+ // "maker_commission":0.0,
780
+ // "kind":"future",
781
+ // "is_active":true,
782
+ // "instrument_name":"BTC-27MAY22",
783
+ // "future_type":"reversed",
784
+ // "expiration_timestamp":1653638400000,
785
+ // "creation_timestamp":1648195209000,
786
+ // "counter_currency":"USD",
787
+ // "contract_size":10.0,
788
+ // "block_trade_commission":0.0001,
789
+ // "base_currency":"BTC"
790
+ // },
791
+ // {
792
+ // "tick_size":0.5,
793
+ // "taker_commission":0.0005,
794
+ // "settlement_period":"perpetual",
795
+ // "settlement_currency":"BTC",
796
+ // "quote_currency":"USD",
797
+ // "min_trade_amount":10.0,
798
+ // "max_liquidation_commission":0.0075,
799
+ // "max_leverage":50,
800
+ // "maker_commission":0.0,
801
+ // "kind":"future",
802
+ // "is_active":true,
803
+ // "instrument_name":"BTC-PERPETUAL",
804
+ // "future_type":"reversed",
805
+ // "expiration_timestamp":32503708800000,
806
+ // "creation_timestamp":1534242287000,
807
+ // "counter_currency":"USD",
808
+ // "contract_size":10.0,
809
+ // "block_trade_commission":0.0001,
810
+ // "base_currency":"BTC"
811
+ // },
812
+ // ],
813
+ // "usIn":1648691472831791,
814
+ // "usOut":1648691472831896,
815
+ // "usDiff":105,
816
+ // "testnet":false
817
+ // }
818
+ //
819
+ instrumentsResponses.push(instrumentsResponse);
820
+ }
821
+ }
822
+ for (let i = 0; i < instrumentsResponses.length; i++) {
823
+ const instrumentsResult = this.safeValue(instrumentsResponses[i], 'result', []);
811
824
  for (let k = 0; k < instrumentsResult.length; k++) {
812
825
  const market = instrumentsResult[k];
813
826
  const kind = this.safeString(market, 'kind');
@@ -2703,15 +2703,15 @@ class kraken extends kraken$1 {
2703
2703
  * @name kraken#fetchPositions
2704
2704
  * @description fetch all open positions
2705
2705
  * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getOpenPositions
2706
- * @param {string[]|undefined} symbols not used by kraken fetchPositions ()
2706
+ * @param {string[]} [symbols] not used by kraken fetchPositions ()
2707
2707
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2708
2708
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
2709
2709
  */
2710
2710
  await this.loadMarkets();
2711
2711
  const request = {
2712
- // 'txid': 'comma delimited list of transaction ids to restrict output to',
2713
- // 'docalcs': false, // whether or not to include profit/loss calculations
2714
- // 'consolidation': 'market', // what to consolidate the positions data around, market will consolidate positions based on market pair
2712
+ // 'txid': 'comma delimited list of transaction ids to restrict output to',
2713
+ 'docalcs': 'true',
2714
+ 'consolidation': 'market', // what to consolidate the positions data around, market will consolidate positions based on market pair
2715
2715
  };
2716
2716
  const response = await this.privatePostOpenPositions(this.extend(request, params));
2717
2717
  //
@@ -2759,9 +2759,58 @@ class kraken extends kraken$1 {
2759
2759
  // ]
2760
2760
  // }
2761
2761
  //
2762
- const result = this.safeValue(response, 'result');
2763
- // todo unify parsePosition/parsePositions
2764
- return result;
2762
+ symbols = this.marketSymbols(symbols);
2763
+ const result = this.safeList(response, 'result');
2764
+ const results = this.parsePositions(result, symbols);
2765
+ return this.filterByArrayPositions(results, 'symbol', symbols, false);
2766
+ }
2767
+ parsePosition(position, market = undefined) {
2768
+ //
2769
+ // {
2770
+ // "pair": "ETHUSDT",
2771
+ // "positions": "1",
2772
+ // "type": "buy",
2773
+ // "leverage": "2.00000",
2774
+ // "cost": "28.49800",
2775
+ // "fee": "0.07979",
2776
+ // "vol": "0.02000000",
2777
+ // "vol_closed": "0.00000000",
2778
+ // "margin": "14.24900"
2779
+ // }
2780
+ //
2781
+ const marketId = this.safeString(position, 'pair');
2782
+ const rawSide = this.safeString(position, 'type');
2783
+ const side = (rawSide === 'buy') ? 'long' : 'short';
2784
+ return this.safePosition({
2785
+ 'info': position,
2786
+ 'id': undefined,
2787
+ 'symbol': this.safeSymbol(marketId, market),
2788
+ 'notional': undefined,
2789
+ 'marginMode': undefined,
2790
+ 'liquidationPrice': undefined,
2791
+ 'entryPrice': undefined,
2792
+ 'unrealizedPnl': this.safeNumber(position, 'net'),
2793
+ 'realizedPnl': undefined,
2794
+ 'percentage': undefined,
2795
+ 'contracts': this.safeNumber(position, 'vol'),
2796
+ 'contractSize': undefined,
2797
+ 'markPrice': undefined,
2798
+ 'lastPrice': undefined,
2799
+ 'side': side,
2800
+ 'hedged': undefined,
2801
+ 'timestamp': undefined,
2802
+ 'datetime': undefined,
2803
+ 'lastUpdateTimestamp': undefined,
2804
+ 'maintenanceMargin': undefined,
2805
+ 'maintenanceMarginPercentage': undefined,
2806
+ 'collateral': undefined,
2807
+ 'initialMargin': this.safeNumber(position, 'margin'),
2808
+ 'initialMarginPercentage': undefined,
2809
+ 'leverage': this.safeNumber(position, 'leverage'),
2810
+ 'marginRatio': undefined,
2811
+ 'stopLossPrice': undefined,
2812
+ 'takeProfitPrice': undefined,
2813
+ });
2765
2814
  }
2766
2815
  parseAccountType(account) {
2767
2816
  const accountByType = {
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, Leverage, Leverages, Option, OptionChain } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, ExchangeClosedByUser } from './src/base/errors.js';
7
- declare const version = "4.2.90";
7
+ declare const version = "4.2.91";
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, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, ExchangeClosedByUser } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.91';
41
+ const version = '4.2.92';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -172,6 +172,7 @@ interface Exchange {
172
172
  privateGetV5BrokerEarningRecord(params?: {}): Promise<implicitReturnType>;
173
173
  privateGetV5BrokerEarningsInfo(params?: {}): Promise<implicitReturnType>;
174
174
  privateGetV5BrokerAccountInfo(params?: {}): Promise<implicitReturnType>;
175
+ privateGetV5BrokerAssetQuerySubMemberDepositRecord(params?: {}): Promise<implicitReturnType>;
175
176
  privatePostOptionUsdcOpenapiPrivateV1PlaceOrder(params?: {}): Promise<implicitReturnType>;
176
177
  privatePostOptionUsdcOpenapiPrivateV1ReplaceOrder(params?: {}): Promise<implicitReturnType>;
177
178
  privatePostOptionUsdcOpenapiPrivateV1CancelOrder(params?: {}): Promise<implicitReturnType>;
@@ -5794,7 +5794,7 @@ export default class Exchange {
5794
5794
  return reconstructedDate;
5795
5795
  }
5796
5796
  convertMarketIdExpireDate(date) {
5797
- // parse 19JAN24 to 240119
5797
+ // parse 03JAN24 to 240103
5798
5798
  const monthMappping = {
5799
5799
  'JAN': '01',
5800
5800
  'FEB': '02',
@@ -5809,6 +5809,10 @@ export default class Exchange {
5809
5809
  'NOV': '11',
5810
5810
  'DEC': '12',
5811
5811
  };
5812
+ // if exchange omits first zero and provides i.e. '3JAN24' instead of '03JAN24'
5813
+ if (date.length === 6) {
5814
+ date = '0' + date;
5815
+ }
5812
5816
  const year = date.slice(0, 2);
5813
5817
  const monthName = date.slice(2, 5);
5814
5818
  const month = this.safeString(monthMappping, monthName);
package/js/src/bybit.js CHANGED
@@ -373,6 +373,7 @@ export default class bybit extends Exchange {
373
373
  'v5/broker/earning-record': 5,
374
374
  'v5/broker/earnings-info': 5,
375
375
  'v5/broker/account-info': 5,
376
+ 'v5/broker/asset/query-sub-member-deposit-record': 10,
376
377
  },
377
378
  'post': {
378
379
  // Legacy option USDC