ccxt 4.3.21 → 4.3.23

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.
@@ -1704,6 +1704,26 @@ class phemex extends phemex$1 {
1704
1704
  // "execId": "8718cae",
1705
1705
  // "execStatus": 6
1706
1706
  // }
1707
+ // spot with fees paid using PT token
1708
+ // "createdAt": "1714990724076",
1709
+ // "symbol": "BTCUSDT",
1710
+ // "currency": "USDT",
1711
+ // "action": "1",
1712
+ // "tradeType": "1",
1713
+ // "execQtyRq": "0.003",
1714
+ // "execPriceRp": "64935",
1715
+ // "side": "2",
1716
+ // "orderQtyRq": "0.003",
1717
+ // "priceRp": "51600",
1718
+ // "execValueRv": "194.805",
1719
+ // "feeRateRr": "0.000495",
1720
+ // "execFeeRv": "0",
1721
+ // "ordType": "3",
1722
+ // "execId": "XXXXXX",
1723
+ // "execStatus": "7",
1724
+ // "posSide": "1",
1725
+ // "ptFeeRv": "0.110012249248",
1726
+ // "ptPriceRp": "0.876524893"
1707
1727
  //
1708
1728
  let priceString;
1709
1729
  let amountString;
@@ -1760,10 +1780,19 @@ class phemex extends phemex$1 {
1760
1780
  priceString = this.safeString(trade, 'execPriceRp');
1761
1781
  amountString = this.safeString(trade, 'execQtyRq');
1762
1782
  costString = this.safeString(trade, 'execValueRv');
1763
- feeCostString = this.safeString(trade, 'execFeeRv');
1783
+ feeCostString = this.omitZero(this.safeString(trade, 'execFeeRv'));
1764
1784
  feeRateString = this.safeString(trade, 'feeRateRr');
1765
- const currencyId = this.safeString(trade, 'currency');
1766
- feeCurrencyCode = this.safeCurrencyCode(currencyId);
1785
+ if (feeCostString !== undefined) {
1786
+ const currencyId = this.safeString(trade, 'currency');
1787
+ feeCurrencyCode = this.safeCurrencyCode(currencyId);
1788
+ }
1789
+ else {
1790
+ const ptFeeRv = this.omitZero(this.safeString(trade, 'ptFeeRv'));
1791
+ if (ptFeeRv !== undefined) {
1792
+ feeCostString = ptFeeRv;
1793
+ feeCurrencyCode = 'PT';
1794
+ }
1795
+ }
1767
1796
  }
1768
1797
  else {
1769
1798
  side = this.safeStringLower(trade, 'side');
@@ -1776,7 +1805,7 @@ class phemex extends phemex$1 {
1776
1805
  amountString = this.fromEv(this.safeString(trade, 'execBaseQtyEv'), market);
1777
1806
  amountString = this.safeString(trade, 'execQty', amountString);
1778
1807
  costString = this.fromEr(this.safeString2(trade, 'execQuoteQtyEv', 'execValueEv'), market);
1779
- feeCostString = this.fromEr(this.safeString(trade, 'execFeeEv'), market);
1808
+ feeCostString = this.fromEr(this.omitZero(this.safeString(trade, 'execFeeEv')), market);
1780
1809
  if (feeCostString !== undefined) {
1781
1810
  feeRateString = this.fromEr(this.safeString(trade, 'feeRateEr'), market);
1782
1811
  if (market['spot']) {
@@ -1790,6 +1819,12 @@ class phemex extends phemex$1 {
1790
1819
  }
1791
1820
  }
1792
1821
  }
1822
+ else {
1823
+ feeCostString = this.safeString(trade, 'ptFeeRv');
1824
+ if (feeCostString !== undefined) {
1825
+ feeCurrencyCode = 'PT';
1826
+ }
1827
+ }
1793
1828
  }
1794
1829
  fee = {
1795
1830
  'cost': feeCostString,
@@ -3872,7 +3907,8 @@ class phemex extends phemex$1 {
3872
3907
  request['limit'] = limit;
3873
3908
  }
3874
3909
  let response = undefined;
3875
- if (market['settle'] === 'USDT') {
3910
+ const isUsdt = market['settle'] === 'USDT';
3911
+ if (isUsdt) {
3876
3912
  response = await this.privateGetApiDataGFuturesFundingFees(this.extend(request, params));
3877
3913
  }
3878
3914
  else {
@@ -3887,13 +3923,13 @@ class phemex extends phemex$1 {
3887
3923
  // {
3888
3924
  // "symbol": "BTCUSD",
3889
3925
  // "currency": "BTC",
3890
- // "execQty": 18,
3926
+ // "execQty": 18, // "execQty" regular, but "execQtyRq" in hedge
3891
3927
  // "side": "Buy",
3892
- // "execPriceEp": 360086455,
3893
- // "execValueEv": 49987,
3894
- // "fundingRateEr": 10000,
3895
- // "feeRateEr": 10000,
3896
- // "execFeeEv": 5,
3928
+ // "execPriceEp": 360086455, // "execPriceEp" regular, but "execPriceRp" in hedge
3929
+ // "execValueEv": 49987, // "execValueEv" regular, but "execValueRv" in hedge
3930
+ // "fundingRateEr": 10000, // "fundingRateEr" regular, but "fundingRateRr" in hedge
3931
+ // "feeRateEr": 10000, // "feeRateEr" regular, but "feeRateRr" in hedge
3932
+ // "execFeeEv": 5, // "execFeeEv" regular, but "execFeeRv" in hedge
3897
3933
  // "createTime": 1651881600000
3898
3934
  // }
3899
3935
  // ]
@@ -3906,18 +3942,34 @@ class phemex extends phemex$1 {
3906
3942
  for (let i = 0; i < rows.length; i++) {
3907
3943
  const entry = rows[i];
3908
3944
  const timestamp = this.safeInteger(entry, 'createTime');
3945
+ const execFee = this.safeString2(entry, 'execFeeEv', 'execFeeRv');
3946
+ const currencyCode = this.safeCurrencyCode(this.safeString(entry, 'currency'));
3909
3947
  result.push({
3910
3948
  'info': entry,
3911
3949
  'symbol': this.safeString(entry, 'symbol'),
3912
- 'code': this.safeCurrencyCode(this.safeString(entry, 'currency')),
3950
+ 'code': currencyCode,
3913
3951
  'timestamp': timestamp,
3914
3952
  'datetime': this.iso8601(timestamp),
3915
3953
  'id': undefined,
3916
- 'amount': this.fromEv(this.safeString(entry, 'execFeeEv'), market),
3954
+ 'amount': this.parseFundingFeeToPrecision(execFee, market, currencyCode),
3917
3955
  });
3918
3956
  }
3919
3957
  return result;
3920
3958
  }
3959
+ parseFundingFeeToPrecision(value, market = undefined, currencyCode = undefined) {
3960
+ if (value === undefined || currencyCode === undefined) {
3961
+ return value;
3962
+ }
3963
+ // it was confirmed by phemex support, that USDT contracts use direct amounts in funding fees, while USD & INVERSE needs 'valueScale'
3964
+ const isUsdt = market['settle'] === 'USDT';
3965
+ if (!isUsdt) {
3966
+ const currency = this.safeCurrency(currencyCode);
3967
+ const scale = this.safeString(currency['info'], 'valueScale');
3968
+ const tickPrecision = this.parsePrecision(scale);
3969
+ value = Precise["default"].stringMul(value, tickPrecision);
3970
+ }
3971
+ return value;
3972
+ }
3921
3973
  async fetchFundingRate(symbol, params = {}) {
3922
3974
  /**
3923
3975
  * @method
@@ -843,31 +843,36 @@ class poloniexfutures extends poloniexfutures$1 {
843
843
  handleDelta(orderbook, delta) {
844
844
  //
845
845
  // {
846
- // "sequence": 18, // Sequence number which is used to judge the continuity of pushed messages
847
- // "change": "5000.0,sell,83" // Price, side, quantity
848
- // "timestamp": 1551770400000
849
- // }
846
+ // sequence: 123677914,
847
+ // lastSequence: 123677913,
848
+ // change: '80.36,buy,4924',
849
+ // changes: [ '80.19,buy,0',"80.15,buy,10794" ],
850
+ // timestamp: 1715643483528
851
+ // },
850
852
  //
851
853
  const sequence = this.safeInteger(delta, 'sequence');
854
+ const lastSequence = this.safeInteger(delta, 'lastSequence');
852
855
  const nonce = this.safeInteger(orderbook, 'nonce');
853
- if (nonce !== sequence - 1) {
854
- const checksum = this.safeBool(this.options, 'checksum', true);
855
- if (checksum) {
856
- // todo: client.reject from handleOrderBookMessage properly
857
- throw new errors.InvalidNonce(this.id + ' watchOrderBook received an out-of-order nonce');
858
- }
856
+ if (nonce > sequence) {
857
+ return;
858
+ }
859
+ if (nonce !== lastSequence) {
860
+ throw new errors.InvalidNonce(this.id + ' watchOrderBook received an out-of-order nonce');
861
+ }
862
+ const changes = this.safeList(delta, 'changes');
863
+ for (let i = 0; i < changes.length; i++) {
864
+ const change = changes[i];
865
+ const splitChange = change.split(',');
866
+ const price = this.safeNumber(splitChange, 0);
867
+ const side = this.safeString(splitChange, 1);
868
+ const size = this.safeNumber(splitChange, 2);
869
+ const orderBookSide = (side === 'buy') ? orderbook['bids'] : orderbook['asks'];
870
+ orderBookSide.store(price, size);
859
871
  }
860
- const change = this.safeString(delta, 'change');
861
- const splitChange = change.split(',');
862
- const price = this.safeNumber(splitChange, 0);
863
- const side = this.safeString(splitChange, 1);
864
- const size = this.safeNumber(splitChange, 2);
865
872
  const timestamp = this.safeInteger(delta, 'timestamp');
866
873
  orderbook['timestamp'] = timestamp;
867
874
  orderbook['datetime'] = this.iso8601(timestamp);
868
875
  orderbook['nonce'] = sequence;
869
- const orderBookSide = (side === 'buy') ? orderbook['bids'] : orderbook['asks'];
870
- orderBookSide.store(price, size);
871
876
  }
872
877
  handleBalance(client, message) {
873
878
  //
@@ -205,41 +205,22 @@ class probit extends probit$1 {
205
205
  },
206
206
  },
207
207
  'commonCurrencies': {
208
- 'AUTO': 'Cube',
209
- 'AZU': 'Azultec',
210
- 'BCC': 'BCC',
211
- 'BDP': 'BidiPass',
212
- 'BIRD': 'Birdchain',
213
- 'BTCBEAR': 'BEAR',
214
- 'BTCBULL': 'BULL',
208
+ 'BB': 'Baby Bali',
215
209
  'CBC': 'CryptoBharatCoin',
216
- 'CHE': 'Chellit',
217
- 'CLR': 'Color Platform',
218
210
  'CTK': 'Cryptyk',
219
211
  'CTT': 'Castweet',
220
- 'DIP': 'Dipper',
221
212
  'DKT': 'DAKOTA',
222
213
  'EGC': 'EcoG9coin',
223
214
  'EPS': 'Epanus',
224
215
  'FX': 'Fanzy',
225
- 'GDT': 'Gorilla Diamond',
226
216
  'GM': 'GM Holding',
227
217
  'GOGOL': 'GOL',
228
218
  'GOL': 'Goldofir',
229
- 'GRB': 'Global Reward Bank',
230
- 'HBC': 'Hybrid Bank Cash',
231
219
  'HUSL': 'The Hustle App',
232
220
  'LAND': 'Landbox',
233
- 'LBK': 'Legal Block',
234
- 'ORC': 'Oracle System',
235
- 'PXP': 'PIXSHOP COIN',
236
- 'PYE': 'CreamPYE',
237
- 'ROOK': 'Reckoon',
238
- 'SOC': 'Soda Coin',
239
221
  'SST': 'SocialSwap',
240
222
  'TCT': 'Top Coin Token',
241
223
  'TOR': 'Torex',
242
- 'TPAY': 'Tetra Pay',
243
224
  'UNI': 'UNICORN Token',
244
225
  'UNISWAP': 'UNI',
245
226
  },
@@ -232,6 +232,15 @@ class whitebit extends whitebit$1 {
232
232
  'convert/estimate',
233
233
  'convert/confirm',
234
234
  'convert/history',
235
+ 'sub-account/create',
236
+ 'sub-account/delete',
237
+ 'sub-account/edit',
238
+ 'sub-account/list',
239
+ 'sub-account/transfer',
240
+ 'sub-account/block',
241
+ 'sub-account/unblock',
242
+ 'sub-account/balances',
243
+ 'sub-account/transfer/history',
235
244
  ],
236
245
  },
237
246
  },
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, Conversion } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
7
- declare const version = "4.3.20";
7
+ declare const version = "4.3.22";
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, MarketClosed, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.21';
41
+ const version = '4.3.23';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -86,6 +86,15 @@ interface Exchange {
86
86
  v4PrivatePostConvertEstimate(params?: {}): Promise<implicitReturnType>;
87
87
  v4PrivatePostConvertConfirm(params?: {}): Promise<implicitReturnType>;
88
88
  v4PrivatePostConvertHistory(params?: {}): Promise<implicitReturnType>;
89
+ v4PrivatePostSubAccountCreate(params?: {}): Promise<implicitReturnType>;
90
+ v4PrivatePostSubAccountDelete(params?: {}): Promise<implicitReturnType>;
91
+ v4PrivatePostSubAccountEdit(params?: {}): Promise<implicitReturnType>;
92
+ v4PrivatePostSubAccountList(params?: {}): Promise<implicitReturnType>;
93
+ v4PrivatePostSubAccountTransfer(params?: {}): Promise<implicitReturnType>;
94
+ v4PrivatePostSubAccountBlock(params?: {}): Promise<implicitReturnType>;
95
+ v4PrivatePostSubAccountUnblock(params?: {}): Promise<implicitReturnType>;
96
+ v4PrivatePostSubAccountBalances(params?: {}): Promise<implicitReturnType>;
97
+ v4PrivatePostSubAccountTransferHistory(params?: {}): Promise<implicitReturnType>;
89
98
  }
90
99
  declare abstract class Exchange extends _Exchange {
91
100
  }
package/js/src/binance.js CHANGED
@@ -9692,7 +9692,7 @@ export default class binance extends Exchange {
9692
9692
  await this.loadMarkets();
9693
9693
  // by default cache the leverage bracket
9694
9694
  // it contains useful stuff like the maintenance margin and initial margin for positions
9695
- const leverageBrackets = this.safeDict(this.options, 'leverageBrackets', {});
9695
+ const leverageBrackets = this.safeDict(this.options, 'leverageBrackets');
9696
9696
  if ((leverageBrackets === undefined) || (reload)) {
9697
9697
  const defaultType = this.safeString(this.options, 'defaultType', 'future');
9698
9698
  const type = this.safeString(params, 'type', defaultType);
@@ -1813,6 +1813,11 @@ export default class coinbase extends Exchange {
1813
1813
  if (symbols !== undefined) {
1814
1814
  request['product_ids'] = this.marketIds(symbols);
1815
1815
  }
1816
+ let marketType = undefined;
1817
+ [marketType, params] = this.handleMarketTypeAndParams('fetchTickers', this.getMarketFromSymbols(symbols), params, 'default');
1818
+ if (marketType !== undefined && marketType !== 'default') {
1819
+ request['product_type'] = (marketType === 'swap') ? 'FUTURE' : 'SPOT';
1820
+ }
1816
1821
  const response = await this.v3PublicGetBrokerageMarketProducts(this.extend(request, params));
1817
1822
  //
1818
1823
  // {
@@ -81,18 +81,18 @@ export default class coinex extends Exchange {
81
81
  info: any;
82
82
  symbol: string;
83
83
  markPrice: number;
84
- indexPrice: number;
84
+ indexPrice: any;
85
85
  interestRate: any;
86
86
  estimatedSettlePrice: any;
87
- timestamp: number;
88
- datetime: string;
87
+ timestamp: any;
88
+ datetime: any;
89
89
  fundingRate: number;
90
90
  fundingTimestamp: number;
91
91
  fundingDatetime: string;
92
92
  nextFundingRate: number;
93
- nextFundingTimestamp: any;
94
- nextFundingDatetime: any;
95
- previousFundingRate: number;
93
+ nextFundingTimestamp: number;
94
+ nextFundingDatetime: string;
95
+ previousFundingRate: any;
96
96
  previousFundingTimestamp: any;
97
97
  previousFundingDatetime: any;
98
98
  }>;
@@ -100,18 +100,18 @@ export default class coinex extends Exchange {
100
100
  info: any;
101
101
  symbol: string;
102
102
  markPrice: number;
103
- indexPrice: number;
103
+ indexPrice: any;
104
104
  interestRate: any;
105
105
  estimatedSettlePrice: any;
106
- timestamp: number;
107
- datetime: string;
106
+ timestamp: any;
107
+ datetime: any;
108
108
  fundingRate: number;
109
109
  fundingTimestamp: number;
110
110
  fundingDatetime: string;
111
111
  nextFundingRate: number;
112
- nextFundingTimestamp: any;
113
- nextFundingDatetime: any;
114
- previousFundingRate: number;
112
+ nextFundingTimestamp: number;
113
+ nextFundingDatetime: string;
114
+ previousFundingRate: any;
115
115
  previousFundingTimestamp: any;
116
116
  previousFundingDatetime: any;
117
117
  };