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