ccxt 4.2.11 → 4.2.13

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 (392) hide show
  1. package/README.md +5 -5
  2. package/build.sh +2 -2
  3. package/dist/ccxt.browser.js +1347 -490
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/_virtual/agent.js +7 -0
  6. package/dist/cjs/_virtual/parse-proxy-response.js +7 -0
  7. package/dist/cjs/_virtual/promisify.js +7 -0
  8. package/dist/cjs/ccxt.js +1 -1
  9. package/dist/cjs/js/ccxt.js +474 -0
  10. package/dist/cjs/js/src/abstract/ace.js +9 -0
  11. package/dist/cjs/js/src/abstract/alpaca.js +9 -0
  12. package/dist/cjs/js/src/abstract/ascendex.js +9 -0
  13. package/dist/cjs/js/src/abstract/bigone.js +9 -0
  14. package/dist/cjs/js/src/abstract/binance.js +9 -0
  15. package/dist/cjs/js/src/abstract/bingx.js +9 -0
  16. package/dist/cjs/js/src/abstract/bit2c.js +9 -0
  17. package/dist/cjs/js/src/abstract/bitbank.js +9 -0
  18. package/dist/cjs/js/src/abstract/bitbns.js +9 -0
  19. package/dist/cjs/js/src/abstract/bitfinex.js +9 -0
  20. package/dist/cjs/js/src/abstract/bitfinex2.js +9 -0
  21. package/dist/cjs/js/src/abstract/bitflyer.js +9 -0
  22. package/dist/cjs/js/src/abstract/bitforex.js +9 -0
  23. package/dist/cjs/js/src/abstract/bitget.js +9 -0
  24. package/dist/cjs/js/src/abstract/bithumb.js +9 -0
  25. package/dist/cjs/js/src/abstract/bitmart.js +9 -0
  26. package/dist/cjs/js/src/abstract/bitmex.js +9 -0
  27. package/dist/cjs/js/src/abstract/bitopro.js +9 -0
  28. package/dist/cjs/js/src/abstract/bitpanda.js +9 -0
  29. package/dist/cjs/js/src/abstract/bitrue.js +9 -0
  30. package/dist/cjs/js/src/abstract/bitso.js +9 -0
  31. package/dist/cjs/js/src/abstract/bitstamp.js +9 -0
  32. package/dist/cjs/js/src/abstract/bitteam.js +9 -0
  33. package/dist/cjs/js/src/abstract/bitvavo.js +9 -0
  34. package/dist/cjs/js/src/abstract/bl3p.js +9 -0
  35. package/dist/cjs/js/src/abstract/blockchaincom.js +9 -0
  36. package/dist/cjs/js/src/abstract/btcalpha.js +9 -0
  37. package/dist/cjs/js/src/abstract/btcbox.js +9 -0
  38. package/dist/cjs/js/src/abstract/btcmarkets.js +9 -0
  39. package/dist/cjs/js/src/abstract/btcturk.js +9 -0
  40. package/dist/cjs/js/src/abstract/bybit.js +9 -0
  41. package/dist/cjs/js/src/abstract/cex.js +9 -0
  42. package/dist/cjs/js/src/abstract/coinbase.js +9 -0
  43. package/dist/cjs/js/src/abstract/coinbasepro.js +9 -0
  44. package/dist/cjs/js/src/abstract/coincheck.js +9 -0
  45. package/dist/cjs/js/src/abstract/coinex.js +9 -0
  46. package/dist/cjs/js/src/abstract/coinlist.js +9 -0
  47. package/dist/cjs/js/src/abstract/coinmate.js +9 -0
  48. package/dist/cjs/js/src/abstract/coinone.js +9 -0
  49. package/dist/cjs/js/src/abstract/coinsph.js +9 -0
  50. package/dist/cjs/js/src/abstract/coinspot.js +9 -0
  51. package/dist/cjs/js/src/abstract/cryptocom.js +9 -0
  52. package/dist/cjs/js/src/abstract/currencycom.js +9 -0
  53. package/dist/cjs/js/src/abstract/delta.js +9 -0
  54. package/dist/cjs/js/src/abstract/deribit.js +9 -0
  55. package/dist/cjs/js/src/abstract/digifinex.js +9 -0
  56. package/dist/cjs/js/src/abstract/exmo.js +9 -0
  57. package/dist/cjs/js/src/abstract/gate.js +9 -0
  58. package/dist/cjs/js/src/abstract/gemini.js +9 -0
  59. package/dist/cjs/js/src/abstract/hitbtc.js +9 -0
  60. package/dist/cjs/js/src/abstract/hollaex.js +9 -0
  61. package/dist/cjs/js/src/abstract/htx.js +9 -0
  62. package/dist/cjs/js/src/abstract/huobijp.js +9 -0
  63. package/dist/cjs/js/src/abstract/idex.js +9 -0
  64. package/dist/cjs/js/src/abstract/independentreserve.js +9 -0
  65. package/dist/cjs/js/src/abstract/indodax.js +9 -0
  66. package/dist/cjs/js/src/abstract/kraken.js +9 -0
  67. package/dist/cjs/js/src/abstract/krakenfutures.js +9 -0
  68. package/dist/cjs/js/src/abstract/kucoin.js +9 -0
  69. package/dist/cjs/js/src/abstract/kucoinfutures.js +9 -0
  70. package/dist/cjs/js/src/abstract/kuna.js +9 -0
  71. package/dist/cjs/js/src/abstract/latoken.js +9 -0
  72. package/dist/cjs/js/src/abstract/lbank.js +9 -0
  73. package/dist/cjs/js/src/abstract/luno.js +9 -0
  74. package/dist/cjs/js/src/abstract/lykke.js +9 -0
  75. package/dist/cjs/js/src/abstract/mercado.js +9 -0
  76. package/dist/cjs/js/src/abstract/mexc.js +9 -0
  77. package/dist/cjs/js/src/abstract/ndax.js +9 -0
  78. package/dist/cjs/js/src/abstract/novadax.js +9 -0
  79. package/dist/cjs/js/src/abstract/oceanex.js +9 -0
  80. package/dist/cjs/js/src/abstract/okcoin.js +9 -0
  81. package/dist/cjs/js/src/abstract/okx.js +9 -0
  82. package/dist/cjs/js/src/abstract/p2b.js +9 -0
  83. package/dist/cjs/js/src/abstract/paymium.js +9 -0
  84. package/dist/cjs/js/src/abstract/phemex.js +9 -0
  85. package/dist/cjs/js/src/abstract/poloniex.js +9 -0
  86. package/dist/cjs/js/src/abstract/poloniexfutures.js +9 -0
  87. package/dist/cjs/js/src/abstract/probit.js +9 -0
  88. package/dist/cjs/js/src/abstract/timex.js +9 -0
  89. package/dist/cjs/js/src/abstract/tokocrypto.js +9 -0
  90. package/dist/cjs/js/src/abstract/upbit.js +9 -0
  91. package/dist/cjs/js/src/abstract/wavesexchange.js +9 -0
  92. package/dist/cjs/js/src/abstract/wazirx.js +9 -0
  93. package/dist/cjs/js/src/abstract/whitebit.js +9 -0
  94. package/dist/cjs/js/src/abstract/woo.js +9 -0
  95. package/dist/cjs/js/src/abstract/yobit.js +9 -0
  96. package/dist/cjs/js/src/abstract/zaif.js +9 -0
  97. package/dist/cjs/js/src/abstract/zonda.js +9 -0
  98. package/dist/cjs/js/src/ace.js +1058 -0
  99. package/dist/cjs/js/src/alpaca.js +1125 -0
  100. package/dist/cjs/js/src/ascendex.js +3360 -0
  101. package/dist/cjs/js/src/base/Exchange.js +5110 -0
  102. package/dist/cjs/js/src/base/Precise.js +263 -0
  103. package/dist/cjs/js/src/base/errors.js +299 -0
  104. package/dist/cjs/js/src/base/functions/crypto.js +78 -0
  105. package/dist/cjs/js/src/base/functions/encode.js +44 -0
  106. package/dist/cjs/js/src/base/functions/generic.js +193 -0
  107. package/dist/cjs/js/src/base/functions/misc.js +96 -0
  108. package/dist/cjs/js/src/base/functions/number.js +297 -0
  109. package/dist/cjs/js/src/base/functions/platform.js +28 -0
  110. package/dist/cjs/js/src/base/functions/rsa.js +34 -0
  111. package/dist/cjs/js/src/base/functions/string.js +48 -0
  112. package/dist/cjs/js/src/base/functions/throttle.js +66 -0
  113. package/dist/cjs/js/src/base/functions/time.js +187 -0
  114. package/dist/cjs/js/src/base/functions/totp.js +24 -0
  115. package/dist/cjs/js/src/base/functions/type.js +162 -0
  116. package/dist/cjs/js/src/base/functions.js +157 -0
  117. package/dist/cjs/js/src/base/ws/Cache.js +254 -0
  118. package/dist/cjs/js/src/base/ws/Client.js +299 -0
  119. package/dist/cjs/js/src/base/ws/Future.js +34 -0
  120. package/dist/cjs/js/src/base/ws/OrderBook.js +107 -0
  121. package/dist/cjs/js/src/base/ws/OrderBookSide.js +281 -0
  122. package/dist/cjs/js/src/base/ws/WsClient.js +69 -0
  123. package/dist/cjs/js/src/bequant.js +33 -0
  124. package/dist/cjs/js/src/bigone.js +2209 -0
  125. package/dist/cjs/js/src/binance.js +9736 -0
  126. package/dist/cjs/js/src/binancecoinm.js +45 -0
  127. package/dist/cjs/js/src/binanceus.js +84 -0
  128. package/dist/cjs/js/src/binanceusdm.js +58 -0
  129. package/dist/cjs/js/src/bingx.js +3807 -0
  130. package/dist/cjs/js/src/bit2c.js +916 -0
  131. package/dist/cjs/js/src/bitbank.js +1000 -0
  132. package/dist/cjs/js/src/bitbay.js +17 -0
  133. package/dist/cjs/js/src/bitbns.js +1220 -0
  134. package/dist/cjs/js/src/bitcoincom.js +17 -0
  135. package/dist/cjs/js/src/bitfinex.js +1670 -0
  136. package/dist/cjs/js/src/bitfinex2.js +2990 -0
  137. package/dist/cjs/js/src/bitflyer.js +1045 -0
  138. package/dist/cjs/js/src/bitforex.js +852 -0
  139. package/dist/cjs/js/src/bitget.js +8291 -0
  140. package/dist/cjs/js/src/bithumb.js +1090 -0
  141. package/dist/cjs/js/src/bitmart.js +4454 -0
  142. package/dist/cjs/js/src/bitmex.js +2884 -0
  143. package/dist/cjs/js/src/bitopro.js +1724 -0
  144. package/dist/cjs/js/src/bitpanda.js +2002 -0
  145. package/dist/cjs/js/src/bitrue.js +3253 -0
  146. package/dist/cjs/js/src/bitso.js +1753 -0
  147. package/dist/cjs/js/src/bitstamp.js +2188 -0
  148. package/dist/cjs/js/src/bitteam.js +2309 -0
  149. package/dist/cjs/js/src/bitvavo.js +1968 -0
  150. package/dist/cjs/js/src/bl3p.js +447 -0
  151. package/dist/cjs/js/src/blockchaincom.js +1160 -0
  152. package/dist/cjs/js/src/btcalpha.js +929 -0
  153. package/dist/cjs/js/src/btcbox.js +565 -0
  154. package/dist/cjs/js/src/btcmarkets.js +1237 -0
  155. package/dist/cjs/js/src/btcturk.js +929 -0
  156. package/dist/cjs/js/src/bybit.js +7646 -0
  157. package/dist/cjs/js/src/cex.js +1693 -0
  158. package/dist/cjs/js/src/coinbase.js +3424 -0
  159. package/dist/cjs/js/src/coinbasepro.js +1866 -0
  160. package/dist/cjs/js/src/coincheck.js +843 -0
  161. package/dist/cjs/js/src/coinex.js +5414 -0
  162. package/dist/cjs/js/src/coinlist.js +2329 -0
  163. package/dist/cjs/js/src/coinmate.js +989 -0
  164. package/dist/cjs/js/src/coinone.js +1185 -0
  165. package/dist/cjs/js/src/coinsph.js +1933 -0
  166. package/dist/cjs/js/src/coinspot.js +548 -0
  167. package/dist/cjs/js/src/cryptocom.js +3007 -0
  168. package/dist/cjs/js/src/currencycom.js +2015 -0
  169. package/dist/cjs/js/src/delta.js +3256 -0
  170. package/dist/cjs/js/src/deribit.js +3306 -0
  171. package/dist/cjs/js/src/digifinex.js +4307 -0
  172. package/dist/cjs/js/src/exmo.js +2645 -0
  173. package/dist/cjs/js/src/fmfwio.js +34 -0
  174. package/dist/cjs/js/src/gate.js +7072 -0
  175. package/dist/cjs/js/src/gateio.js +16 -0
  176. package/dist/cjs/js/src/gemini.js +1801 -0
  177. package/dist/cjs/js/src/hitbtc.js +3660 -0
  178. package/dist/cjs/js/src/hitbtc3.js +19 -0
  179. package/dist/cjs/js/src/hollaex.js +1882 -0
  180. package/dist/cjs/js/src/htx.js +9049 -0
  181. package/dist/cjs/js/src/huobi.js +16 -0
  182. package/dist/cjs/js/src/huobijp.js +1918 -0
  183. package/dist/cjs/js/src/idex.js +1770 -0
  184. package/dist/cjs/js/src/independentreserve.js +761 -0
  185. package/dist/cjs/js/src/indodax.js +1069 -0
  186. package/dist/cjs/js/src/kraken.js +2857 -0
  187. package/dist/cjs/js/src/krakenfutures.js +2407 -0
  188. package/dist/cjs/js/src/kucoin.js +4489 -0
  189. package/dist/cjs/js/src/kucoinfutures.js +2475 -0
  190. package/dist/cjs/js/src/kuna.js +1949 -0
  191. package/dist/cjs/js/src/latoken.js +1729 -0
  192. package/dist/cjs/js/src/lbank.js +2851 -0
  193. package/dist/cjs/js/src/luno.js +1044 -0
  194. package/dist/cjs/js/src/lykke.js +1303 -0
  195. package/dist/cjs/js/src/mercado.js +897 -0
  196. package/dist/cjs/js/src/mexc.js +5407 -0
  197. package/dist/cjs/js/src/ndax.js +2450 -0
  198. package/dist/cjs/js/src/novadax.js +1556 -0
  199. package/dist/cjs/js/src/oceanex.js +964 -0
  200. package/dist/cjs/js/src/okcoin.js +3115 -0
  201. package/dist/cjs/js/src/okx.js +7330 -0
  202. package/dist/cjs/js/src/p2b.js +1243 -0
  203. package/dist/cjs/js/src/paymium.js +597 -0
  204. package/dist/cjs/js/src/phemex.js +4722 -0
  205. package/dist/cjs/js/src/poloniex.js +2356 -0
  206. package/dist/cjs/js/src/poloniexfutures.js +1794 -0
  207. package/dist/cjs/js/src/pro/alpaca.js +714 -0
  208. package/dist/cjs/js/src/pro/ascendex.js +957 -0
  209. package/dist/cjs/js/src/pro/bequant.js +33 -0
  210. package/dist/cjs/js/src/pro/binance.js +2796 -0
  211. package/dist/cjs/js/src/pro/binancecoinm.js +23 -0
  212. package/dist/cjs/js/src/pro/binanceus.js +51 -0
  213. package/dist/cjs/js/src/pro/binanceusdm.js +32 -0
  214. package/dist/cjs/js/src/pro/bingx.js +944 -0
  215. package/dist/cjs/js/src/pro/bitcoincom.js +29 -0
  216. package/dist/cjs/js/src/pro/bitfinex.js +672 -0
  217. package/dist/cjs/js/src/pro/bitfinex2.js +1159 -0
  218. package/dist/cjs/js/src/pro/bitget.js +1733 -0
  219. package/dist/cjs/js/src/pro/bitmart.js +1486 -0
  220. package/dist/cjs/js/src/pro/bitmex.js +1576 -0
  221. package/dist/cjs/js/src/pro/bitopro.js +327 -0
  222. package/dist/cjs/js/src/pro/bitpanda.js +1341 -0
  223. package/dist/cjs/js/src/pro/bitrue.js +462 -0
  224. package/dist/cjs/js/src/pro/bitstamp.js +547 -0
  225. package/dist/cjs/js/src/pro/bitvavo.js +704 -0
  226. package/dist/cjs/js/src/pro/blockchaincom.js +794 -0
  227. package/dist/cjs/js/src/pro/bybit.js +1843 -0
  228. package/dist/cjs/js/src/pro/cex.js +1510 -0
  229. package/dist/cjs/js/src/pro/coinbase.js +561 -0
  230. package/dist/cjs/js/src/pro/coinbasepro.js +968 -0
  231. package/dist/cjs/js/src/pro/coinex.js +1095 -0
  232. package/dist/cjs/js/src/pro/cryptocom.js +1020 -0
  233. package/dist/cjs/js/src/pro/currencycom.js +563 -0
  234. package/dist/cjs/js/src/pro/deribit.js +825 -0
  235. package/dist/cjs/js/src/pro/exmo.js +658 -0
  236. package/dist/cjs/js/src/pro/gate.js +1316 -0
  237. package/dist/cjs/js/src/pro/gateio.js +16 -0
  238. package/dist/cjs/js/src/pro/gemini.js +649 -0
  239. package/dist/cjs/js/src/pro/hitbtc.js +1293 -0
  240. package/dist/cjs/js/src/pro/hollaex.js +597 -0
  241. package/dist/cjs/js/src/pro/htx.js +2383 -0
  242. package/dist/cjs/js/src/pro/huobi.js +16 -0
  243. package/dist/cjs/js/src/pro/huobijp.js +606 -0
  244. package/dist/cjs/js/src/pro/idex.js +714 -0
  245. package/dist/cjs/js/src/pro/independentreserve.js +280 -0
  246. package/dist/cjs/js/src/pro/kraken.js +1364 -0
  247. package/dist/cjs/js/src/pro/krakenfutures.js +1500 -0
  248. package/dist/cjs/js/src/pro/kucoin.js +1052 -0
  249. package/dist/cjs/js/src/pro/kucoinfutures.js +981 -0
  250. package/dist/cjs/js/src/pro/luno.js +322 -0
  251. package/dist/cjs/js/src/pro/mexc.js +1170 -0
  252. package/dist/cjs/js/src/pro/ndax.js +545 -0
  253. package/dist/cjs/js/src/pro/okcoin.js +760 -0
  254. package/dist/cjs/js/src/pro/okx.js +1608 -0
  255. package/dist/cjs/js/src/pro/phemex.js +1511 -0
  256. package/dist/cjs/js/src/pro/poloniex.js +1253 -0
  257. package/dist/cjs/js/src/pro/poloniexfutures.js +1014 -0
  258. package/dist/cjs/js/src/pro/probit.js +586 -0
  259. package/dist/cjs/js/src/pro/upbit.js +234 -0
  260. package/dist/cjs/js/src/pro/wazirx.js +776 -0
  261. package/dist/cjs/js/src/pro/whitebit.js +927 -0
  262. package/dist/cjs/js/src/pro/woo.js +769 -0
  263. package/dist/cjs/js/src/probit.js +1867 -0
  264. package/dist/cjs/js/src/static_dependencies/fflake/browser.js +401 -0
  265. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +195 -0
  266. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +308 -0
  267. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +554 -0
  268. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +94 -0
  269. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +70 -0
  270. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +91 -0
  271. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +16 -0
  272. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1760 -0
  273. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +52 -0
  274. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +81 -0
  275. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +376 -0
  276. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +70 -0
  277. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1580 -0
  278. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +74 -0
  279. package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +24 -0
  280. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +158 -0
  281. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +429 -0
  282. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +176 -0
  283. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +324 -0
  284. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +163 -0
  285. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +245 -0
  286. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +1018 -0
  287. package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +383 -0
  288. package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +258 -0
  289. package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +53 -0
  290. package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +120 -0
  291. package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +69 -0
  292. package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +7 -0
  293. package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +83 -0
  294. package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +240 -0
  295. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +91 -0
  296. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +130 -0
  297. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +214 -0
  298. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +239 -0
  299. package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +93 -0
  300. package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +354 -0
  301. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +16 -0
  302. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +20 -0
  303. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +30 -0
  304. package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +239 -0
  305. package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +372 -0
  306. package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +273 -0
  307. package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +139 -0
  308. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +14 -0
  309. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +16 -0
  310. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +81 -0
  311. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +292 -0
  312. package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +103 -0
  313. package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +140 -0
  314. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +175 -0
  315. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +95 -0
  316. package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +7 -0
  317. package/dist/cjs/js/src/static_dependencies/scure-base/index.js +383 -0
  318. package/dist/cjs/js/src/timex.js +1562 -0
  319. package/dist/cjs/js/src/tokocrypto.js +2542 -0
  320. package/dist/cjs/js/src/upbit.js +1844 -0
  321. package/dist/cjs/js/src/wavesexchange.js +2607 -0
  322. package/dist/cjs/js/src/wazirx.js +953 -0
  323. package/dist/cjs/js/src/whitebit.js +2309 -0
  324. package/dist/cjs/js/src/woo.js +2765 -0
  325. package/dist/cjs/js/src/yobit.js +1314 -0
  326. package/dist/cjs/js/src/zaif.js +736 -0
  327. package/dist/cjs/js/src/zonda.js +1883 -0
  328. package/js/ccxt.d.ts +1 -1
  329. package/js/ccxt.js +1 -1
  330. package/js/src/abstract/bigone.d.ts +18 -0
  331. package/js/src/abstract/binance.d.ts +2 -0
  332. package/js/src/abstract/binancecoinm.d.ts +2 -0
  333. package/js/src/abstract/binanceus.d.ts +2 -0
  334. package/js/src/abstract/binanceusdm.d.ts +2 -0
  335. package/js/src/abstract/bingx.d.ts +2 -0
  336. package/js/src/abstract/bybit.d.ts +1 -0
  337. package/js/src/abstract/gate.d.ts +11 -0
  338. package/js/src/abstract/gateio.d.ts +11 -0
  339. package/js/src/abstract/okx.d.ts +1 -0
  340. package/js/src/alpaca.js +18 -18
  341. package/js/src/base/Exchange.d.ts +5 -1
  342. package/js/src/base/Exchange.js +101 -12
  343. package/js/src/bigone.d.ts +3 -2
  344. package/js/src/bigone.js +429 -167
  345. package/js/src/binance.js +48 -34
  346. package/js/src/bingx.js +115 -38
  347. package/js/src/bitfinex.d.ts +2 -2
  348. package/js/src/bitfinex.js +2 -3
  349. package/js/src/bitget.js +33 -13
  350. package/js/src/bitmart.d.ts +2 -2
  351. package/js/src/bitmart.js +5 -5
  352. package/js/src/bitmex.js +1 -0
  353. package/js/src/bybit.js +2 -0
  354. package/js/src/coinbase.d.ts +26 -3
  355. package/js/src/coinbase.js +176 -26
  356. package/js/src/coinlist.js +3 -4
  357. package/js/src/coinone.js +1 -1
  358. package/js/src/coinsph.js +2 -3
  359. package/js/src/deribit.js +1 -0
  360. package/js/src/gate.d.ts +4 -4
  361. package/js/src/gate.js +96 -59
  362. package/js/src/gemini.js +1 -1
  363. package/js/src/hitbtc.d.ts +4 -4
  364. package/js/src/hitbtc.js +2 -3
  365. package/js/src/htx.d.ts +1 -0
  366. package/js/src/htx.js +29 -7
  367. package/js/src/huobijp.js +2 -3
  368. package/js/src/independentreserve.js +7 -5
  369. package/js/src/kraken.js +3 -6
  370. package/js/src/lbank.js +59 -33
  371. package/js/src/mexc.js +2 -1
  372. package/js/src/oceanex.js +1 -1
  373. package/js/src/okx.js +14 -3
  374. package/js/src/phemex.js +9 -2
  375. package/js/src/pro/binance.d.ts +2 -23
  376. package/js/src/pro/binance.js +58 -22
  377. package/js/src/pro/coinbase.d.ts +2 -2
  378. package/js/src/pro/coinbase.js +4 -1
  379. package/js/src/pro/coinbasepro.d.ts +2 -2
  380. package/js/src/pro/hitbtc.d.ts +2 -2
  381. package/js/src/pro/kraken.js +1 -1
  382. package/js/src/pro/okx.d.ts +1 -0
  383. package/js/src/pro/okx.js +52 -2
  384. package/js/src/pro/poloniex.d.ts +2 -2
  385. package/js/src/probit.js +4 -2
  386. package/js/src/upbit.d.ts +3 -101
  387. package/js/src/upbit.js +12 -12
  388. package/js/src/wavesexchange.js +1 -1
  389. package/js/src/woo.d.ts +2 -0
  390. package/js/src/woo.js +52 -0
  391. package/package.json +1 -1
  392. package/skip-tests.json +5 -0
@@ -0,0 +1,1562 @@
1
+ 'use strict';
2
+
3
+ var timex$1 = require('./abstract/timex.js');
4
+ var errors = require('./base/errors.js');
5
+ var Precise = require('./base/Precise.js');
6
+ var number = require('./base/functions/number.js');
7
+
8
+ /**
9
+ * @class timex
10
+ * @augments Exchange
11
+ */
12
+ class timex extends timex$1 {
13
+ describe() {
14
+ return this.deepExtend(super.describe(), {
15
+ 'id': 'timex',
16
+ 'name': 'TimeX',
17
+ 'countries': ['AU'],
18
+ 'version': 'v1',
19
+ 'rateLimit': 1500,
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
+ 'cancelOrders': true,
30
+ 'createOrder': true,
31
+ 'createReduceOnlyOrder': false,
32
+ 'createStopLimitOrder': false,
33
+ 'createStopMarketOrder': false,
34
+ 'createStopOrder': false,
35
+ 'editOrder': true,
36
+ 'fetchBalance': true,
37
+ 'fetchBorrowRateHistories': false,
38
+ 'fetchBorrowRateHistory': false,
39
+ 'fetchClosedOrders': true,
40
+ 'fetchCrossBorrowRate': false,
41
+ 'fetchCrossBorrowRates': false,
42
+ 'fetchCurrencies': true,
43
+ 'fetchDeposit': false,
44
+ 'fetchDeposits': true,
45
+ 'fetchFundingHistory': false,
46
+ 'fetchFundingRate': false,
47
+ 'fetchFundingRateHistory': false,
48
+ 'fetchFundingRates': false,
49
+ 'fetchIndexOHLCV': false,
50
+ 'fetchIsolatedBorrowRate': false,
51
+ 'fetchIsolatedBorrowRates': false,
52
+ 'fetchLeverage': false,
53
+ 'fetchLeverageTiers': false,
54
+ 'fetchMarginMode': false,
55
+ 'fetchMarkets': true,
56
+ 'fetchMarkOHLCV': false,
57
+ 'fetchMyTrades': true,
58
+ 'fetchOHLCV': true,
59
+ 'fetchOpenInterestHistory': false,
60
+ 'fetchOpenOrders': true,
61
+ 'fetchOrder': true,
62
+ 'fetchOrderBook': true,
63
+ 'fetchPosition': false,
64
+ 'fetchPositionMode': false,
65
+ 'fetchPositions': false,
66
+ 'fetchPositionsRisk': false,
67
+ 'fetchPremiumIndexOHLCV': false,
68
+ 'fetchTicker': true,
69
+ 'fetchTickers': true,
70
+ 'fetchTrades': true,
71
+ 'fetchTradingFee': true,
72
+ 'fetchWithdrawal': false,
73
+ 'fetchWithdrawals': true,
74
+ 'reduceMargin': false,
75
+ 'setLeverage': false,
76
+ 'setMarginMode': false,
77
+ 'setPositionMode': false,
78
+ },
79
+ 'timeframes': {
80
+ '1m': 'I1',
81
+ '5m': 'I5',
82
+ '15m': 'I15',
83
+ '30m': 'I30',
84
+ '1h': 'H1',
85
+ '2h': 'H2',
86
+ '4h': 'H4',
87
+ '6h': 'H6',
88
+ '12h': 'H12',
89
+ '1d': 'D1',
90
+ '1w': 'W1',
91
+ },
92
+ 'urls': {
93
+ 'logo': 'https://user-images.githubusercontent.com/1294454/70423869-6839ab00-1a7f-11ea-8f94-13ae72c31115.jpg',
94
+ 'api': {
95
+ 'rest': 'https://plasma-relay-backend.timex.io',
96
+ },
97
+ 'www': 'https://timex.io',
98
+ 'doc': 'https://docs.timex.io',
99
+ 'referral': 'https://timex.io/?refcode=1x27vNkTbP1uwkCck',
100
+ },
101
+ 'api': {
102
+ 'addressbook': {
103
+ 'get': [
104
+ 'me',
105
+ ],
106
+ 'post': [
107
+ '',
108
+ 'id/{id}',
109
+ 'id/{id}/remove',
110
+ ],
111
+ },
112
+ 'custody': {
113
+ 'get': [
114
+ 'credentials',
115
+ 'credentials/h/{hash}',
116
+ 'credentials/k/{key}',
117
+ 'credentials/me',
118
+ 'credentials/me/address',
119
+ 'deposit-addresses',
120
+ 'deposit-addresses/h/{hash}', // Get deposit address by hash
121
+ ],
122
+ },
123
+ 'history': {
124
+ 'get': [
125
+ 'orders',
126
+ 'orders/details',
127
+ 'orders/export/csv',
128
+ 'trades',
129
+ 'trades/export/csv', // Export trades to csv
130
+ ],
131
+ },
132
+ 'currencies': {
133
+ 'get': [
134
+ 'a/{address}',
135
+ 'i/{id}',
136
+ 's/{symbol}', // Gets currency by symbol
137
+ ],
138
+ 'post': [
139
+ 'perform',
140
+ 'prepare',
141
+ 'remove/perform',
142
+ 's/{symbol}/remove/prepare',
143
+ 's/{symbol}/update/perform',
144
+ 's/{symbol}/update/prepare', // Prepare update currency by symbol
145
+ ],
146
+ },
147
+ 'manager': {
148
+ 'get': [
149
+ 'deposits',
150
+ 'transfers',
151
+ 'withdrawals',
152
+ ],
153
+ },
154
+ 'markets': {
155
+ 'get': [
156
+ 'i/{id}',
157
+ 's/{symbol}', // Gets market by symbol
158
+ ],
159
+ 'post': [
160
+ 'perform',
161
+ 'prepare',
162
+ 'remove/perform',
163
+ 's/{symbol}/remove/prepare',
164
+ 's/{symbol}/update/perform',
165
+ 's/{symbol}/update/prepare', // Prepare update market by symbol
166
+ ],
167
+ },
168
+ 'public': {
169
+ 'get': [
170
+ 'candles',
171
+ 'currencies',
172
+ 'markets',
173
+ 'orderbook',
174
+ 'orderbook/raw',
175
+ 'orderbook/v2',
176
+ 'tickers',
177
+ 'trades', // Gets trades
178
+ ],
179
+ },
180
+ 'statistics': {
181
+ 'get': [
182
+ 'address', // calculateAddressStatistics
183
+ ],
184
+ },
185
+ 'trading': {
186
+ 'get': [
187
+ 'balances',
188
+ 'fees',
189
+ 'orders', // Gets open orders
190
+ ],
191
+ 'post': [
192
+ 'orders',
193
+ 'orders/json', // Create orders
194
+ ],
195
+ 'put': [
196
+ 'orders',
197
+ 'orders/json', // Update orders
198
+ ],
199
+ 'delete': [
200
+ 'orders',
201
+ 'orders/json', // Delete orders
202
+ ],
203
+ },
204
+ 'tradingview': {
205
+ 'get': [
206
+ 'config',
207
+ 'history',
208
+ 'symbol_info',
209
+ 'time', // Gets time
210
+ ],
211
+ },
212
+ },
213
+ 'precisionMode': number.TICK_SIZE,
214
+ 'exceptions': {
215
+ 'exact': {
216
+ '0': errors.ExchangeError,
217
+ '1': errors.NotSupported,
218
+ '4000': errors.BadRequest,
219
+ '4001': errors.BadRequest,
220
+ '4002': errors.InsufficientFunds,
221
+ '4003': errors.AuthenticationError,
222
+ '4004': errors.AuthenticationError,
223
+ '4005': errors.BadRequest,
224
+ '4006': errors.BadRequest,
225
+ '4007': errors.BadRequest,
226
+ '4300': errors.PermissionDenied,
227
+ '4100': errors.AuthenticationError,
228
+ '4400': errors.OrderNotFound,
229
+ '5001': errors.InvalidOrder,
230
+ '5002': errors.ExchangeError,
231
+ '400': errors.BadRequest,
232
+ '401': errors.AuthenticationError,
233
+ '403': errors.PermissionDenied,
234
+ '404': errors.OrderNotFound,
235
+ '429': errors.RateLimitExceeded,
236
+ '500': errors.ExchangeError,
237
+ '503': errors.ExchangeNotAvailable,
238
+ },
239
+ 'broad': {
240
+ 'Insufficient': errors.InsufficientFunds,
241
+ },
242
+ },
243
+ 'options': {
244
+ 'expireIn': 31536000,
245
+ 'fetchTickers': {
246
+ 'period': '1d',
247
+ },
248
+ 'fetchTrades': {
249
+ 'sort': 'timestamp,asc',
250
+ },
251
+ 'fetchMyTrades': {
252
+ 'sort': 'timestamp,asc',
253
+ },
254
+ 'fetchOpenOrders': {
255
+ 'sort': 'createdAt,asc',
256
+ },
257
+ 'fetchClosedOrders': {
258
+ 'sort': 'createdAt,asc',
259
+ },
260
+ 'defaultSort': 'timestamp,asc',
261
+ 'defaultSortOrders': 'createdAt,asc',
262
+ },
263
+ });
264
+ }
265
+ async fetchMarkets(params = {}) {
266
+ /**
267
+ * @method
268
+ * @name timex#fetchMarkets
269
+ * @description retrieves data on all markets for timex
270
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
271
+ * @returns {object[]} an array of objects representing market data
272
+ */
273
+ const response = await this.publicGetMarkets(params);
274
+ //
275
+ // [
276
+ // {
277
+ // "symbol": "ETHBTC",
278
+ // "name": "ETH/BTC",
279
+ // "baseCurrency": "ETH",
280
+ // "baseTokenAddress": "0x45932db54b38af1f5a57136302eeba66a5975c15",
281
+ // "quoteCurrency": "BTC",
282
+ // "quoteTokenAddress": "0x8370fbc6ddec1e18b4e41e72ed943e238458487c",
283
+ // "feeCurrency": "BTC",
284
+ // "feeTokenAddress": "0x8370fbc6ddec1e18b4e41e72ed943e238458487c",
285
+ // "quantityIncrement": "0.0000001",
286
+ // "takerFee": "0.005",
287
+ // "makerFee": "0.0025",
288
+ // "tickSize": "0.00000001",
289
+ // "baseMinSize": "0.0001",
290
+ // "quoteMinSize": "0.00001",
291
+ // "locked": false
292
+ // }
293
+ // ]
294
+ //
295
+ return this.parseMarkets(response);
296
+ }
297
+ async fetchCurrencies(params = {}) {
298
+ /**
299
+ * @method
300
+ * @name timex#fetchCurrencies
301
+ * @description fetches all available currencies on an exchange
302
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
303
+ * @returns {object} an associative dictionary of currencies
304
+ */
305
+ const response = await this.publicGetCurrencies(params);
306
+ //
307
+ // [
308
+ // {
309
+ // "symbol": "BTC",
310
+ // "name": "Bitcoin",
311
+ // "address": "0x8370fbc6ddec1e18b4e41e72ed943e238458487c",
312
+ // "icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggb3BhY2l0eT0iMC41IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTMwIDUzQzQyLjcwMjUgNTMgNTMgNDIuNzAyNSA1MyAzMEM1MyAxNy4yOTc1IDQyLjcwMjUgNyAzMCA3QzE3LjI5NzUgNyA3IDE3LjI5NzUgNyAzMEM3IDQyLjcwMjUgMTcuMjk3NSA1MyAzMCA1M1pNMzAgNTVDNDMuODA3MSA1NSA1NSA0My44MDcxIDU1IDMwQzU1IDE2LjE5MjkgNDMuODA3MSA1IDMwIDVDMTYuMTkyOSA1IDUgMTYuMTkyOSA1IDMwQzUgNDMuODA3MSAxNi4xOTI5IDU1IDMwIDU1WiIvPgo8cGF0aCBkPSJNNDAuOTQyNSAyNi42NTg1QzQxLjQwMDMgMjMuNjExMyAzOS4wNzA1IDIxLjk3MzIgMzUuODg0OCAyMC44ODA0TDM2LjkxODIgMTYuNzUyNkwzNC4zOTUxIDE2LjEyNjRMMzMuMzg5IDIwLjE0NTVDMzIuNzI1OCAxOS45ODA5IDMyLjA0NDUgMTkuODI1NiAzMS4zNjc1IDE5LjY3MTdMMzIuMzgwOCAxNS42MjYyTDI5Ljg1OTEgMTVMMjguODI1IDE5LjEyNjRDMjguMjc2IDE5LjAwMTkgMjcuNzM3IDE4Ljg3ODggMjcuMjEzOSAxOC43NDkzTDI3LjIxNjggMTguNzM2NEwyMy43MzcyIDE3Ljg3MTJMMjMuMDY2IDIwLjU1NDhDMjMuMDY2IDIwLjU1NDggMjQuOTM4IDIwLjk4MjEgMjQuODk4NSAyMS4wMDg1QzI1LjkyMDQgMjEuMjYyNiAyNi4xMDUgMjEuOTM2IDI2LjA3NDEgMjIuNDY5OUwyNC44OTcgMjcuMTcyNEMyNC45Njc1IDI3LjE5MDMgMjUuMDU4NyAyNy4yMTYgMjUuMTU5MyAyNy4yNTYxQzI1LjA3NTMgMjcuMjM1NCAyNC45ODU0IDI3LjIxMjQgMjQuODkyNyAyNy4xOTAzTDIzLjI0MjggMzMuNzc3OEMyMy4xMTc3IDM0LjA4NjkgMjIuODAwOCAzNC41NTA2IDIyLjA4NjUgMzQuMzc0NkMyMi4xMTE3IDM0LjQxMTEgMjAuMjUyNiAzMy45MTg3IDIwLjI1MjYgMzMuOTE4N0wxOSAzNi43OTQ5TDIyLjI4MzQgMzcuNjFDMjIuODk0MiAzNy43NjI0IDIzLjQ5MjggMzcuOTIyIDI0LjA4MjEgMzguMDcyM0wyMy4wMzggNDIuMjQ3NEwyNS41NTgyIDQyLjg3MzZMMjYuNTkyMyAzOC43NDI5QzI3LjI4MDcgMzguOTI5IDI3Ljk0OSAzOS4xMDA3IDI4LjYwMyAzOS4yNjI0TDI3LjU3MjUgNDMuMzczOEwzMC4wOTU2IDQ0TDMxLjEzOTcgMzkuODMyOEMzNS40NDIyIDQwLjY0MzYgMzguNjc3NCA0MC4zMTY2IDQwLjAzOTIgMzYuNDQxNEM0MS4xMzY1IDMzLjMyMTIgMzkuOTg0NiAzMS41MjEzIDM3LjcyMDkgMzAuMzQ3N0MzOS4zNjk0IDI5Ljk2OTEgNDAuNjExMiAyOC44ODkyIDQwLjk0MjUgMjYuNjU4NVYyNi42NTg1Wk0zNS4xNzc3IDM0LjcwODhDMzQuMzk4IDM3LjgyOSAyOS4xMjI2IDM2LjE0MjIgMjcuNDEyMiAzNS43MTkzTDI4Ljc5NzcgMzAuMTg4MUMzMC41MDgxIDMwLjYxMzIgMzUuOTkyNiAzMS40NTQ4IDM1LjE3NzcgMzQuNzA4OFpNMzUuOTU4MSAyNi42MTM0QzM1LjI0NjcgMjkuNDUxNyAzMC44NTU5IDI4LjAwOTcgMjkuNDMxNiAyNy42NTYxTDMwLjY4NzcgMjIuNjM5NUMzMi4xMTIgMjIuOTkzIDM2LjY5OSAyMy42NTI4IDM1Ljk1ODEgMjYuNjEzNFoiLz4KPC9zdmc+Cg==",
313
+ // "background": "transparent",
314
+ // "fiatSymbol": "BTC",
315
+ // "decimals": 8,
316
+ // "tradeDecimals": 20,
317
+ // "displayDecimals": 4,
318
+ // "crypto": true,
319
+ // "depositEnabled": true,
320
+ // "withdrawalEnabled": true,
321
+ // "transferEnabled": true,
322
+ // "buyEnabled": false,
323
+ // "purchaseEnabled": false,
324
+ // "redeemEnabled": false,
325
+ // "active": true,
326
+ // "withdrawalFee": "50000000000000000",
327
+ // "purchaseCommissions": []
328
+ // },
329
+ // ]
330
+ //
331
+ const result = [];
332
+ for (let i = 0; i < response.length; i++) {
333
+ const currency = response[i];
334
+ result.push(this.parseCurrency(currency));
335
+ }
336
+ return this.indexBy(result, 'code');
337
+ }
338
+ async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
339
+ /**
340
+ * @method
341
+ * @name timex#fetchDeposits
342
+ * @description fetch all deposits made to an account
343
+ * @param {string} code unified currency code
344
+ * @param {int} [since] the earliest time in ms to fetch deposits for
345
+ * @param {int} [limit] the maximum number of deposits structures to retrieve
346
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
347
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
348
+ */
349
+ const address = this.safeString(params, 'address');
350
+ params = this.omit(params, 'address');
351
+ if (address === undefined) {
352
+ throw new errors.ArgumentsRequired(this.id + ' fetchDeposits() requires an address parameter');
353
+ }
354
+ const request = {
355
+ 'address': address,
356
+ };
357
+ const response = await this.managerGetDeposits(this.extend(request, params));
358
+ //
359
+ // [
360
+ // {
361
+ // "from": "0x1134cc86b45039cc211c6d1d2e4b3c77f60207ed",
362
+ // "timestamp": "2022-01-01T00:00:00Z",
363
+ // "to": "0x1134cc86b45039cc211c6d1d2e4b3c77f60207ed",
364
+ // "token": "0x6baad3fe5d0fd4be604420e728adbd68d67e119e",
365
+ // "transferHash": "0x5464cdff35448314e178b8677ea41e670ea0f2533f4e52bfbd4e4a6cfcdef4c2",
366
+ // "value": "100"
367
+ // }
368
+ // ]
369
+ //
370
+ const currency = this.safeCurrency(code);
371
+ return this.parseTransactions(response, currency, since, limit);
372
+ }
373
+ async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
374
+ /**
375
+ * @method
376
+ * @name timex#fetchWithdrawals
377
+ * @description fetch all withdrawals made to an account
378
+ * @param {string} code unified currency code
379
+ * @param {int} [since] the earliest time in ms to fetch withdrawals for
380
+ * @param {int} [limit] the maximum number of transaction structures to retrieve
381
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
382
+ * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
383
+ */
384
+ const address = this.safeString(params, 'address');
385
+ params = this.omit(params, 'address');
386
+ if (address === undefined) {
387
+ throw new errors.ArgumentsRequired(this.id + ' fetchDeposits() requires an address parameter');
388
+ }
389
+ const request = {
390
+ 'address': address,
391
+ };
392
+ const response = await this.managerGetWithdrawals(this.extend(request, params));
393
+ //
394
+ // [
395
+ // {
396
+ // "from": "0x1134cc86b45039cc211c6d1d2e4b3c77f60207ed",
397
+ // "timestamp": "2022-01-01T00:00:00Z",
398
+ // "to": "0x1134cc86b45039cc211c6d1d2e4b3c77f60207ed",
399
+ // "token": "0x6baad3fe5d0fd4be604420e728adbd68d67e119e",
400
+ // "transferHash": "0x5464cdff35448314e178b8677ea41e670ea0f2533f4e52bfbd4e4a6cfcdef4c2",
401
+ // "value": "100"
402
+ // }
403
+ // ]
404
+ //
405
+ const currency = this.safeCurrency(code);
406
+ return this.parseTransactions(response, currency, since, limit);
407
+ }
408
+ getCurrencyByAddress(address) {
409
+ const currencies = this.currencies;
410
+ for (let i = 0; i < currencies.length; i++) {
411
+ const currency = currencies[i];
412
+ const info = this.safeValue(currency, 'info', {});
413
+ const a = this.safeString(info, 'address');
414
+ if (a === address) {
415
+ return currency;
416
+ }
417
+ }
418
+ return undefined;
419
+ }
420
+ parseTransaction(transaction, currency = undefined) {
421
+ //
422
+ // {
423
+ // "from": "0x1134cc86b45039cc211c6d1d2e4b3c77f60207ed",
424
+ // "timestamp": "2022-01-01T00:00:00Z",
425
+ // "to": "0x1134cc86b45039cc211c6d1d2e4b3c77f60207ed",
426
+ // "token": "0x6baad3fe5d0fd4be604420e728adbd68d67e119e",
427
+ // "transferHash": "0x5464cdff35448314e178b8677ea41e670ea0f2533f4e52bfbd4e4a6cfcdef4c2",
428
+ // "value": "100"
429
+ // }
430
+ //
431
+ const datetime = this.safeString(transaction, 'timestamp');
432
+ const currencyAddresss = this.safeString(transaction, 'token', '');
433
+ currency = this.getCurrencyByAddress(currencyAddresss);
434
+ return {
435
+ 'info': transaction,
436
+ 'id': this.safeString(transaction, 'transferHash'),
437
+ 'txid': this.safeString(transaction, 'txid'),
438
+ 'timestamp': this.parse8601(datetime),
439
+ 'datetime': datetime,
440
+ 'network': undefined,
441
+ 'address': undefined,
442
+ 'addressTo': this.safeString(transaction, 'to'),
443
+ 'addressFrom': this.safeString(transaction, 'from'),
444
+ 'tag': undefined,
445
+ 'tagTo': undefined,
446
+ 'tagFrom': undefined,
447
+ 'type': undefined,
448
+ 'amount': this.safeNumber(transaction, 'value'),
449
+ 'currency': this.safeCurrencyCode(undefined, currency),
450
+ 'status': 'ok',
451
+ 'updated': undefined,
452
+ 'internal': undefined,
453
+ 'comment': undefined,
454
+ 'fee': undefined,
455
+ };
456
+ }
457
+ async fetchTickers(symbols = undefined, params = {}) {
458
+ /**
459
+ * @method
460
+ * @name timex#fetchTickers
461
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
462
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
463
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
464
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
465
+ */
466
+ await this.loadMarkets();
467
+ const period = this.safeString(this.options['fetchTickers'], 'period', '1d');
468
+ const request = {
469
+ 'period': this.timeframes[period], // I1, I5, I15, I30, H1, H2, H4, H6, H12, D1, W1
470
+ };
471
+ const response = await this.publicGetTickers(this.extend(request, params));
472
+ //
473
+ // [
474
+ // {
475
+ // "ask": 0.017,
476
+ // "bid": 0.016,
477
+ // "high": 0.019,
478
+ // "last": 0.017,
479
+ // "low": 0.015,
480
+ // "market": "TIME/ETH",
481
+ // "open": 0.016,
482
+ // "period": "H1",
483
+ // "timestamp": "2018-12-14T20:50:36.134Z",
484
+ // "volume": 4.57,
485
+ // "volumeQuote": 0.07312
486
+ // }
487
+ // ]
488
+ //
489
+ return this.parseTickers(response, symbols);
490
+ }
491
+ async fetchTicker(symbol, params = {}) {
492
+ /**
493
+ * @method
494
+ * @name timex#fetchTicker
495
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
496
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
497
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
498
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
499
+ */
500
+ await this.loadMarkets();
501
+ const market = this.market(symbol);
502
+ const period = this.safeString(this.options['fetchTickers'], 'period', '1d');
503
+ const request = {
504
+ 'market': market['id'],
505
+ 'period': this.timeframes[period], // I1, I5, I15, I30, H1, H2, H4, H6, H12, D1, W1
506
+ };
507
+ const response = await this.publicGetTickers(this.extend(request, params));
508
+ //
509
+ // [
510
+ // {
511
+ // "ask": 0.017,
512
+ // "bid": 0.016,
513
+ // "high": 0.019,
514
+ // "last": 0.017,
515
+ // "low": 0.015,
516
+ // "market": "TIME/ETH",
517
+ // "open": 0.016,
518
+ // "period": "H1",
519
+ // "timestamp": "2018-12-14T20:50:36.134Z",
520
+ // "volume": 4.57,
521
+ // "volumeQuote": 0.07312
522
+ // }
523
+ // ]
524
+ //
525
+ const ticker = this.safeValue(response, 0);
526
+ return this.parseTicker(ticker, market);
527
+ }
528
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
529
+ /**
530
+ * @method
531
+ * @name timex#fetchOrderBook
532
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
533
+ * @param {string} symbol unified symbol of the market to fetch the order book for
534
+ * @param {int} [limit] the maximum amount of order book entries to return
535
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
536
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
537
+ */
538
+ await this.loadMarkets();
539
+ const market = this.market(symbol);
540
+ const request = {
541
+ 'market': market['id'],
542
+ };
543
+ if (limit !== undefined) {
544
+ request['limit'] = limit;
545
+ }
546
+ const response = await this.publicGetOrderbookV2(this.extend(request, params));
547
+ //
548
+ // {
549
+ // "timestamp":"2019-12-05T00:21:09.538",
550
+ // "bid":[
551
+ // {
552
+ // "index":"2",
553
+ // "price":"0.02024007",
554
+ // "baseTokenAmount":"0.0096894",
555
+ // "baseTokenCumulativeAmount":"0.0096894",
556
+ // "quoteTokenAmount":"0.000196114134258",
557
+ // "quoteTokenCumulativeAmount":"0.000196114134258"
558
+ // },
559
+ // "ask":[
560
+ // {
561
+ // "index":"-3",
562
+ // "price":"0.02024012",
563
+ // "baseTokenAmount":"0.005",
564
+ // "baseTokenCumulativeAmount":"0.005",
565
+ // "quoteTokenAmount":"0.0001012006",
566
+ // "quoteTokenCumulativeAmount":"0.0001012006"
567
+ // },
568
+ // ]
569
+ // }
570
+ //
571
+ const timestamp = this.parse8601(this.safeString(response, 'timestamp'));
572
+ return this.parseOrderBook(response, symbol, timestamp, 'bid', 'ask', 'price', 'baseTokenAmount');
573
+ }
574
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
575
+ /**
576
+ * @method
577
+ * @name timex#fetchTrades
578
+ * @description get the list of most recent trades for a particular symbol
579
+ * @param {string} symbol unified symbol of the market to fetch trades for
580
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
581
+ * @param {int} [limit] the maximum amount of trades to fetch
582
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
583
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
584
+ */
585
+ await this.loadMarkets();
586
+ const market = this.market(symbol);
587
+ const options = this.safeValue(this.options, 'fetchTrades', {});
588
+ const defaultSort = this.safeValue(options, 'sort', 'timestamp,asc');
589
+ const sort = this.safeString(params, 'sort', defaultSort);
590
+ const query = this.omit(params, 'sort');
591
+ const request = {
592
+ // 'address': 'string', // trade’s member account (?)
593
+ // 'cursor': 1234, // int64 (?)
594
+ // 'from': this.iso8601 (since),
595
+ 'market': market['id'],
596
+ // 'page': 0, // results page you want to retrieve 0 .. N
597
+ // 'size': limit, // number of records per page, 100 by default
598
+ 'sort': sort, // array[string], sorting criteria in the format "property,asc" or "property,desc", default is ascending
599
+ // 'till': this.iso8601 (this.milliseconds ()),
600
+ };
601
+ if (since !== undefined) {
602
+ request['from'] = this.iso8601(since);
603
+ }
604
+ if (limit !== undefined) {
605
+ request['size'] = limit; // default is 100
606
+ }
607
+ const response = await this.publicGetTrades(this.extend(request, query));
608
+ //
609
+ // [
610
+ // {
611
+ // "id":1,
612
+ // "timestamp":"2019-06-25T17:01:50.309",
613
+ // "direction":"BUY",
614
+ // "price":"0.027",
615
+ // "quantity":"0.001"
616
+ // }
617
+ // ]
618
+ //
619
+ return this.parseTrades(response, market, since, limit);
620
+ }
621
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
622
+ /**
623
+ * @method
624
+ * @name timex#fetchOHLCV
625
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
626
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
627
+ * @param {string} timeframe the length of time each candle represents
628
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
629
+ * @param {int} [limit] the maximum amount of candles to fetch
630
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
631
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
632
+ */
633
+ await this.loadMarkets();
634
+ const market = this.market(symbol);
635
+ const request = {
636
+ 'market': market['id'],
637
+ 'period': this.safeString(this.timeframes, timeframe, timeframe),
638
+ };
639
+ // if since and limit are not specified
640
+ const duration = this.parseTimeframe(timeframe);
641
+ if (limit === undefined) {
642
+ limit = 1000; // exchange provides tens of thousands of data, but we set generous default value
643
+ }
644
+ if (since !== undefined) {
645
+ request['from'] = this.iso8601(since);
646
+ request['till'] = this.iso8601(this.sum(since, this.sum(limit, 1) * duration * 1000));
647
+ }
648
+ else {
649
+ const now = this.milliseconds();
650
+ request['till'] = this.iso8601(now);
651
+ request['from'] = this.iso8601(now - limit * duration * 1000 - 1);
652
+ }
653
+ const response = await this.publicGetCandles(this.extend(request, params));
654
+ //
655
+ // [
656
+ // {
657
+ // "timestamp":"2019-12-04T23:00:00",
658
+ // "open":"0.02024009",
659
+ // "high":"0.02024009",
660
+ // "low":"0.02024009",
661
+ // "close":"0.02024009",
662
+ // "volume":"0.00008096036",
663
+ // "volumeQuote":"0.004",
664
+ // },
665
+ // ]
666
+ //
667
+ return this.parseOHLCVs(response, market, timeframe, since, limit);
668
+ }
669
+ parseBalance(response) {
670
+ const result = {
671
+ 'info': response,
672
+ 'timestamp': undefined,
673
+ 'datetime': undefined,
674
+ };
675
+ for (let i = 0; i < response.length; i++) {
676
+ const balance = response[i];
677
+ const currencyId = this.safeString(balance, 'currency');
678
+ const code = this.safeCurrencyCode(currencyId);
679
+ const account = this.account();
680
+ account['total'] = this.safeString(balance, 'totalBalance');
681
+ account['used'] = this.safeString(balance, 'lockedBalance');
682
+ result[code] = account;
683
+ }
684
+ return this.safeBalance(result);
685
+ }
686
+ async fetchBalance(params = {}) {
687
+ /**
688
+ * @method
689
+ * @name timex#fetchBalance
690
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
691
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
692
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
693
+ */
694
+ await this.loadMarkets();
695
+ const response = await this.tradingGetBalances(params);
696
+ //
697
+ // [
698
+ // {"currency":"BTC","totalBalance":"0","lockedBalance":"0"},
699
+ // {"currency":"AUDT","totalBalance":"0","lockedBalance":"0"},
700
+ // {"currency":"ETH","totalBalance":"0","lockedBalance":"0"},
701
+ // {"currency":"TIME","totalBalance":"0","lockedBalance":"0"},
702
+ // {"currency":"USDT","totalBalance":"0","lockedBalance":"0"}
703
+ // ]
704
+ //
705
+ return this.parseBalance(response);
706
+ }
707
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
708
+ /**
709
+ * @method
710
+ * @name timex#createOrder
711
+ * @description create a trade order
712
+ * @param {string} symbol unified symbol of the market to create an order in
713
+ * @param {string} type 'market' or 'limit'
714
+ * @param {string} side 'buy' or 'sell'
715
+ * @param {float} amount how much of currency you want to trade in units of base currency
716
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
717
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
718
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
719
+ */
720
+ await this.loadMarkets();
721
+ const market = this.market(symbol);
722
+ const uppercaseSide = side.toUpperCase();
723
+ let uppercaseType = type.toUpperCase();
724
+ const postOnly = this.safeValue(params, 'postOnly', false);
725
+ if (postOnly) {
726
+ uppercaseType = 'POST_ONLY';
727
+ params = this.omit(params, ['postOnly']);
728
+ }
729
+ const request = {
730
+ 'symbol': market['id'],
731
+ 'quantity': this.amountToPrecision(symbol, amount),
732
+ 'side': uppercaseSide,
733
+ 'orderTypes': uppercaseType,
734
+ // 'clientOrderId': '123',
735
+ // 'expireIn': 1575523308, // in seconds
736
+ // 'expireTime': 1575523308, // unix timestamp
737
+ };
738
+ let query = params;
739
+ if ((uppercaseType === 'LIMIT') || (uppercaseType === 'POST_ONLY')) {
740
+ request['price'] = this.priceToPrecision(symbol, price);
741
+ const defaultExpireIn = this.safeInteger(this.options, 'expireIn');
742
+ const expireTime = this.safeValue(params, 'expireTime');
743
+ const expireIn = this.safeValue(params, 'expireIn', defaultExpireIn);
744
+ if (expireTime !== undefined) {
745
+ request['expireTime'] = expireTime;
746
+ }
747
+ else if (expireIn !== undefined) {
748
+ request['expireIn'] = expireIn;
749
+ }
750
+ else {
751
+ throw new errors.InvalidOrder(this.id + ' createOrder() method requires a expireTime or expireIn param for a ' + type + ' order, you can also set the expireIn exchange-wide option');
752
+ }
753
+ query = this.omit(params, ['expireTime', 'expireIn']);
754
+ }
755
+ else {
756
+ request['price'] = 0;
757
+ }
758
+ const response = await this.tradingPostOrders(this.extend(request, query));
759
+ //
760
+ // {
761
+ // "orders": [
762
+ // {
763
+ // "cancelledQuantity": "0.3",
764
+ // "clientOrderId": "my-order-1",
765
+ // "createdAt": "1970-01-01T00:00:00",
766
+ // "cursorId": 50,
767
+ // "expireTime": "1970-01-01T00:00:00",
768
+ // "filledQuantity": "0.3",
769
+ // "id": "string",
770
+ // "price": "0.017",
771
+ // "quantity": "0.3",
772
+ // "side": "BUY",
773
+ // "symbol": "TIMEETH",
774
+ // "type": "LIMIT",
775
+ // "updatedAt": "1970-01-01T00:00:00"
776
+ // }
777
+ // ]
778
+ // }
779
+ //
780
+ const orders = this.safeValue(response, 'orders', []);
781
+ const order = this.safeValue(orders, 0, {});
782
+ return this.parseOrder(order, market);
783
+ }
784
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
785
+ await this.loadMarkets();
786
+ const market = this.market(symbol);
787
+ const request = {
788
+ 'id': id,
789
+ };
790
+ if (amount !== undefined) {
791
+ request['quantity'] = this.amountToPrecision(symbol, amount);
792
+ }
793
+ if (price !== undefined) {
794
+ request['price'] = this.priceToPrecision(symbol, price);
795
+ }
796
+ const response = await this.tradingPutOrders(this.extend(request, params));
797
+ //
798
+ // {
799
+ // "changedOrders": [
800
+ // {
801
+ // "newOrder": {
802
+ // "cancelledQuantity": "0.3",
803
+ // "clientOrderId": "my-order-1",
804
+ // "createdAt": "1970-01-01T00:00:00",
805
+ // "cursorId": 50,
806
+ // "expireTime": "1970-01-01T00:00:00",
807
+ // "filledQuantity": "0.3",
808
+ // "id": "string",
809
+ // "price": "0.017",
810
+ // "quantity": "0.3",
811
+ // "side": "BUY",
812
+ // "symbol": "TIMEETH",
813
+ // "type": "LIMIT",
814
+ // "updatedAt": "1970-01-01T00:00:00"
815
+ // },
816
+ // "oldId": "string",
817
+ // },
818
+ // ],
819
+ // "unchangedOrders": [ "string" ],
820
+ // }
821
+ //
822
+ if ('unchangedOrders' in response) {
823
+ const orderIds = this.safeValue(response, 'unchangedOrders', []);
824
+ const orderId = this.safeString(orderIds, 0);
825
+ return this.safeOrder({
826
+ 'id': orderId,
827
+ 'info': response,
828
+ });
829
+ }
830
+ const orders = this.safeValue(response, 'changedOrders', []);
831
+ const firstOrder = this.safeValue(orders, 0, {});
832
+ const order = this.safeValue(firstOrder, 'newOrder', {});
833
+ return this.parseOrder(order, market);
834
+ }
835
+ async cancelOrder(id, symbol = undefined, params = {}) {
836
+ /**
837
+ * @method
838
+ * @name timex#cancelOrder
839
+ * @description cancels an open order
840
+ * @param {string} id order id
841
+ * @param {string} symbol not used by timex cancelOrder ()
842
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
843
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
844
+ */
845
+ await this.loadMarkets();
846
+ return await this.cancelOrders([id], symbol, params);
847
+ }
848
+ async cancelOrders(ids, symbol = undefined, params = {}) {
849
+ /**
850
+ * @method
851
+ * @name timex#cancelOrders
852
+ * @description cancel multiple orders
853
+ * @param {string[]} ids order ids
854
+ * @param {string} symbol unified market symbol, default is undefined
855
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
856
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
857
+ */
858
+ await this.loadMarkets();
859
+ const request = {
860
+ 'id': ids,
861
+ };
862
+ const response = await this.tradingDeleteOrders(this.extend(request, params));
863
+ //
864
+ // {
865
+ // "changedOrders": [
866
+ // {
867
+ // "newOrder": {
868
+ // "cancelledQuantity": "0.3",
869
+ // "clientOrderId": "my-order-1",
870
+ // "createdAt": "1970-01-01T00:00:00",
871
+ // "cursorId": 50,
872
+ // "expireTime": "1970-01-01T00:00:00",
873
+ // "filledQuantity": "0.3",
874
+ // "id": "string",
875
+ // "price": "0.017",
876
+ // "quantity": "0.3",
877
+ // "side": "BUY",
878
+ // "symbol": "TIMEETH",
879
+ // "type": "LIMIT",
880
+ // "updatedAt": "1970-01-01T00:00:00"
881
+ // },
882
+ // "oldId": "string",
883
+ // },
884
+ // ],
885
+ // "unchangedOrders": [ "string" ],
886
+ // }
887
+ return response;
888
+ }
889
+ async fetchOrder(id, symbol = undefined, params = {}) {
890
+ /**
891
+ * @method
892
+ * @name timex#fetchOrder
893
+ * @description fetches information on an order made by the user
894
+ * @param {string} symbol not used by timex fetchOrder
895
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
896
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
897
+ */
898
+ await this.loadMarkets();
899
+ const request = {
900
+ 'orderHash': id,
901
+ };
902
+ const response = await this.historyGetOrdersDetails(request);
903
+ //
904
+ // {
905
+ // "order": {
906
+ // "cancelledQuantity": "0.3",
907
+ // "clientOrderId": "my-order-1",
908
+ // "createdAt": "1970-01-01T00:00:00",
909
+ // "cursorId": 50,
910
+ // "expireTime": "1970-01-01T00:00:00",
911
+ // "filledQuantity": "0.3",
912
+ // "id": "string",
913
+ // "price": "0.017",
914
+ // "quantity": "0.3",
915
+ // "side": "BUY",
916
+ // "symbol": "TIMEETH",
917
+ // "type": "LIMIT",
918
+ // "updatedAt": "1970-01-01T00:00:00"
919
+ // },
920
+ // "trades": [
921
+ // {
922
+ // "fee": "0.3",
923
+ // "id": 100,
924
+ // "makerOrTaker": "MAKER",
925
+ // "makerOrderId": "string",
926
+ // "price": "0.017",
927
+ // "quantity": "0.3",
928
+ // "side": "BUY",
929
+ // "symbol": "TIMEETH",
930
+ // "takerOrderId": "string",
931
+ // "timestamp": "2019-12-05T07:48:26.310Z"
932
+ // }
933
+ // ]
934
+ // }
935
+ //
936
+ const order = this.safeValue(response, 'order', {});
937
+ const trades = this.safeValue(response, 'trades', []);
938
+ return this.parseOrder(this.extend(order, { 'trades': trades }));
939
+ }
940
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
941
+ /**
942
+ * @method
943
+ * @name timex#fetchOpenOrders
944
+ * @description fetch all unfilled currently open orders
945
+ * @param {string} symbol unified market symbol
946
+ * @param {int} [since] the earliest time in ms to fetch open orders for
947
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
948
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
949
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
950
+ */
951
+ await this.loadMarkets();
952
+ const options = this.safeValue(this.options, 'fetchOpenOrders', {});
953
+ const defaultSort = this.safeValue(options, 'sort', 'createdAt,asc');
954
+ const sort = this.safeString(params, 'sort', defaultSort);
955
+ const query = this.omit(params, 'sort');
956
+ const request = {
957
+ // 'clientOrderId': '123', // order’s client id list for filter
958
+ // page: 0, // results page you want to retrieve (0 .. N)
959
+ 'sort': sort, // sorting criteria in the format "property,asc" or "property,desc", default order is ascending, multiple sort criteria are supported
960
+ };
961
+ let market = undefined;
962
+ if (symbol !== undefined) {
963
+ market = this.market(symbol);
964
+ request['symbol'] = market['id'];
965
+ }
966
+ if (limit !== undefined) {
967
+ request['size'] = limit;
968
+ }
969
+ const response = await this.tradingGetOrders(this.extend(request, query));
970
+ //
971
+ // {
972
+ // "orders": [
973
+ // {
974
+ // "cancelledQuantity": "0.3",
975
+ // "clientOrderId": "my-order-1",
976
+ // "createdAt": "1970-01-01T00:00:00",
977
+ // "cursorId": 50,
978
+ // "expireTime": "1970-01-01T00:00:00",
979
+ // "filledQuantity": "0.3",
980
+ // "id": "string",
981
+ // "price": "0.017",
982
+ // "quantity": "0.3",
983
+ // "side": "BUY",
984
+ // "symbol": "TIMEETH",
985
+ // "type": "LIMIT",
986
+ // "updatedAt": "1970-01-01T00:00:00"
987
+ // }
988
+ // ]
989
+ // }
990
+ //
991
+ const orders = this.safeValue(response, 'orders', []);
992
+ return this.parseOrders(orders, market, since, limit);
993
+ }
994
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
995
+ /**
996
+ * @method
997
+ * @name timex#fetchClosedOrders
998
+ * @description fetches information on multiple closed orders made by the user
999
+ * @param {string} symbol unified market symbol of the market orders were made in
1000
+ * @param {int} [since] the earliest time in ms to fetch orders for
1001
+ * @param {int} [limit] the maximum number of order structures to retrieve
1002
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1003
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1004
+ */
1005
+ await this.loadMarkets();
1006
+ const options = this.safeValue(this.options, 'fetchClosedOrders', {});
1007
+ const defaultSort = this.safeValue(options, 'sort', 'createdAt,asc');
1008
+ const sort = this.safeString(params, 'sort', defaultSort);
1009
+ const query = this.omit(params, 'sort');
1010
+ const request = {
1011
+ // 'clientOrderId': '123', // order’s client id list for filter
1012
+ // page: 0, // results page you want to retrieve (0 .. N)
1013
+ 'sort': sort,
1014
+ 'side': 'BUY', // or 'SELL'
1015
+ // 'till': this.iso8601 (this.milliseconds ()),
1016
+ };
1017
+ let market = undefined;
1018
+ if (symbol !== undefined) {
1019
+ market = this.market(symbol);
1020
+ request['symbol'] = market['id'];
1021
+ }
1022
+ if (since !== undefined) {
1023
+ request['from'] = this.iso8601(since);
1024
+ }
1025
+ if (limit !== undefined) {
1026
+ request['size'] = limit;
1027
+ }
1028
+ const response = await this.historyGetOrders(this.extend(request, query));
1029
+ //
1030
+ // {
1031
+ // "orders": [
1032
+ // {
1033
+ // "cancelledQuantity": "0.3",
1034
+ // "clientOrderId": "my-order-1",
1035
+ // "createdAt": "1970-01-01T00:00:00",
1036
+ // "cursorId": 50,
1037
+ // "expireTime": "1970-01-01T00:00:00",
1038
+ // "filledQuantity": "0.3",
1039
+ // "id": "string",
1040
+ // "price": "0.017",
1041
+ // "quantity": "0.3",
1042
+ // "side": "BUY",
1043
+ // "symbol": "TIMEETH",
1044
+ // "type": "LIMIT",
1045
+ // "updatedAt": "1970-01-01T00:00:00"
1046
+ // }
1047
+ // ]
1048
+ // }
1049
+ //
1050
+ const orders = this.safeValue(response, 'orders', []);
1051
+ return this.parseOrders(orders, market, since, limit);
1052
+ }
1053
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1054
+ /**
1055
+ * @method
1056
+ * @name timex#fetchMyTrades
1057
+ * @description fetch all trades made by the user
1058
+ * @param {string} symbol unified market symbol
1059
+ * @param {int} [since] the earliest time in ms to fetch trades for
1060
+ * @param {int} [limit] the maximum number of trades structures to retrieve
1061
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1062
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1063
+ */
1064
+ await this.loadMarkets();
1065
+ const options = this.safeValue(this.options, 'fetchMyTrades', {});
1066
+ const defaultSort = this.safeValue(options, 'sort', 'timestamp,asc');
1067
+ const sort = this.safeString(params, 'sort', defaultSort);
1068
+ const query = this.omit(params, 'sort');
1069
+ const request = {
1070
+ // 'cursorId': 123, // int64 (?)
1071
+ // 'from': this.iso8601 (since),
1072
+ // 'makerOrderId': '1234', // maker order hash
1073
+ // 'owner': '...', // owner address (?)
1074
+ // 'page': 0, // results page you want to retrieve (0 .. N)
1075
+ // 'side': 'BUY', // or 'SELL'
1076
+ // 'size': limit,
1077
+ 'sort': sort, // sorting criteria in the format "property,asc" or "property,desc", default order is ascending, multiple sort criteria are supported
1078
+ // 'symbol': market['id'],
1079
+ // 'takerOrderId': '1234',
1080
+ // 'till': this.iso8601 (this.milliseconds ()),
1081
+ };
1082
+ let market = undefined;
1083
+ if (symbol !== undefined) {
1084
+ market = this.market(symbol);
1085
+ request['symbol'] = market['id'];
1086
+ }
1087
+ if (since !== undefined) {
1088
+ request['from'] = this.iso8601(since);
1089
+ }
1090
+ if (limit !== undefined) {
1091
+ request['size'] = limit;
1092
+ }
1093
+ const response = await this.historyGetTrades(this.extend(request, query));
1094
+ //
1095
+ // {
1096
+ // "trades": [
1097
+ // {
1098
+ // "fee": "0.3",
1099
+ // "id": 100,
1100
+ // "makerOrTaker": "MAKER",
1101
+ // "makerOrderId": "string",
1102
+ // "price": "0.017",
1103
+ // "quantity": "0.3",
1104
+ // "side": "BUY",
1105
+ // "symbol": "TIMEETH",
1106
+ // "takerOrderId": "string",
1107
+ // "timestamp": "2019-12-08T04:54:11.171Z"
1108
+ // }
1109
+ // ]
1110
+ // }
1111
+ //
1112
+ const trades = this.safeValue(response, 'trades', []);
1113
+ return this.parseTrades(trades, market, since, limit);
1114
+ }
1115
+ parseTradingFee(fee, market = undefined) {
1116
+ //
1117
+ // {
1118
+ // "fee": 0.0075,
1119
+ // "market": "ETHBTC"
1120
+ // }
1121
+ //
1122
+ const marketId = this.safeString(fee, 'market');
1123
+ const rate = this.safeNumber(fee, 'fee');
1124
+ return {
1125
+ 'info': fee,
1126
+ 'symbol': this.safeSymbol(marketId, market),
1127
+ 'maker': rate,
1128
+ 'taker': rate,
1129
+ };
1130
+ }
1131
+ async fetchTradingFee(symbol, params = {}) {
1132
+ /**
1133
+ * @method
1134
+ * @name timex#fetchTradingFee
1135
+ * @description fetch the trading fees for a market
1136
+ * @param {string} symbol unified market symbol
1137
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1138
+ * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
1139
+ */
1140
+ await this.loadMarkets();
1141
+ const market = this.market(symbol);
1142
+ const request = {
1143
+ 'markets': market['id'],
1144
+ };
1145
+ const response = await this.tradingGetFees(this.extend(request, params));
1146
+ //
1147
+ // [
1148
+ // {
1149
+ // "fee": 0.0075,
1150
+ // "market": "ETHBTC"
1151
+ // }
1152
+ // ]
1153
+ //
1154
+ const result = this.safeValue(response, 0, {});
1155
+ return this.parseTradingFee(result, market);
1156
+ }
1157
+ parseMarket(market) {
1158
+ //
1159
+ // {
1160
+ // "symbol": "ETHBTC",
1161
+ // "name": "ETH/BTC",
1162
+ // "baseCurrency": "ETH",
1163
+ // "baseTokenAddress": "0x45932db54b38af1f5a57136302eeba66a5975c15",
1164
+ // "quoteCurrency": "BTC",
1165
+ // "quoteTokenAddress": "0x8370fbc6ddec1e18b4e41e72ed943e238458487c",
1166
+ // "feeCurrency": "BTC",
1167
+ // "feeTokenAddress": "0x8370fbc6ddec1e18b4e41e72ed943e238458487c",
1168
+ // "quantityIncrement": "0.0000001",
1169
+ // "takerFee": "0.005",
1170
+ // "makerFee": "0.0025",
1171
+ // "tickSize": "0.00000001",
1172
+ // "baseMinSize": "0.0001",
1173
+ // "quoteMinSize": "0.00001",
1174
+ // "locked": false
1175
+ // }
1176
+ //
1177
+ const locked = this.safeValue(market, 'locked');
1178
+ const id = this.safeString(market, 'symbol');
1179
+ const baseId = this.safeString(market, 'baseCurrency');
1180
+ const quoteId = this.safeString(market, 'quoteCurrency');
1181
+ const base = this.safeCurrencyCode(baseId);
1182
+ const quote = this.safeCurrencyCode(quoteId);
1183
+ const amountIncrement = this.safeString(market, 'quantityIncrement');
1184
+ const minBase = this.safeString(market, 'baseMinSize');
1185
+ const minAmount = Precise["default"].stringMax(amountIncrement, minBase);
1186
+ const priceIncrement = this.safeString(market, 'tickSize');
1187
+ const minCost = this.safeNumber(market, 'quoteMinSize');
1188
+ return {
1189
+ 'id': id,
1190
+ 'symbol': base + '/' + quote,
1191
+ 'base': base,
1192
+ 'quote': quote,
1193
+ 'settle': undefined,
1194
+ 'baseId': baseId,
1195
+ 'quoteId': quoteId,
1196
+ 'settleId': undefined,
1197
+ 'type': 'spot',
1198
+ 'spot': true,
1199
+ 'margin': false,
1200
+ 'swap': false,
1201
+ 'future': false,
1202
+ 'option': false,
1203
+ 'active': !locked,
1204
+ 'contract': false,
1205
+ 'linear': undefined,
1206
+ 'inverse': undefined,
1207
+ 'taker': this.safeNumber(market, 'takerFee'),
1208
+ 'maker': this.safeNumber(market, 'makerFee'),
1209
+ 'contractSize': undefined,
1210
+ 'expiry': undefined,
1211
+ 'expiryDatetime': undefined,
1212
+ 'strike': undefined,
1213
+ 'optionType': undefined,
1214
+ 'precision': {
1215
+ 'amount': this.safeNumber(market, 'quantityIncrement'),
1216
+ 'price': this.safeNumber(market, 'tickSize'),
1217
+ },
1218
+ 'limits': {
1219
+ 'leverage': {
1220
+ 'min': undefined,
1221
+ 'max': undefined,
1222
+ },
1223
+ 'amount': {
1224
+ 'min': this.parseNumber(minAmount),
1225
+ 'max': undefined,
1226
+ },
1227
+ 'price': {
1228
+ 'min': this.parseNumber(priceIncrement),
1229
+ 'max': undefined,
1230
+ },
1231
+ 'cost': {
1232
+ 'min': minCost,
1233
+ 'max': undefined,
1234
+ },
1235
+ },
1236
+ 'created': undefined,
1237
+ 'info': market,
1238
+ };
1239
+ }
1240
+ parseCurrency(currency) {
1241
+ //
1242
+ // {
1243
+ // "symbol": "BTC",
1244
+ // "name": "Bitcoin",
1245
+ // "address": "0x8370fbc6ddec1e18b4e41e72ed943e238458487c",
1246
+ // "icon": "data:image/svg+xml;base64,PHN2ZyB3aWR...mc+Cg==",
1247
+ // "background": "transparent",
1248
+ // "fiatSymbol": "BTC",
1249
+ // "decimals": 8,
1250
+ // "tradeDecimals": 20,
1251
+ // "displayDecimals": 4,
1252
+ // "crypto": true,
1253
+ // "depositEnabled": true,
1254
+ // "withdrawalEnabled": true,
1255
+ // "transferEnabled": true,
1256
+ // "buyEnabled": false,
1257
+ // "purchaseEnabled": false,
1258
+ // "redeemEnabled": false,
1259
+ // "active": true,
1260
+ // "withdrawalFee": "50000000000000000",
1261
+ // "purchaseCommissions": []
1262
+ // }
1263
+ //
1264
+ // https://github.com/ccxt/ccxt/issues/6878
1265
+ //
1266
+ // {
1267
+ // "symbol":"XRP",
1268
+ // "name":"Ripple",
1269
+ // "address":"0x0dc8882914f3ddeebf4cec6dc20edb99df3def6c",
1270
+ // "decimals":6,
1271
+ // "tradeDecimals":16,
1272
+ // "depositEnabled":true,
1273
+ // "withdrawalEnabled":true,
1274
+ // "transferEnabled":true,
1275
+ // "active":true
1276
+ // }
1277
+ //
1278
+ const id = this.safeString(currency, 'symbol');
1279
+ const code = this.safeCurrencyCode(id);
1280
+ const name = this.safeString(currency, 'name');
1281
+ const depositEnabled = this.safeValue(currency, 'depositEnabled');
1282
+ const withdrawEnabled = this.safeValue(currency, 'withdrawalEnabled');
1283
+ const isActive = this.safeValue(currency, 'active');
1284
+ const active = depositEnabled && withdrawEnabled && isActive;
1285
+ // const fee = this.safeNumber (currency, 'withdrawalFee');
1286
+ const feeString = this.safeString(currency, 'withdrawalFee');
1287
+ const tradeDecimals = this.safeInteger(currency, 'tradeDecimals');
1288
+ let fee = undefined;
1289
+ if ((feeString !== undefined) && (tradeDecimals !== undefined)) {
1290
+ const feeStringLen = feeString.length;
1291
+ const dotIndex = feeStringLen - tradeDecimals;
1292
+ if (dotIndex > 0) {
1293
+ const whole = feeString.slice(0, dotIndex);
1294
+ const fraction = feeString.slice(-dotIndex);
1295
+ fee = this.parseNumber(whole + '.' + fraction);
1296
+ }
1297
+ else {
1298
+ let fraction = '.';
1299
+ for (let i = 0; i < -dotIndex; i++) {
1300
+ fraction += '0';
1301
+ }
1302
+ fee = this.parseNumber(fraction + feeString);
1303
+ }
1304
+ }
1305
+ return {
1306
+ 'id': code,
1307
+ 'code': code,
1308
+ 'info': currency,
1309
+ 'type': undefined,
1310
+ 'name': name,
1311
+ 'active': active,
1312
+ 'deposit': depositEnabled,
1313
+ 'withdraw': withdrawEnabled,
1314
+ 'fee': fee,
1315
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'decimals'))),
1316
+ 'limits': {
1317
+ 'withdraw': { 'min': fee, 'max': undefined },
1318
+ 'amount': { 'min': undefined, 'max': undefined },
1319
+ },
1320
+ 'networks': {},
1321
+ };
1322
+ }
1323
+ parseTicker(ticker, market = undefined) {
1324
+ //
1325
+ // {
1326
+ // "ask": 0.017,
1327
+ // "bid": 0.016,
1328
+ // "high": 0.019,
1329
+ // "last": 0.017,
1330
+ // "low": 0.015,
1331
+ // "market": "TIME/ETH",
1332
+ // "open": 0.016,
1333
+ // "period": "H1",
1334
+ // "timestamp": "2018-12-14T20:50:36.134Z",
1335
+ // "volume": 4.57,
1336
+ // "volumeQuote": 0.07312
1337
+ // }
1338
+ //
1339
+ const marketId = this.safeString(ticker, 'market');
1340
+ const symbol = this.safeSymbol(marketId, market, '/');
1341
+ const timestamp = this.parse8601(this.safeString(ticker, 'timestamp'));
1342
+ const last = this.safeString(ticker, 'last');
1343
+ const open = this.safeString(ticker, 'open');
1344
+ return this.safeTicker({
1345
+ 'symbol': symbol,
1346
+ 'info': ticker,
1347
+ 'timestamp': timestamp,
1348
+ 'datetime': this.iso8601(timestamp),
1349
+ 'high': this.safeString(ticker, 'high'),
1350
+ 'low': this.safeString(ticker, 'low'),
1351
+ 'bid': this.safeString(ticker, 'bid'),
1352
+ 'bidVolume': undefined,
1353
+ 'ask': this.safeString(ticker, 'ask'),
1354
+ 'askVolume': undefined,
1355
+ 'vwap': undefined,
1356
+ 'open': open,
1357
+ 'close': last,
1358
+ 'last': last,
1359
+ 'previousClose': undefined,
1360
+ 'change': undefined,
1361
+ 'percentage': undefined,
1362
+ 'average': undefined,
1363
+ 'baseVolume': this.safeString(ticker, 'volume'),
1364
+ 'quoteVolume': this.safeString(ticker, 'volumeQuote'),
1365
+ }, market);
1366
+ }
1367
+ parseTrade(trade, market = undefined) {
1368
+ //
1369
+ // fetchTrades (public)
1370
+ //
1371
+ // {
1372
+ // "id":1,
1373
+ // "timestamp":"2019-06-25T17:01:50.309",
1374
+ // "direction":"BUY",
1375
+ // "price":"0.027",
1376
+ // "quantity":"0.001"
1377
+ // }
1378
+ //
1379
+ // fetchMyTrades, fetchOrder (private)
1380
+ //
1381
+ // {
1382
+ // "id": "7613414",
1383
+ // "makerOrderId": "0x8420af060722f560098f786a2894d4358079b6ea5d14b395969ed77bc87a623a",
1384
+ // "takerOrderId": "0x1235ef158a361815b54c9988b6241c85aedcbc1fe81caf8df8587d5ab0373d1a",
1385
+ // "symbol": "LTCUSDT",
1386
+ // "side": "BUY",
1387
+ // "quantity": "0.2",
1388
+ // "fee": "0.22685",
1389
+ // "feeToken": "USDT",
1390
+ // "price": "226.85",
1391
+ // "makerOrTaker": "TAKER",
1392
+ // "timestamp": "2021-04-09T15:39:45.608"
1393
+ // }
1394
+ //
1395
+ const marketId = this.safeString(trade, 'symbol');
1396
+ const symbol = this.safeSymbol(marketId, market);
1397
+ const timestamp = this.parse8601(this.safeString(trade, 'timestamp'));
1398
+ const priceString = this.safeString(trade, 'price');
1399
+ const amountString = this.safeString(trade, 'quantity');
1400
+ const price = this.parseNumber(priceString);
1401
+ const amount = this.parseNumber(amountString);
1402
+ const cost = this.parseNumber(Precise["default"].stringMul(priceString, amountString));
1403
+ const id = this.safeString(trade, 'id');
1404
+ const side = this.safeStringLower2(trade, 'direction', 'side');
1405
+ const takerOrMaker = this.safeStringLower(trade, 'makerOrTaker');
1406
+ let orderId = undefined;
1407
+ if (takerOrMaker !== undefined) {
1408
+ orderId = this.safeString(trade, takerOrMaker + 'OrderId');
1409
+ }
1410
+ let fee = undefined;
1411
+ const feeCost = this.safeNumber(trade, 'fee');
1412
+ const feeCurrency = this.safeCurrencyCode(this.safeString(trade, 'feeToken'));
1413
+ if (feeCost !== undefined) {
1414
+ fee = {
1415
+ 'cost': feeCost,
1416
+ 'currency': feeCurrency,
1417
+ };
1418
+ }
1419
+ return {
1420
+ 'info': trade,
1421
+ 'id': id,
1422
+ 'timestamp': timestamp,
1423
+ 'datetime': this.iso8601(timestamp),
1424
+ 'symbol': symbol,
1425
+ 'order': orderId,
1426
+ 'type': undefined,
1427
+ 'side': side,
1428
+ 'price': price,
1429
+ 'amount': amount,
1430
+ 'cost': cost,
1431
+ 'takerOrMaker': takerOrMaker,
1432
+ 'fee': fee,
1433
+ };
1434
+ }
1435
+ parseOHLCV(ohlcv, market = undefined) {
1436
+ //
1437
+ // {
1438
+ // "timestamp":"2019-12-04T23:00:00",
1439
+ // "open":"0.02024009",
1440
+ // "high":"0.02024009",
1441
+ // "low":"0.02024009",
1442
+ // "close":"0.02024009",
1443
+ // "volume":"0.00008096036",
1444
+ // "volumeQuote":"0.004",
1445
+ // }
1446
+ //
1447
+ return [
1448
+ this.parse8601(this.safeString(ohlcv, 'timestamp')),
1449
+ this.safeNumber(ohlcv, 'open'),
1450
+ this.safeNumber(ohlcv, 'high'),
1451
+ this.safeNumber(ohlcv, 'low'),
1452
+ this.safeNumber(ohlcv, 'close'),
1453
+ this.safeNumber(ohlcv, 'volume'),
1454
+ ];
1455
+ }
1456
+ parseOrder(order, market = undefined) {
1457
+ //
1458
+ // fetchOrder, createOrder, cancelOrder, cancelOrders, fetchOpenOrders, fetchClosedOrders
1459
+ //
1460
+ // {
1461
+ // "cancelledQuantity": "0.3",
1462
+ // "clientOrderId": "my-order-1",
1463
+ // "createdAt": "1970-01-01T00:00:00",
1464
+ // "cursorId": 50,
1465
+ // "expireTime": "1970-01-01T00:00:00",
1466
+ // "filledQuantity": "0.3",
1467
+ // "id": "string",
1468
+ // "price": "0.017",
1469
+ // "quantity": "0.3",
1470
+ // "side": "BUY",
1471
+ // "symbol": "TIMEETH",
1472
+ // "type": "LIMIT",
1473
+ // "updatedAt": "1970-01-01T00:00:00"
1474
+ // "trades": [], // injected from the outside
1475
+ // }
1476
+ //
1477
+ const id = this.safeString(order, 'id');
1478
+ const type = this.safeStringLower(order, 'type');
1479
+ const side = this.safeStringLower(order, 'side');
1480
+ const marketId = this.safeString(order, 'symbol');
1481
+ const symbol = this.safeSymbol(marketId, market);
1482
+ const timestamp = this.parse8601(this.safeString(order, 'createdAt'));
1483
+ const price = this.safeString(order, 'price');
1484
+ const amount = this.safeString(order, 'quantity');
1485
+ const filled = this.safeString(order, 'filledQuantity');
1486
+ const canceledQuantity = this.omitZero(this.safeString(order, 'cancelledQuantity'));
1487
+ let status;
1488
+ if (Precise["default"].stringEquals(filled, amount)) {
1489
+ status = 'closed';
1490
+ }
1491
+ else if (canceledQuantity !== undefined) {
1492
+ status = 'canceled';
1493
+ }
1494
+ else {
1495
+ status = 'open';
1496
+ }
1497
+ const rawTrades = this.safeValue(order, 'trades', []);
1498
+ const clientOrderId = this.safeString(order, 'clientOrderId');
1499
+ return this.safeOrder({
1500
+ 'info': order,
1501
+ 'id': id,
1502
+ 'clientOrderId': clientOrderId,
1503
+ 'timestamp': timestamp,
1504
+ 'datetime': this.iso8601(timestamp),
1505
+ 'lastTradeTimestamp': undefined,
1506
+ 'symbol': symbol,
1507
+ 'type': type,
1508
+ 'timeInForce': undefined,
1509
+ 'postOnly': undefined,
1510
+ 'side': side,
1511
+ 'price': price,
1512
+ 'stopPrice': undefined,
1513
+ 'triggerPrice': undefined,
1514
+ 'amount': amount,
1515
+ 'cost': undefined,
1516
+ 'average': undefined,
1517
+ 'filled': filled,
1518
+ 'remaining': undefined,
1519
+ 'status': status,
1520
+ 'fee': undefined,
1521
+ 'trades': rawTrades,
1522
+ }, market);
1523
+ }
1524
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1525
+ let url = this.urls['api']['rest'] + '/' + api + '/' + path;
1526
+ if (Object.keys(params).length) {
1527
+ url += '?' + this.urlencodeWithArrayRepeat(params);
1528
+ }
1529
+ if (api !== 'public') {
1530
+ this.checkRequiredCredentials();
1531
+ const auth = this.stringToBase64(this.apiKey + ':' + this.secret);
1532
+ const secret = 'Basic ' + auth;
1533
+ headers = { 'authorization': secret };
1534
+ }
1535
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1536
+ }
1537
+ handleErrors(statusCode, statusText, url, method, responseHeaders, responseBody, response, requestHeaders, requestBody) {
1538
+ if (response === undefined) {
1539
+ return undefined;
1540
+ }
1541
+ if (statusCode >= 400) {
1542
+ //
1543
+ // {"error":{"timestamp":"05.12.2019T05:25:43.584+0000","status":"BAD_REQUEST","message":"Insufficient ETH balance. Required: 1, actual: 0.","code":4001}}
1544
+ // {"error":{"timestamp":"05.12.2019T04:03:25.419+0000","status":"FORBIDDEN","message":"Access denied","code":4300}}
1545
+ //
1546
+ const feedback = this.id + ' ' + responseBody;
1547
+ let error = this.safeValue(response, 'error');
1548
+ if (error === undefined) {
1549
+ error = response;
1550
+ }
1551
+ const code = this.safeString2(error, 'code', 'status');
1552
+ const message = this.safeString2(error, 'message', 'debugMessage');
1553
+ this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
1554
+ this.throwExactlyMatchedException(this.exceptions['exact'], code, feedback);
1555
+ this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
1556
+ throw new errors.ExchangeError(feedback);
1557
+ }
1558
+ return undefined;
1559
+ }
1560
+ }
1561
+
1562
+ module.exports = timex;