ccxt 4.1.50 → 4.1.52

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.
Files changed (183) hide show
  1. package/README.md +110 -113
  2. package/dist/ccxt.browser.js +1377 -2931
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +1 -7
  5. package/dist/cjs/src/alpaca.js +62 -64
  6. package/dist/cjs/src/ascendex.js +3 -1
  7. package/dist/cjs/src/base/Exchange.js +10 -0
  8. package/dist/cjs/src/bigone.js +60 -77
  9. package/dist/cjs/src/binance.js +1 -0
  10. package/dist/cjs/src/bingx.js +4 -11
  11. package/dist/cjs/src/bitbank.js +58 -59
  12. package/dist/cjs/src/bitbns.js +1 -0
  13. package/dist/cjs/src/bitfinex.js +1 -0
  14. package/dist/cjs/src/bitfinex2.js +1 -0
  15. package/dist/cjs/src/bitflyer.js +1 -0
  16. package/dist/cjs/src/bitget.js +3 -8
  17. package/dist/cjs/src/bithumb.js +1 -0
  18. package/dist/cjs/src/bitmart.js +10 -1
  19. package/dist/cjs/src/bitmex.js +114 -119
  20. package/dist/cjs/src/bitopro.js +63 -65
  21. package/dist/cjs/src/bitpanda.js +60 -60
  22. package/dist/cjs/src/bitrue.js +67 -71
  23. package/dist/cjs/src/bitso.js +1 -0
  24. package/dist/cjs/src/bitstamp.js +1 -0
  25. package/dist/cjs/src/bittrex.js +57 -57
  26. package/dist/cjs/src/bitvavo.js +10 -2
  27. package/dist/cjs/src/blockchaincom.js +2 -2
  28. package/dist/cjs/src/btcalpha.js +59 -60
  29. package/dist/cjs/src/btcmarkets.js +68 -69
  30. package/dist/cjs/src/btcturk.js +72 -74
  31. package/dist/cjs/src/bybit.js +3 -1
  32. package/dist/cjs/src/coinbase.js +7 -2
  33. package/dist/cjs/src/coinbasepro.js +1 -0
  34. package/dist/cjs/src/coincheck.js +1 -0
  35. package/dist/cjs/src/coinex.js +4 -0
  36. package/dist/cjs/src/coinlist.js +60 -60
  37. package/dist/cjs/src/coinmate.js +1 -0
  38. package/dist/cjs/src/coinsph.js +2 -4
  39. package/dist/cjs/src/cryptocom.js +1 -0
  40. package/dist/cjs/src/currencycom.js +2 -2
  41. package/dist/cjs/src/deribit.js +2 -0
  42. package/dist/cjs/src/digifinex.js +5 -2
  43. package/dist/cjs/src/exmo.js +1 -0
  44. package/dist/cjs/src/gate.js +2 -0
  45. package/dist/cjs/src/gemini.js +2 -0
  46. package/dist/cjs/src/hitbtc.js +4 -0
  47. package/dist/cjs/src/hollaex.js +2 -0
  48. package/dist/cjs/src/htx.js +4 -0
  49. package/dist/cjs/src/huobijp.js +2 -0
  50. package/dist/cjs/src/idex.js +2 -0
  51. package/dist/cjs/src/indodax.js +1 -0
  52. package/dist/cjs/src/kraken.js +10 -13
  53. package/dist/cjs/src/kucoin.js +6 -5
  54. package/dist/cjs/src/kuna.js +3 -1
  55. package/dist/cjs/src/latoken.js +1 -0
  56. package/dist/cjs/src/lbank.js +1 -0
  57. package/dist/cjs/src/lykke.js +2 -0
  58. package/dist/cjs/src/mercado.js +1 -0
  59. package/dist/cjs/src/mexc.js +2 -0
  60. package/dist/cjs/src/ndax.js +2 -0
  61. package/dist/cjs/src/novadax.js +1 -0
  62. package/dist/cjs/src/okcoin.js +2 -0
  63. package/dist/cjs/src/okx.js +2 -0
  64. package/dist/cjs/src/phemex.js +2 -0
  65. package/dist/cjs/src/poloniex.js +1 -0
  66. package/dist/cjs/src/pro/binance.js +5 -3
  67. package/dist/cjs/src/pro/coinbase.js +12 -3
  68. package/dist/cjs/src/pro/cryptocom.js +17 -17
  69. package/dist/cjs/src/pro/krakenfutures.js +24 -3
  70. package/dist/cjs/src/probit.js +4 -2
  71. package/dist/cjs/src/tidex.js +1 -0
  72. package/dist/cjs/src/timex.js +2 -0
  73. package/dist/cjs/src/upbit.js +2 -0
  74. package/dist/cjs/src/wavesexchange.js +2 -1
  75. package/dist/cjs/src/whitebit.js +1 -0
  76. package/dist/cjs/src/woo.js +1 -0
  77. package/dist/cjs/src/zaif.js +1 -0
  78. package/dist/cjs/src/zonda.js +1 -0
  79. package/js/ccxt.d.ts +2 -8
  80. package/js/ccxt.js +2 -6
  81. package/js/src/abstract/kraken.d.ts +0 -5
  82. package/js/src/alpaca.d.ts +3 -2
  83. package/js/src/alpaca.js +62 -64
  84. package/js/src/ascendex.js +3 -1
  85. package/js/src/base/Exchange.d.ts +2 -0
  86. package/js/src/base/Exchange.js +10 -0
  87. package/js/src/base/types.d.ts +6 -3
  88. package/js/src/bigone.d.ts +3 -3
  89. package/js/src/bigone.js +60 -77
  90. package/js/src/binance.js +1 -0
  91. package/js/src/bingx.d.ts +2 -2
  92. package/js/src/bingx.js +4 -11
  93. package/js/src/bitbank.d.ts +3 -2
  94. package/js/src/bitbank.js +58 -59
  95. package/js/src/bitbns.js +1 -0
  96. package/js/src/bitfinex.js +1 -0
  97. package/js/src/bitfinex2.js +1 -0
  98. package/js/src/bitflyer.js +1 -0
  99. package/js/src/bitget.d.ts +1 -2
  100. package/js/src/bitget.js +3 -8
  101. package/js/src/bithumb.js +1 -0
  102. package/js/src/bitmart.js +10 -1
  103. package/js/src/bitmex.d.ts +3 -2
  104. package/js/src/bitmex.js +114 -119
  105. package/js/src/bitopro.d.ts +3 -2
  106. package/js/src/bitopro.js +63 -65
  107. package/js/src/bitpanda.d.ts +3 -2
  108. package/js/src/bitpanda.js +60 -60
  109. package/js/src/bitrue.d.ts +3 -2
  110. package/js/src/bitrue.js +67 -71
  111. package/js/src/bitso.js +1 -0
  112. package/js/src/bitstamp.js +1 -0
  113. package/js/src/bittrex.d.ts +3 -2
  114. package/js/src/bittrex.js +57 -57
  115. package/js/src/bitvavo.js +10 -2
  116. package/js/src/blockchaincom.js +2 -2
  117. package/js/src/btcalpha.d.ts +3 -2
  118. package/js/src/btcalpha.js +59 -60
  119. package/js/src/btcmarkets.d.ts +3 -2
  120. package/js/src/btcmarkets.js +68 -69
  121. package/js/src/btcturk.d.ts +3 -2
  122. package/js/src/btcturk.js +72 -74
  123. package/js/src/bybit.js +3 -1
  124. package/js/src/coinbase.js +7 -2
  125. package/js/src/coinbasepro.js +1 -0
  126. package/js/src/coincheck.js +1 -0
  127. package/js/src/coinex.js +4 -0
  128. package/js/src/coinlist.d.ts +3 -2
  129. package/js/src/coinlist.js +60 -60
  130. package/js/src/coinmate.js +1 -0
  131. package/js/src/coinsph.js +2 -4
  132. package/js/src/cryptocom.js +1 -0
  133. package/js/src/currencycom.js +2 -2
  134. package/js/src/deribit.js +2 -0
  135. package/js/src/digifinex.js +5 -2
  136. package/js/src/exmo.js +1 -0
  137. package/js/src/gate.js +2 -0
  138. package/js/src/gemini.js +2 -0
  139. package/js/src/hitbtc.js +4 -0
  140. package/js/src/hollaex.js +2 -0
  141. package/js/src/htx.js +4 -0
  142. package/js/src/huobijp.js +2 -0
  143. package/js/src/idex.js +2 -0
  144. package/js/src/indodax.js +1 -0
  145. package/js/src/kraken.js +10 -13
  146. package/js/src/kucoin.js +6 -5
  147. package/js/src/kuna.js +3 -1
  148. package/js/src/latoken.js +1 -0
  149. package/js/src/lbank.js +1 -0
  150. package/js/src/lykke.js +2 -0
  151. package/js/src/mercado.js +1 -0
  152. package/js/src/mexc.js +2 -0
  153. package/js/src/ndax.js +2 -0
  154. package/js/src/novadax.js +1 -0
  155. package/js/src/okcoin.js +2 -0
  156. package/js/src/okx.js +2 -0
  157. package/js/src/phemex.js +2 -0
  158. package/js/src/poloniex.js +1 -0
  159. package/js/src/pro/binance.js +5 -3
  160. package/js/src/pro/coinbase.js +12 -3
  161. package/js/src/pro/cryptocom.js +17 -17
  162. package/js/src/pro/krakenfutures.js +24 -3
  163. package/js/src/probit.js +4 -2
  164. package/js/src/tidex.js +1 -0
  165. package/js/src/timex.js +2 -0
  166. package/js/src/upbit.js +2 -0
  167. package/js/src/wavesexchange.js +2 -1
  168. package/js/src/whitebit.js +1 -0
  169. package/js/src/woo.js +1 -0
  170. package/js/src/zaif.js +1 -0
  171. package/js/src/zonda.js +1 -0
  172. package/package.json +1 -1
  173. package/skip-tests.json +2 -3
  174. package/dist/cjs/src/btctradeua.js +0 -571
  175. package/dist/cjs/src/coinfalcon.js +0 -1012
  176. package/js/src/abstract/btctradeua.d.ts +0 -20
  177. package/js/src/abstract/btctradeua.js +0 -11
  178. package/js/src/abstract/coinfalcon.d.ts +0 -26
  179. package/js/src/abstract/coinfalcon.js +0 -11
  180. package/js/src/btctradeua.d.ts +0 -30
  181. package/js/src/btctradeua.js +0 -572
  182. package/js/src/coinfalcon.d.ts +0 -53
  183. package/js/src/coinfalcon.js +0 -1013
package/js/src/bitbank.js CHANGED
@@ -193,67 +193,65 @@ export default class bitbank extends Exchange {
193
193
  //
194
194
  const data = this.safeValue(response, 'data');
195
195
  const pairs = this.safeValue(data, 'pairs', []);
196
- const result = [];
197
- for (let i = 0; i < pairs.length; i++) {
198
- const entry = pairs[i];
199
- const id = this.safeString(entry, 'name');
200
- const baseId = this.safeString(entry, 'base_asset');
201
- const quoteId = this.safeString(entry, 'quote_asset');
202
- const base = this.safeCurrencyCode(baseId);
203
- const quote = this.safeCurrencyCode(quoteId);
204
- result.push({
205
- 'id': id,
206
- 'symbol': base + '/' + quote,
207
- 'base': base,
208
- 'quote': quote,
209
- 'settle': undefined,
210
- 'baseId': baseId,
211
- 'quoteId': quoteId,
212
- 'settleId': undefined,
213
- 'type': 'spot',
214
- 'spot': true,
215
- 'margin': false,
216
- 'swap': false,
217
- 'future': false,
218
- 'option': false,
219
- 'active': this.safeValue(entry, 'is_enabled'),
220
- 'contract': false,
221
- 'linear': undefined,
222
- 'inverse': undefined,
223
- 'taker': this.safeNumber(entry, 'taker_fee_rate_quote'),
224
- 'maker': this.safeNumber(entry, 'maker_fee_rate_quote'),
225
- 'contractSize': undefined,
226
- 'expiry': undefined,
227
- 'expiryDatetime': undefined,
228
- 'strike': undefined,
229
- 'optionType': undefined,
230
- 'precision': {
231
- 'amount': this.parseNumber(this.parsePrecision(this.safeString(entry, 'amount_digits'))),
232
- 'price': this.parseNumber(this.parsePrecision(this.safeString(entry, 'price_digits'))),
196
+ return this.parseMarkets(pairs);
197
+ }
198
+ parseMarket(entry) {
199
+ const id = this.safeString(entry, 'name');
200
+ const baseId = this.safeString(entry, 'base_asset');
201
+ const quoteId = this.safeString(entry, 'quote_asset');
202
+ const base = this.safeCurrencyCode(baseId);
203
+ const quote = this.safeCurrencyCode(quoteId);
204
+ return {
205
+ 'id': id,
206
+ 'symbol': base + '/' + quote,
207
+ 'base': base,
208
+ 'quote': quote,
209
+ 'settle': undefined,
210
+ 'baseId': baseId,
211
+ 'quoteId': quoteId,
212
+ 'settleId': undefined,
213
+ 'type': 'spot',
214
+ 'spot': true,
215
+ 'margin': false,
216
+ 'swap': false,
217
+ 'future': false,
218
+ 'option': false,
219
+ 'active': this.safeValue(entry, 'is_enabled'),
220
+ 'contract': false,
221
+ 'linear': undefined,
222
+ 'inverse': undefined,
223
+ 'taker': this.safeNumber(entry, 'taker_fee_rate_quote'),
224
+ 'maker': this.safeNumber(entry, 'maker_fee_rate_quote'),
225
+ 'contractSize': undefined,
226
+ 'expiry': undefined,
227
+ 'expiryDatetime': undefined,
228
+ 'strike': undefined,
229
+ 'optionType': undefined,
230
+ 'precision': {
231
+ 'amount': this.parseNumber(this.parsePrecision(this.safeString(entry, 'amount_digits'))),
232
+ 'price': this.parseNumber(this.parsePrecision(this.safeString(entry, 'price_digits'))),
233
+ },
234
+ 'limits': {
235
+ 'leverage': {
236
+ 'min': undefined,
237
+ 'max': undefined,
233
238
  },
234
- 'limits': {
235
- 'leverage': {
236
- 'min': undefined,
237
- 'max': undefined,
238
- },
239
- 'amount': {
240
- 'min': this.safeNumber(entry, 'unit_amount'),
241
- 'max': this.safeNumber(entry, 'limit_max_amount'),
242
- },
243
- 'price': {
244
- 'min': undefined,
245
- 'max': undefined,
246
- },
247
- 'cost': {
248
- 'min': undefined,
249
- 'max': undefined,
250
- },
239
+ 'amount': {
240
+ 'min': this.safeNumber(entry, 'unit_amount'),
241
+ 'max': this.safeNumber(entry, 'limit_max_amount'),
251
242
  },
252
- 'created': undefined,
253
- 'info': entry,
254
- });
255
- }
256
- return result;
243
+ 'price': {
244
+ 'min': undefined,
245
+ 'max': undefined,
246
+ },
247
+ 'cost': {
248
+ 'min': undefined,
249
+ 'max': undefined,
250
+ },
251
+ },
252
+ 'created': undefined,
253
+ 'info': entry,
254
+ };
257
255
  }
258
256
  parseTicker(ticker, market = undefined) {
259
257
  const symbol = this.safeSymbol(undefined, market);
@@ -871,6 +869,7 @@ export default class bitbank extends Exchange {
871
869
  'tag': undefined,
872
870
  'tagTo': undefined,
873
871
  'comment': undefined,
872
+ 'internal': undefined,
874
873
  'fee': undefined,
875
874
  'info': transaction,
876
875
  };
package/js/src/bitbns.js CHANGED
@@ -1104,6 +1104,7 @@ export default class bitbns extends Exchange {
1104
1104
  'currency': code,
1105
1105
  'status': status,
1106
1106
  'updated': undefined,
1107
+ 'comment': undefined,
1107
1108
  'internal': undefined,
1108
1109
  'fee': fee,
1109
1110
  };
@@ -1504,6 +1504,7 @@ export default class bitfinex extends Exchange {
1504
1504
  'tagTo': undefined,
1505
1505
  'updated': this.safeTimestamp(transaction, 'timestamp'),
1506
1506
  'comment': undefined,
1507
+ 'internal': undefined,
1507
1508
  'fee': {
1508
1509
  'currency': code,
1509
1510
  'cost': this.parseNumber(feeCost),
@@ -2172,6 +2172,7 @@ export default class bitfinex2 extends Exchange {
2172
2172
  'tagTo': tag,
2173
2173
  'updated': updated,
2174
2174
  'comment': comment,
2175
+ 'internal': undefined,
2175
2176
  'fee': {
2176
2177
  'currency': code,
2177
2178
  'cost': this.parseNumber(feeCost),
@@ -998,6 +998,7 @@ export default class bitflyer extends Exchange {
998
998
  'currency': code,
999
999
  'status': status,
1000
1000
  'updated': undefined,
1001
+ 'comment': undefined,
1001
1002
  'internal': undefined,
1002
1003
  'fee': fee,
1003
1004
  };
@@ -9,9 +9,8 @@ export default class bitget extends Exchange {
9
9
  setSandboxMode(enabled: any): void;
10
10
  fetchTime(params?: {}): Promise<number>;
11
11
  fetchMarkets(params?: {}): Promise<any>;
12
- parseMarkets(markets: any): any[];
13
12
  parseMarket(market: any): Market;
14
- fetchMarketsByType(type: any, params?: {}): Promise<any[]>;
13
+ fetchMarketsByType(type: any, params?: {}): Promise<Market[]>;
15
14
  fetchCurrencies(params?: {}): Promise<{}>;
16
15
  fetchMarketLeverageTiers(symbol: string, params?: {}): Promise<any[]>;
17
16
  parseMarketLeverageTiers(info: any, market?: any): any[];
package/js/src/bitget.js CHANGED
@@ -825,6 +825,7 @@ export default class bitget extends Exchange {
825
825
  '40017': ExchangeError,
826
826
  '40018': PermissionDenied,
827
827
  '40019': BadRequest,
828
+ '40031': AccountSuspended,
828
829
  '40037': AuthenticationError,
829
830
  '40102': BadRequest,
830
831
  '40103': BadRequest,
@@ -1133,13 +1134,6 @@ export default class bitget extends Exchange {
1133
1134
  }
1134
1135
  return result;
1135
1136
  }
1136
- parseMarkets(markets) {
1137
- const result = [];
1138
- for (let i = 0; i < markets.length; i++) {
1139
- result.push(this.parseMarket(markets[i]));
1140
- }
1141
- return result;
1142
- }
1143
1137
  parseMarket(market) {
1144
1138
  //
1145
1139
  // spot
@@ -1935,6 +1929,7 @@ export default class bitget extends Exchange {
1935
1929
  'tag': tag,
1936
1930
  'tagTo': tag,
1937
1931
  'comment': undefined,
1932
+ 'internal': undefined,
1938
1933
  'fee': fee,
1939
1934
  };
1940
1935
  }
@@ -3469,7 +3464,7 @@ export default class bitget extends Exchange {
3469
3464
  const amount = this.safeValue(rawOrder, 'amount');
3470
3465
  const price = this.safeValue(rawOrder, 'price');
3471
3466
  const orderParams = this.safeValue(rawOrder, 'params', {});
3472
- const marginResult = this.handleMarginModeAndParams('createOrders', params);
3467
+ const marginResult = this.handleMarginModeAndParams('createOrders', orderParams);
3473
3468
  const currentMarginMode = marginResult[0];
3474
3469
  if (currentMarginMode !== undefined) {
3475
3470
  if (marginMode === undefined) {
package/js/src/bithumb.js CHANGED
@@ -1006,6 +1006,7 @@ export default class bithumb extends Exchange {
1006
1006
  'tag': undefined,
1007
1007
  'tagTo': undefined,
1008
1008
  'comment': undefined,
1009
+ 'internal': undefined,
1009
1010
  'fee': undefined,
1010
1011
  'info': transaction,
1011
1012
  };
package/js/src/bitmart.js CHANGED
@@ -399,7 +399,14 @@ export default class bitmart extends Exchange {
399
399
  '40032': InvalidOrder,
400
400
  '40033': InvalidOrder,
401
401
  '40034': BadSymbol,
402
- '53002': PermissionDenied, // 403, Your account has not yet completed the kyc advanced certification, please complete first
402
+ '53002': PermissionDenied,
403
+ '53003': PermissionDenied,
404
+ '53005': PermissionDenied,
405
+ '53006': PermissionDenied,
406
+ '53007': PermissionDenied,
407
+ '53008': PermissionDenied,
408
+ '53009': PermissionDenied,
409
+ '53010': PermissionDenied, // 403 This account is restricted from borrowing
403
410
  },
404
411
  'broad': {},
405
412
  },
@@ -3158,6 +3165,8 @@ export default class bitmart extends Exchange {
3158
3165
  'type': type,
3159
3166
  'updated': undefined,
3160
3167
  'txid': txid,
3168
+ 'internal': undefined,
3169
+ 'comment': undefined,
3161
3170
  'timestamp': (timestamp !== 0) ? timestamp : undefined,
3162
3171
  'datetime': (timestamp !== 0) ? this.iso8601(timestamp) : undefined,
3163
3172
  'fee': fee,
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitmex.js';
2
- import { Int, OrderSide, OrderType, Trade, OHLCV, Order, Liquidation, OrderBook, Balances, Transaction, Ticker, Tickers } from './base/types.js';
2
+ import { Int, OrderSide, OrderType, Trade, OHLCV, Order, Liquidation, OrderBook, Balances, Transaction, Ticker, Tickers, Market } from './base/types.js';
3
3
  /**
4
4
  * @class bitmex
5
5
  * @extends Exchange
@@ -12,7 +12,8 @@ export default class bitmex extends Exchange {
12
12
  amountToPrecision(symbol: any, amount: any): any;
13
13
  convertFromRawQuantity(symbol: any, rawQuantity: any, currencySide?: string): number;
14
14
  convertFromRawCost(symbol: any, rawQuantity: any): number;
15
- fetchMarkets(params?: {}): Promise<any[]>;
15
+ fetchMarkets(params?: {}): Promise<Market[]>;
16
+ parseMarket(market: any): Market;
16
17
  parseBalance(response: any): Balances;
17
18
  fetchBalance(params?: {}): Promise<Balances>;
18
19
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
package/js/src/bitmex.js CHANGED
@@ -544,130 +544,124 @@ export default class bitmex extends Exchange {
544
544
  // }
545
545
  // ]
546
546
  //
547
- const result = [];
548
- for (let i = 0; i < response.length; i++) {
549
- const market = response[i];
550
- const id = this.safeString(market, 'symbol');
551
- const baseId = this.safeString(market, 'underlying');
552
- const quoteId = this.safeString(market, 'quoteCurrency');
553
- const settleId = this.safeString(market, 'settlCurrency');
554
- const base = this.safeCurrencyCode(baseId);
555
- const quote = this.safeCurrencyCode(quoteId);
556
- const settle = this.safeCurrencyCode(settleId);
557
- // 'positionCurrency' may be empty ("", as Bitmex currently returns for ETHUSD)
558
- // so let's take the settlCurrency first and then adjust if needed
559
- const typ = this.safeString(market, 'typ'); // type definitions at: https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_get
560
- const types = {
561
- 'FFWCSX': 'swap',
562
- 'FFWCSF': 'swap',
563
- 'IFXXXP': 'spot',
564
- 'FFCCSX': 'future',
565
- 'MRBXXX': 'index',
566
- 'MRCXXX': 'index',
567
- 'MRFXXX': 'index',
568
- 'MRRXXX': 'index',
569
- 'MRIXXX': 'index',
570
- };
571
- const type = this.safeString(types, typ, typ);
572
- const swap = type === 'swap';
573
- const future = type === 'future';
574
- const spot = type === 'spot';
575
- const contract = swap || future;
576
- let contractSize = undefined;
577
- const index = type === 'index';
578
- const isInverse = this.safeValue(market, 'isInverse'); // this is true when BASE and SETTLE are same, i.e. BTC/XXX:BTC
579
- const isQuanto = this.safeValue(market, 'isQuanto'); // this is true when BASE and SETTLE are different, i.e. AXS/XXX:BTC
580
- const linear = contract ? (!isInverse && !isQuanto) : undefined;
581
- const status = this.safeString(market, 'state');
582
- const active = status !== 'Unlisted';
583
- let expiry = undefined;
584
- let expiryDatetime = undefined;
585
- let symbol = undefined;
586
- if (spot) {
587
- symbol = base + '/' + quote;
588
- }
589
- else if (contract) {
590
- symbol = base + '/' + quote + ':' + settle;
591
- const multiplierString = Precise.stringAbs(this.safeString(market, 'multiplier'));
592
- if (linear) {
593
- contractSize = this.parseNumber(Precise.stringDiv('1', market['underlyingToPositionMultiplier']));
594
- }
595
- else {
596
- contractSize = this.parseNumber(multiplierString);
597
- }
598
- if (future) {
599
- expiryDatetime = this.safeString(market, 'expiry');
600
- expiry = this.parse8601(expiryDatetime);
601
- symbol = symbol + '-' + this.yymmdd(expiry);
602
- }
547
+ return this.parseMarkets(response);
548
+ }
549
+ parseMarket(market) {
550
+ const id = this.safeString(market, 'symbol');
551
+ const baseId = this.safeString(market, 'underlying');
552
+ const quoteId = this.safeString(market, 'quoteCurrency');
553
+ const settleId = this.safeString(market, 'settlCurrency');
554
+ const base = this.safeCurrencyCode(baseId);
555
+ const quote = this.safeCurrencyCode(quoteId);
556
+ const settle = this.safeCurrencyCode(settleId);
557
+ // 'positionCurrency' may be empty ("", as Bitmex currently returns for ETHUSD)
558
+ // so let's take the settlCurrency first and then adjust if needed
559
+ const typ = this.safeString(market, 'typ'); // type definitions at: https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_get
560
+ const types = {
561
+ 'FFWCSX': 'swap',
562
+ 'FFWCSF': 'swap',
563
+ 'IFXXXP': 'spot',
564
+ 'FFCCSX': 'future',
565
+ 'MRBXXX': 'index',
566
+ 'MRCXXX': 'index',
567
+ 'MRFXXX': 'index',
568
+ 'MRRXXX': 'index',
569
+ 'MRIXXX': 'index',
570
+ };
571
+ const type = this.safeString(types, typ, typ);
572
+ const swap = type === 'swap';
573
+ const future = type === 'future';
574
+ const spot = type === 'spot';
575
+ const contract = swap || future;
576
+ let contractSize = undefined;
577
+ const isInverse = this.safeValue(market, 'isInverse'); // this is true when BASE and SETTLE are same, i.e. BTC/XXX:BTC
578
+ const isQuanto = this.safeValue(market, 'isQuanto'); // this is true when BASE and SETTLE are different, i.e. AXS/XXX:BTC
579
+ const linear = contract ? (!isInverse && !isQuanto) : undefined;
580
+ const status = this.safeString(market, 'state');
581
+ const active = status !== 'Unlisted';
582
+ let expiry = undefined;
583
+ let expiryDatetime = undefined;
584
+ let symbol = undefined;
585
+ if (spot) {
586
+ symbol = base + '/' + quote;
587
+ }
588
+ else if (contract) {
589
+ symbol = base + '/' + quote + ':' + settle;
590
+ const multiplierString = Precise.stringAbs(this.safeString(market, 'multiplier'));
591
+ if (linear) {
592
+ contractSize = this.parseNumber(Precise.stringDiv('1', market['underlyingToPositionMultiplier']));
603
593
  }
604
594
  else {
605
- // for index/exotic markets, default to id
606
- symbol = id;
595
+ contractSize = this.parseNumber(multiplierString);
607
596
  }
608
- const positionId = this.safeString2(market, 'positionCurrency', 'underlying');
609
- const position = this.safeCurrencyCode(positionId);
610
- const positionIsQuote = (position === quote);
611
- const maxOrderQty = this.safeNumber(market, 'maxOrderQty');
612
- const initMargin = this.safeString(market, 'initMargin', '1');
613
- const maxLeverage = this.parseNumber(Precise.stringDiv('1', initMargin));
614
- result.push({
615
- 'id': id,
616
- 'symbol': symbol,
617
- 'base': base,
618
- 'quote': quote,
619
- 'settle': settle,
620
- 'baseId': baseId,
621
- 'quoteId': quoteId,
622
- 'settleId': settleId,
623
- 'type': type,
624
- 'spot': spot,
625
- 'margin': false,
626
- 'swap': swap,
627
- 'future': future,
628
- 'option': false,
629
- 'index': index,
630
- 'active': active,
631
- 'contract': contract,
632
- 'linear': linear,
633
- 'inverse': isInverse,
634
- 'quanto': isQuanto,
635
- 'taker': this.safeNumber(market, 'takerFee'),
636
- 'maker': this.safeNumber(market, 'makerFee'),
637
- 'contractSize': contractSize,
638
- 'expiry': expiry,
639
- 'expiryDatetime': expiryDatetime,
640
- 'strike': this.safeNumber(market, 'optionStrikePrice'),
641
- 'optionType': undefined,
642
- 'precision': {
643
- 'amount': this.safeNumber(market, 'lotSize'),
644
- 'price': this.safeNumber(market, 'tickSize'),
645
- 'quote': this.safeNumber(market, 'tickSize'),
646
- 'base': this.safeNumber(market, 'tickSize'),
597
+ if (future) {
598
+ expiryDatetime = this.safeString(market, 'expiry');
599
+ expiry = this.parse8601(expiryDatetime);
600
+ symbol = symbol + '-' + this.yymmdd(expiry);
601
+ }
602
+ }
603
+ else {
604
+ // for index/exotic markets, default to id
605
+ symbol = id;
606
+ }
607
+ const positionId = this.safeString2(market, 'positionCurrency', 'underlying');
608
+ const position = this.safeCurrencyCode(positionId);
609
+ const positionIsQuote = (position === quote);
610
+ const maxOrderQty = this.safeNumber(market, 'maxOrderQty');
611
+ const initMargin = this.safeString(market, 'initMargin', '1');
612
+ const maxLeverage = this.parseNumber(Precise.stringDiv('1', initMargin));
613
+ return {
614
+ 'id': id,
615
+ 'symbol': symbol,
616
+ 'base': base,
617
+ 'quote': quote,
618
+ 'settle': settle,
619
+ 'baseId': baseId,
620
+ 'quoteId': quoteId,
621
+ 'settleId': settleId,
622
+ 'type': type,
623
+ 'spot': spot,
624
+ 'margin': false,
625
+ 'swap': swap,
626
+ 'future': future,
627
+ 'option': false,
628
+ 'active': active,
629
+ 'contract': contract,
630
+ 'linear': linear,
631
+ 'inverse': isInverse,
632
+ 'quanto': isQuanto,
633
+ 'taker': this.safeNumber(market, 'takerFee'),
634
+ 'maker': this.safeNumber(market, 'makerFee'),
635
+ 'contractSize': contractSize,
636
+ 'expiry': expiry,
637
+ 'expiryDatetime': expiryDatetime,
638
+ 'strike': this.safeNumber(market, 'optionStrikePrice'),
639
+ 'optionType': undefined,
640
+ 'precision': {
641
+ 'amount': this.safeNumber(market, 'lotSize'),
642
+ 'price': this.safeNumber(market, 'tickSize'),
643
+ },
644
+ 'limits': {
645
+ 'leverage': {
646
+ 'min': contract ? this.parseNumber('1') : undefined,
647
+ 'max': contract ? maxLeverage : undefined,
647
648
  },
648
- 'limits': {
649
- 'leverage': {
650
- 'min': contract ? this.parseNumber('1') : undefined,
651
- 'max': contract ? maxLeverage : undefined,
652
- },
653
- 'amount': {
654
- 'min': undefined,
655
- 'max': positionIsQuote ? undefined : maxOrderQty,
656
- },
657
- 'price': {
658
- 'min': undefined,
659
- 'max': this.safeNumber(market, 'maxPrice'),
660
- },
661
- 'cost': {
662
- 'min': undefined,
663
- 'max': positionIsQuote ? maxOrderQty : undefined,
664
- },
649
+ 'amount': {
650
+ 'min': undefined,
651
+ 'max': positionIsQuote ? undefined : maxOrderQty,
665
652
  },
666
- 'created': this.parse8601(this.safeString(market, 'listing')),
667
- 'info': market,
668
- });
669
- }
670
- return result;
653
+ 'price': {
654
+ 'min': undefined,
655
+ 'max': this.safeNumber(market, 'maxPrice'),
656
+ },
657
+ 'cost': {
658
+ 'min': undefined,
659
+ 'max': positionIsQuote ? maxOrderQty : undefined,
660
+ },
661
+ },
662
+ 'created': this.parse8601(this.safeString(market, 'listing')),
663
+ 'info': market,
664
+ };
671
665
  }
672
666
  parseBalance(response) {
673
667
  //
@@ -1306,6 +1300,7 @@ export default class bitmex extends Exchange {
1306
1300
  'tagFrom': undefined,
1307
1301
  'tagTo': undefined,
1308
1302
  'updated': timestamp,
1303
+ 'internal': undefined,
1309
1304
  'comment': undefined,
1310
1305
  'fee': {
1311
1306
  'currency': currency['code'],
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitopro.js';
2
- import { Balances, Int, OHLCV, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction } from './base/types.js';
2
+ import { Balances, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction } from './base/types.js';
3
3
  /**
4
4
  * @class bitopro
5
5
  * @extends Exchange
@@ -7,7 +7,8 @@ import { Balances, Int, OHLCV, Order, OrderBook, OrderSide, OrderType, Ticker, T
7
7
  export default class bitopro extends Exchange {
8
8
  describe(): any;
9
9
  fetchCurrencies(params?: {}): Promise<{}>;
10
- fetchMarkets(params?: {}): Promise<any[]>;
10
+ fetchMarkets(params?: {}): Promise<Market[]>;
11
+ parseMarket(market: any): Market;
11
12
  parseTicker(ticker: any, market?: any): Ticker;
12
13
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
13
14
  fetchTickers(symbols?: string[], params?: {}): Promise<Tickers>;