ccxt-look 1.81.50

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 (264) hide show
  1. package/.cache/eslintcache +1 -0
  2. package/.dockerignore +6 -0
  3. package/.eslintignore +1 -0
  4. package/.gitattributes +5 -0
  5. package/.readthedocs.yaml +16 -0
  6. package/CONTRIBUTING.md +1049 -0
  7. package/LICENSE.txt +21 -0
  8. package/README.md +537 -0
  9. package/SECURITY.md +5 -0
  10. package/build/cleanup-old-tags.js +94 -0
  11. package/build/countries.js +256 -0
  12. package/build/export-exchanges.js +520 -0
  13. package/build/fs.js +51 -0
  14. package/build/transpile.js +1772 -0
  15. package/build/vss.js +78 -0
  16. package/ccxt.browser.js +7 -0
  17. package/ccxt.d.ts +692 -0
  18. package/ccxt.js +171 -0
  19. package/cleanup.sh +2 -0
  20. package/composer-install.sh +20 -0
  21. package/dist/ccxt.browser.js +208383 -0
  22. package/gource.sh +3 -0
  23. package/index.html +7 -0
  24. package/js/.eslintrc +87 -0
  25. package/js/aax.js +2686 -0
  26. package/js/ascendex.js +2584 -0
  27. package/js/base/.eslintrc.js +43 -0
  28. package/js/base/Exchange.js +2371 -0
  29. package/js/base/Precise.js +283 -0
  30. package/js/base/errorHierarchy.js +47 -0
  31. package/js/base/errors.js +55 -0
  32. package/js/base/functions/crypto.js +158 -0
  33. package/js/base/functions/encode.js +118 -0
  34. package/js/base/functions/generic.js +270 -0
  35. package/js/base/functions/misc.js +138 -0
  36. package/js/base/functions/number.js +329 -0
  37. package/js/base/functions/platform.js +38 -0
  38. package/js/base/functions/string.js +21 -0
  39. package/js/base/functions/throttle.js +79 -0
  40. package/js/base/functions/time.js +210 -0
  41. package/js/base/functions/type.js +66 -0
  42. package/js/base/functions.js +28 -0
  43. package/js/bequant.js +32 -0
  44. package/js/bibox.js +1407 -0
  45. package/js/bigone.js +1366 -0
  46. package/js/binance.js +5652 -0
  47. package/js/binancecoinm.js +46 -0
  48. package/js/binanceus.js +46 -0
  49. package/js/binanceusdm.js +49 -0
  50. package/js/bit2c.js +535 -0
  51. package/js/bitbank.js +842 -0
  52. package/js/bitbay.js +16 -0
  53. package/js/bitbns.js +1073 -0
  54. package/js/bitcoincom.js +15 -0
  55. package/js/bitfinex.js +1433 -0
  56. package/js/bitfinex2.js +2025 -0
  57. package/js/bitflyer.js +840 -0
  58. package/js/bitforex.js +614 -0
  59. package/js/bitget.js +2397 -0
  60. package/js/bithumb.js +980 -0
  61. package/js/bitmart.js +2516 -0
  62. package/js/bitmex.js +1809 -0
  63. package/js/bitopro.js +1443 -0
  64. package/js/bitpanda.js +1782 -0
  65. package/js/bitrue.js +1747 -0
  66. package/js/bitso.js +1062 -0
  67. package/js/bitstamp.js +1757 -0
  68. package/js/bitstamp1.js +343 -0
  69. package/js/bittrex.js +1876 -0
  70. package/js/bitvavo.js +1579 -0
  71. package/js/bkex.js +1233 -0
  72. package/js/bl3p.js +346 -0
  73. package/js/blockchaincom.js +969 -0
  74. package/js/btcalpha.js +680 -0
  75. package/js/btcbox.js +477 -0
  76. package/js/btcmarkets.js +1022 -0
  77. package/js/btctradeua.js +466 -0
  78. package/js/btcturk.js +734 -0
  79. package/js/buda.js +946 -0
  80. package/js/bw.js +1265 -0
  81. package/js/bybit.js +3372 -0
  82. package/js/bytetrade.js +1336 -0
  83. package/js/cdax.js +1646 -0
  84. package/js/cex.js +1410 -0
  85. package/js/coinbase.js +1342 -0
  86. package/js/coinbaseprime.js +31 -0
  87. package/js/coinbasepro.js +1466 -0
  88. package/js/coincheck.js +755 -0
  89. package/js/coinex.js +3400 -0
  90. package/js/coinfalcon.js +880 -0
  91. package/js/coinmate.js +794 -0
  92. package/js/coinone.js +816 -0
  93. package/js/coinspot.js +345 -0
  94. package/js/crex24.js +1636 -0
  95. package/js/cryptocom.js +1832 -0
  96. package/js/currencycom.js +1748 -0
  97. package/js/delta.js +1547 -0
  98. package/js/deribit.js +2148 -0
  99. package/js/digifinex.js +1585 -0
  100. package/js/eqonex.js +1660 -0
  101. package/js/exmo.js +1670 -0
  102. package/js/fairdesk.js +1231 -0
  103. package/js/flowbtc.js +35 -0
  104. package/js/fmfwio.js +34 -0
  105. package/js/ftx.js +2751 -0
  106. package/js/ftxus.js +38 -0
  107. package/js/gateio.js +4174 -0
  108. package/js/gemini.js +1397 -0
  109. package/js/hitbtc.js +1343 -0
  110. package/js/hitbtc3.js +2329 -0
  111. package/js/hollaex.js +1486 -0
  112. package/js/huobi.js +5706 -0
  113. package/js/huobijp.js +1710 -0
  114. package/js/huobipro.js +18 -0
  115. package/js/idex.js +1439 -0
  116. package/js/independentreserve.js +649 -0
  117. package/js/indodax.js +742 -0
  118. package/js/itbit.js +722 -0
  119. package/js/kraken.js +2179 -0
  120. package/js/kucoin.js +2571 -0
  121. package/js/kucoinfutures.js +1771 -0
  122. package/js/kuna.js +809 -0
  123. package/js/latoken.js +1445 -0
  124. package/js/lbank.js +760 -0
  125. package/js/liquid.js +1432 -0
  126. package/js/luno.js +873 -0
  127. package/js/lykke.js +1147 -0
  128. package/js/mercado.js +771 -0
  129. package/js/mexc.js +3151 -0
  130. package/js/ndax.js +2233 -0
  131. package/js/novadax.js +1318 -0
  132. package/js/oceanex.js +816 -0
  133. package/js/okcoin.js +3841 -0
  134. package/js/okex.js +16 -0
  135. package/js/okex5.js +16 -0
  136. package/js/okx.js +4795 -0
  137. package/js/paymium.js +498 -0
  138. package/js/phemex.js +2957 -0
  139. package/js/poloniex.js +1674 -0
  140. package/js/probit.js +1346 -0
  141. package/js/qtrade.js +1588 -0
  142. package/js/ripio.js +1061 -0
  143. package/js/static_dependencies/BN/bn.js +3526 -0
  144. package/js/static_dependencies/README.md +1 -0
  145. package/js/static_dependencies/crypto-js/crypto-js.js +5988 -0
  146. package/js/static_dependencies/elliptic/lib/elliptic/curve/base.js +375 -0
  147. package/js/static_dependencies/elliptic/lib/elliptic/curve/edwards.js +433 -0
  148. package/js/static_dependencies/elliptic/lib/elliptic/curve/index.js +8 -0
  149. package/js/static_dependencies/elliptic/lib/elliptic/curve/mont.js +180 -0
  150. package/js/static_dependencies/elliptic/lib/elliptic/curve/short.js +938 -0
  151. package/js/static_dependencies/elliptic/lib/elliptic/curves.js +204 -0
  152. package/js/static_dependencies/elliptic/lib/elliptic/ec/index.js +240 -0
  153. package/js/static_dependencies/elliptic/lib/elliptic/ec/key.js +119 -0
  154. package/js/static_dependencies/elliptic/lib/elliptic/ec/signature.js +24 -0
  155. package/js/static_dependencies/elliptic/lib/elliptic/eddsa/index.js +145 -0
  156. package/js/static_dependencies/elliptic/lib/elliptic/eddsa/key.js +100 -0
  157. package/js/static_dependencies/elliptic/lib/elliptic/eddsa/signature.js +65 -0
  158. package/js/static_dependencies/elliptic/lib/elliptic/precomputed/secp256k1.js +780 -0
  159. package/js/static_dependencies/elliptic/lib/elliptic/utils.js +214 -0
  160. package/js/static_dependencies/elliptic/lib/elliptic.js +22 -0
  161. package/js/static_dependencies/elliptic/lib/hmac-drbg/hmac-drbg.js +114 -0
  162. package/js/static_dependencies/fetch-ponyfill/fetch-node.js +39 -0
  163. package/js/static_dependencies/node-fetch/index.js +1564 -0
  164. package/js/static_dependencies/node-rsa/NodeRSA.js +223 -0
  165. package/js/static_dependencies/node-rsa/asn1/ber/errors.js +13 -0
  166. package/js/static_dependencies/node-rsa/asn1/ber/index.js +21 -0
  167. package/js/static_dependencies/node-rsa/asn1/ber/reader.js +262 -0
  168. package/js/static_dependencies/node-rsa/asn1/ber/types.js +36 -0
  169. package/js/static_dependencies/node-rsa/asn1/index.js +17 -0
  170. package/js/static_dependencies/node-rsa/encryptEngines/js.js +34 -0
  171. package/js/static_dependencies/node-rsa/formats/components.js +71 -0
  172. package/js/static_dependencies/node-rsa/formats/formats.js +31 -0
  173. package/js/static_dependencies/node-rsa/formats/pkcs1.js +148 -0
  174. package/js/static_dependencies/node-rsa/formats/pkcs8.js +187 -0
  175. package/js/static_dependencies/node-rsa/libs/jsbn.js +1252 -0
  176. package/js/static_dependencies/node-rsa/libs/rsa.js +147 -0
  177. package/js/static_dependencies/node-rsa/schemes/pkcs1.js +176 -0
  178. package/js/static_dependencies/node-rsa/schemes/schemes.js +21 -0
  179. package/js/static_dependencies/node-rsa/utils.js +98 -0
  180. package/js/static_dependencies/qs/formats.js +18 -0
  181. package/js/static_dependencies/qs/index.js +11 -0
  182. package/js/static_dependencies/qs/parse.js +242 -0
  183. package/js/static_dependencies/qs/stringify.js +269 -0
  184. package/js/static_dependencies/qs/utils.js +230 -0
  185. package/js/stex.js +1925 -0
  186. package/js/test/.eslintrc.js +42 -0
  187. package/js/test/Exchange/test.balance.js +61 -0
  188. package/js/test/Exchange/test.borrowRate.js +32 -0
  189. package/js/test/Exchange/test.currency.js +52 -0
  190. package/js/test/Exchange/test.fetchBalance.js +23 -0
  191. package/js/test/Exchange/test.fetchBorrowInterest.js +59 -0
  192. package/js/test/Exchange/test.fetchBorrowRate.js +32 -0
  193. package/js/test/Exchange/test.fetchBorrowRates.js +28 -0
  194. package/js/test/Exchange/test.fetchClosedOrders.js +32 -0
  195. package/js/test/Exchange/test.fetchCurrencies.js +35 -0
  196. package/js/test/Exchange/test.fetchDeposits.js +31 -0
  197. package/js/test/Exchange/test.fetchFundingFees.js +19 -0
  198. package/js/test/Exchange/test.fetchFundingRateHistory.js +40 -0
  199. package/js/test/Exchange/test.fetchL2OrderBook.js +23 -0
  200. package/js/test/Exchange/test.fetchLedger.js +42 -0
  201. package/js/test/Exchange/test.fetchLeverageTiers.js +33 -0
  202. package/js/test/Exchange/test.fetchMarketLeverageTiers.js +22 -0
  203. package/js/test/Exchange/test.fetchMarkets.js +33 -0
  204. package/js/test/Exchange/test.fetchMyTrades.js +42 -0
  205. package/js/test/Exchange/test.fetchOHLCV.js +46 -0
  206. package/js/test/Exchange/test.fetchOpenOrders.js +36 -0
  207. package/js/test/Exchange/test.fetchOrderBook.js +25 -0
  208. package/js/test/Exchange/test.fetchOrderBooks.js +35 -0
  209. package/js/test/Exchange/test.fetchOrders.js +41 -0
  210. package/js/test/Exchange/test.fetchPositions.js +47 -0
  211. package/js/test/Exchange/test.fetchStatus.js +35 -0
  212. package/js/test/Exchange/test.fetchTicker.js +38 -0
  213. package/js/test/Exchange/test.fetchTickers.js +49 -0
  214. package/js/test/Exchange/test.fetchTrades.js +39 -0
  215. package/js/test/Exchange/test.fetchTradingFee.js +18 -0
  216. package/js/test/Exchange/test.fetchTradingFees.js +22 -0
  217. package/js/test/Exchange/test.fetchTransactions.js +31 -0
  218. package/js/test/Exchange/test.fetchWithdrawals.js +31 -0
  219. package/js/test/Exchange/test.ledgerItem.js +46 -0
  220. package/js/test/Exchange/test.leverageTier.js +33 -0
  221. package/js/test/Exchange/test.loadMarkets.js +35 -0
  222. package/js/test/Exchange/test.market.js +129 -0
  223. package/js/test/Exchange/test.ohlcv.js +33 -0
  224. package/js/test/Exchange/test.order.js +62 -0
  225. package/js/test/Exchange/test.orderbook.js +61 -0
  226. package/js/test/Exchange/test.position.js +21 -0
  227. package/js/test/Exchange/test.throttle.js +94 -0
  228. package/js/test/Exchange/test.ticker.js +95 -0
  229. package/js/test/Exchange/test.trade.js +68 -0
  230. package/js/test/Exchange/test.tradingFee.js +34 -0
  231. package/js/test/Exchange/test.transaction.js +35 -0
  232. package/js/test/base/.eslintrc +38 -0
  233. package/js/test/base/functions/test.crypto.js +110 -0
  234. package/js/test/base/functions/test.datetime.js +62 -0
  235. package/js/test/base/functions/test.generic.js +152 -0
  236. package/js/test/base/functions/test.number.js +362 -0
  237. package/js/test/base/functions/test.time.js +56 -0
  238. package/js/test/base/functions/test.type.js +53 -0
  239. package/js/test/base/test.base.js +193 -0
  240. package/js/test/errors/test.InsufficientFunds.js +86 -0
  241. package/js/test/errors/test.InvalidNonce.js +64 -0
  242. package/js/test/errors/test.InvalidOrder.js +35 -0
  243. package/js/test/errors/test.OrderNotFound.js +39 -0
  244. package/js/test/test.js +426 -0
  245. package/js/test/test.timeout_hang.js +12 -0
  246. package/js/therock.js +1431 -0
  247. package/js/tidebit.js +632 -0
  248. package/js/tidex.js +939 -0
  249. package/js/timex.js +1283 -0
  250. package/js/upbit.js +1622 -0
  251. package/js/vcc.js +1353 -0
  252. package/js/wavesexchange.js +2185 -0
  253. package/js/wazirx.js +732 -0
  254. package/js/whitebit.js +1352 -0
  255. package/js/woo.js +1577 -0
  256. package/js/xena.js +1948 -0
  257. package/js/yobit.js +1129 -0
  258. package/js/zaif.js +647 -0
  259. package/js/zb.js +4088 -0
  260. package/js/zipmex.js +40 -0
  261. package/js/zonda.js +1497 -0
  262. package/multilang.sh +159 -0
  263. package/package.json +591 -0
  264. package/postinstall.js +103 -0
package/js/coinmate.js ADDED
@@ -0,0 +1,794 @@
1
+ 'use strict';
2
+
3
+ // ---------------------------------------------------------------------------
4
+
5
+ const Exchange = require ('./base/Exchange');
6
+ const { ExchangeError, ArgumentsRequired, InvalidOrder, OrderNotFound, RateLimitExceeded, InsufficientFunds, AuthenticationError } = require ('./base/errors');
7
+ const Precise = require ('./base/Precise');
8
+
9
+ // ---------------------------------------------------------------------------
10
+
11
+ module.exports = class coinmate extends Exchange {
12
+ describe () {
13
+ return this.deepExtend (super.describe (), {
14
+ 'id': 'coinmate',
15
+ 'name': 'CoinMate',
16
+ 'countries': [ 'GB', 'CZ', 'EU' ], // UK, Czech Republic
17
+ 'rateLimit': 1000,
18
+ 'has': {
19
+ 'CORS': true,
20
+ 'spot': true,
21
+ 'margin': false,
22
+ 'swap': false,
23
+ 'future': false,
24
+ 'option': false,
25
+ 'addMargin': false,
26
+ 'cancelOrder': true,
27
+ 'createOrder': true,
28
+ 'createReduceOnlyOrder': false,
29
+ 'fetchBalance': true,
30
+ 'fetchBorrowRate': false,
31
+ 'fetchBorrowRateHistories': false,
32
+ 'fetchBorrowRateHistory': false,
33
+ 'fetchBorrowRates': false,
34
+ 'fetchBorrowRatesPerSymbol': false,
35
+ 'fetchFundingHistory': false,
36
+ 'fetchFundingRate': false,
37
+ 'fetchFundingRateHistory': false,
38
+ 'fetchFundingRates': false,
39
+ 'fetchIndexOHLCV': false,
40
+ 'fetchLeverage': false,
41
+ 'fetchLeverageTiers': false,
42
+ 'fetchMarkets': true,
43
+ 'fetchMarkOHLCV': false,
44
+ 'fetchMyTrades': true,
45
+ 'fetchOpenOrders': true,
46
+ 'fetchOrder': true,
47
+ 'fetchOrderBook': true,
48
+ 'fetchOrders': true,
49
+ 'fetchPosition': false,
50
+ 'fetchPositions': false,
51
+ 'fetchPositionsRisk': false,
52
+ 'fetchPremiumIndexOHLCV': false,
53
+ 'fetchTicker': true,
54
+ 'fetchTrades': true,
55
+ 'fetchTradingFee': true,
56
+ 'fetchTradingFees': false,
57
+ 'fetchTransactions': true,
58
+ 'reduceMargin': false,
59
+ 'setLeverage': false,
60
+ 'setMarginMode': false,
61
+ 'setPositionMode': false,
62
+ 'transfer': false,
63
+ },
64
+ 'urls': {
65
+ 'logo': 'https://user-images.githubusercontent.com/51840849/87460806-1c9f3f00-c616-11ea-8c46-a77018a8f3f4.jpg',
66
+ 'api': 'https://coinmate.io/api',
67
+ 'www': 'https://coinmate.io',
68
+ 'fees': 'https://coinmate.io/fees',
69
+ 'doc': [
70
+ 'https://coinmate.docs.apiary.io',
71
+ 'https://coinmate.io/developers',
72
+ ],
73
+ 'referral': 'https://coinmate.io?referral=YTFkM1RsOWFObVpmY1ZjMGREQmpTRnBsWjJJNVp3PT0',
74
+ },
75
+ 'requiredCredentials': {
76
+ 'apiKey': true,
77
+ 'secret': true,
78
+ 'uid': true,
79
+ },
80
+ 'api': {
81
+ 'public': {
82
+ 'get': [
83
+ 'orderBook',
84
+ 'ticker',
85
+ 'transactions',
86
+ 'tradingPairs',
87
+ ],
88
+ },
89
+ 'private': {
90
+ 'post': [
91
+ 'balances',
92
+ 'bitcoinCashWithdrawal',
93
+ 'bitcoinCashDepositAddresses',
94
+ 'bitcoinDepositAddresses',
95
+ 'bitcoinWithdrawal',
96
+ 'bitcoinWithdrawalFees',
97
+ 'buyInstant',
98
+ 'buyLimit',
99
+ 'cancelOrder',
100
+ 'cancelOrderWithInfo',
101
+ 'createVoucher',
102
+ 'dashDepositAddresses',
103
+ 'dashWithdrawal',
104
+ 'ethereumWithdrawal',
105
+ 'ethereumDepositAddresses',
106
+ 'litecoinWithdrawal',
107
+ 'litecoinDepositAddresses',
108
+ 'openOrders',
109
+ 'order',
110
+ 'orderHistory',
111
+ 'orderById',
112
+ 'pusherAuth',
113
+ 'redeemVoucher',
114
+ 'replaceByBuyLimit',
115
+ 'replaceByBuyInstant',
116
+ 'replaceBySellLimit',
117
+ 'replaceBySellInstant',
118
+ 'rippleDepositAddresses',
119
+ 'rippleWithdrawal',
120
+ 'sellInstant',
121
+ 'sellLimit',
122
+ 'transactionHistory',
123
+ 'traderFees',
124
+ 'tradeHistory',
125
+ 'transfer',
126
+ 'transferHistory',
127
+ 'unconfirmedBitcoinDeposits',
128
+ 'unconfirmedBitcoinCashDeposits',
129
+ 'unconfirmedDashDeposits',
130
+ 'unconfirmedEthereumDeposits',
131
+ 'unconfirmedLitecoinDeposits',
132
+ 'unconfirmedRippleDeposits',
133
+ ],
134
+ },
135
+ },
136
+ 'fees': {
137
+ 'trading': {
138
+ 'tierBased': true,
139
+ 'percentage': true,
140
+ 'maker': 0.12 / 100,
141
+ 'taker': 0.25 / 100,
142
+ 'tiers': {
143
+ 'taker': [
144
+ [ this.parseNumber ('0'), this.parseNumber ('0.0035') ],
145
+ [ this.parseNumber ('10000'), this.parseNumber ('0.0023') ],
146
+ [ this.parseNumber ('100000'), this.parseNumber ('0.0021') ],
147
+ [ this.parseNumber ('250000'), this.parseNumber ('0.0020') ],
148
+ [ this.parseNumber ('500000'), this.parseNumber ('0.0015') ],
149
+ [ this.parseNumber ('1000000'), this.parseNumber ('0.0013') ],
150
+ [ this.parseNumber ('3000000'), this.parseNumber ('0.0010') ],
151
+ [ this.parseNumber ('15000000'), this.parseNumber ('0.0005') ],
152
+ ],
153
+ 'maker': [
154
+ [ this.parseNumber ('0'), this.parseNumber ('0.003') ],
155
+ [ this.parseNumber ('10000'), this.parseNumber ('0.0011') ],
156
+ [ this.parseNumber ('100000'), this.parseNumber ('0.0010') ],
157
+ [ this.parseNumber ('250000'), this.parseNumber ('0.0008') ],
158
+ [ this.parseNumber ('500000'), this.parseNumber ('0.0005') ],
159
+ [ this.parseNumber ('1000000'), this.parseNumber ('0.0003') ],
160
+ [ this.parseNumber ('3000000'), this.parseNumber ('0.0002') ],
161
+ [ this.parseNumber ('15000000'), this.parseNumber ('0') ],
162
+ ],
163
+ },
164
+ },
165
+ },
166
+ 'exceptions': {
167
+ 'exact': {
168
+ 'No order with given ID': OrderNotFound,
169
+ },
170
+ 'broad': {
171
+ 'Not enough account balance available': InsufficientFunds,
172
+ 'Incorrect order ID': InvalidOrder,
173
+ 'Minimum Order Size ': InvalidOrder,
174
+ 'TOO MANY REQUESTS': RateLimitExceeded,
175
+ 'Access denied.': AuthenticationError, // {"error":true,"errorMessage":"Access denied.","data":null}
176
+ },
177
+ },
178
+ });
179
+ }
180
+
181
+ async fetchMarkets (params = {}) {
182
+ const response = await this.publicGetTradingPairs (params);
183
+ //
184
+ // {
185
+ // "error":false,
186
+ // "errorMessage":null,
187
+ // "data": [
188
+ // {
189
+ // "name":"BTC_EUR",
190
+ // "firstCurrency":"BTC",
191
+ // "secondCurrency":"EUR",
192
+ // "priceDecimals":2,
193
+ // "lotDecimals":8,
194
+ // "minAmount":0.0002,
195
+ // "tradesWebSocketChannelId":"trades-BTC_EUR",
196
+ // "orderBookWebSocketChannelId":"order_book-BTC_EUR",
197
+ // "tradeStatisticsWebSocketChannelId":"statistics-BTC_EUR"
198
+ // },
199
+ // ]
200
+ // }
201
+ //
202
+ const data = this.safeValue (response, 'data');
203
+ const result = [];
204
+ for (let i = 0; i < data.length; i++) {
205
+ const market = data[i];
206
+ const id = this.safeString (market, 'name');
207
+ const baseId = this.safeString (market, 'firstCurrency');
208
+ const quoteId = this.safeString (market, 'secondCurrency');
209
+ const base = this.safeCurrencyCode (baseId);
210
+ const quote = this.safeCurrencyCode (quoteId);
211
+ const symbol = base + '/' + quote;
212
+ result.push ({
213
+ 'id': id,
214
+ 'symbol': symbol,
215
+ 'base': base,
216
+ 'quote': quote,
217
+ 'settle': undefined,
218
+ 'baseId': baseId,
219
+ 'quoteId': quoteId,
220
+ 'settleId': undefined,
221
+ 'type': 'spot',
222
+ 'spot': true,
223
+ 'margin': false,
224
+ 'swap': false,
225
+ 'future': false,
226
+ 'option': false,
227
+ 'active': undefined,
228
+ 'contract': false,
229
+ 'linear': undefined,
230
+ 'inverse': undefined,
231
+ 'contractSize': undefined,
232
+ 'expiry': undefined,
233
+ 'expiryDatetime': undefined,
234
+ 'strike': undefined,
235
+ 'optionType': undefined,
236
+ 'precision': {
237
+ 'amount': this.safeInteger (market, 'lotDecimals'),
238
+ 'price': this.safeInteger (market, 'priceDecimals'),
239
+ },
240
+ 'limits': {
241
+ 'leverage': {
242
+ 'min': undefined,
243
+ 'max': undefined,
244
+ },
245
+ 'amount': {
246
+ 'min': this.safeNumber (market, 'minAmount'),
247
+ 'max': undefined,
248
+ },
249
+ 'price': {
250
+ 'min': undefined,
251
+ 'max': undefined,
252
+ },
253
+ 'cost': {
254
+ 'min': undefined,
255
+ 'max': undefined,
256
+ },
257
+ },
258
+ 'info': market,
259
+ });
260
+ }
261
+ return result;
262
+ }
263
+
264
+ parseBalance (response) {
265
+ const balances = this.safeValue (response, 'data');
266
+ const result = { 'info': response };
267
+ const currencyIds = Object.keys (balances);
268
+ for (let i = 0; i < currencyIds.length; i++) {
269
+ const currencyId = currencyIds[i];
270
+ const code = this.safeCurrencyCode (currencyId);
271
+ const balance = this.safeValue (balances, currencyId);
272
+ const account = this.account ();
273
+ account['free'] = this.safeString (balance, 'available');
274
+ account['used'] = this.safeString (balance, 'reserved');
275
+ account['total'] = this.safeString (balance, 'balance');
276
+ result[code] = account;
277
+ }
278
+ return this.safeBalance (result);
279
+ }
280
+
281
+ async fetchBalance (params = {}) {
282
+ await this.loadMarkets ();
283
+ const response = await this.privatePostBalances (params);
284
+ return this.parseBalance (response);
285
+ }
286
+
287
+ async fetchOrderBook (symbol, limit = undefined, params = {}) {
288
+ await this.loadMarkets ();
289
+ const request = {
290
+ 'currencyPair': this.marketId (symbol),
291
+ 'groupByPriceLimit': 'False',
292
+ };
293
+ const response = await this.publicGetOrderBook (this.extend (request, params));
294
+ const orderbook = response['data'];
295
+ const timestamp = this.safeTimestamp (orderbook, 'timestamp');
296
+ return this.parseOrderBook (orderbook, symbol, timestamp, 'bids', 'asks', 'price', 'amount');
297
+ }
298
+
299
+ async fetchTicker (symbol, params = {}) {
300
+ await this.loadMarkets ();
301
+ const request = {
302
+ 'currencyPair': this.marketId (symbol),
303
+ };
304
+ const response = await this.publicGetTicker (this.extend (request, params));
305
+ const ticker = this.safeValue (response, 'data');
306
+ const timestamp = this.safeTimestamp (ticker, 'timestamp');
307
+ const last = this.safeNumber (ticker, 'last');
308
+ return {
309
+ 'symbol': symbol,
310
+ 'timestamp': timestamp,
311
+ 'datetime': this.iso8601 (timestamp),
312
+ 'high': this.safeNumber (ticker, 'high'),
313
+ 'low': this.safeNumber (ticker, 'low'),
314
+ 'bid': this.safeNumber (ticker, 'bid'),
315
+ 'bidVolume': undefined,
316
+ 'ask': this.safeNumber (ticker, 'ask'),
317
+ 'vwap': undefined,
318
+ 'askVolume': undefined,
319
+ 'open': undefined,
320
+ 'close': last,
321
+ 'last': last,
322
+ 'previousClose': undefined,
323
+ 'change': undefined,
324
+ 'percentage': undefined,
325
+ 'average': undefined,
326
+ 'baseVolume': this.safeNumber (ticker, 'amount'),
327
+ 'quoteVolume': undefined,
328
+ 'info': ticker,
329
+ };
330
+ }
331
+
332
+ async fetchTransactions (code = undefined, since = undefined, limit = undefined, params = {}) {
333
+ await this.loadMarkets ();
334
+ const request = {
335
+ 'limit': 1000,
336
+ };
337
+ if (limit !== undefined) {
338
+ request['limit'] = limit;
339
+ }
340
+ if (since !== undefined) {
341
+ request['timestampFrom'] = since;
342
+ }
343
+ if (code !== undefined) {
344
+ const currency = this.currency (code);
345
+ request['currency'] = currency['id'];
346
+ }
347
+ const response = await this.privatePostTransferHistory (this.extend (request, params));
348
+ const items = response['data'];
349
+ return this.parseTransactions (items, undefined, since, limit);
350
+ }
351
+
352
+ parseTransactionStatus (status) {
353
+ const statuses = {
354
+ // any other types ?
355
+ 'COMPLETED': 'ok',
356
+ };
357
+ return this.safeString (statuses, status, status);
358
+ }
359
+
360
+ parseTransaction (transaction, currency = undefined) {
361
+ //
362
+ // deposits
363
+ //
364
+ // {
365
+ // transactionId: 1862815,
366
+ // timestamp: 1516803982388,
367
+ // amountCurrency: 'LTC',
368
+ // amount: 1,
369
+ // fee: 0,
370
+ // walletType: 'LTC',
371
+ // transferType: 'DEPOSIT',
372
+ // transferStatus: 'COMPLETED',
373
+ // txid:
374
+ // 'ccb9255dfa874e6c28f1a64179769164025329d65e5201849c2400abd6bce245',
375
+ // destination: 'LQrtSKA6LnhcwRrEuiborQJnjFF56xqsFn',
376
+ // destinationTag: null
377
+ // }
378
+ //
379
+ // withdrawals
380
+ //
381
+ // {
382
+ // transactionId: 2140966,
383
+ // timestamp: 1519314282976,
384
+ // amountCurrency: 'EUR',
385
+ // amount: 8421.7228,
386
+ // fee: 16.8772,
387
+ // walletType: 'BANK_WIRE',
388
+ // transferType: 'WITHDRAWAL',
389
+ // transferStatus: 'COMPLETED',
390
+ // txid: null,
391
+ // destination: null,
392
+ // destinationTag: null
393
+ // }
394
+ //
395
+ const timestamp = this.safeInteger (transaction, 'timestamp');
396
+ const amount = this.safeNumber (transaction, 'amount');
397
+ const fee = this.safeNumber (transaction, 'fee');
398
+ const txid = this.safeString (transaction, 'txid');
399
+ const address = this.safeString (transaction, 'destination');
400
+ const tag = this.safeString (transaction, 'destinationTag');
401
+ const currencyId = this.safeString (transaction, 'amountCurrency');
402
+ const code = this.safeCurrencyCode (currencyId, currency);
403
+ const type = this.safeStringLower (transaction, 'transferType');
404
+ const status = this.parseTransactionStatus (this.safeString (transaction, 'transferStatus'));
405
+ const id = this.safeString (transaction, 'transactionId');
406
+ const network = this.safeString (transaction, 'walletType');
407
+ return {
408
+ 'id': id,
409
+ 'timestamp': timestamp,
410
+ 'datetime': this.iso8601 (timestamp),
411
+ 'currency': code,
412
+ 'amount': amount,
413
+ 'type': type,
414
+ 'txid': txid,
415
+ 'network': network,
416
+ 'address': address,
417
+ 'addressTo': undefined,
418
+ 'addressFrom': undefined,
419
+ 'tag': tag,
420
+ 'tagTo': undefined,
421
+ 'tagFrom': undefined,
422
+ 'status': status,
423
+ 'fee': {
424
+ 'cost': fee,
425
+ 'currency': code,
426
+ },
427
+ 'info': transaction,
428
+ };
429
+ }
430
+
431
+ async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
432
+ await this.loadMarkets ();
433
+ if (limit === undefined) {
434
+ limit = 1000;
435
+ }
436
+ const request = {
437
+ 'limit': limit,
438
+ };
439
+ if (symbol !== undefined) {
440
+ const market = this.market (symbol);
441
+ request['currencyPair'] = market['id'];
442
+ }
443
+ if (since !== undefined) {
444
+ request['timestampFrom'] = since;
445
+ }
446
+ const response = await this.privatePostTradeHistory (this.extend (request, params));
447
+ const data = this.safeValue (response, 'data', []);
448
+ return this.parseTrades (data, undefined, since, limit);
449
+ }
450
+
451
+ parseTrade (trade, market = undefined) {
452
+ //
453
+ // fetchMyTrades (private)
454
+ //
455
+ // {
456
+ // transactionId: 2671819,
457
+ // createdTimestamp: 1529649127605,
458
+ // currencyPair: 'LTC_BTC',
459
+ // type: 'BUY',
460
+ // orderType: 'LIMIT',
461
+ // orderId: 101810227,
462
+ // amount: 0.01,
463
+ // price: 0.01406,
464
+ // fee: 0,
465
+ // feeType: 'MAKER'
466
+ // }
467
+ //
468
+ // fetchTrades (public)
469
+ //
470
+ // {
471
+ // "timestamp":1561598833416,
472
+ // "transactionId":"4156303",
473
+ // "price":10950.41,
474
+ // "amount":0.004,
475
+ // "currencyPair":"BTC_EUR",
476
+ // "tradeType":"BUY"
477
+ // }
478
+ //
479
+ const marketId = this.safeString (trade, 'currencyPair');
480
+ market = this.safeMarket (marketId, market, '_');
481
+ const priceString = this.safeString (trade, 'price');
482
+ const amountString = this.safeString (trade, 'amount');
483
+ const side = this.safeStringLower2 (trade, 'type', 'tradeType');
484
+ const type = this.safeStringLower (trade, 'orderType');
485
+ const orderId = this.safeString (trade, 'orderId');
486
+ const id = this.safeString (trade, 'transactionId');
487
+ const timestamp = this.safeInteger2 (trade, 'timestamp', 'createdTimestamp');
488
+ let fee = undefined;
489
+ const feeCostString = this.safeString (trade, 'fee');
490
+ if (feeCostString !== undefined) {
491
+ fee = {
492
+ 'cost': feeCostString,
493
+ 'currency': market['quote'],
494
+ };
495
+ }
496
+ let takerOrMaker = this.safeString (trade, 'feeType');
497
+ takerOrMaker = (takerOrMaker === 'MAKER') ? 'maker' : 'taker';
498
+ return this.safeTrade ({
499
+ 'id': id,
500
+ 'info': trade,
501
+ 'timestamp': timestamp,
502
+ 'datetime': this.iso8601 (timestamp),
503
+ 'symbol': market['symbol'],
504
+ 'type': type,
505
+ 'side': side,
506
+ 'order': orderId,
507
+ 'takerOrMaker': takerOrMaker,
508
+ 'price': priceString,
509
+ 'amount': amountString,
510
+ 'cost': undefined,
511
+ 'fee': fee,
512
+ }, market);
513
+ }
514
+
515
+ async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
516
+ await this.loadMarkets ();
517
+ const market = this.market (symbol);
518
+ const request = {
519
+ 'currencyPair': market['id'],
520
+ 'minutesIntoHistory': 10,
521
+ };
522
+ const response = await this.publicGetTransactions (this.extend (request, params));
523
+ //
524
+ // {
525
+ // "error":false,
526
+ // "errorMessage":null,
527
+ // "data":[
528
+ // {
529
+ // "timestamp":1561598833416,
530
+ // "transactionId":"4156303",
531
+ // "price":10950.41,
532
+ // "amount":0.004,
533
+ // "currencyPair":"BTC_EUR",
534
+ // "tradeType":"BUY"
535
+ // }
536
+ // ]
537
+ // }
538
+ //
539
+ const data = this.safeValue (response, 'data', []);
540
+ return this.parseTrades (data, market, since, limit);
541
+ }
542
+
543
+ async fetchTradingFee (symbol, params = {}) {
544
+ await this.loadMarkets ();
545
+ const market = this.market (symbol);
546
+ const request = {
547
+ 'currencyPair': market['id'],
548
+ };
549
+ const response = await this.privatePostTraderFees (this.extend (request, params));
550
+ //
551
+ // {
552
+ // error: false,
553
+ // errorMessage: null,
554
+ // data: { maker: '0.3', taker: '0.35', timestamp: '1646253217815' }
555
+ // }
556
+ //
557
+ const data = this.safeValue (response, 'data', {});
558
+ const makerString = this.safeString (data, 'maker');
559
+ const takerString = this.safeString (data, 'taker');
560
+ const maker = this.parseNumber (Precise.stringDiv (makerString, '100'));
561
+ const taker = this.parseNumber (Precise.stringDiv (takerString, '100'));
562
+ return {
563
+ 'info': data,
564
+ 'symbol': symbol,
565
+ 'maker': maker,
566
+ 'taker': taker,
567
+ 'percentage': true,
568
+ 'tierBased': true,
569
+ };
570
+ }
571
+
572
+ async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
573
+ const response = await this.privatePostOpenOrders (this.extend ({}, params));
574
+ const extension = { 'status': 'open' };
575
+ return this.parseOrders (response['data'], undefined, since, limit, extension);
576
+ }
577
+
578
+ async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
579
+ if (symbol === undefined) {
580
+ throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument');
581
+ }
582
+ await this.loadMarkets ();
583
+ const market = this.market (symbol);
584
+ const request = {
585
+ 'currencyPair': market['id'],
586
+ };
587
+ // offset param that appears in other parts of the API doesn't appear to be supported here
588
+ if (limit !== undefined) {
589
+ request['limit'] = limit;
590
+ }
591
+ const response = await this.privatePostOrderHistory (this.extend (request, params));
592
+ return this.parseOrders (response['data'], market, since, limit);
593
+ }
594
+
595
+ parseOrderStatus (status) {
596
+ const statuses = {
597
+ 'FILLED': 'closed',
598
+ 'CANCELLED': 'canceled',
599
+ 'PARTIALLY_FILLED': 'open',
600
+ 'OPEN': 'open',
601
+ };
602
+ return this.safeString (statuses, status, status);
603
+ }
604
+
605
+ parseOrderType (type) {
606
+ const types = {
607
+ 'LIMIT': 'limit',
608
+ 'MARKET': 'market',
609
+ };
610
+ return this.safeString (types, type, type);
611
+ }
612
+
613
+ parseOrder (order, market = undefined) {
614
+ //
615
+ // limit sell
616
+ //
617
+ // {
618
+ // id: 781246605,
619
+ // timestamp: 1584480015133,
620
+ // trailingUpdatedTimestamp: null,
621
+ // type: 'SELL',
622
+ // currencyPair: 'ETH_BTC',
623
+ // price: 0.0345,
624
+ // amount: 0.01,
625
+ // stopPrice: null,
626
+ // originalStopPrice: null,
627
+ // marketPriceAtLastUpdate: null,
628
+ // marketPriceAtOrderCreation: null,
629
+ // orderTradeType: 'LIMIT',
630
+ // hidden: false,
631
+ // trailing: false,
632
+ // clientOrderId: null
633
+ // }
634
+ //
635
+ // limit buy
636
+ //
637
+ // {
638
+ // id: 67527001,
639
+ // timestamp: 1517931722613,
640
+ // trailingUpdatedTimestamp: null,
641
+ // type: 'BUY',
642
+ // price: 5897.24,
643
+ // remainingAmount: 0.002367,
644
+ // originalAmount: 0.1,
645
+ // stopPrice: null,
646
+ // originalStopPrice: null,
647
+ // marketPriceAtLastUpdate: null,
648
+ // marketPriceAtOrderCreation: null,
649
+ // status: 'CANCELLED',
650
+ // orderTradeType: 'LIMIT',
651
+ // hidden: false,
652
+ // avgPrice: null,
653
+ // trailing: false,
654
+ // }
655
+ //
656
+ const id = this.safeString (order, 'id');
657
+ const timestamp = this.safeInteger (order, 'timestamp');
658
+ const side = this.safeStringLower (order, 'type');
659
+ const priceString = this.safeString (order, 'price');
660
+ const amountString = this.safeString (order, 'originalAmount');
661
+ const remainingString = this.safeString2 (order, 'remainingAmount', 'amount');
662
+ const status = this.parseOrderStatus (this.safeString (order, 'status'));
663
+ const type = this.parseOrderType (this.safeString (order, 'orderTradeType'));
664
+ const averageString = this.safeString (order, 'avgPrice');
665
+ const marketId = this.safeString (order, 'currencyPair');
666
+ const symbol = this.safeSymbol (marketId, market, '_');
667
+ const clientOrderId = this.safeString (order, 'clientOrderId');
668
+ const stopPrice = this.safeNumber (order, 'stopPrice');
669
+ return this.safeOrder ({
670
+ 'id': id,
671
+ 'clientOrderId': clientOrderId,
672
+ 'timestamp': timestamp,
673
+ 'datetime': this.iso8601 (timestamp),
674
+ 'lastTradeTimestamp': undefined,
675
+ 'symbol': symbol,
676
+ 'type': type,
677
+ 'timeInForce': undefined,
678
+ 'postOnly': undefined,
679
+ 'side': side,
680
+ 'price': priceString,
681
+ 'stopPrice': stopPrice,
682
+ 'amount': amountString,
683
+ 'cost': undefined,
684
+ 'average': averageString,
685
+ 'filled': undefined,
686
+ 'remaining': remainingString,
687
+ 'status': status,
688
+ 'trades': undefined,
689
+ 'info': order,
690
+ 'fee': undefined,
691
+ }, market);
692
+ }
693
+
694
+ async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
695
+ await this.loadMarkets ();
696
+ let method = 'privatePost' + this.capitalize (side);
697
+ const request = {
698
+ 'currencyPair': this.marketId (symbol),
699
+ };
700
+ if (type === 'market') {
701
+ if (side === 'buy') {
702
+ request['total'] = this.amountToPrecision (symbol, amount); // amount in fiat
703
+ } else {
704
+ request['amount'] = this.amountToPrecision (symbol, amount); // amount in fiat
705
+ }
706
+ method += 'Instant';
707
+ } else {
708
+ request['amount'] = this.amountToPrecision (symbol, amount); // amount in crypto
709
+ request['price'] = this.priceToPrecision (symbol, price);
710
+ method += this.capitalize (type);
711
+ }
712
+ const response = await this[method] (this.extend (request, params));
713
+ const id = this.safeString (response, 'data');
714
+ return {
715
+ 'info': response,
716
+ 'id': id,
717
+ };
718
+ }
719
+
720
+ async fetchOrder (id, symbol = undefined, params = {}) {
721
+ await this.loadMarkets ();
722
+ const request = {
723
+ 'orderId': id,
724
+ };
725
+ let market = undefined;
726
+ if (symbol) {
727
+ market = this.market (symbol);
728
+ }
729
+ const response = await this.privatePostOrderById (this.extend (request, params));
730
+ const data = this.safeValue (response, 'data');
731
+ return this.parseOrder (data, market);
732
+ }
733
+
734
+ async cancelOrder (id, symbol = undefined, params = {}) {
735
+ // {"error":false,"errorMessage":null,"data":{"success":true,"remainingAmount":0.01}}
736
+ const request = { 'orderId': id };
737
+ const response = await this.privatePostCancelOrderWithInfo (this.extend (request, params));
738
+ return {
739
+ 'info': response,
740
+ };
741
+ }
742
+
743
+ nonce () {
744
+ return this.milliseconds ();
745
+ }
746
+
747
+ sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
748
+ let url = this.urls['api'] + '/' + path;
749
+ if (api === 'public') {
750
+ if (Object.keys (params).length) {
751
+ url += '?' + this.urlencode (params);
752
+ }
753
+ } else {
754
+ this.checkRequiredCredentials ();
755
+ const nonce = this.nonce ().toString ();
756
+ const auth = nonce + this.uid + this.apiKey;
757
+ const signature = this.hmac (this.encode (auth), this.encode (this.secret));
758
+ body = this.urlencode (this.extend ({
759
+ 'clientId': this.uid,
760
+ 'nonce': nonce,
761
+ 'publicKey': this.apiKey,
762
+ 'signature': signature.toUpperCase (),
763
+ }, params));
764
+ headers = {
765
+ 'Content-Type': 'application/x-www-form-urlencoded',
766
+ };
767
+ }
768
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
769
+ }
770
+
771
+ handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
772
+ if (response !== undefined) {
773
+ if ('error' in response) {
774
+ // {"error":true,"errorMessage":"Minimum Order Size 0.01 ETH","data":null}
775
+ if (response['error']) {
776
+ const message = this.safeString (response, 'errorMessage');
777
+ const feedback = this.id + ' ' + message;
778
+ this.throwExactlyMatchedException (this.exceptions['exact'], message, feedback);
779
+ this.throwBroadlyMatchedException (this.exceptions['broad'], message, feedback);
780
+ throw new ExchangeError (this.id + ' ' + this.json (response));
781
+ }
782
+ }
783
+ }
784
+ if (code > 400) {
785
+ if (body) {
786
+ const feedback = this.id + ' ' + body;
787
+ this.throwExactlyMatchedException (this.exceptions['exact'], body, feedback);
788
+ this.throwBroadlyMatchedException (this.exceptions['broad'], body, feedback);
789
+ throw new ExchangeError (feedback); // unknown message
790
+ }
791
+ throw new ExchangeError (this.id + ' ' + body);
792
+ }
793
+ }
794
+ };