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/bithumb.js ADDED
@@ -0,0 +1,980 @@
1
+ 'use strict';
2
+
3
+ // ---------------------------------------------------------------------------
4
+
5
+ const Exchange = require ('./base/Exchange');
6
+ const { ExchangeError, ExchangeNotAvailable, AuthenticationError, BadRequest, PermissionDenied, InvalidAddress, ArgumentsRequired, InvalidOrder } = require ('./base/errors');
7
+ const { DECIMAL_PLACES, SIGNIFICANT_DIGITS, TRUNCATE } = require ('./base/functions/number');
8
+ const Precise = require ('./base/Precise');
9
+
10
+ // ---------------------------------------------------------------------------
11
+
12
+ module.exports = class bithumb extends Exchange {
13
+ describe () {
14
+ return this.deepExtend (super.describe (), {
15
+ 'id': 'bithumb',
16
+ 'name': 'Bithumb',
17
+ 'countries': [ 'KR' ], // South Korea
18
+ 'rateLimit': 500,
19
+ 'has': {
20
+ 'CORS': true,
21
+ 'spot': true,
22
+ 'margin': false,
23
+ 'swap': false,
24
+ 'future': false,
25
+ 'option': false,
26
+ 'addMargin': false,
27
+ 'cancelOrder': true,
28
+ 'createMarketOrder': true,
29
+ 'createOrder': true,
30
+ 'createReduceOnlyOrder': false,
31
+ 'fetchBalance': true,
32
+ 'fetchBorrowRate': false,
33
+ 'fetchBorrowRateHistories': false,
34
+ 'fetchBorrowRateHistory': false,
35
+ 'fetchBorrowRates': false,
36
+ 'fetchBorrowRatesPerSymbol': false,
37
+ 'fetchFundingHistory': false,
38
+ 'fetchFundingRate': false,
39
+ 'fetchFundingRateHistory': false,
40
+ 'fetchFundingRates': false,
41
+ 'fetchIndexOHLCV': false,
42
+ 'fetchLeverage': false,
43
+ 'fetchMarkets': true,
44
+ 'fetchMarkOHLCV': false,
45
+ 'fetchOHLCV': true,
46
+ 'fetchOpenOrders': true,
47
+ 'fetchOrder': true,
48
+ 'fetchOrderBook': true,
49
+ 'fetchPosition': false,
50
+ 'fetchPositions': false,
51
+ 'fetchPositionsRisk': false,
52
+ 'fetchPremiumIndexOHLCV': false,
53
+ 'fetchTicker': true,
54
+ 'fetchTickers': true,
55
+ 'fetchTrades': true,
56
+ 'fetchTransfer': false,
57
+ 'fetchTransfers': false,
58
+ 'reduceMargin': false,
59
+ 'setLeverage': false,
60
+ 'setMarginMode': false,
61
+ 'setPositionMode': false,
62
+ 'transfer': false,
63
+ 'withdraw': true,
64
+ },
65
+ 'hostname': 'bithumb.com',
66
+ 'urls': {
67
+ 'logo': 'https://user-images.githubusercontent.com/1294454/30597177-ea800172-9d5e-11e7-804c-b9d4fa9b56b0.jpg',
68
+ 'api': {
69
+ 'public': 'https://api.{hostname}/public',
70
+ 'private': 'https://api.{hostname}',
71
+ },
72
+ 'www': 'https://www.bithumb.com',
73
+ 'doc': 'https://apidocs.bithumb.com',
74
+ 'fees': 'https://en.bithumb.com/customer_support/info_fee',
75
+ },
76
+ 'api': {
77
+ 'public': {
78
+ 'get': [
79
+ 'ticker/{currency}',
80
+ 'ticker/all',
81
+ 'ticker/ALL_BTC',
82
+ 'ticker/ALL_KRW',
83
+ 'orderbook/{currency}',
84
+ 'orderbook/all',
85
+ 'transaction_history/{currency}',
86
+ 'transaction_history/all',
87
+ 'candlestick/{currency}/{interval}',
88
+ ],
89
+ },
90
+ 'private': {
91
+ 'post': [
92
+ 'info/account',
93
+ 'info/balance',
94
+ 'info/wallet_address',
95
+ 'info/ticker',
96
+ 'info/orders',
97
+ 'info/user_transactions',
98
+ 'info/order_detail',
99
+ 'trade/place',
100
+ 'trade/cancel',
101
+ 'trade/btc_withdrawal',
102
+ 'trade/krw_deposit',
103
+ 'trade/krw_withdrawal',
104
+ 'trade/market_buy',
105
+ 'trade/market_sell',
106
+ ],
107
+ },
108
+ },
109
+ 'fees': {
110
+ 'trading': {
111
+ 'maker': this.parseNumber ('0.0025'),
112
+ 'taker': this.parseNumber ('0.0025'),
113
+ },
114
+ },
115
+ 'precisionMode': SIGNIFICANT_DIGITS,
116
+ 'exceptions': {
117
+ 'Bad Request(SSL)': BadRequest,
118
+ 'Bad Request(Bad Method)': BadRequest,
119
+ 'Bad Request.(Auth Data)': AuthenticationError, // { "status": "5100", "message": "Bad Request.(Auth Data)" }
120
+ 'Not Member': AuthenticationError,
121
+ 'Invalid Apikey': AuthenticationError, // {"status":"5300","message":"Invalid Apikey"}
122
+ 'Method Not Allowed.(Access IP)': PermissionDenied,
123
+ 'Method Not Allowed.(BTC Adress)': InvalidAddress,
124
+ 'Method Not Allowed.(Access)': PermissionDenied,
125
+ 'Database Fail': ExchangeNotAvailable,
126
+ 'Invalid Parameter': BadRequest,
127
+ '5600': ExchangeError,
128
+ 'Unknown Error': ExchangeError,
129
+ 'After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions': ExchangeError, // {"status":"5100","message":"After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions"}
130
+ },
131
+ 'timeframes': {
132
+ '1m': '1m',
133
+ '3m': '3m',
134
+ '5m': '5m',
135
+ '10m': '10m',
136
+ '30m': '30m',
137
+ '1h': '1h',
138
+ '6h': '6h',
139
+ '12h': '12h',
140
+ '1d': '24h',
141
+ },
142
+ 'options': {
143
+ 'quoteCurrencies': {
144
+ 'BTC': {
145
+ 'limits': {
146
+ 'cost': {
147
+ 'min': 0.0002,
148
+ 'max': 100,
149
+ },
150
+ },
151
+ },
152
+ 'KRW': {
153
+ 'limits': {
154
+ 'cost': {
155
+ 'min': 500,
156
+ 'max': 5000000000,
157
+ },
158
+ },
159
+ },
160
+ },
161
+ },
162
+ 'commonCurrencies': {
163
+ 'FTC': 'FTC2',
164
+ 'MIR': 'MIR COIN',
165
+ 'SOC': 'Soda Coin',
166
+ },
167
+ });
168
+ }
169
+
170
+ amountToPrecision (symbol, amount) {
171
+ return this.decimalToPrecision (amount, TRUNCATE, this.markets[symbol]['precision']['amount'], DECIMAL_PLACES);
172
+ }
173
+
174
+ async fetchMarkets (params = {}) {
175
+ const result = [];
176
+ const quoteCurrencies = this.safeValue (this.options, 'quoteCurrencies', {});
177
+ const quotes = Object.keys (quoteCurrencies);
178
+ for (let i = 0; i < quotes.length; i++) {
179
+ const quote = quotes[i];
180
+ const quoteId = quote;
181
+ const extension = this.safeValue (quoteCurrencies, quote, {});
182
+ const method = 'publicGetTickerALL' + quote;
183
+ const response = await this[method] (params);
184
+ const data = this.safeValue (response, 'data');
185
+ const currencyIds = Object.keys (data);
186
+ for (let j = 0; j < currencyIds.length; j++) {
187
+ const currencyId = currencyIds[j];
188
+ if (currencyId === 'date') {
189
+ continue;
190
+ }
191
+ const market = data[currencyId];
192
+ const base = this.safeCurrencyCode (currencyId);
193
+ let active = true;
194
+ if (Array.isArray (market)) {
195
+ const numElements = market.length;
196
+ if (numElements === 0) {
197
+ active = false;
198
+ }
199
+ }
200
+ const entry = this.deepExtend ({
201
+ 'id': currencyId,
202
+ 'symbol': base + '/' + quote,
203
+ 'base': base,
204
+ 'quote': quote,
205
+ 'settle': undefined,
206
+ 'baseId': currencyId,
207
+ 'quoteId': quoteId,
208
+ 'settleId': undefined,
209
+ 'type': 'spot',
210
+ 'spot': true,
211
+ 'margin': false,
212
+ 'swap': false,
213
+ 'future': false,
214
+ 'option': false,
215
+ 'active': active,
216
+ 'contract': false,
217
+ 'linear': undefined,
218
+ 'inverse': undefined,
219
+ 'contractSize': undefined,
220
+ 'expiry': undefined,
221
+ 'expiryDateTime': undefined,
222
+ 'strike': undefined,
223
+ 'optionType': undefined,
224
+ 'precision': {
225
+ 'amount': parseInt ('4'),
226
+ 'price': parseInt ('4'),
227
+ },
228
+ 'limits': {
229
+ 'leverage': {
230
+ 'min': undefined,
231
+ 'max': undefined,
232
+ },
233
+ 'amount': {
234
+ 'min': undefined,
235
+ 'max': undefined,
236
+ },
237
+ 'price': {
238
+ 'min': undefined,
239
+ 'max': undefined,
240
+ },
241
+ 'cost': {}, // set via options
242
+ },
243
+ 'info': market,
244
+ }, extension);
245
+ result.push (entry);
246
+ }
247
+ }
248
+ return result;
249
+ }
250
+
251
+ parseBalance (response) {
252
+ const result = { 'info': response };
253
+ const balances = this.safeValue (response, 'data');
254
+ const codes = Object.keys (this.currencies);
255
+ for (let i = 0; i < codes.length; i++) {
256
+ const code = codes[i];
257
+ const account = this.account ();
258
+ const currency = this.currency (code);
259
+ const lowerCurrencyId = this.safeStringLower (currency, 'id');
260
+ account['total'] = this.safeString (balances, 'total_' + lowerCurrencyId);
261
+ account['used'] = this.safeString (balances, 'in_use_' + lowerCurrencyId);
262
+ account['free'] = this.safeString (balances, 'available_' + lowerCurrencyId);
263
+ result[code] = account;
264
+ }
265
+ return this.safeBalance (result);
266
+ }
267
+
268
+ async fetchBalance (params = {}) {
269
+ await this.loadMarkets ();
270
+ const request = {
271
+ 'currency': 'ALL',
272
+ };
273
+ const response = await this.privatePostInfoBalance (this.extend (request, params));
274
+ return this.parseBalance (response);
275
+ }
276
+
277
+ async fetchOrderBook (symbol, limit = undefined, params = {}) {
278
+ await this.loadMarkets ();
279
+ const market = this.market (symbol);
280
+ const request = {
281
+ 'currency': market['base'] + '_' + market['quote'],
282
+ };
283
+ if (limit !== undefined) {
284
+ request['count'] = limit; // default 30, max 30
285
+ }
286
+ const response = await this.publicGetOrderbookCurrency (this.extend (request, params));
287
+ //
288
+ // {
289
+ // "status":"0000",
290
+ // "data":{
291
+ // "timestamp":"1587621553942",
292
+ // "payment_currency":"KRW",
293
+ // "order_currency":"BTC",
294
+ // "bids":[
295
+ // {"price":"8652000","quantity":"0.0043"},
296
+ // {"price":"8651000","quantity":"0.0049"},
297
+ // {"price":"8650000","quantity":"8.4791"},
298
+ // ],
299
+ // "asks":[
300
+ // {"price":"8654000","quantity":"0.119"},
301
+ // {"price":"8655000","quantity":"0.254"},
302
+ // {"price":"8658000","quantity":"0.119"},
303
+ // ]
304
+ // }
305
+ // }
306
+ //
307
+ const data = this.safeValue (response, 'data', {});
308
+ const timestamp = this.safeInteger (data, 'timestamp');
309
+ return this.parseOrderBook (data, symbol, timestamp, 'bids', 'asks', 'price', 'quantity');
310
+ }
311
+
312
+ parseTicker (ticker, market = undefined) {
313
+ //
314
+ // fetchTicker, fetchTickers
315
+ //
316
+ // {
317
+ // "opening_price":"227100",
318
+ // "closing_price":"228400",
319
+ // "min_price":"222300",
320
+ // "max_price":"230000",
321
+ // "units_traded":"82618.56075337",
322
+ // "acc_trade_value":"18767376138.6031",
323
+ // "prev_closing_price":"227100",
324
+ // "units_traded_24H":"151871.13484676",
325
+ // "acc_trade_value_24H":"34247610416.8974",
326
+ // "fluctate_24H":"8700",
327
+ // "fluctate_rate_24H":"3.96",
328
+ // "date":"1587710327264", // fetchTickers inject this
329
+ // }
330
+ //
331
+ const timestamp = this.safeInteger (ticker, 'date');
332
+ const symbol = this.safeSymbol (undefined, market);
333
+ const open = this.safeString (ticker, 'opening_price');
334
+ const close = this.safeString (ticker, 'closing_price');
335
+ const baseVolume = this.safeString (ticker, 'units_traded_24H');
336
+ const quoteVolume = this.safeString (ticker, 'acc_trade_value_24H');
337
+ return this.safeTicker ({
338
+ 'symbol': symbol,
339
+ 'timestamp': timestamp,
340
+ 'datetime': this.iso8601 (timestamp),
341
+ 'high': this.safeString (ticker, 'max_price'),
342
+ 'low': this.safeString (ticker, 'min_price'),
343
+ 'bid': this.safeString (ticker, 'buy_price'),
344
+ 'bidVolume': undefined,
345
+ 'ask': this.safeString (ticker, 'sell_price'),
346
+ 'askVolume': undefined,
347
+ 'vwap': undefined,
348
+ 'open': open,
349
+ 'close': close,
350
+ 'last': close,
351
+ 'previousClose': undefined,
352
+ 'change': undefined,
353
+ 'percentage': undefined,
354
+ 'average': undefined,
355
+ 'baseVolume': baseVolume,
356
+ 'quoteVolume': quoteVolume,
357
+ 'info': ticker,
358
+ }, market, false);
359
+ }
360
+
361
+ async fetchTickers (symbols = undefined, params = {}) {
362
+ await this.loadMarkets ();
363
+ const response = await this.publicGetTickerAll (params);
364
+ //
365
+ // {
366
+ // "status":"0000",
367
+ // "data":{
368
+ // "BTC":{
369
+ // "opening_price":"9045000",
370
+ // "closing_price":"9132000",
371
+ // "min_price":"8938000",
372
+ // "max_price":"9168000",
373
+ // "units_traded":"4619.79967497",
374
+ // "acc_trade_value":"42021363832.5187",
375
+ // "prev_closing_price":"9041000",
376
+ // "units_traded_24H":"8793.5045804",
377
+ // "acc_trade_value_24H":"78933458515.4962",
378
+ // "fluctate_24H":"530000",
379
+ // "fluctate_rate_24H":"6.16"
380
+ // },
381
+ // "date":"1587710878669"
382
+ // }
383
+ // }
384
+ //
385
+ const result = {};
386
+ const data = this.safeValue (response, 'data', {});
387
+ const timestamp = this.safeInteger (data, 'date');
388
+ const tickers = this.omit (data, 'date');
389
+ const ids = Object.keys (tickers);
390
+ for (let i = 0; i < ids.length; i++) {
391
+ const id = ids[i];
392
+ let symbol = id;
393
+ let market = undefined;
394
+ if (id in this.markets_by_id) {
395
+ market = this.markets_by_id[id];
396
+ symbol = market['symbol'];
397
+ }
398
+ const ticker = tickers[id];
399
+ const isArray = Array.isArray (ticker);
400
+ if (!isArray) {
401
+ ticker['date'] = timestamp;
402
+ result[symbol] = this.parseTicker (ticker, market);
403
+ }
404
+ }
405
+ return this.filterByArray (result, 'symbol', symbols);
406
+ }
407
+
408
+ async fetchTicker (symbol, params = {}) {
409
+ await this.loadMarkets ();
410
+ const market = this.market (symbol);
411
+ const request = {
412
+ 'currency': market['base'],
413
+ };
414
+ const response = await this.publicGetTickerCurrency (this.extend (request, params));
415
+ //
416
+ // {
417
+ // "status":"0000",
418
+ // "data":{
419
+ // "opening_price":"227100",
420
+ // "closing_price":"228400",
421
+ // "min_price":"222300",
422
+ // "max_price":"230000",
423
+ // "units_traded":"82618.56075337",
424
+ // "acc_trade_value":"18767376138.6031",
425
+ // "prev_closing_price":"227100",
426
+ // "units_traded_24H":"151871.13484676",
427
+ // "acc_trade_value_24H":"34247610416.8974",
428
+ // "fluctate_24H":"8700",
429
+ // "fluctate_rate_24H":"3.96",
430
+ // "date":"1587710327264"
431
+ // }
432
+ // }
433
+ //
434
+ const data = this.safeValue (response, 'data', {});
435
+ return this.parseTicker (data, market);
436
+ }
437
+
438
+ parseOHLCV (ohlcv, market = undefined) {
439
+ //
440
+ // [
441
+ // 1576823400000, // 기준 시간
442
+ // '8284000', // 시가
443
+ // '8286000', // 종가
444
+ // '8289000', // 고가
445
+ // '8276000', // 저가
446
+ // '15.41503692' // 거래량
447
+ // ]
448
+ //
449
+ return [
450
+ this.safeInteger (ohlcv, 0),
451
+ this.safeNumber (ohlcv, 1),
452
+ this.safeNumber (ohlcv, 3),
453
+ this.safeNumber (ohlcv, 4),
454
+ this.safeNumber (ohlcv, 2),
455
+ this.safeNumber (ohlcv, 5),
456
+ ];
457
+ }
458
+
459
+ async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
460
+ await this.loadMarkets ();
461
+ const market = this.market (symbol);
462
+ const request = {
463
+ 'currency': market['base'],
464
+ 'interval': this.timeframes[timeframe],
465
+ };
466
+ const response = await this.publicGetCandlestickCurrencyInterval (this.extend (request, params));
467
+ //
468
+ // {
469
+ // 'status': '0000',
470
+ // 'data': {
471
+ // [
472
+ // 1576823400000, // 기준 시간
473
+ // '8284000', // 시가
474
+ // '8286000', // 종가
475
+ // '8289000', // 고가
476
+ // '8276000', // 저가
477
+ // '15.41503692' // 거래량
478
+ // ],
479
+ // [
480
+ // 1576824000000, // 기준 시간
481
+ // '8284000', // 시가
482
+ // '8281000', // 종가
483
+ // '8289000', // 고가
484
+ // '8275000', // 저가
485
+ // '6.19584467' // 거래량
486
+ // ],
487
+ // }
488
+ // }
489
+ //
490
+ const data = this.safeValue (response, 'data', []);
491
+ return this.parseOHLCVs (data, market, timeframe, since, limit);
492
+ }
493
+
494
+ parseTrade (trade, market = undefined) {
495
+ //
496
+ // fetchTrades (public)
497
+ //
498
+ // {
499
+ // "transaction_date":"2020-04-23 22:21:46",
500
+ // "type":"ask",
501
+ // "units_traded":"0.0125",
502
+ // "price":"8667000",
503
+ // "total":"108337"
504
+ // }
505
+ //
506
+ // fetchOrder (private)
507
+ //
508
+ // {
509
+ // "transaction_date": "1572497603902030",
510
+ // "price": "8601000",
511
+ // "units": "0.005",
512
+ // "fee_currency": "KRW",
513
+ // "fee": "107.51",
514
+ // "total": "43005"
515
+ // }
516
+ //
517
+ // a workaround for their bug in date format, hours are not 0-padded
518
+ let timestamp = undefined;
519
+ const transactionDatetime = this.safeString (trade, 'transaction_date');
520
+ if (transactionDatetime !== undefined) {
521
+ const parts = transactionDatetime.split (' ');
522
+ const numParts = parts.length;
523
+ if (numParts > 1) {
524
+ const transactionDate = parts[0];
525
+ let transactionTime = parts[1];
526
+ if (transactionTime.length < 8) {
527
+ transactionTime = '0' + transactionTime;
528
+ }
529
+ timestamp = this.parse8601 (transactionDate + ' ' + transactionTime);
530
+ } else {
531
+ timestamp = this.safeIntegerProduct (trade, 'transaction_date', 0.001);
532
+ }
533
+ }
534
+ if (timestamp !== undefined) {
535
+ timestamp -= 9 * 3600000; // they report UTC + 9 hours, server in Korean timezone
536
+ }
537
+ const type = undefined;
538
+ let side = this.safeString (trade, 'type');
539
+ side = (side === 'ask') ? 'sell' : 'buy';
540
+ const id = this.safeString (trade, 'cont_no');
541
+ market = this.safeMarket (undefined, market);
542
+ const priceString = this.safeString (trade, 'price');
543
+ const amountString = this.safeString2 (trade, 'units_traded', 'units');
544
+ const costString = this.safeString (trade, 'total');
545
+ let fee = undefined;
546
+ const feeCostString = this.safeString (trade, 'fee');
547
+ if (feeCostString !== undefined) {
548
+ const feeCurrencyId = this.safeString (trade, 'fee_currency');
549
+ const feeCurrencyCode = this.commonCurrencyCode (feeCurrencyId);
550
+ fee = {
551
+ 'cost': feeCostString,
552
+ 'currency': feeCurrencyCode,
553
+ };
554
+ }
555
+ return this.safeTrade ({
556
+ 'id': id,
557
+ 'info': trade,
558
+ 'timestamp': timestamp,
559
+ 'datetime': this.iso8601 (timestamp),
560
+ 'symbol': market['symbol'],
561
+ 'order': undefined,
562
+ 'type': type,
563
+ 'side': side,
564
+ 'takerOrMaker': undefined,
565
+ 'price': priceString,
566
+ 'amount': amountString,
567
+ 'cost': costString,
568
+ 'fee': fee,
569
+ }, market);
570
+ }
571
+
572
+ async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
573
+ await this.loadMarkets ();
574
+ const market = this.market (symbol);
575
+ const request = {
576
+ 'currency': market['base'],
577
+ };
578
+ if (limit === undefined) {
579
+ request['count'] = limit; // default 20, max 100
580
+ }
581
+ const response = await this.publicGetTransactionHistoryCurrency (this.extend (request, params));
582
+ //
583
+ // {
584
+ // "status":"0000",
585
+ // "data":[
586
+ // {
587
+ // "transaction_date":"2020-04-23 22:21:46",
588
+ // "type":"ask",
589
+ // "units_traded":"0.0125",
590
+ // "price":"8667000",
591
+ // "total":"108337"
592
+ // },
593
+ // ]
594
+ // }
595
+ //
596
+ const data = this.safeValue (response, 'data', []);
597
+ return this.parseTrades (data, market, since, limit);
598
+ }
599
+
600
+ async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
601
+ await this.loadMarkets ();
602
+ const market = this.market (symbol);
603
+ const request = {
604
+ 'order_currency': market['id'],
605
+ 'payment_currency': market['quote'],
606
+ 'units': amount,
607
+ };
608
+ let method = 'privatePostTradePlace';
609
+ if (type === 'limit') {
610
+ request['price'] = price;
611
+ request['type'] = (side === 'buy') ? 'bid' : 'ask';
612
+ } else {
613
+ method = 'privatePostTradeMarket' + this.capitalize (side);
614
+ }
615
+ const response = await this[method] (this.extend (request, params));
616
+ const id = this.safeString (response, 'order_id');
617
+ if (id === undefined) {
618
+ throw new InvalidOrder (this.id + ' createOrder() did not return an order id');
619
+ }
620
+ return {
621
+ 'info': response,
622
+ 'symbol': symbol,
623
+ 'type': type,
624
+ 'side': side,
625
+ 'id': id,
626
+ };
627
+ }
628
+
629
+ async fetchOrder (id, symbol = undefined, params = {}) {
630
+ if (symbol === undefined) {
631
+ throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument');
632
+ }
633
+ await this.loadMarkets ();
634
+ const market = this.market (symbol);
635
+ const request = {
636
+ 'order_id': id,
637
+ 'count': 1,
638
+ 'order_currency': market['base'],
639
+ 'payment_currency': market['quote'],
640
+ };
641
+ const response = await this.privatePostInfoOrderDetail (this.extend (request, params));
642
+ //
643
+ // {
644
+ // "status": "0000",
645
+ // "data": {
646
+ // order_date: '1603161798539254',
647
+ // type: 'ask',
648
+ // order_status: 'Cancel',
649
+ // order_currency: 'BTC',
650
+ // payment_currency: 'KRW',
651
+ // watch_price: '0',
652
+ // order_price: '13344000',
653
+ // order_qty: '0.0125',
654
+ // cancel_date: '1603161803809993',
655
+ // cancel_type: '사용자취소',
656
+ // contract: [
657
+ // {
658
+ // transaction_date: '1603161799976383',
659
+ // price: '13344000',
660
+ // units: '0.0015',
661
+ // fee_currency: 'KRW',
662
+ // fee: '0',
663
+ // total: '20016'
664
+ // }
665
+ // ],
666
+ // }
667
+ // }
668
+ //
669
+ const data = this.safeValue (response, 'data');
670
+ return this.parseOrder (this.extend (data, { 'order_id': id }), market);
671
+ }
672
+
673
+ parseOrderStatus (status) {
674
+ const statuses = {
675
+ 'Pending': 'open',
676
+ 'Completed': 'closed',
677
+ 'Cancel': 'canceled',
678
+ };
679
+ return this.safeString (statuses, status, status);
680
+ }
681
+
682
+ parseOrder (order, market = undefined) {
683
+ //
684
+ //
685
+ // fetchOrder
686
+ //
687
+ // {
688
+ // "transaction_date": "1572497603668315",
689
+ // "type": "bid",
690
+ // "order_status": "Completed",
691
+ // "order_currency": "BTC",
692
+ // "payment_currency": "KRW",
693
+ // "order_price": "8601000",
694
+ // "order_qty": "0.007",
695
+ // "cancel_date": "",
696
+ // "cancel_type": "",
697
+ // "contract": [
698
+ // {
699
+ // "transaction_date": "1572497603902030",
700
+ // "price": "8601000",
701
+ // "units": "0.005",
702
+ // "fee_currency": "KRW",
703
+ // "fee": "107.51",
704
+ // "total": "43005"
705
+ // },
706
+ // ]
707
+ // }
708
+ //
709
+ // {
710
+ // order_date: '1603161798539254',
711
+ // type: 'ask',
712
+ // order_status: 'Cancel',
713
+ // order_currency: 'BTC',
714
+ // payment_currency: 'KRW',
715
+ // watch_price: '0',
716
+ // order_price: '13344000',
717
+ // order_qty: '0.0125',
718
+ // cancel_date: '1603161803809993',
719
+ // cancel_type: '사용자취소',
720
+ // contract: [
721
+ // {
722
+ // transaction_date: '1603161799976383',
723
+ // price: '13344000',
724
+ // units: '0.0015',
725
+ // fee_currency: 'KRW',
726
+ // fee: '0',
727
+ // total: '20016'
728
+ // }
729
+ // ],
730
+ // }
731
+ //
732
+ // fetchOpenOrders
733
+ //
734
+ // {
735
+ // "order_currency": "BTC",
736
+ // "payment_currency": "KRW",
737
+ // "order_id": "C0101000007408440032",
738
+ // "order_date": "1571728739360570",
739
+ // "type": "bid",
740
+ // "units": "5.0",
741
+ // "units_remaining": "5.0",
742
+ // "price": "501000",
743
+ // }
744
+ //
745
+ const timestamp = this.safeIntegerProduct (order, 'order_date', 0.001);
746
+ const sideProperty = this.safeValue2 (order, 'type', 'side');
747
+ const side = (sideProperty === 'bid') ? 'buy' : 'sell';
748
+ const status = this.parseOrderStatus (this.safeString (order, 'order_status'));
749
+ const price = this.safeString2 (order, 'order_price', 'price');
750
+ let type = 'limit';
751
+ if (Precise.stringEquals (price, '0')) {
752
+ type = 'market';
753
+ }
754
+ const amount = this.safeString2 (order, 'order_qty', 'units');
755
+ let remaining = this.safeString (order, 'units_remaining');
756
+ if (remaining === undefined) {
757
+ if (status === 'closed') {
758
+ remaining = '0';
759
+ } else if (status !== 'canceled') {
760
+ remaining = amount;
761
+ }
762
+ }
763
+ let symbol = undefined;
764
+ const baseId = this.safeString (order, 'order_currency');
765
+ const quoteId = this.safeString (order, 'payment_currency');
766
+ const base = this.safeCurrencyCode (baseId);
767
+ const quote = this.safeCurrencyCode (quoteId);
768
+ if ((base !== undefined) && (quote !== undefined)) {
769
+ symbol = base + '/' + quote;
770
+ }
771
+ if (symbol === undefined) {
772
+ market = this.safeMarket (undefined, market);
773
+ symbol = market['symbol'];
774
+ }
775
+ const id = this.safeString (order, 'order_id');
776
+ const rawTrades = this.safeValue (order, 'contract', []);
777
+ return this.safeOrder ({
778
+ 'info': order,
779
+ 'id': id,
780
+ 'clientOrderId': undefined,
781
+ 'timestamp': timestamp,
782
+ 'datetime': this.iso8601 (timestamp),
783
+ 'lastTradeTimestamp': undefined,
784
+ 'symbol': symbol,
785
+ 'type': type,
786
+ 'timeInForce': undefined,
787
+ 'postOnly': undefined,
788
+ 'side': side,
789
+ 'price': price,
790
+ 'stopPrice': undefined,
791
+ 'amount': amount,
792
+ 'cost': undefined,
793
+ 'average': undefined,
794
+ 'filled': undefined,
795
+ 'remaining': remaining,
796
+ 'status': status,
797
+ 'fee': undefined,
798
+ 'trades': rawTrades,
799
+ }, market);
800
+ }
801
+
802
+ async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
803
+ if (symbol === undefined) {
804
+ throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument');
805
+ }
806
+ await this.loadMarkets ();
807
+ const market = this.market (symbol);
808
+ if (limit === undefined) {
809
+ limit = 100;
810
+ }
811
+ const request = {
812
+ 'count': limit,
813
+ 'order_currency': market['base'],
814
+ 'payment_currency': market['quote'],
815
+ };
816
+ if (since !== undefined) {
817
+ request['after'] = since;
818
+ }
819
+ const response = await this.privatePostInfoOrders (this.extend (request, params));
820
+ //
821
+ // {
822
+ // "status": "0000",
823
+ // "data": [
824
+ // {
825
+ // "order_currency": "BTC",
826
+ // "payment_currency": "KRW",
827
+ // "order_id": "C0101000007408440032",
828
+ // "order_date": "1571728739360570",
829
+ // "type": "bid",
830
+ // "units": "5.0",
831
+ // "units_remaining": "5.0",
832
+ // "price": "501000",
833
+ // }
834
+ // ]
835
+ // }
836
+ //
837
+ const data = this.safeValue (response, 'data', []);
838
+ return this.parseOrders (data, market, since, limit);
839
+ }
840
+
841
+ async cancelOrder (id, symbol = undefined, params = {}) {
842
+ const side_in_params = ('side' in params);
843
+ if (!side_in_params) {
844
+ throw new ArgumentsRequired (this.id + ' cancelOrder() requires a `side` parameter (sell or buy)');
845
+ }
846
+ if (symbol === undefined) {
847
+ throw new ArgumentsRequired (this.id + ' cancelOrder() requires a `symbol` argument');
848
+ }
849
+ const market = this.market (symbol);
850
+ const side = (params['side'] === 'buy') ? 'bid' : 'ask';
851
+ params = this.omit (params, [ 'side', 'currency' ]);
852
+ // https://github.com/ccxt/ccxt/issues/6771
853
+ const request = {
854
+ 'order_id': id,
855
+ 'type': side,
856
+ 'order_currency': market['base'],
857
+ 'payment_currency': market['quote'],
858
+ };
859
+ return await this.privatePostTradeCancel (this.extend (request, params));
860
+ }
861
+
862
+ cancelUnifiedOrder (order, params = {}) {
863
+ const request = {
864
+ 'side': order['side'],
865
+ };
866
+ return this.cancelOrder (order['id'], order['symbol'], this.extend (request, params));
867
+ }
868
+
869
+ async withdraw (code, amount, address, tag = undefined, params = {}) {
870
+ [ tag, params ] = this.handleWithdrawTagAndParams (tag, params);
871
+ this.checkAddress (address);
872
+ await this.loadMarkets ();
873
+ const currency = this.currency (code);
874
+ const request = {
875
+ 'units': amount,
876
+ 'address': address,
877
+ 'currency': currency['id'],
878
+ };
879
+ if (currency === 'XRP' || currency === 'XMR' || currency === 'EOS' || currency === 'STEEM') {
880
+ const destination = this.safeString (params, 'destination');
881
+ if ((tag === undefined) && (destination === undefined)) {
882
+ throw new ArgumentsRequired (this.id + ' ' + code + ' withdraw() requires a tag argument or an extra destination param');
883
+ } else if (tag !== undefined) {
884
+ request['destination'] = tag;
885
+ }
886
+ }
887
+ const response = await this.privatePostTradeBtcWithdrawal (this.extend (request, params));
888
+ //
889
+ // { "status" : "0000"}
890
+ //
891
+ return this.parseTransaction (response, currency);
892
+ }
893
+
894
+ parseTransaction (transaction, currency = undefined) {
895
+ //
896
+ // withdraw
897
+ //
898
+ // { "status" : "0000"}
899
+ //
900
+ currency = this.safeCurrency (undefined, currency);
901
+ return {
902
+ 'id': undefined,
903
+ 'txid': undefined,
904
+ 'timestamp': undefined,
905
+ 'datetime': undefined,
906
+ 'network': undefined,
907
+ 'addressFrom': undefined,
908
+ 'address': undefined,
909
+ 'addressTo': undefined,
910
+ 'amount': undefined,
911
+ 'type': undefined,
912
+ 'currency': currency['code'],
913
+ 'status': undefined,
914
+ 'updated': undefined,
915
+ 'tagFrom': undefined,
916
+ 'tag': undefined,
917
+ 'tagTo': undefined,
918
+ 'comment': undefined,
919
+ 'fee': undefined,
920
+ 'info': transaction,
921
+ };
922
+ }
923
+
924
+ nonce () {
925
+ return this.milliseconds ();
926
+ }
927
+
928
+ sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
929
+ const endpoint = '/' + this.implodeParams (path, params);
930
+ let url = this.implodeHostname (this.urls['api'][api]) + endpoint;
931
+ const query = this.omit (params, this.extractParams (path));
932
+ if (api === 'public') {
933
+ if (Object.keys (query).length) {
934
+ url += '?' + this.urlencode (query);
935
+ }
936
+ } else {
937
+ this.checkRequiredCredentials ();
938
+ body = this.urlencode (this.extend ({
939
+ 'endpoint': endpoint,
940
+ }, query));
941
+ const nonce = this.nonce ().toString ();
942
+ const auth = endpoint + "\0" + body + "\0" + nonce; // eslint-disable-line quotes
943
+ const signature = this.hmac (this.encode (auth), this.encode (this.secret), 'sha512');
944
+ const signature64 = this.decode (this.stringToBase64 (signature));
945
+ headers = {
946
+ 'Accept': 'application/json',
947
+ 'Content-Type': 'application/x-www-form-urlencoded',
948
+ 'Api-Key': this.apiKey,
949
+ 'Api-Sign': signature64,
950
+ 'Api-Nonce': nonce,
951
+ };
952
+ }
953
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
954
+ }
955
+
956
+ handleErrors (httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
957
+ if (response === undefined) {
958
+ return; // fallback to default error handler
959
+ }
960
+ if ('status' in response) {
961
+ //
962
+ // {"status":"5100","message":"After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions"}
963
+ //
964
+ const status = this.safeString (response, 'status');
965
+ const message = this.safeString (response, 'message');
966
+ if (status !== undefined) {
967
+ if (status === '0000') {
968
+ return; // no error
969
+ } else if (message === '거래 진행중인 내역이 존재하지 않습니다') {
970
+ // https://github.com/ccxt/ccxt/issues/9017
971
+ return; // no error
972
+ }
973
+ const feedback = this.id + ' ' + body;
974
+ this.throwExactlyMatchedException (this.exceptions, status, feedback);
975
+ this.throwExactlyMatchedException (this.exceptions, message, feedback);
976
+ throw new ExchangeError (feedback);
977
+ }
978
+ }
979
+ }
980
+ };