ccxt 4.1.51 → 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 (182) hide show
  1. package/README.md +110 -113
  2. package/dist/ccxt.browser.js +1361 -2933
  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 +3 -3
  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 +15 -15
  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/alpaca.d.ts +3 -2
  82. package/js/src/alpaca.js +62 -64
  83. package/js/src/ascendex.js +3 -1
  84. package/js/src/base/Exchange.d.ts +2 -0
  85. package/js/src/base/Exchange.js +10 -0
  86. package/js/src/base/types.d.ts +6 -3
  87. package/js/src/bigone.d.ts +3 -3
  88. package/js/src/bigone.js +60 -77
  89. package/js/src/binance.js +1 -0
  90. package/js/src/bingx.d.ts +2 -2
  91. package/js/src/bingx.js +4 -11
  92. package/js/src/bitbank.d.ts +3 -2
  93. package/js/src/bitbank.js +58 -59
  94. package/js/src/bitbns.js +1 -0
  95. package/js/src/bitfinex.js +1 -0
  96. package/js/src/bitfinex2.js +1 -0
  97. package/js/src/bitflyer.js +1 -0
  98. package/js/src/bitget.d.ts +1 -2
  99. package/js/src/bitget.js +3 -8
  100. package/js/src/bithumb.js +1 -0
  101. package/js/src/bitmart.js +10 -1
  102. package/js/src/bitmex.d.ts +3 -2
  103. package/js/src/bitmex.js +114 -119
  104. package/js/src/bitopro.d.ts +3 -2
  105. package/js/src/bitopro.js +63 -65
  106. package/js/src/bitpanda.d.ts +3 -2
  107. package/js/src/bitpanda.js +60 -60
  108. package/js/src/bitrue.d.ts +3 -2
  109. package/js/src/bitrue.js +67 -71
  110. package/js/src/bitso.js +1 -0
  111. package/js/src/bitstamp.js +1 -0
  112. package/js/src/bittrex.d.ts +3 -2
  113. package/js/src/bittrex.js +57 -57
  114. package/js/src/bitvavo.js +10 -2
  115. package/js/src/blockchaincom.js +2 -2
  116. package/js/src/btcalpha.d.ts +3 -2
  117. package/js/src/btcalpha.js +59 -60
  118. package/js/src/btcmarkets.d.ts +3 -2
  119. package/js/src/btcmarkets.js +68 -69
  120. package/js/src/btcturk.d.ts +3 -2
  121. package/js/src/btcturk.js +72 -74
  122. package/js/src/bybit.js +3 -1
  123. package/js/src/coinbase.js +7 -2
  124. package/js/src/coinbasepro.js +1 -0
  125. package/js/src/coincheck.js +1 -0
  126. package/js/src/coinex.js +4 -0
  127. package/js/src/coinlist.d.ts +3 -2
  128. package/js/src/coinlist.js +60 -60
  129. package/js/src/coinmate.js +1 -0
  130. package/js/src/coinsph.js +2 -4
  131. package/js/src/cryptocom.js +1 -0
  132. package/js/src/currencycom.js +2 -2
  133. package/js/src/deribit.js +2 -0
  134. package/js/src/digifinex.js +5 -2
  135. package/js/src/exmo.js +1 -0
  136. package/js/src/gate.js +2 -0
  137. package/js/src/gemini.js +2 -0
  138. package/js/src/hitbtc.js +4 -0
  139. package/js/src/hollaex.js +2 -0
  140. package/js/src/htx.js +4 -0
  141. package/js/src/huobijp.js +2 -0
  142. package/js/src/idex.js +2 -0
  143. package/js/src/indodax.js +1 -0
  144. package/js/src/kraken.js +3 -3
  145. package/js/src/kucoin.js +6 -5
  146. package/js/src/kuna.js +3 -1
  147. package/js/src/latoken.js +1 -0
  148. package/js/src/lbank.js +1 -0
  149. package/js/src/lykke.js +2 -0
  150. package/js/src/mercado.js +1 -0
  151. package/js/src/mexc.js +2 -0
  152. package/js/src/ndax.js +2 -0
  153. package/js/src/novadax.js +1 -0
  154. package/js/src/okcoin.js +2 -0
  155. package/js/src/okx.js +2 -0
  156. package/js/src/phemex.js +2 -0
  157. package/js/src/poloniex.js +1 -0
  158. package/js/src/pro/binance.js +5 -3
  159. package/js/src/pro/coinbase.js +12 -3
  160. package/js/src/pro/cryptocom.js +17 -17
  161. package/js/src/pro/krakenfutures.js +15 -15
  162. package/js/src/probit.js +4 -2
  163. package/js/src/tidex.js +1 -0
  164. package/js/src/timex.js +2 -0
  165. package/js/src/upbit.js +2 -0
  166. package/js/src/wavesexchange.js +2 -1
  167. package/js/src/whitebit.js +1 -0
  168. package/js/src/woo.js +1 -0
  169. package/js/src/zaif.js +1 -0
  170. package/js/src/zonda.js +1 -0
  171. package/package.json +1 -1
  172. package/skip-tests.json +2 -3
  173. package/dist/cjs/src/btctradeua.js +0 -571
  174. package/dist/cjs/src/coinfalcon.js +0 -1012
  175. package/js/src/abstract/btctradeua.d.ts +0 -20
  176. package/js/src/abstract/btctradeua.js +0 -11
  177. package/js/src/abstract/coinfalcon.d.ts +0 -26
  178. package/js/src/abstract/coinfalcon.js +0 -11
  179. package/js/src/btctradeua.d.ts +0 -30
  180. package/js/src/btctradeua.js +0 -572
  181. package/js/src/coinfalcon.d.ts +0 -53
  182. package/js/src/coinfalcon.js +0 -1013
@@ -1,571 +0,0 @@
1
- 'use strict';
2
-
3
- var btctradeua$1 = require('./abstract/btctradeua.js');
4
- var errors = require('./base/errors.js');
5
- var Precise = require('./base/Precise.js');
6
- var number = require('./base/functions/number.js');
7
- var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
8
-
9
- // ---------------------------------------------------------------------------
10
- // ---------------------------------------------------------------------------
11
- /**
12
- * @class btctradeua
13
- * @extends Exchange
14
- */
15
- class btctradeua extends btctradeua$1 {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'btctradeua',
19
- 'name': 'BTC Trade UA',
20
- 'countries': ['UA'],
21
- 'rateLimit': 3000,
22
- 'pro': false,
23
- 'has': {
24
- 'CORS': undefined,
25
- 'spot': true,
26
- 'margin': false,
27
- 'swap': false,
28
- 'future': false,
29
- 'option': false,
30
- 'addMargin': false,
31
- 'cancelOrder': true,
32
- 'createMarketOrder': false,
33
- 'createOrder': true,
34
- 'createReduceOnlyOrder': false,
35
- 'fetchBalance': true,
36
- 'fetchBorrowRate': false,
37
- 'fetchBorrowRateHistories': false,
38
- 'fetchBorrowRateHistory': false,
39
- 'fetchBorrowRates': false,
40
- 'fetchBorrowRatesPerSymbol': false,
41
- 'fetchFundingHistory': false,
42
- 'fetchFundingRate': false,
43
- 'fetchFundingRateHistory': false,
44
- 'fetchFundingRates': false,
45
- 'fetchIndexOHLCV': false,
46
- 'fetchLeverage': false,
47
- 'fetchMarginMode': false,
48
- 'fetchMarkOHLCV': false,
49
- 'fetchOpenInterestHistory': false,
50
- 'fetchOpenOrders': true,
51
- 'fetchOrderBook': true,
52
- 'fetchPosition': false,
53
- 'fetchPositionMode': false,
54
- 'fetchPositions': false,
55
- 'fetchPositionsRisk': false,
56
- 'fetchPremiumIndexOHLCV': false,
57
- 'fetchTicker': true,
58
- 'fetchTrades': true,
59
- 'fetchTradingFee': false,
60
- 'fetchTradingFees': false,
61
- 'reduceMargin': false,
62
- 'setLeverage': false,
63
- 'setMarginMode': false,
64
- 'setPositionMode': false,
65
- 'signIn': true,
66
- 'ws': false,
67
- },
68
- 'urls': {
69
- 'referral': 'https://btc-trade.com.ua/registration/22689',
70
- 'logo': 'https://user-images.githubusercontent.com/1294454/27941483-79fc7350-62d9-11e7-9f61-ac47f28fcd96.jpg',
71
- 'api': {
72
- 'rest': 'https://btc-trade.com.ua/api',
73
- },
74
- 'www': 'https://btc-trade.com.ua',
75
- 'doc': 'https://docs.google.com/document/d/1ocYA0yMy_RXd561sfG3qEPZ80kyll36HUxvCRe5GbhE/edit',
76
- },
77
- 'api': {
78
- 'public': {
79
- 'get': [
80
- 'deals/{symbol}',
81
- 'trades/sell/{symbol}',
82
- 'trades/buy/{symbol}',
83
- 'japan_stat/high/{symbol}',
84
- ],
85
- },
86
- 'private': {
87
- 'post': [
88
- 'auth',
89
- 'ask/{symbol}',
90
- 'balance',
91
- 'bid/{symbol}',
92
- 'buy/{symbol}',
93
- 'my_orders/{symbol}',
94
- 'order/status/{id}',
95
- 'remove/order/{id}',
96
- 'sell/{symbol}',
97
- ],
98
- },
99
- },
100
- 'precisionMode': number.TICK_SIZE,
101
- 'markets': {
102
- 'BCH/UAH': this.safeMarketStructure({ 'id': 'bch_uah', 'symbol': 'BCH/UAH', 'base': 'BCH', 'quote': 'UAH', 'baseId': 'bch', 'quoteId': 'uah', 'type': 'spot', 'spot': true }),
103
- 'BTC/UAH': this.safeMarketStructure({ 'id': 'btc_uah', 'symbol': 'BTC/UAH', 'base': 'BTC', 'quote': 'UAH', 'baseId': 'btc', 'quoteId': 'uah', 'precision': { 'price': this.parseNumber('1e-1') }, 'limits': { 'amount': { 'min': this.parseNumber('1e-10') } }, 'type': 'spot', 'spot': true }),
104
- 'DASH/BTC': this.safeMarketStructure({ 'id': 'dash_btc', 'symbol': 'DASH/BTC', 'base': 'DASH', 'quote': 'BTC', 'baseId': 'dash', 'quoteId': 'btc', 'type': 'spot', 'spot': true }),
105
- 'DASH/UAH': this.safeMarketStructure({ 'id': 'dash_uah', 'symbol': 'DASH/UAH', 'base': 'DASH', 'quote': 'UAH', 'baseId': 'dash', 'quoteId': 'uah', 'type': 'spot', 'spot': true }),
106
- 'DOGE/BTC': this.safeMarketStructure({ 'id': 'doge_btc', 'symbol': 'DOGE/BTC', 'base': 'DOGE', 'quote': 'BTC', 'baseId': 'doge', 'quoteId': 'btc', 'type': 'spot', 'spot': true }),
107
- 'DOGE/UAH': this.safeMarketStructure({ 'id': 'doge_uah', 'symbol': 'DOGE/UAH', 'base': 'DOGE', 'quote': 'UAH', 'baseId': 'doge', 'quoteId': 'uah', 'type': 'spot', 'spot': true }),
108
- 'ETH/UAH': this.safeMarketStructure({ 'id': 'eth_uah', 'symbol': 'ETH/UAH', 'base': 'ETH', 'quote': 'UAH', 'baseId': 'eth', 'quoteId': 'uah', 'type': 'spot', 'spot': true }),
109
- 'ITI/UAH': this.safeMarketStructure({ 'id': 'iti_uah', 'symbol': 'ITI/UAH', 'base': 'ITI', 'quote': 'UAH', 'baseId': 'iti', 'quoteId': 'uah', 'type': 'spot', 'spot': true }),
110
- 'KRB/UAH': this.safeMarketStructure({ 'id': 'krb_uah', 'symbol': 'KRB/UAH', 'base': 'KRB', 'quote': 'UAH', 'baseId': 'krb', 'quoteId': 'uah', 'type': 'spot', 'spot': true }),
111
- 'LTC/BTC': this.safeMarketStructure({ 'id': 'ltc_btc', 'symbol': 'LTC/BTC', 'base': 'LTC', 'quote': 'BTC', 'baseId': 'ltc', 'quoteId': 'btc', 'type': 'spot', 'spot': true }),
112
- 'LTC/UAH': this.safeMarketStructure({ 'id': 'ltc_uah', 'symbol': 'LTC/UAH', 'base': 'LTC', 'quote': 'UAH', 'baseId': 'ltc', 'quoteId': 'uah', 'type': 'spot', 'spot': true }),
113
- 'NVC/BTC': this.safeMarketStructure({ 'id': 'nvc_btc', 'symbol': 'NVC/BTC', 'base': 'NVC', 'quote': 'BTC', 'baseId': 'nvc', 'quoteId': 'btc', 'type': 'spot', 'spot': true }),
114
- 'NVC/UAH': this.safeMarketStructure({ 'id': 'nvc_uah', 'symbol': 'NVC/UAH', 'base': 'NVC', 'quote': 'UAH', 'baseId': 'nvc', 'quoteId': 'uah', 'type': 'spot', 'spot': true }),
115
- 'PPC/BTC': this.safeMarketStructure({ 'id': 'ppc_btc', 'symbol': 'PPC/BTC', 'base': 'PPC', 'quote': 'BTC', 'baseId': 'ppc', 'quoteId': 'btc', 'type': 'spot', 'spot': true }),
116
- 'SIB/UAH': this.safeMarketStructure({ 'id': 'sib_uah', 'symbol': 'SIB/UAH', 'base': 'SIB', 'quote': 'UAH', 'baseId': 'sib', 'quoteId': 'uah', 'type': 'spot', 'spot': true }),
117
- 'XMR/UAH': this.safeMarketStructure({ 'id': 'xmr_uah', 'symbol': 'XMR/UAH', 'base': 'XMR', 'quote': 'UAH', 'baseId': 'xmr', 'quoteId': 'uah', 'type': 'spot', 'spot': true }),
118
- 'ZEC/UAH': this.safeMarketStructure({ 'id': 'zec_uah', 'symbol': 'ZEC/UAH', 'base': 'ZEC', 'quote': 'UAH', 'baseId': 'zec', 'quoteId': 'uah', 'type': 'spot', 'spot': true }),
119
- },
120
- 'fees': {
121
- 'trading': {
122
- 'maker': this.parseNumber('0.001'),
123
- 'taker': this.parseNumber('0.001'),
124
- },
125
- },
126
- });
127
- }
128
- async signIn(params = {}) {
129
- /**
130
- * @method
131
- * @name btctradeua#signIn
132
- * @description sign in, must be called prior to using other authenticated methods
133
- * @param {object} [params] extra parameters specific to the btctradeua api endpoint
134
- * @returns response from exchange
135
- */
136
- return await this.privatePostAuth(params);
137
- }
138
- parseBalance(response) {
139
- const result = { 'info': response };
140
- const balances = this.safeValue(response, 'accounts', []);
141
- for (let i = 0; i < balances.length; i++) {
142
- const balance = balances[i];
143
- const currencyId = this.safeString(balance, 'currency');
144
- const code = this.safeCurrencyCode(currencyId);
145
- const account = this.account();
146
- account['total'] = this.safeString(balance, 'balance');
147
- result[code] = account;
148
- }
149
- return this.safeBalance(result);
150
- }
151
- async fetchBalance(params = {}) {
152
- /**
153
- * @method
154
- * @name btctradeua#fetchBalance
155
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
156
- * @param {object} [params] extra parameters specific to the btctradeua api endpoint
157
- * @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
158
- */
159
- await this.loadMarkets();
160
- const response = await this.privatePostBalance(params);
161
- return this.parseBalance(response);
162
- }
163
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
164
- /**
165
- * @method
166
- * @name btctradeua#fetchOrderBook
167
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
168
- * @param {string} symbol unified symbol of the market to fetch the order book for
169
- * @param {int} [limit] the maximum amount of order book entries to return
170
- * @param {object} [params] extra parameters specific to the btctradeua api endpoint
171
- * @returns {object} A dictionary of [order book structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure} indexed by market symbols
172
- */
173
- await this.loadMarkets();
174
- const market = this.market(symbol);
175
- const request = {
176
- 'symbol': market['id'],
177
- };
178
- const bids = await this.publicGetTradesBuySymbol(this.extend(request, params));
179
- const asks = await this.publicGetTradesSellSymbol(this.extend(request, params));
180
- const orderbook = {
181
- 'bids': [],
182
- 'asks': [],
183
- };
184
- if (bids) {
185
- if ('list' in bids) {
186
- orderbook['bids'] = bids['list'];
187
- }
188
- }
189
- if (asks) {
190
- if ('list' in asks) {
191
- orderbook['asks'] = asks['list'];
192
- }
193
- }
194
- return this.parseOrderBook(orderbook, market['symbol'], undefined, 'bids', 'asks', 'price', 'currency_trade');
195
- }
196
- parseTicker(ticker, market = undefined) {
197
- //
198
- // [
199
- // [1640789101000, 1292663.0, 1311823.61303, 1295794.252, 1311823.61303, 0.030175],
200
- // [1640790902000, 1311823.61303, 1310820.96, 1290000.0, 1290000.0, 0.042533],
201
- // ],
202
- //
203
- const symbol = this.safeSymbol(undefined, market);
204
- const timestamp = this.milliseconds();
205
- const result = {
206
- 'symbol': symbol,
207
- 'timestamp': timestamp,
208
- 'datetime': this.iso8601(timestamp),
209
- 'high': undefined,
210
- 'low': undefined,
211
- 'bid': undefined,
212
- 'bidVolume': undefined,
213
- 'ask': undefined,
214
- 'askVolume': undefined,
215
- 'vwap': undefined,
216
- 'open': undefined,
217
- 'close': undefined,
218
- 'last': undefined,
219
- 'previousClose': undefined,
220
- 'change': undefined,
221
- 'percentage': undefined,
222
- 'average': undefined,
223
- 'baseVolume': undefined,
224
- 'quoteVolume': undefined,
225
- 'info': ticker,
226
- };
227
- const tickerLength = ticker.length;
228
- if (tickerLength > 0) {
229
- const start = Math.max(tickerLength - 48, 0);
230
- for (let i = start; i < ticker.length; i++) {
231
- const candle = ticker[i];
232
- if (result['open'] === undefined) {
233
- result['open'] = this.safeString(candle, 1);
234
- }
235
- const high = this.safeString(candle, 2);
236
- if ((result['high'] === undefined) || ((high !== undefined) && Precise["default"].stringLt(result['high'], high))) {
237
- result['high'] = high;
238
- }
239
- const low = this.safeString(candle, 3);
240
- if ((result['low'] === undefined) || ((low !== undefined) && Precise["default"].stringLt(result['low'], low))) {
241
- result['low'] = low;
242
- }
243
- const baseVolume = this.safeString(candle, 5);
244
- if (result['baseVolume'] === undefined) {
245
- result['baseVolume'] = baseVolume;
246
- }
247
- else {
248
- result['baseVolume'] = Precise["default"].stringAdd(result['baseVolume'], baseVolume);
249
- }
250
- }
251
- const last = tickerLength - 1;
252
- result['last'] = this.safeString(ticker[last], 4);
253
- result['close'] = result['last'];
254
- }
255
- return this.safeTicker(result, market);
256
- }
257
- async fetchTicker(symbol, params = {}) {
258
- /**
259
- * @method
260
- * @name btctradeua#fetchTicker
261
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
262
- * @param {string} symbol unified symbol of the market to fetch the ticker for
263
- * @param {object} [params] extra parameters specific to the btctradeua api endpoint
264
- * @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
265
- */
266
- await this.loadMarkets();
267
- const market = this.market(symbol);
268
- const request = {
269
- 'symbol': market['id'],
270
- };
271
- const response = await this.publicGetJapanStatHighSymbol(this.extend(request, params));
272
- const ticker = this.safeValue(response, 'trades');
273
- //
274
- // {
275
- // "status": true,
276
- // "volume_trade": "0.495703",
277
- // "trades": [
278
- // [1640789101000, 1292663.0, 1311823.61303, 1295794.252, 1311823.61303, 0.030175],
279
- // [1640790902000, 1311823.61303, 1310820.96, 1290000.0, 1290000.0, 0.042533],
280
- // ],
281
- // }
282
- //
283
- return this.parseTicker(ticker, market);
284
- }
285
- convertMonthNameToString(cyrillic) {
286
- const months = {
287
- 'Jan': '01',
288
- 'January': '01',
289
- 'Feb': '02',
290
- 'February': '02',
291
- 'Mar': '03',
292
- 'March': '03',
293
- 'Apr': '04',
294
- 'April': '04',
295
- 'May': '05',
296
- 'Jun': '06',
297
- 'June': '06',
298
- 'Jul': '07',
299
- 'July': '07',
300
- 'Aug': '08',
301
- 'August': '08',
302
- 'Sept': '09',
303
- 'September': '09',
304
- 'Oct': '10',
305
- 'October': '10',
306
- 'Nov': '11',
307
- 'November': '11',
308
- 'Dec': '12',
309
- 'December': '12',
310
- };
311
- return this.safeString(months, cyrillic);
312
- }
313
- parseExchangeSpecificDatetime(cyrillic) {
314
- const parts = cyrillic.split(' ');
315
- let month = parts[0];
316
- let day = parts[1].replace(',', '');
317
- if (day.length < 2) {
318
- day = '0' + day;
319
- }
320
- const year = parts[2].replace(',', '');
321
- month = month.replace(',', '');
322
- month = month.replace('.', '');
323
- month = this.convertMonthNameToString(month);
324
- if (!month) {
325
- throw new errors.ExchangeError(this.id + ' parseTrade() unrecognized month name: ' + cyrillic);
326
- }
327
- const hms = parts[3];
328
- const hmsParts = hms.split(':');
329
- let h = this.safeString(hmsParts, 0);
330
- let m = '00';
331
- const ampm = this.safeString(parts, 4);
332
- if (h === 'noon') {
333
- h = '12';
334
- }
335
- else {
336
- let intH = parseInt(h);
337
- if ((ampm !== undefined) && (ampm[0] === 'p')) {
338
- intH = 12 + intH;
339
- if (intH > 23) {
340
- intH = 0;
341
- }
342
- }
343
- h = intH.toString();
344
- if (h.length < 2) {
345
- h = '0' + h;
346
- }
347
- m = this.safeString(hmsParts, 1, '00');
348
- if (m.length < 2) {
349
- m = '0' + m;
350
- }
351
- }
352
- const ymd = [year, month, day].join('-');
353
- const ymdhms = ymd + 'T' + h + ':' + m + ':00';
354
- const timestamp = this.parse8601(ymdhms);
355
- // server reports local time, adjust to UTC
356
- // a special case for DST
357
- // subtract 2 hours during winter
358
- const intM = parseInt(m);
359
- if (intM < 11 || intM > 2) {
360
- return timestamp - 7200000;
361
- }
362
- // subtract 3 hours during summer
363
- return timestamp - 10800000;
364
- }
365
- parseTrade(trade, market = undefined) {
366
- //
367
- // fetchTrades
368
- //
369
- // {
370
- // "amnt_base": "2220.1204701750",
371
- // "order_id": 247644861,
372
- // "unixtime": 1694340398,
373
- // "price": "1019739.3229211044",
374
- // "amnt_trade": "0.0021771451",
375
- // "user": "Vasily1989",
376
- // "type": "sell",
377
- // "pub_date": "Sept. 10, 2023, 1:06 p.m.",
378
- // "id": 7498807
379
- // }
380
- //
381
- const timestamp = this.parseExchangeSpecificDatetime(this.safeString(trade, 'pub_date'));
382
- const id = this.safeString(trade, 'id');
383
- const type = 'limit';
384
- const side = this.safeString(trade, 'type');
385
- const priceString = this.safeString(trade, 'price');
386
- const amountString = this.safeString(trade, 'amnt_trade');
387
- market = this.safeMarket(undefined, market);
388
- return this.safeTrade({
389
- 'id': id,
390
- 'info': trade,
391
- 'timestamp': timestamp,
392
- 'datetime': this.iso8601(timestamp),
393
- 'symbol': market['symbol'],
394
- 'type': type,
395
- 'side': side,
396
- 'order': undefined,
397
- 'takerOrMaker': undefined,
398
- 'price': priceString,
399
- 'amount': amountString,
400
- 'cost': undefined,
401
- 'fee': undefined,
402
- }, market);
403
- }
404
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
405
- /**
406
- * @method
407
- * @name btctradeua#fetchTrades
408
- * @description get the list of most recent trades for a particular symbol
409
- * @param {string} symbol unified symbol of the market to fetch trades for
410
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
411
- * @param {int} [limit] the maximum amount of trades to fetch
412
- * @param {object} [params] extra parameters specific to the btctradeua api endpoint
413
- * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
414
- */
415
- await this.loadMarkets();
416
- const market = this.market(symbol);
417
- const request = {
418
- 'symbol': market['id'],
419
- };
420
- const response = await this.publicGetDealsSymbol(this.extend(request, params));
421
- //
422
- // [
423
- // {
424
- // "amnt_base": "2220.1204701750",
425
- // "order_id": 247644861,
426
- // "unixtime": 1694340398,
427
- // "price": "1019739.3229211044",
428
- // "amnt_trade": "0.0021771451",
429
- // "user": "Vasily1989",
430
- // "type": "sell",
431
- // "pub_date": "Sept. 10, 2023, 1:06 p.m.",
432
- // "id": 7498807
433
- // },
434
- // ]
435
- //
436
- // they report each trade twice (once for both of the two sides of the fill)
437
- // deduplicate trades for that reason
438
- const trades = [];
439
- for (let i = 0; i < response.length; i++) {
440
- const id = this.safeInteger(response[i], 'id');
441
- if (id % 2) {
442
- trades.push(response[i]);
443
- }
444
- }
445
- return this.parseTrades(trades, market, since, limit);
446
- }
447
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
448
- /**
449
- * @method
450
- * @name btctradeua#createOrder
451
- * @description create a trade order
452
- * @param {string} symbol unified symbol of the market to create an order in
453
- * @param {string} type must be 'limit'
454
- * @param {string} side 'buy' or 'sell'
455
- * @param {float} amount how much of currency you want to trade in units of base currency
456
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
457
- * @param {object} [params] extra parameters specific to the btctradeua api endpoint
458
- * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
459
- */
460
- if (type === 'market') {
461
- throw new errors.ExchangeError(this.id + ' createOrder() allows limit orders only');
462
- }
463
- await this.loadMarkets();
464
- const market = this.market(symbol);
465
- const method = 'privatePost' + this.capitalize(side) + 'Id';
466
- const request = {
467
- 'count': amount,
468
- 'currency1': market['quoteId'],
469
- 'currency': market['baseId'],
470
- 'price': price,
471
- };
472
- return this[method](this.extend(request, params));
473
- }
474
- async cancelOrder(id, symbol = undefined, params = {}) {
475
- /**
476
- * @method
477
- * @name btctradeua#cancelOrder
478
- * @description cancels an open order
479
- * @param {string} id order id
480
- * @param {string} symbol not used by btctradeua cancelOrder ()
481
- * @param {object} [params] extra parameters specific to the btctradeua api endpoint
482
- * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
483
- */
484
- const request = {
485
- 'id': id,
486
- };
487
- return await this.privatePostRemoveOrderId(this.extend(request, params));
488
- }
489
- parseOrder(order, market = undefined) {
490
- const timestamp = this.milliseconds();
491
- const symbol = this.safeSymbol(undefined, market);
492
- const side = this.safeString(order, 'type');
493
- const price = this.safeString(order, 'price');
494
- const amount = this.safeString(order, 'amnt_trade');
495
- const remaining = this.safeString(order, 'amnt_trade');
496
- return this.safeOrder({
497
- 'id': this.safeString(order, 'id'),
498
- 'clientOrderId': undefined,
499
- 'timestamp': timestamp,
500
- 'datetime': this.iso8601(timestamp),
501
- 'lastTradeTimestamp': undefined,
502
- 'status': 'open',
503
- 'symbol': symbol,
504
- 'type': undefined,
505
- 'timeInForce': undefined,
506
- 'postOnly': undefined,
507
- 'side': side,
508
- 'price': price,
509
- 'stopPrice': undefined,
510
- 'triggerPrice': undefined,
511
- 'amount': amount,
512
- 'filled': undefined,
513
- 'remaining': remaining,
514
- 'trades': undefined,
515
- 'info': order,
516
- 'cost': undefined,
517
- 'average': undefined,
518
- 'fee': undefined,
519
- }, market);
520
- }
521
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
522
- /**
523
- * @method
524
- * @name btctradeua#fetchOpenOrders
525
- * @description fetch all unfilled currently open orders
526
- * @param {string} symbol unified market symbol
527
- * @param {int} [since] the earliest time in ms to fetch open orders for
528
- * @param {int} [limit] the maximum number of open order structures to retrieve
529
- * @param {object} [params] extra parameters specific to the btctradeua api endpoint
530
- * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
531
- */
532
- this.checkRequiredSymbol('fetchOpenOrders', symbol);
533
- await this.loadMarkets();
534
- const market = this.market(symbol);
535
- const request = {
536
- 'symbol': market['id'],
537
- };
538
- const response = await this.privatePostMyOrdersSymbol(this.extend(request, params));
539
- const orders = this.safeValue(response, 'your_open_orders');
540
- return this.parseOrders(orders, market, since, limit);
541
- }
542
- nonce() {
543
- return this.milliseconds();
544
- }
545
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
546
- let url = this.urls['api']['rest'] + '/' + this.implodeParams(path, params);
547
- const query = this.omit(params, this.extractParams(path));
548
- if (api === 'public') {
549
- if (Object.keys(query).length) {
550
- url += this.implodeParams(path, query);
551
- }
552
- }
553
- else {
554
- this.checkRequiredCredentials();
555
- const nonce = this.nonce();
556
- body = this.urlencode(this.extend({
557
- 'out_order_id': nonce,
558
- 'nonce': nonce,
559
- }, query));
560
- const auth = body + this.secret;
561
- headers = {
562
- 'public-key': this.apiKey,
563
- 'api-sign': this.hash(this.encode(auth), sha256.sha256),
564
- 'Content-Type': 'application/x-www-form-urlencoded',
565
- };
566
- }
567
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
568
- }
569
- }
570
-
571
- module.exports = btctradeua;