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/coinone.js ADDED
@@ -0,0 +1,816 @@
1
+ 'use strict';
2
+
3
+ // ---------------------------------------------------------------------------
4
+
5
+ const Exchange = require ('./base/Exchange');
6
+ const { BadSymbol, BadRequest, ExchangeError, ArgumentsRequired, OrderNotFound, OnMaintenance } = require ('./base/errors');
7
+ const Precise = require ('./base/Precise');
8
+
9
+ // ---------------------------------------------------------------------------
10
+
11
+ module.exports = class coinone extends Exchange {
12
+ describe () {
13
+ return this.deepExtend (super.describe (), {
14
+ 'id': 'coinone',
15
+ 'name': 'CoinOne',
16
+ 'countries': [ 'KR' ], // Korea
17
+ // 'enableRateLimit': false,
18
+ 'rateLimit': 667,
19
+ 'version': 'v2',
20
+ 'has': {
21
+ 'CORS': undefined,
22
+ 'spot': true,
23
+ 'margin': false,
24
+ 'swap': false,
25
+ 'future': false,
26
+ 'option': false,
27
+ 'addMargin': false,
28
+ 'cancelOrder': true,
29
+ 'createMarketOrder': undefined,
30
+ 'createOrder': true,
31
+ 'createReduceOnlyOrder': false,
32
+ 'fetchBalance': true,
33
+ 'fetchBorrowRate': false,
34
+ 'fetchBorrowRateHistories': false,
35
+ 'fetchBorrowRateHistory': false,
36
+ 'fetchBorrowRates': false,
37
+ 'fetchBorrowRatesPerSymbol': false,
38
+ 'fetchClosedOrders': undefined, // the endpoint that should return closed orders actually returns trades, https://github.com/ccxt/ccxt/pull/7067
39
+ 'fetchDepositAddresses': true,
40
+ 'fetchFundingHistory': false,
41
+ 'fetchFundingRate': false,
42
+ 'fetchFundingRateHistory': false,
43
+ 'fetchFundingRates': false,
44
+ 'fetchIndexOHLCV': false,
45
+ 'fetchLeverage': false,
46
+ 'fetchLeverageTiers': false,
47
+ 'fetchMarkets': true,
48
+ 'fetchMarkOHLCV': false,
49
+ 'fetchMyTrades': true,
50
+ 'fetchOpenOrders': true,
51
+ 'fetchOrder': true,
52
+ 'fetchOrderBook': true,
53
+ 'fetchPosition': false,
54
+ 'fetchPositions': false,
55
+ 'fetchPositionsRisk': false,
56
+ 'fetchPremiumIndexOHLCV': false,
57
+ 'fetchTicker': true,
58
+ 'fetchTickers': true,
59
+ 'fetchTrades': true,
60
+ 'reduceMargin': false,
61
+ 'setLeverage': false,
62
+ 'setMarginMode': false,
63
+ 'setPositionMode': false,
64
+ },
65
+ 'urls': {
66
+ 'logo': 'https://user-images.githubusercontent.com/1294454/38003300-adc12fba-323f-11e8-8525-725f53c4a659.jpg',
67
+ 'api': 'https://api.coinone.co.kr',
68
+ 'www': 'https://coinone.co.kr',
69
+ 'doc': 'https://doc.coinone.co.kr',
70
+ },
71
+ 'requiredCredentials': {
72
+ 'apiKey': true,
73
+ 'secret': true,
74
+ },
75
+ 'api': {
76
+ 'public': {
77
+ 'get': [
78
+ 'orderbook/',
79
+ 'trades/',
80
+ 'ticker/',
81
+ ],
82
+ },
83
+ 'private': {
84
+ 'post': [
85
+ 'account/deposit_address/',
86
+ 'account/btc_deposit_address/',
87
+ 'account/balance/',
88
+ 'account/daily_balance/',
89
+ 'account/user_info/',
90
+ 'account/virtual_account/',
91
+ 'order/cancel_all/',
92
+ 'order/cancel/',
93
+ 'order/limit_buy/',
94
+ 'order/limit_sell/',
95
+ 'order/complete_orders/',
96
+ 'order/limit_orders/',
97
+ 'order/order_info/',
98
+ 'transaction/auth_number/',
99
+ 'transaction/history/',
100
+ 'transaction/krw/history/',
101
+ 'transaction/btc/',
102
+ 'transaction/coin/',
103
+ ],
104
+ },
105
+ },
106
+ 'fees': {
107
+ 'trading': {
108
+ 'tierBased': false,
109
+ 'percentage': true,
110
+ 'taker': 0.002,
111
+ 'maker': 0.002,
112
+ },
113
+ },
114
+ 'precision': {
115
+ 'price': 4,
116
+ 'amount': 4,
117
+ 'cost': 8,
118
+ },
119
+ 'exceptions': {
120
+ '405': OnMaintenance, // {"errorCode":"405","status":"maintenance","result":"error"}
121
+ '104': OrderNotFound, // {"errorCode":"104","errorMsg":"Order id is not exist","result":"error"}
122
+ '108': BadSymbol, // {"errorCode":"108","errorMsg":"Unknown CryptoCurrency","result":"error"}
123
+ '107': BadRequest, // {"errorCode":"107","errorMsg":"Parameter error","result":"error"}
124
+ },
125
+ 'commonCurrencies': {
126
+ 'SOC': 'Soda Coin',
127
+ },
128
+ });
129
+ }
130
+
131
+ async fetchMarkets (params = {}) {
132
+ const request = {
133
+ 'currency': 'all',
134
+ };
135
+ const response = await this.publicGetTicker (request);
136
+ //
137
+ // {
138
+ // "result": "success",
139
+ // "errorCode": "0",
140
+ // "timestamp": "1643676668",
141
+ // "xec": {
142
+ // "currency": "xec",
143
+ // "first": "0.0914",
144
+ // "low": "0.0894",
145
+ // "high": "0.096",
146
+ // "last": "0.0937",
147
+ // "volume": "1673283662.9797",
148
+ // "yesterday_first": "0.0929",
149
+ // "yesterday_low": "0.0913",
150
+ // "yesterday_high": "0.0978",
151
+ // "yesterday_last": "0.0913",
152
+ // "yesterday_volume": "1167285865.4571"
153
+ // },
154
+ // ...
155
+ // }
156
+ //
157
+ const result = [];
158
+ const quoteId = 'krw';
159
+ const quote = this.safeCurrencyCode (quoteId);
160
+ const baseIds = Object.keys (response);
161
+ for (let i = 0; i < baseIds.length; i++) {
162
+ const baseId = baseIds[i];
163
+ const ticker = this.safeValue (response, baseId, {});
164
+ const currency = this.safeValue (ticker, 'currency');
165
+ if (currency === undefined) {
166
+ continue;
167
+ }
168
+ const base = this.safeCurrencyCode (baseId);
169
+ result.push ({
170
+ 'id': baseId,
171
+ 'symbol': base + '/' + quote,
172
+ 'base': base,
173
+ 'quote': quote,
174
+ 'settle': undefined,
175
+ 'baseId': baseId,
176
+ 'quoteId': quoteId,
177
+ 'settleId': undefined,
178
+ 'type': 'spot',
179
+ 'spot': true,
180
+ 'margin': false,
181
+ 'swap': false,
182
+ 'future': false,
183
+ 'option': false,
184
+ 'active': undefined,
185
+ 'contract': false,
186
+ 'linear': undefined,
187
+ 'inverse': undefined,
188
+ 'contractSize': undefined,
189
+ 'expiry': undefined,
190
+ 'expiryDatetime': undefined,
191
+ 'strike': undefined,
192
+ 'optionType': undefined,
193
+ 'precision': {
194
+ 'amount': undefined,
195
+ 'price': undefined,
196
+ },
197
+ 'limits': {
198
+ 'leverage': {
199
+ 'min': undefined,
200
+ 'max': undefined,
201
+ },
202
+ 'amount': {
203
+ 'min': undefined,
204
+ 'max': undefined,
205
+ },
206
+ 'price': {
207
+ 'min': undefined,
208
+ 'max': undefined,
209
+ },
210
+ 'cost': {
211
+ 'min': undefined,
212
+ 'max': undefined,
213
+ },
214
+ },
215
+ 'info': ticker,
216
+ });
217
+ }
218
+ return result;
219
+ }
220
+
221
+ parseBalance (response) {
222
+ const result = { 'info': response };
223
+ const balances = this.omit (response, [
224
+ 'errorCode',
225
+ 'result',
226
+ 'normalWallets',
227
+ ]);
228
+ const currencyIds = Object.keys (balances);
229
+ for (let i = 0; i < currencyIds.length; i++) {
230
+ const currencyId = currencyIds[i];
231
+ const balance = balances[currencyId];
232
+ const code = this.safeCurrencyCode (currencyId);
233
+ const account = this.account ();
234
+ account['free'] = this.safeString (balance, 'avail');
235
+ account['total'] = this.safeString (balance, 'balance');
236
+ result[code] = account;
237
+ }
238
+ return this.safeBalance (result);
239
+ }
240
+
241
+ async fetchBalance (params = {}) {
242
+ await this.loadMarkets ();
243
+ const response = await this.privatePostAccountBalance (params);
244
+ return this.parseBalance (response);
245
+ }
246
+
247
+ async fetchOrderBook (symbol, limit = undefined, params = {}) {
248
+ await this.loadMarkets ();
249
+ const market = this.market (symbol);
250
+ const request = {
251
+ 'currency': market['id'],
252
+ 'format': 'json',
253
+ };
254
+ const response = await this.publicGetOrderbook (this.extend (request, params));
255
+ const timestamp = this.safeTimestamp (response, 'timestamp');
256
+ return this.parseOrderBook (response, symbol, timestamp, 'bid', 'ask', 'price', 'qty');
257
+ }
258
+
259
+ async fetchTickers (symbols = undefined, params = {}) {
260
+ await this.loadMarkets ();
261
+ const request = {
262
+ 'currency': 'all',
263
+ 'format': 'json',
264
+ };
265
+ const response = await this.publicGetTicker (this.extend (request, params));
266
+ const result = {};
267
+ const ids = Object.keys (response);
268
+ const timestamp = this.safeTimestamp (response, 'timestamp');
269
+ for (let i = 0; i < ids.length; i++) {
270
+ const id = ids[i];
271
+ let symbol = id;
272
+ let market = undefined;
273
+ if (id in this.markets_by_id) {
274
+ market = this.markets_by_id[id];
275
+ symbol = market['symbol'];
276
+ const ticker = response[id];
277
+ result[symbol] = this.parseTicker (ticker, market);
278
+ result[symbol]['timestamp'] = timestamp;
279
+ }
280
+ }
281
+ return this.filterByArray (result, 'symbol', symbols);
282
+ }
283
+
284
+ async fetchTicker (symbol, params = {}) {
285
+ await this.loadMarkets ();
286
+ const market = this.market (symbol);
287
+ const request = {
288
+ 'currency': market['id'],
289
+ 'format': 'json',
290
+ };
291
+ const response = await this.publicGetTicker (this.extend (request, params));
292
+ return this.parseTicker (response, market);
293
+ }
294
+
295
+ parseTicker (ticker, market = undefined) {
296
+ //
297
+ // {
298
+ // "currency":"xec",
299
+ // "first":"0.1069",
300
+ // "low":"0.09",
301
+ // "high":"0.1069",
302
+ // "last":"0.0911",
303
+ // "volume":"4591217267.4974",
304
+ // "yesterday_first":"0.1128",
305
+ // "yesterday_low":"0.1035",
306
+ // "yesterday_high":"0.1167",
307
+ // "yesterday_last":"0.1069",
308
+ // "yesterday_volume":"4014832231.5102"
309
+ // }
310
+ //
311
+ const timestamp = this.safeTimestamp (ticker, 'timestamp');
312
+ const open = this.safeString (ticker, 'first');
313
+ const last = this.safeString (ticker, 'last');
314
+ const previousClose = this.safeString (ticker, 'yesterday_last');
315
+ const symbol = this.safeSymbol (undefined, market);
316
+ return this.safeTicker ({
317
+ 'symbol': symbol,
318
+ 'timestamp': timestamp,
319
+ 'datetime': this.iso8601 (timestamp),
320
+ 'high': this.safeString (ticker, 'high'),
321
+ 'low': this.safeString (ticker, 'low'),
322
+ 'bid': undefined,
323
+ 'bidVolume': undefined,
324
+ 'ask': undefined,
325
+ 'askVolume': undefined,
326
+ 'vwap': undefined,
327
+ 'open': open,
328
+ 'close': last,
329
+ 'last': last,
330
+ 'previousClose': previousClose,
331
+ 'change': undefined,
332
+ 'percentage': undefined,
333
+ 'average': undefined,
334
+ 'baseVolume': this.safeString (ticker, 'volume'),
335
+ 'quoteVolume': undefined,
336
+ 'info': ticker,
337
+ }, market, false);
338
+ }
339
+
340
+ parseTrade (trade, market = undefined) {
341
+ //
342
+ // fetchTrades (public)
343
+ //
344
+ // {
345
+ // "timestamp": "1416893212",
346
+ // "price": "420000.0",
347
+ // "qty": "0.1",
348
+ // "is_ask": "1"
349
+ // }
350
+ //
351
+ // fetchMyTrades (private)
352
+ //
353
+ // {
354
+ // "timestamp": "1416561032",
355
+ // "price": "419000.0",
356
+ // "type": "bid",
357
+ // "qty": "0.001",
358
+ // "feeRate": "-0.0015",
359
+ // "fee": "-0.0000015",
360
+ // "orderId": "E84A1AC2-8088-4FA0-B093-A3BCDB9B3C85"
361
+ // }
362
+ //
363
+ const timestamp = this.safeTimestamp (trade, 'timestamp');
364
+ market = this.safeMarket (undefined, market);
365
+ const is_ask = this.safeString (trade, 'is_ask');
366
+ let side = this.safeString (trade, 'type');
367
+ if (is_ask !== undefined) {
368
+ if (is_ask === '1') {
369
+ side = 'sell';
370
+ } else if (is_ask === '0') {
371
+ side = 'buy';
372
+ }
373
+ } else {
374
+ if (side === 'ask') {
375
+ side = 'sell';
376
+ } else if (side === 'bid') {
377
+ side = 'buy';
378
+ }
379
+ }
380
+ const priceString = this.safeString (trade, 'price');
381
+ const amountString = this.safeString (trade, 'qty');
382
+ const orderId = this.safeString (trade, 'orderId');
383
+ let feeCostString = this.safeString (trade, 'fee');
384
+ let fee = undefined;
385
+ if (feeCostString !== undefined) {
386
+ feeCostString = Precise.stringAbs (feeCostString);
387
+ let feeRateString = this.safeString (trade, 'feeRate');
388
+ feeRateString = Precise.stringAbs (feeRateString);
389
+ const feeCurrencyCode = (side === 'sell') ? market['quote'] : market['base'];
390
+ fee = {
391
+ 'cost': feeCostString,
392
+ 'currency': feeCurrencyCode,
393
+ 'rate': feeRateString,
394
+ };
395
+ }
396
+ return this.safeTrade ({
397
+ 'id': this.safeString (trade, 'id'),
398
+ 'info': trade,
399
+ 'timestamp': timestamp,
400
+ 'datetime': this.iso8601 (timestamp),
401
+ 'order': orderId,
402
+ 'symbol': market['symbol'],
403
+ 'type': undefined,
404
+ 'side': side,
405
+ 'takerOrMaker': undefined,
406
+ 'price': priceString,
407
+ 'amount': amountString,
408
+ 'cost': undefined,
409
+ 'fee': fee,
410
+ }, market);
411
+ }
412
+
413
+ async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
414
+ await this.loadMarkets ();
415
+ const market = this.market (symbol);
416
+ const request = {
417
+ 'currency': market['id'],
418
+ 'format': 'json',
419
+ };
420
+ const response = await this.publicGetTrades (this.extend (request, params));
421
+ //
422
+ // {
423
+ // "result": "success",
424
+ // "errorCode": "0",
425
+ // "timestamp": "1416895635",
426
+ // "currency": "btc",
427
+ // "completeOrders": [
428
+ // {
429
+ // "timestamp": "1416893212",
430
+ // "price": "420000.0",
431
+ // "qty": "0.1",
432
+ // "is_ask": "1"
433
+ // }
434
+ // ]
435
+ // }
436
+ //
437
+ const completeOrders = this.safeValue (response, 'completeOrders', []);
438
+ return this.parseTrades (completeOrders, market, since, limit);
439
+ }
440
+
441
+ async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
442
+ if (type !== 'limit') {
443
+ throw new ExchangeError (this.id + ' createOrder() allows limit orders only');
444
+ }
445
+ await this.loadMarkets ();
446
+ const request = {
447
+ 'price': price,
448
+ 'currency': this.marketId (symbol),
449
+ 'qty': amount,
450
+ };
451
+ const method = 'privatePostOrder' + this.capitalize (type) + this.capitalize (side);
452
+ const response = await this[method] (this.extend (request, params));
453
+ //
454
+ // {
455
+ // "result": "success",
456
+ // "errorCode": "0",
457
+ // "orderId": "8a82c561-40b4-4cb3-9bc0-9ac9ffc1d63b"
458
+ // }
459
+ //
460
+ return this.parseOrder (response);
461
+ }
462
+
463
+ async fetchOrder (id, symbol = undefined, params = {}) {
464
+ if (symbol === undefined) {
465
+ throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument');
466
+ }
467
+ await this.loadMarkets ();
468
+ const market = this.market (symbol);
469
+ const request = {
470
+ 'order_id': id,
471
+ 'currency': market['id'],
472
+ };
473
+ const response = await this.privatePostOrderOrderInfo (this.extend (request, params));
474
+ //
475
+ // {
476
+ // "result": "success",
477
+ // "errorCode": "0",
478
+ // "status": "live",
479
+ // "info": {
480
+ // "orderId": "32FF744B-D501-423A-8BA1-05BB6BE7814A",
481
+ // "currency": "BTC",
482
+ // "type": "bid",
483
+ // "price": "2922000.0",
484
+ // "qty": "115.4950",
485
+ // "remainQty": "45.4950",
486
+ // "feeRate": "0.0003",
487
+ // "fee": "0",
488
+ // "timestamp": "1499340941"
489
+ // }
490
+ // }
491
+ //
492
+ const info = this.safeValue (response, 'info', {});
493
+ info['status'] = this.safeString (info, 'status');
494
+ return this.parseOrder (info, market);
495
+ }
496
+
497
+ parseOrderStatus (status) {
498
+ const statuses = {
499
+ 'live': 'open',
500
+ 'partially_filled': 'open',
501
+ 'filled': 'closed',
502
+ };
503
+ return this.safeString (statuses, status, status);
504
+ }
505
+
506
+ parseOrder (order, market = undefined) {
507
+ //
508
+ // createOrder
509
+ //
510
+ // {
511
+ // "result": "success",
512
+ // "errorCode": "0",
513
+ // "orderId": "8a82c561-40b4-4cb3-9bc0-9ac9ffc1d63b"
514
+ // }
515
+ //
516
+ // fetchOrder
517
+ //
518
+ // {
519
+ // "status": "live", // injected in fetchOrder
520
+ // "orderId": "32FF744B-D501-423A-8BA1-05BB6BE7814A",
521
+ // "currency": "BTC",
522
+ // "type": "bid",
523
+ // "price": "2922000.0",
524
+ // "qty": "115.4950",
525
+ // "remainQty": "45.4950",
526
+ // "feeRate": "0.0003",
527
+ // "fee": "0",
528
+ // "timestamp": "1499340941"
529
+ // }
530
+ //
531
+ // fetchOpenOrders
532
+ //
533
+ // {
534
+ // "index": "0",
535
+ // "orderId": "68665943-1eb5-4e4b-9d76-845fc54f5489",
536
+ // "timestamp": "1449037367",
537
+ // "price": "444000.0",
538
+ // "qty": "0.3456",
539
+ // "type": "ask",
540
+ // "feeRate": "-0.0015"
541
+ // }
542
+ //
543
+ const id = this.safeString (order, 'orderId');
544
+ const priceString = this.safeString (order, 'price');
545
+ const timestamp = this.safeTimestamp (order, 'timestamp');
546
+ let side = this.safeString (order, 'type');
547
+ if (side === 'ask') {
548
+ side = 'sell';
549
+ } else if (side === 'bid') {
550
+ side = 'buy';
551
+ }
552
+ const remainingString = this.safeString (order, 'remainQty');
553
+ const amountString = this.safeString (order, 'qty');
554
+ let status = this.safeString (order, 'status');
555
+ // https://github.com/ccxt/ccxt/pull/7067
556
+ if (status === 'live') {
557
+ if ((remainingString !== undefined) && (amountString !== undefined)) {
558
+ const isLessThan = Precise.stringLt (remainingString, amountString);
559
+ if (isLessThan) {
560
+ status = 'canceled';
561
+ }
562
+ }
563
+ }
564
+ status = this.parseOrderStatus (status);
565
+ let symbol = undefined;
566
+ let base = undefined;
567
+ let quote = undefined;
568
+ const marketId = this.safeStringLower (order, 'currency');
569
+ if (marketId !== undefined) {
570
+ if (marketId in this.markets_by_id) {
571
+ market = this.markets_by_id[marketId];
572
+ } else {
573
+ base = this.safeCurrencyCode (marketId);
574
+ quote = 'KRW';
575
+ symbol = base + '/' + quote;
576
+ }
577
+ }
578
+ if ((symbol === undefined) && (market !== undefined)) {
579
+ symbol = market['symbol'];
580
+ base = market['base'];
581
+ quote = market['quote'];
582
+ }
583
+ let fee = undefined;
584
+ const feeCostString = this.safeString (order, 'fee');
585
+ if (feeCostString !== undefined) {
586
+ const feeCurrencyCode = (side === 'sell') ? quote : base;
587
+ fee = {
588
+ 'cost': feeCostString,
589
+ 'rate': this.safeString (order, 'feeRate'),
590
+ 'currency': feeCurrencyCode,
591
+ };
592
+ }
593
+ return this.safeOrder ({
594
+ 'info': order,
595
+ 'id': id,
596
+ 'clientOrderId': undefined,
597
+ 'timestamp': timestamp,
598
+ 'datetime': this.iso8601 (timestamp),
599
+ 'lastTradeTimestamp': undefined,
600
+ 'symbol': symbol,
601
+ 'type': 'limit',
602
+ 'timeInForce': undefined,
603
+ 'postOnly': undefined,
604
+ 'side': side,
605
+ 'price': priceString,
606
+ 'stopPrice': undefined,
607
+ 'cost': undefined,
608
+ 'average': undefined,
609
+ 'amount': amountString,
610
+ 'filled': undefined,
611
+ 'remaining': remainingString,
612
+ 'status': status,
613
+ 'fee': fee,
614
+ 'trades': undefined,
615
+ }, market);
616
+ }
617
+
618
+ async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
619
+ // The returned amount might not be same as the ordered amount. If an order is partially filled, the returned amount means the remaining amount.
620
+ // For the same reason, the returned amount and remaining are always same, and the returned filled and cost are always zero.
621
+ if (symbol === undefined) {
622
+ throw new ExchangeError (this.id + ' fetchOpenOrders() allows fetching closed orders with a specific symbol');
623
+ }
624
+ await this.loadMarkets ();
625
+ const market = this.market (symbol);
626
+ const request = {
627
+ 'currency': market['id'],
628
+ };
629
+ const response = await this.privatePostOrderLimitOrders (this.extend (request, params));
630
+ //
631
+ // {
632
+ // "result": "success",
633
+ // "errorCode": "0",
634
+ // "limitOrders": [
635
+ // {
636
+ // "index": "0",
637
+ // "orderId": "68665943-1eb5-4e4b-9d76-845fc54f5489",
638
+ // "timestamp": "1449037367",
639
+ // "price": "444000.0",
640
+ // "qty": "0.3456",
641
+ // "type": "ask",
642
+ // "feeRate": "-0.0015"
643
+ // }
644
+ // ]
645
+ // }
646
+ //
647
+ const limitOrders = this.safeValue (response, 'limitOrders', []);
648
+ return this.parseOrders (limitOrders, market, since, limit);
649
+ }
650
+
651
+ async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
652
+ if (symbol === undefined) {
653
+ throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument');
654
+ }
655
+ await this.loadMarkets ();
656
+ const market = this.market (symbol);
657
+ const request = {
658
+ 'currency': market['id'],
659
+ };
660
+ const response = await this.privatePostOrderCompleteOrders (this.extend (request, params));
661
+ //
662
+ // despite the name of the endpoint it returns trades which may have a duplicate orderId
663
+ // https://github.com/ccxt/ccxt/pull/7067
664
+ //
665
+ // {
666
+ // "result": "success",
667
+ // "errorCode": "0",
668
+ // "completeOrders": [
669
+ // {
670
+ // "timestamp": "1416561032",
671
+ // "price": "419000.0",
672
+ // "type": "bid",
673
+ // "qty": "0.001",
674
+ // "feeRate": "-0.0015",
675
+ // "fee": "-0.0000015",
676
+ // "orderId": "E84A1AC2-8088-4FA0-B093-A3BCDB9B3C85"
677
+ // }
678
+ // ]
679
+ // }
680
+ //
681
+ const completeOrders = this.safeValue (response, 'completeOrders', []);
682
+ return this.parseTrades (completeOrders, market, since, limit);
683
+ }
684
+
685
+ async cancelOrder (id, symbol = undefined, params = {}) {
686
+ if (symbol === undefined) {
687
+ // eslint-disable-next-line quotes
688
+ throw new ArgumentsRequired (this.id + " cancelOrder() requires a symbol argument. To cancel the order, pass a symbol argument and {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument of cancelOrder.");
689
+ }
690
+ const price = this.safeNumber (params, 'price');
691
+ const qty = this.safeNumber (params, 'qty');
692
+ const isAsk = this.safeInteger (params, 'is_ask');
693
+ if ((price === undefined) || (qty === undefined) || (isAsk === undefined)) {
694
+ // eslint-disable-next-line quotes
695
+ throw new ArgumentsRequired (this.id + " cancelOrder() requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument.");
696
+ }
697
+ await this.loadMarkets ();
698
+ const request = {
699
+ 'order_id': id,
700
+ 'price': price,
701
+ 'qty': qty,
702
+ 'is_ask': isAsk,
703
+ 'currency': this.marketId (symbol),
704
+ };
705
+ const response = await this.privatePostOrderCancel (this.extend (request, params));
706
+ //
707
+ // {
708
+ // "result": "success",
709
+ // "errorCode": "0"
710
+ // }
711
+ //
712
+ return response;
713
+ }
714
+
715
+ async fetchDepositAddresses (codes = undefined, params = {}) {
716
+ await this.loadMarkets ();
717
+ const response = await this.privatePostAccountDepositAddress (params);
718
+ //
719
+ // {
720
+ // result: 'success',
721
+ // errorCode: '0',
722
+ // walletAddress: {
723
+ // matic: null,
724
+ // btc: "mnobqu4i6qMCJWDpf5UimRmr8JCvZ8FLcN",
725
+ // xrp: null,
726
+ // xrp_tag: '-1',
727
+ // kava: null,
728
+ // kava_memo: null,
729
+ // }
730
+ // }
731
+ //
732
+ const walletAddress = this.safeValue (response, 'walletAddress', {});
733
+ const keys = Object.keys (walletAddress);
734
+ const result = {};
735
+ for (let i = 0; i < keys.length; i++) {
736
+ const key = keys[i];
737
+ const value = walletAddress[key];
738
+ if ((!value) || (value === '-1')) {
739
+ continue;
740
+ }
741
+ const parts = key.split ('_');
742
+ const currencyId = this.safeValue (parts, 0);
743
+ const secondPart = this.safeValue (parts, 1);
744
+ const code = this.safeCurrencyCode (currencyId);
745
+ let depositAddress = this.safeValue (result, code);
746
+ if (depositAddress === undefined) {
747
+ depositAddress = {
748
+ 'currency': code,
749
+ 'address': undefined,
750
+ 'tag': undefined,
751
+ 'info': value,
752
+ };
753
+ }
754
+ const address = this.safeString (depositAddress, 'address', value);
755
+ this.checkAddress (address);
756
+ depositAddress['address'] = address;
757
+ depositAddress['info'] = address;
758
+ if ((secondPart === 'tag' || secondPart === 'memo')) {
759
+ depositAddress['tag'] = value;
760
+ depositAddress['info'] = [ address, value ];
761
+ }
762
+ result[code] = depositAddress;
763
+ }
764
+ return result;
765
+ }
766
+
767
+ sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
768
+ const request = this.implodeParams (path, params);
769
+ const query = this.omit (params, this.extractParams (path));
770
+ let url = this.urls['api'] + '/';
771
+ if (api === 'public') {
772
+ url += request;
773
+ if (Object.keys (query).length) {
774
+ url += '?' + this.urlencode (query);
775
+ }
776
+ } else {
777
+ this.checkRequiredCredentials ();
778
+ url += this.version + '/' + request;
779
+ const nonce = this.nonce ().toString ();
780
+ const json = this.json (this.extend ({
781
+ 'access_token': this.apiKey,
782
+ 'nonce': nonce,
783
+ }, params));
784
+ const payload = this.stringToBase64 (json);
785
+ body = this.decode (payload);
786
+ const secret = this.secret.toUpperCase ();
787
+ const signature = this.hmac (payload, this.encode (secret), 'sha512');
788
+ headers = {
789
+ 'Content-Type': 'application/json',
790
+ 'X-COINONE-PAYLOAD': payload,
791
+ 'X-COINONE-SIGNATURE': signature,
792
+ };
793
+ }
794
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
795
+ }
796
+
797
+ handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
798
+ if (response === undefined) {
799
+ return;
800
+ }
801
+ if ('result' in response) {
802
+ const result = response['result'];
803
+ if (result !== 'success') {
804
+ //
805
+ // { "errorCode": "405", "status": "maintenance", "result": "error"}
806
+ //
807
+ const errorCode = this.safeString (response, 'errorCode');
808
+ const feedback = this.id + ' ' + body;
809
+ this.throwExactlyMatchedException (this.exceptions, errorCode, feedback);
810
+ throw new ExchangeError (feedback);
811
+ }
812
+ } else {
813
+ throw new ExchangeError (this.id + ' ' + body);
814
+ }
815
+ }
816
+ };