ccxt 4.2.95 → 4.2.96

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.
@@ -285,7 +285,13 @@ class gemini extends gemini$1 {
285
285
  'ATOM': 'cosmos',
286
286
  'DOT': 'polkadot',
287
287
  },
288
- 'nonce': 'milliseconds', // if getting a Network 400 error change to seconds
288
+ 'nonce': 'milliseconds',
289
+ 'conflictingMarkets': {
290
+ 'paxgusd': {
291
+ 'base': 'PAXG',
292
+ 'quote': 'USD',
293
+ },
294
+ },
289
295
  },
290
296
  });
291
297
  }
@@ -679,17 +685,29 @@ class gemini extends gemini$1 {
679
685
  const marketIdUpper = marketId.toUpperCase();
680
686
  const isPerp = (marketIdUpper.indexOf('PERP') >= 0);
681
687
  const marketIdWithoutPerp = marketIdUpper.replace('PERP', '');
682
- const quoteQurrencies = this.handleOption('fetchMarketsFromAPI', 'quoteCurrencies', []);
683
- for (let i = 0; i < quoteQurrencies.length; i++) {
684
- const quoteCurrency = quoteQurrencies[i];
685
- if (marketIdWithoutPerp.endsWith(quoteCurrency)) {
686
- const quoteLength = this.parseToInt(-1 * quoteCurrency.length);
687
- baseId = marketIdWithoutPerp.slice(0, quoteLength);
688
- quoteId = quoteCurrency;
689
- if (isPerp) {
690
- settleId = quoteCurrency; // always same
688
+ const conflictingMarkets = this.safeDict(this.options, 'conflictingMarkets', {});
689
+ const lowerCaseId = marketIdWithoutPerp.toLowerCase();
690
+ if (lowerCaseId in conflictingMarkets) {
691
+ const conflictingMarket = conflictingMarkets[lowerCaseId];
692
+ baseId = conflictingMarket['base'];
693
+ quoteId = conflictingMarket['quote'];
694
+ if (isPerp) {
695
+ settleId = conflictingMarket['quote'];
696
+ }
697
+ }
698
+ else {
699
+ const quoteCurrencies = this.handleOption('fetchMarketsFromAPI', 'quoteCurrencies', []);
700
+ for (let i = 0; i < quoteCurrencies.length; i++) {
701
+ const quoteCurrency = quoteCurrencies[i];
702
+ if (marketIdWithoutPerp.endsWith(quoteCurrency)) {
703
+ const quoteLength = this.parseToInt(-1 * quoteCurrency.length);
704
+ baseId = marketIdWithoutPerp.slice(0, quoteLength);
705
+ quoteId = quoteCurrency;
706
+ if (isPerp) {
707
+ settleId = quoteCurrency; // always same
708
+ }
709
+ break;
691
710
  }
692
- break;
693
711
  }
694
712
  }
695
713
  }
@@ -140,6 +140,11 @@ class coinbase extends coinbase$1 {
140
140
  // "low_52_w": "15460",
141
141
  // "high_52_w": "48240",
142
142
  // "price_percent_chg_24_h": "-4.15775596190603"
143
+ // new as of 2024-04-12
144
+ // "best_bid":"21835.29",
145
+ // "best_bid_quantity": "0.02000000",
146
+ // "best_ask":"23011.18",
147
+ // "best_ask_quantity": "0.01500000"
143
148
  // }
144
149
  // ]
145
150
  // }
@@ -165,6 +170,11 @@ class coinbase extends coinbase$1 {
165
170
  // "low_52_w": "0.04908",
166
171
  // "high_52_w": "0.1801",
167
172
  // "price_percent_chg_24_h": "0.50177456859626"
173
+ // new as of 2024-04-12
174
+ // "best_bid":"0.07989",
175
+ // "best_bid_quantity": "500.0",
176
+ // "best_ask":"0.08308",
177
+ // "best_ask_quantity": "300.0"
168
178
  // }
169
179
  // ]
170
180
  // }
@@ -219,6 +229,11 @@ class coinbase extends coinbase$1 {
219
229
  // "low_52_w": "0.04908",
220
230
  // "high_52_w": "0.1801",
221
231
  // "price_percent_chg_24_h": "0.50177456859626"
232
+ // new as of 2024-04-12
233
+ // "best_bid":"0.07989",
234
+ // "best_bid_quantity": "500.0",
235
+ // "best_ask":"0.08308",
236
+ // "best_ask_quantity": "300.0"
222
237
  // }
223
238
  //
224
239
  const marketId = this.safeString(ticker, 'product_id');
@@ -231,10 +246,10 @@ class coinbase extends coinbase$1 {
231
246
  'datetime': this.iso8601(timestamp),
232
247
  'high': this.safeString(ticker, 'high_24_h'),
233
248
  'low': this.safeString(ticker, 'low_24_h'),
234
- 'bid': undefined,
235
- 'bidVolume': undefined,
236
- 'ask': undefined,
237
- 'askVolume': undefined,
249
+ 'bid': this.safeString(ticker, 'best_bid'),
250
+ 'bidVolume': this.safeString(ticker, 'best_bid_quantity'),
251
+ 'ask': this.safeString(ticker, 'best_ask'),
252
+ 'askVolume': this.safeString(ticker, 'best_ask_quantity'),
238
253
  'vwap': undefined,
239
254
  'open': undefined,
240
255
  'close': last,
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, 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.2.94";
7
+ declare const version = "4.2.95";
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, 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.2.95';
41
+ const version = '4.2.96';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -82,6 +82,7 @@ interface Exchange {
82
82
  v3PrivatePostBrokerageConvertTradeTradeId(params?: {}): Promise<implicitReturnType>;
83
83
  v3PrivatePostBrokerageCfmSweepsSchedule(params?: {}): Promise<implicitReturnType>;
84
84
  v3PrivatePostBrokerageIntxAllocate(params?: {}): Promise<implicitReturnType>;
85
+ v3PrivatePostBrokerageOrdersClosePosition(params?: {}): Promise<implicitReturnType>;
85
86
  v3PrivatePutBrokeragePortfoliosPortfolioUuid(params?: {}): Promise<implicitReturnType>;
86
87
  v3PrivateDeleteBrokeragePortfoliosPortfolioUuid(params?: {}): Promise<implicitReturnType>;
87
88
  v3PrivateDeleteBrokerageCfmSweeps(params?: {}): Promise<implicitReturnType>;
@@ -5,7 +5,7 @@ import { Hex } from '../../static_dependencies/noble-curves/abstract/utils.js';
5
5
  declare type Digest = 'binary' | 'hex' | 'base64';
6
6
  declare const hash: (request: Input, hash: CHash, digest?: Digest) => any;
7
7
  declare const hmac: (request: Input, secret: Input, hash: CHash, digest?: Digest) => any;
8
- declare function ecdsa(request: Hex, secret: Hex, curve: CurveFn, prehash?: CHash): {
8
+ declare function ecdsa(request: Hex, secret: Hex, curve: CurveFn, prehash?: CHash, fixedLength?: boolean): {
9
9
  r: string;
10
10
  s: string;
11
11
  v: number;
@@ -11,6 +11,7 @@ import { Base64 } from '../../static_dependencies/jsencrypt/lib/asn1js/base64.js
11
11
  import { ASN1 } from "../../static_dependencies/jsencrypt/lib/asn1js/asn1.js";
12
12
  import { secp256k1 } from '../../static_dependencies/noble-curves/secp256k1.js';
13
13
  import { P256 } from '../../static_dependencies/noble-curves/p256.js';
14
+ import { numberToBytesLE } from '../../static_dependencies/noble-curves/abstract/utils.js';
14
15
  /* ------------------------------------------------------------------------ */
15
16
  const encoders = {
16
17
  binary: x => x,
@@ -32,7 +33,7 @@ const hmac = (request, secret, hash, digest = 'hex') => {
32
33
  return encoders[digest](binary);
33
34
  };
34
35
  /* ............................................. */
35
- function ecdsa(request, secret, curve, prehash = null) {
36
+ function ecdsa(request, secret, curve, prehash = null, fixedLength = false) {
36
37
  if (prehash) {
37
38
  request = hash(request, prehash, 'hex');
38
39
  }
@@ -66,7 +67,19 @@ function ecdsa(request, secret, curve, prehash = null) {
66
67
  throw new Error('Unsupported key format');
67
68
  }
68
69
  }
69
- const signature = curve.sign(request, secret);
70
+ let signature = curve.sign(request, secret, {
71
+ lowS: true,
72
+ });
73
+ const minimumSize = (BigInt(1) << (BigInt(8) * BigInt(31))) - BigInt(1);
74
+ const halfOrder = curve.CURVE.n / BigInt(2);
75
+ let counter = 0;
76
+ while (fixedLength && (signature.r > halfOrder || signature.r <= minimumSize || signature.s <= minimumSize)) {
77
+ signature = curve.sign(request, secret, {
78
+ lowS: true,
79
+ extraEntropy: numberToBytesLE(BigInt(counter), 32)
80
+ });
81
+ counter += 1;
82
+ }
70
83
  return {
71
84
  'r': signature.r.toString(16),
72
85
  's': signature.s.toString(16),
@@ -40,8 +40,8 @@ function jwt(request, secret, hash, isRSA = false, opts = {}) {
40
40
  }
41
41
  else if (algoType === 'ES') {
42
42
  const signedHash = ecdsa(token, utf8.encode(secret), P256, hash);
43
- const r = (signedHash.r.length === 64) ? signedHash.r : '0' + signedHash.r;
44
- const s = (signedHash.s.length === 64) ? signedHash.s : '0' + signedHash.s;
43
+ const r = signedHash.r.padStart(64, '0');
44
+ const s = signedHash.s.padStart(64, '0');
45
45
  signature = urlencodeBase64(binaryToBase64(base16ToBinary(r + s)));
46
46
  }
47
47
  return [token, signature].join('.');
@@ -129,6 +129,7 @@ export interface OrderBook {
129
129
  datetime: Str;
130
130
  timestamp: Int;
131
131
  nonce: Int;
132
+ symbol: Str;
132
133
  }
133
134
  export interface Ticker {
134
135
  symbol: string;
@@ -10,6 +10,7 @@ declare class OrderBook implements CustomOrderBookProp {
10
10
  timestamp: Int;
11
11
  datetime: Str;
12
12
  nonce: Int;
13
+ symbol: Str;
13
14
  constructor(snapshot?: {}, depth?: any);
14
15
  limit(): this;
15
16
  update(snapshot: any): this;
@@ -4,7 +4,7 @@ interface IOrderBookSide<T> extends Array<T> {
4
4
  storeArray(array: any[]): any;
5
5
  limit(): any;
6
6
  }
7
- declare class OrderBookSide implements IOrderBookSide extends Array {
7
+ declare class OrderBookSide extends Array implements IOrderBookSide {
8
8
  constructor(deltas?: any[], depth?: any);
9
9
  storeArray(delta: any): void;
10
10
  store(price: any, size: any): void;
@@ -14,7 +14,7 @@ declare class CountedOrderBookSide extends OrderBookSide {
14
14
  store(price: any, size: any, count: any): void;
15
15
  storeArray(delta: any): void;
16
16
  }
17
- declare class IndexedOrderBookSide implements IOrderBookSide extends Array {
17
+ declare class IndexedOrderBookSide extends Array implements IOrderBookSide {
18
18
  constructor(deltas?: any[], depth?: number);
19
19
  store(price: any, size: any, id: any): void;
20
20
  storeArray(delta: any): void;
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/coinbase.js';
2
- import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies, MarketInterface } from './base/types.js';
3
3
  /**
4
4
  * @class coinbase
5
5
  * @augments Exchange
@@ -10,6 +10,7 @@ export default class coinbase extends Exchange {
10
10
  fetchAccounts(params?: {}): Promise<Account[]>;
11
11
  fetchAccountsV2(params?: {}): Promise<Account[]>;
12
12
  fetchAccountsV3(params?: {}): Promise<Account[]>;
13
+ fetchPortfolios(params?: {}): Promise<Account[]>;
13
14
  parseAccount(account: any): {
14
15
  id: string;
15
16
  type: string;
@@ -33,6 +34,8 @@ export default class coinbase extends Exchange {
33
34
  fetchMarkets(params?: {}): Promise<Market[]>;
34
35
  fetchMarketsV2(params?: {}): Promise<any[]>;
35
36
  fetchMarketsV3(params?: {}): Promise<any[]>;
37
+ parseSpotMarket(market: any, feeTier: any): MarketInterface;
38
+ parseContractMarket(market: any, feeTier: any): MarketInterface;
36
39
  fetchCurrenciesFromCache(params?: {}): Promise<import("./base/types.js").Dictionary<any>>;
37
40
  fetchCurrencies(params?: {}): Promise<Currencies>;
38
41
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
@@ -101,6 +104,10 @@ export default class coinbase extends Exchange {
101
104
  };
102
105
  deposit(code: string, amount: number, id: string, params?: {}): Promise<Transaction>;
103
106
  fetchDeposit(id: string, code?: Str, params?: {}): Promise<Transaction>;
107
+ closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
108
+ fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
109
+ fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
110
+ parsePosition(position: any, market?: Market): import("./base/types.js").Position;
104
111
  sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
105
112
  url: string;
106
113
  method: string;