ccxt 4.2.94 → 4.2.95

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.
@@ -5,74 +5,37 @@
5
5
  // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
6
 
7
7
  /* eslint-disable max-classes-per-file */
8
- // import { errorHierarchy } from './errorHierarchy.js';
9
- // Commented out since I'm not sure this is mandatory anymore
10
- // and does not work out of the box with esm
11
- // /* ------------------------------------------------------------------------ */
12
- // function subclass (BaseClass, classes, namespace = {}) {
13
- // for (const [className, subclasses] of Object.entries (classes)) {
14
- // const Class = Object.assign (namespace, {
15
- // /* By creating a named property, we trick compiler to assign our class constructor function a name.
16
- // Otherwise, all our error constructors would be shown as [Function: Error] in the debugger! And
17
- // the super-useful `e.constructor.name` magic wouldn't work — we then would have no chance to
18
- // obtain a error type string from an error instance programmatically! */
19
- // [className]: class extends BaseClass {
20
- // constructor (message) {
21
- // super (message)
22
- // /* A workaround to make `instanceof` work on custom Error classes in transpiled ES5.
23
- // See my blog post for the explanation of this hack:
24
- // https://medium.com/@xpl/javascript-deriving-from-error-properly-8d2f8f315801 */
25
- // this.constructor = Class
26
- // this.__proto__ = Class.prototype
27
- // this.name = className
28
- // this.message = message
29
- // // https://github.com/Microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work
30
- // Object.setPrototypeOf (this, Class.prototype)
31
- // }
32
- // }
33
- // })[className]
34
- // subclass (Class, subclasses, namespace)
35
- // }
36
- // return namespace
37
- // }
38
8
  class BaseError extends Error {
39
9
  constructor(message) {
40
10
  super(message);
41
11
  this.name = 'BaseError';
42
12
  }
43
13
  }
44
- // Exchange Error errors
45
- class ExchangeError extends Error {
14
+ class ExchangeError extends BaseError {
46
15
  constructor(message) {
47
16
  super(message);
48
17
  this.name = 'ExchangeError';
49
18
  }
50
19
  }
51
- class ExchangeClosedByUser extends Error {
52
- constructor(message) {
53
- super(message);
54
- this.name = 'ExchangeClosedByUser';
55
- }
56
- }
57
20
  class AuthenticationError extends ExchangeError {
58
21
  constructor(message) {
59
22
  super(message);
60
23
  this.name = 'AuthenticationError';
61
24
  }
62
25
  }
63
- class PermissionDenied extends ExchangeError {
26
+ class PermissionDenied extends AuthenticationError {
64
27
  constructor(message) {
65
28
  super(message);
66
29
  this.name = 'PermissionDenied';
67
30
  }
68
31
  }
69
- class AccountNotEnabled extends ExchangeError {
32
+ class AccountNotEnabled extends PermissionDenied {
70
33
  constructor(message) {
71
34
  super(message);
72
35
  this.name = 'AccountNotEnabled';
73
36
  }
74
37
  }
75
- class AccountSuspended extends ExchangeError {
38
+ class AccountSuspended extends AuthenticationError {
76
39
  constructor(message) {
77
40
  super(message);
78
41
  this.name = 'AccountSuspended';
@@ -90,16 +53,16 @@ class BadRequest extends ExchangeError {
90
53
  this.name = 'BadRequest';
91
54
  }
92
55
  }
93
- class OperationRejected extends ExchangeError {
56
+ class BadSymbol extends BadRequest {
94
57
  constructor(message) {
95
58
  super(message);
96
- this.name = 'OperationRejected';
59
+ this.name = 'BadSymbol';
97
60
  }
98
61
  }
99
- class BadSymbol extends BadRequest {
62
+ class OperationRejected extends ExchangeError {
100
63
  constructor(message) {
101
64
  super(message);
102
- this.name = 'BadSymbol';
65
+ this.name = 'OperationRejected';
103
66
  }
104
67
  }
105
68
  class NoChange extends OperationRejected {
@@ -120,7 +83,7 @@ class BadResponse extends ExchangeError {
120
83
  this.name = 'BadResponse';
121
84
  }
122
85
  }
123
- class NullResponse extends ExchangeError {
86
+ class NullResponse extends BadResponse {
124
87
  constructor(message) {
125
88
  super(message);
126
89
  this.name = 'NullResponse';
@@ -150,12 +113,6 @@ class InvalidOrder extends ExchangeError {
150
113
  this.name = 'InvalidOrder';
151
114
  }
152
115
  }
153
- class ContractUnavailable extends InvalidOrder {
154
- constructor(message) {
155
- super(message);
156
- this.name = 'ContractUnavailable';
157
- }
158
- }
159
116
  class OrderNotFound extends InvalidOrder {
160
117
  constructor(message) {
161
118
  super(message);
@@ -192,25 +149,36 @@ class DuplicateOrderId extends InvalidOrder {
192
149
  this.name = 'DuplicateOrderId';
193
150
  }
194
151
  }
152
+ class ContractUnavailable extends InvalidOrder {
153
+ constructor(message) {
154
+ super(message);
155
+ this.name = 'ContractUnavailable';
156
+ }
157
+ }
195
158
  class NotSupported extends ExchangeError {
196
159
  constructor(message) {
197
160
  super(message);
198
161
  this.name = 'NotSupported';
199
162
  }
200
163
  }
201
- class OperationFailed extends BaseError {
164
+ class ProxyError extends ExchangeError {
202
165
  constructor(message) {
203
166
  super(message);
204
- this.name = 'OperationFailed';
167
+ this.name = 'ProxyError';
205
168
  }
206
169
  }
207
- class ProxyError extends ExchangeError {
170
+ class ExchangeClosedByUser extends ExchangeError {
171
+ constructor(message) {
172
+ super(message);
173
+ this.name = 'ExchangeClosedByUser';
174
+ }
175
+ }
176
+ class OperationFailed extends BaseError {
208
177
  constructor(message) {
209
178
  super(message);
210
179
  this.name = 'OperationFailed';
211
180
  }
212
181
  }
213
- // Network error
214
182
  class NetworkError extends OperationFailed {
215
183
  constructor(message) {
216
184
  super(message);
@@ -253,13 +221,5 @@ class RequestTimeout extends NetworkError {
253
221
  this.name = 'RequestTimeout';
254
222
  }
255
223
  }
256
- /* ------------------------------------------------------------------------ */
257
- // export default subclass (
258
- // // Root class
259
- // Error,
260
- // // Derived class hierarchy
261
- // errorHierarchy
262
- // )
263
- const errors = { BaseError, ExchangeClosedByUser, 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, ContractUnavailable, NoChange, OperationRejected, OperationFailed, ProxyError };
264
- export { BaseError, ExchangeClosedByUser, 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, ContractUnavailable, NoChange, OperationRejected, OperationFailed, ProxyError };
265
- export default errors;
224
+ export { 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 };
225
+ export default { 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 };
@@ -1,8 +1,15 @@
1
+ import { IOrderBookSide } from './OrderBookSide.js';
2
+ import { Int, Str } from '../types.js';
1
3
  interface CustomOrderBookProp {
2
4
  cache: any[];
3
5
  }
4
6
  declare class OrderBook implements CustomOrderBookProp {
5
7
  cache: any[];
8
+ asks: IOrderBookSide<any>;
9
+ bids: IOrderBookSide<any>;
10
+ timestamp: Int;
11
+ datetime: Str;
12
+ nonce: Int;
6
13
  constructor(snapshot?: {}, depth?: any);
7
14
  limit(): this;
8
15
  update(snapshot: any): this;
@@ -8,12 +8,7 @@
8
8
  // @ts-nocheck
9
9
  import { iso8601 } from '../../base/functions/time.js';
10
10
  import { extend } from '../../base/functions/generic.js';
11
- import { Asks, Bids, CountedAsks, CountedBids, IndexedAsks, IndexedBids,
12
- // IncrementalAsks,
13
- // IncrementalBids,
14
- // IncrementalIndexedAsks,
15
- // IncrementalIndexedBids, // check this
16
- } from './OrderBookSide.js';
11
+ import { Asks, Bids, CountedAsks, CountedBids, IndexedAsks, IndexedBids } from './OrderBookSide.js';
17
12
  class OrderBook {
18
13
  constructor(snapshot = {}, depth = undefined) {
19
14
  this.cache = []; // make prop visible so we use typed OrderBooks
@@ -1,4 +1,10 @@
1
- declare class OrderBookSide extends Array {
1
+ interface IOrderBookSide<T> extends Array<T> {
2
+ store(price: any, size: any): any;
3
+ store(price: any, size: any, index: any): any;
4
+ storeArray(array: any[]): any;
5
+ limit(): any;
6
+ }
7
+ declare class OrderBookSide implements IOrderBookSide extends Array {
2
8
  constructor(deltas?: any[], depth?: any);
3
9
  storeArray(delta: any): void;
4
10
  store(price: any, size: any): void;
@@ -8,7 +14,7 @@ declare class CountedOrderBookSide extends OrderBookSide {
8
14
  store(price: any, size: any, count: any): void;
9
15
  storeArray(delta: any): void;
10
16
  }
11
- declare class IndexedOrderBookSide extends Array {
17
+ declare class IndexedOrderBookSide implements IOrderBookSide extends Array {
12
18
  constructor(deltas?: any[], depth?: number);
13
19
  store(price: any, size: any, id: any): void;
14
20
  storeArray(delta: any): void;
@@ -32,4 +38,4 @@ declare class IndexedAsks extends IndexedOrderBookSide {
32
38
  declare class IndexedBids extends IndexedOrderBookSide {
33
39
  get side(): boolean;
34
40
  }
35
- export { Asks, Bids, OrderBookSide, CountedAsks, CountedBids, CountedOrderBookSide, IndexedAsks, IndexedBids, IndexedOrderBookSide, };
41
+ export { Asks, Bids, OrderBookSide, CountedAsks, CountedBids, CountedOrderBookSide, IndexedAsks, IndexedBids, IndexedOrderBookSide, IOrderBookSide };
@@ -12,6 +12,11 @@
12
12
  // Author: github.com/frosty00
13
13
  // Email: carlo.revelli@berkeley.edu
14
14
  //
15
+ /**
16
+ *
17
+ * @param array
18
+ * @param x
19
+ */
15
20
  function bisectLeft(array, x) {
16
21
  let low = 0;
17
22
  let high = array.length - 1;
@@ -278,4 +283,4 @@ Asks, Bids, OrderBookSide,
278
283
  // count-based
279
284
  CountedAsks, CountedBids, CountedOrderBookSide,
280
285
  // order-id based
281
- IndexedAsks, IndexedBids, IndexedOrderBookSide, };
286
+ IndexedAsks, IndexedBids, IndexedOrderBookSide };
@@ -360,6 +360,12 @@ export default class bitstamp extends Exchange {
360
360
  'blur_address/': 1,
361
361
  'vext_withdrawal/': 1,
362
362
  'vext_address/': 1,
363
+ 'cspr_withdrawal/': 1,
364
+ 'cspr_address/': 1,
365
+ 'vchf_withdrawal/': 1,
366
+ 'vchf_address/': 1,
367
+ 'veur_withdrawal/': 1,
368
+ 'veur_address/': 1,
363
369
  },
364
370
  },
365
371
  },
package/js/src/coinex.js CHANGED
@@ -1091,8 +1091,8 @@ export default class coinex extends Exchange {
1091
1091
  * @method
1092
1092
  * @name coinex#fetchOrderBook
1093
1093
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1094
- * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market004_market_depth
1095
- * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http010_market_depth
1094
+ * @see https://docs.coinex.com/api/v2/spot/market/http/list-market-depth
1095
+ * @see https://docs.coinex.com/api/v2/futures/market/http/list-market-depth
1096
1096
  * @param {string} symbol unified symbol of the market to fetch the order book for
1097
1097
  * @param {int} [limit] the maximum amount of order book entries to return
1098
1098
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1104,65 +1104,71 @@ export default class coinex extends Exchange {
1104
1104
  limit = 20; // default
1105
1105
  }
1106
1106
  const request = {
1107
- 'market': this.marketId(symbol),
1108
- 'merge': '0',
1109
- 'limit': limit.toString(),
1107
+ 'market': market['id'],
1108
+ 'limit': limit,
1109
+ 'interval': '0',
1110
1110
  };
1111
1111
  let response = undefined;
1112
1112
  if (market['swap']) {
1113
- response = await this.v1PerpetualPublicGetMarketDepth(this.extend(request, params));
1113
+ response = await this.v2PublicGetFuturesDepth(this.extend(request, params));
1114
+ //
1115
+ // {
1116
+ // "code": 0,
1117
+ // "data": {
1118
+ // "depth": {
1119
+ // "asks": [
1120
+ // ["70851.94", "0.2119"],
1121
+ // ["70851.95", "0.0004"],
1122
+ // ["70851.96", "0.0004"]
1123
+ // ],
1124
+ // "bids": [
1125
+ // ["70851.93", "1.0314"],
1126
+ // ["70850.93", "0.0021"],
1127
+ // ["70850.42", "0.0306"]
1128
+ // ],
1129
+ // "checksum": 2956436260,
1130
+ // "last": "70851.94",
1131
+ // "updated_at": 1712824003252
1132
+ // },
1133
+ // "is_full": true,
1134
+ // "market": "BTCUSDT"
1135
+ // },
1136
+ // "message": "OK"
1137
+ // }
1138
+ //
1114
1139
  }
1115
1140
  else {
1116
- response = await this.v1PublicGetMarketDepth(this.extend(request, params));
1141
+ response = await this.v2PublicGetSpotDepth(this.extend(request, params));
1142
+ //
1143
+ // {
1144
+ // "code": 0,
1145
+ // "data": {
1146
+ // "depth": {
1147
+ // "asks": [
1148
+ // ["70875.31", "0.28670282"],
1149
+ // ["70875.32", "0.31008114"],
1150
+ // ["70875.42", "0.05876653"]
1151
+ // ],
1152
+ // "bids": [
1153
+ // ["70855.3", "0.00632222"],
1154
+ // ["70855.29", "0.36216834"],
1155
+ // ["70855.17", "0.10166802"]
1156
+ // ],
1157
+ // "checksum": 2313816665,
1158
+ // "last": "70857.19",
1159
+ // "updated_at": 1712823790987
1160
+ // },
1161
+ // "is_full": true,
1162
+ // "market": "BTCUSDT"
1163
+ // },
1164
+ // "message": "OK"
1165
+ // }
1166
+ //
1117
1167
  }
1118
- //
1119
- // Spot
1120
- //
1121
- // {
1122
- // "code": 0,
1123
- // "data": {
1124
- // "asks": [
1125
- // ["41056.33", "0.31727613"],
1126
- // ["41056.34", "1.05657294"],
1127
- // ["41056.35", "0.02346648"]
1128
- // ],
1129
- // "bids": [
1130
- // ["41050.61", "0.40618608"],
1131
- // ["41046.98", "0.13800000"],
1132
- // ["41046.56", "0.22579234"]
1133
- // ],
1134
- // "last": "41050.61",
1135
- // "time": 1650573220346
1136
- // },
1137
- // "message": "OK"
1138
- // }
1139
- //
1140
- // Swap
1141
- //
1142
- // {
1143
- // "code": 0,
1144
- // "data": {
1145
- // "asks": [
1146
- // ["40620.90", "0.0384"],
1147
- // ["40625.50", "0.0219"],
1148
- // ["40625.90", "0.3506"]
1149
- // ],
1150
- // "bids": [
1151
- // ["40620.89", "19.6861"],
1152
- // ["40620.80", "0.0012"],
1153
- // ["40619.87", "0.0365"]
1154
- // ],
1155
- // "last": "40620.89",
1156
- // "time": 1650587672406,
1157
- // "sign_price": "40619.32",
1158
- // "index_price": "40609.93"
1159
- // },
1160
- // "message": "OK"
1161
- // }
1162
- //
1163
- const result = this.safeValue(response, 'data', {});
1164
- const timestamp = this.safeInteger(result, 'time');
1165
- return this.parseOrderBook(result, symbol, timestamp);
1168
+ const data = this.safeDict(response, 'data', {});
1169
+ const depth = this.safeDict(data, 'depth', {});
1170
+ const timestamp = this.safeInteger(depth, 'updated_at');
1171
+ return this.parseOrderBook(depth, symbol, timestamp);
1166
1172
  }
1167
1173
  parseTrade(trade, market = undefined) {
1168
1174
  //
package/js/src/gemini.js CHANGED
@@ -686,7 +686,8 @@ export default class gemini extends Exchange {
686
686
  for (let i = 0; i < quoteQurrencies.length; i++) {
687
687
  const quoteCurrency = quoteQurrencies[i];
688
688
  if (marketIdWithoutPerp.endsWith(quoteCurrency)) {
689
- baseId = marketIdWithoutPerp.replace(quoteCurrency, '');
689
+ const quoteLength = this.parseToInt(-1 * quoteCurrency.length);
690
+ baseId = marketIdWithoutPerp.slice(0, quoteLength);
690
691
  quoteId = quoteCurrency;
691
692
  if (isPerp) {
692
693
  settleId = quoteCurrency; // always same
package/js/src/htx.d.ts CHANGED
@@ -38,6 +38,7 @@ export default class htx extends Exchange {
38
38
  costToPrecision(symbol: any, cost: any): any;
39
39
  fetchMarkets(params?: {}): Promise<Market[]>;
40
40
  fetchMarketsByTypeAndSubType(type: any, subType: any, params?: {}): Promise<any[]>;
41
+ tryGetSymbolFromFutureMarkets(symbolOrMarketId: string): any;
41
42
  parseTicker(ticker: any, market?: Market): Ticker;
42
43
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
43
44
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;