ccxt 4.2.17 → 4.2.19

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 (439) hide show
  1. package/README.md +9 -9
  2. package/dist/ccxt.browser.js +48992 -47725
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +12 -1
  5. package/dist/cjs/src/alpaca.js +18 -18
  6. package/dist/cjs/src/ascendex.js +13 -6
  7. package/dist/cjs/src/base/Exchange.js +266 -27
  8. package/dist/cjs/src/bigone.js +434 -168
  9. package/dist/cjs/src/binance.js +163 -34
  10. package/dist/cjs/src/binanceus.js +8 -0
  11. package/dist/cjs/src/bingx.js +183 -41
  12. package/dist/cjs/src/bitfinex.js +2 -3
  13. package/dist/cjs/src/bitget.js +59 -16
  14. package/dist/cjs/src/bitmart.js +5 -5
  15. package/dist/cjs/src/bitmex.js +4 -6
  16. package/dist/cjs/src/bitpanda.js +5 -1991
  17. package/dist/cjs/src/bitstamp.js +8 -0
  18. package/dist/cjs/src/bybit.js +27 -47
  19. package/dist/cjs/src/coinbase.js +176 -26
  20. package/dist/cjs/src/coincheck.js +1 -0
  21. package/dist/cjs/src/coinex.js +3 -0
  22. package/dist/cjs/src/coinlist.js +13 -6
  23. package/dist/cjs/src/coinone.js +2 -2
  24. package/dist/cjs/src/coinsph.js +4 -5
  25. package/dist/cjs/src/delta.js +7 -1
  26. package/dist/cjs/src/deribit.js +17 -4
  27. package/dist/cjs/src/gate.js +151 -169
  28. package/dist/cjs/src/gemini.js +1 -1
  29. package/dist/cjs/src/hitbtc.js +2 -3
  30. package/dist/cjs/src/htx.js +157 -7
  31. package/dist/cjs/src/huobijp.js +2 -3
  32. package/dist/cjs/src/independentreserve.js +7 -5
  33. package/dist/cjs/src/kraken.js +86 -54
  34. package/dist/cjs/src/kucoin.js +5 -0
  35. package/dist/cjs/src/kucoinfutures.js +131 -77
  36. package/dist/cjs/src/lbank.js +60 -33
  37. package/dist/cjs/src/luno.js +84 -2
  38. package/dist/cjs/src/mexc.js +3 -3
  39. package/dist/cjs/src/oceanex.js +1 -1
  40. package/dist/cjs/src/okx.js +23 -11
  41. package/dist/cjs/{js/src/bitpanda.js → src/onetrading.js} +39 -39
  42. package/dist/cjs/src/phemex.js +37 -27
  43. package/dist/cjs/src/poloniexfutures.js +1 -0
  44. package/dist/cjs/src/pro/binance.js +66 -25
  45. package/dist/cjs/src/pro/bitget.js +1 -1
  46. package/dist/cjs/src/pro/bitpanda.js +5 -1330
  47. package/dist/cjs/src/pro/coinbase.js +4 -1
  48. package/dist/cjs/src/pro/coincheck.js +208 -0
  49. package/dist/cjs/src/pro/hitbtc.js +5 -4
  50. package/dist/cjs/src/pro/htx.js +6 -1
  51. package/dist/cjs/src/pro/kraken.js +1 -1
  52. package/dist/cjs/src/pro/krakenfutures.js +7 -1
  53. package/dist/cjs/src/pro/kucoin.js +46 -36
  54. package/dist/cjs/src/pro/kucoinfutures.js +45 -37
  55. package/dist/cjs/src/pro/lbank.js +881 -0
  56. package/dist/cjs/src/pro/okx.js +52 -2
  57. package/dist/cjs/{js/src/pro/bitpanda.js → src/pro/onetrading.js} +4 -7
  58. package/dist/cjs/src/pro/poloniex.js +2 -2
  59. package/dist/cjs/src/pro/poloniexfutures.js +43 -35
  60. package/dist/cjs/src/pro/woo.js +126 -0
  61. package/dist/cjs/src/probit.js +4 -2
  62. package/dist/cjs/src/upbit.js +12 -12
  63. package/dist/cjs/src/wavesexchange.js +1 -1
  64. package/dist/cjs/src/whitebit.js +1 -0
  65. package/dist/cjs/src/woo.js +56 -0
  66. package/js/ccxt.d.ts +14 -2
  67. package/js/ccxt.js +10 -2
  68. package/js/src/abstract/bitpanda.d.ts +4 -4
  69. package/js/src/abstract/bitstamp.d.ts +8 -0
  70. package/js/src/abstract/gate.d.ts +1 -0
  71. package/js/src/abstract/gateio.d.ts +1 -0
  72. package/js/src/abstract/htx.d.ts +3 -0
  73. package/js/src/abstract/huobi.d.ts +3 -0
  74. package/js/src/abstract/luno.d.ts +1 -0
  75. package/js/src/abstract/onetrading.d.ts +38 -0
  76. package/js/src/ascendex.js +2 -0
  77. package/js/src/base/Exchange.d.ts +2 -3
  78. package/js/src/base/Exchange.js +5 -2
  79. package/js/src/binance.js +7 -1
  80. package/js/src/bingx.d.ts +1 -0
  81. package/js/src/bingx.js +26 -0
  82. package/js/src/bitget.js +22 -3
  83. package/js/src/bitpanda.d.ts +2 -72
  84. package/js/src/bitpanda.js +5 -1991
  85. package/js/src/bitstamp.js +8 -0
  86. package/js/src/bybit.js +21 -47
  87. package/js/src/coincheck.js +1 -0
  88. package/js/src/deribit.js +16 -4
  89. package/js/src/gate.d.ts +1 -0
  90. package/js/src/gate.js +50 -110
  91. package/js/src/htx.js +3 -0
  92. package/js/src/kraken.d.ts +1 -0
  93. package/js/src/kraken.js +40 -39
  94. package/js/src/lbank.js +1 -0
  95. package/js/src/luno.d.ts +3 -1
  96. package/js/src/luno.js +84 -2
  97. package/js/src/mexc.js +1 -2
  98. package/js/src/onetrading.d.ts +74 -0
  99. package/js/src/onetrading.js +2003 -0
  100. package/js/src/poloniexfutures.js +1 -0
  101. package/js/src/pro/binance.js +7 -2
  102. package/js/src/pro/bitget.js +1 -1
  103. package/js/src/pro/bitpanda.d.ts +2 -34
  104. package/js/src/pro/bitpanda.js +5 -1330
  105. package/js/src/pro/coincheck.d.ts +12 -0
  106. package/js/src/pro/coincheck.js +209 -0
  107. package/js/src/pro/kucoin.js +43 -35
  108. package/js/src/pro/kucoinfutures.js +45 -37
  109. package/js/src/pro/lbank.d.ts +29 -0
  110. package/js/src/pro/lbank.js +882 -0
  111. package/js/src/pro/onetrading.d.ts +36 -0
  112. package/js/src/pro/onetrading.js +1339 -0
  113. package/js/src/pro/poloniexfutures.js +43 -35
  114. package/js/src/whitebit.js +1 -0
  115. package/package.json +2 -2
  116. package/rollup.config.js +2 -0
  117. package/skip-tests.json +14 -2
  118. package/test-commonjs.cjs +25 -1
  119. package/dist/cjs/js/ccxt.js +0 -476
  120. package/dist/cjs/js/src/abstract/alpaca.js +0 -9
  121. package/dist/cjs/js/src/abstract/ascendex.js +0 -9
  122. package/dist/cjs/js/src/abstract/bigone.js +0 -9
  123. package/dist/cjs/js/src/abstract/binance.js +0 -9
  124. package/dist/cjs/js/src/abstract/bingx.js +0 -9
  125. package/dist/cjs/js/src/abstract/bit2c.js +0 -9
  126. package/dist/cjs/js/src/abstract/bitbank.js +0 -9
  127. package/dist/cjs/js/src/abstract/bitbns.js +0 -9
  128. package/dist/cjs/js/src/abstract/bitfinex.js +0 -9
  129. package/dist/cjs/js/src/abstract/bitfinex2.js +0 -9
  130. package/dist/cjs/js/src/abstract/bitflyer.js +0 -9
  131. package/dist/cjs/js/src/abstract/bitforex.js +0 -9
  132. package/dist/cjs/js/src/abstract/bitget.js +0 -9
  133. package/dist/cjs/js/src/abstract/bithumb.js +0 -9
  134. package/dist/cjs/js/src/abstract/bitmart.js +0 -9
  135. package/dist/cjs/js/src/abstract/bitmex.js +0 -9
  136. package/dist/cjs/js/src/abstract/bitopro.js +0 -9
  137. package/dist/cjs/js/src/abstract/bitpanda.js +0 -9
  138. package/dist/cjs/js/src/abstract/bitrue.js +0 -9
  139. package/dist/cjs/js/src/abstract/bitso.js +0 -9
  140. package/dist/cjs/js/src/abstract/bitstamp.js +0 -9
  141. package/dist/cjs/js/src/abstract/bitteam.js +0 -9
  142. package/dist/cjs/js/src/abstract/bitvavo.js +0 -9
  143. package/dist/cjs/js/src/abstract/bl3p.js +0 -9
  144. package/dist/cjs/js/src/abstract/blockchaincom.js +0 -9
  145. package/dist/cjs/js/src/abstract/btcalpha.js +0 -9
  146. package/dist/cjs/js/src/abstract/btcbox.js +0 -9
  147. package/dist/cjs/js/src/abstract/btcmarkets.js +0 -9
  148. package/dist/cjs/js/src/abstract/btcturk.js +0 -9
  149. package/dist/cjs/js/src/abstract/bybit.js +0 -9
  150. package/dist/cjs/js/src/abstract/cex.js +0 -9
  151. package/dist/cjs/js/src/abstract/coinbase.js +0 -9
  152. package/dist/cjs/js/src/abstract/coinbasepro.js +0 -9
  153. package/dist/cjs/js/src/abstract/coincheck.js +0 -9
  154. package/dist/cjs/js/src/abstract/coinex.js +0 -9
  155. package/dist/cjs/js/src/abstract/coinlist.js +0 -9
  156. package/dist/cjs/js/src/abstract/coinmate.js +0 -9
  157. package/dist/cjs/js/src/abstract/coinone.js +0 -9
  158. package/dist/cjs/js/src/abstract/coinsph.js +0 -9
  159. package/dist/cjs/js/src/abstract/coinspot.js +0 -9
  160. package/dist/cjs/js/src/abstract/cryptocom.js +0 -9
  161. package/dist/cjs/js/src/abstract/currencycom.js +0 -9
  162. package/dist/cjs/js/src/abstract/delta.js +0 -9
  163. package/dist/cjs/js/src/abstract/deribit.js +0 -9
  164. package/dist/cjs/js/src/abstract/digifinex.js +0 -9
  165. package/dist/cjs/js/src/abstract/exmo.js +0 -9
  166. package/dist/cjs/js/src/abstract/gate.js +0 -9
  167. package/dist/cjs/js/src/abstract/gemini.js +0 -9
  168. package/dist/cjs/js/src/abstract/hitbtc.js +0 -9
  169. package/dist/cjs/js/src/abstract/hollaex.js +0 -9
  170. package/dist/cjs/js/src/abstract/htx.js +0 -9
  171. package/dist/cjs/js/src/abstract/huobijp.js +0 -9
  172. package/dist/cjs/js/src/abstract/idex.js +0 -9
  173. package/dist/cjs/js/src/abstract/independentreserve.js +0 -9
  174. package/dist/cjs/js/src/abstract/indodax.js +0 -9
  175. package/dist/cjs/js/src/abstract/kraken.js +0 -9
  176. package/dist/cjs/js/src/abstract/krakenfutures.js +0 -9
  177. package/dist/cjs/js/src/abstract/kucoin.js +0 -9
  178. package/dist/cjs/js/src/abstract/kucoinfutures.js +0 -9
  179. package/dist/cjs/js/src/abstract/kuna.js +0 -9
  180. package/dist/cjs/js/src/abstract/latoken.js +0 -9
  181. package/dist/cjs/js/src/abstract/lbank.js +0 -9
  182. package/dist/cjs/js/src/abstract/luno.js +0 -9
  183. package/dist/cjs/js/src/abstract/lykke.js +0 -9
  184. package/dist/cjs/js/src/abstract/mercado.js +0 -9
  185. package/dist/cjs/js/src/abstract/mexc.js +0 -9
  186. package/dist/cjs/js/src/abstract/ndax.js +0 -9
  187. package/dist/cjs/js/src/abstract/novadax.js +0 -9
  188. package/dist/cjs/js/src/abstract/oceanex.js +0 -9
  189. package/dist/cjs/js/src/abstract/okcoin.js +0 -9
  190. package/dist/cjs/js/src/abstract/okx.js +0 -9
  191. package/dist/cjs/js/src/abstract/p2b.js +0 -9
  192. package/dist/cjs/js/src/abstract/paymium.js +0 -9
  193. package/dist/cjs/js/src/abstract/phemex.js +0 -9
  194. package/dist/cjs/js/src/abstract/poloniex.js +0 -9
  195. package/dist/cjs/js/src/abstract/poloniexfutures.js +0 -9
  196. package/dist/cjs/js/src/abstract/probit.js +0 -9
  197. package/dist/cjs/js/src/abstract/timex.js +0 -9
  198. package/dist/cjs/js/src/abstract/tokocrypto.js +0 -9
  199. package/dist/cjs/js/src/abstract/upbit.js +0 -9
  200. package/dist/cjs/js/src/abstract/wavesexchange.js +0 -9
  201. package/dist/cjs/js/src/abstract/wazirx.js +0 -9
  202. package/dist/cjs/js/src/abstract/whitebit.js +0 -9
  203. package/dist/cjs/js/src/abstract/woo.js +0 -9
  204. package/dist/cjs/js/src/abstract/yobit.js +0 -9
  205. package/dist/cjs/js/src/abstract/zaif.js +0 -9
  206. package/dist/cjs/js/src/abstract/zonda.js +0 -9
  207. package/dist/cjs/js/src/ace.js +0 -1058
  208. package/dist/cjs/js/src/alpaca.js +0 -1125
  209. package/dist/cjs/js/src/ascendex.js +0 -3365
  210. package/dist/cjs/js/src/base/Exchange.js +0 -5257
  211. package/dist/cjs/js/src/base/Precise.js +0 -263
  212. package/dist/cjs/js/src/base/errors.js +0 -299
  213. package/dist/cjs/js/src/base/functions/crypto.js +0 -78
  214. package/dist/cjs/js/src/base/functions/encode.js +0 -44
  215. package/dist/cjs/js/src/base/functions/generic.js +0 -193
  216. package/dist/cjs/js/src/base/functions/misc.js +0 -96
  217. package/dist/cjs/js/src/base/functions/number.js +0 -297
  218. package/dist/cjs/js/src/base/functions/platform.js +0 -28
  219. package/dist/cjs/js/src/base/functions/rsa.js +0 -34
  220. package/dist/cjs/js/src/base/functions/string.js +0 -48
  221. package/dist/cjs/js/src/base/functions/throttle.js +0 -66
  222. package/dist/cjs/js/src/base/functions/time.js +0 -187
  223. package/dist/cjs/js/src/base/functions/totp.js +0 -24
  224. package/dist/cjs/js/src/base/functions/type.js +0 -162
  225. package/dist/cjs/js/src/base/functions.js +0 -157
  226. package/dist/cjs/js/src/base/ws/Cache.js +0 -254
  227. package/dist/cjs/js/src/base/ws/Client.js +0 -299
  228. package/dist/cjs/js/src/base/ws/Future.js +0 -34
  229. package/dist/cjs/js/src/base/ws/OrderBook.js +0 -107
  230. package/dist/cjs/js/src/base/ws/OrderBookSide.js +0 -281
  231. package/dist/cjs/js/src/base/ws/WsClient.js +0 -69
  232. package/dist/cjs/js/src/bequant.js +0 -33
  233. package/dist/cjs/js/src/bigone.js +0 -2213
  234. package/dist/cjs/js/src/binance.js +0 -9845
  235. package/dist/cjs/js/src/binancecoinm.js +0 -45
  236. package/dist/cjs/js/src/binanceus.js +0 -92
  237. package/dist/cjs/js/src/binanceusdm.js +0 -58
  238. package/dist/cjs/js/src/bingx.js +0 -3846
  239. package/dist/cjs/js/src/bit2c.js +0 -916
  240. package/dist/cjs/js/src/bitbank.js +0 -1000
  241. package/dist/cjs/js/src/bitbay.js +0 -17
  242. package/dist/cjs/js/src/bitbns.js +0 -1220
  243. package/dist/cjs/js/src/bitcoincom.js +0 -17
  244. package/dist/cjs/js/src/bitfinex.js +0 -1670
  245. package/dist/cjs/js/src/bitfinex2.js +0 -2990
  246. package/dist/cjs/js/src/bitflyer.js +0 -1045
  247. package/dist/cjs/js/src/bitforex.js +0 -852
  248. package/dist/cjs/js/src/bitget.js +0 -8295
  249. package/dist/cjs/js/src/bithumb.js +0 -1090
  250. package/dist/cjs/js/src/bitmart.js +0 -4454
  251. package/dist/cjs/js/src/bitmex.js +0 -2881
  252. package/dist/cjs/js/src/bitopro.js +0 -1724
  253. package/dist/cjs/js/src/bitrue.js +0 -3253
  254. package/dist/cjs/js/src/bitso.js +0 -1753
  255. package/dist/cjs/js/src/bitstamp.js +0 -2188
  256. package/dist/cjs/js/src/bitteam.js +0 -2309
  257. package/dist/cjs/js/src/bitvavo.js +0 -1968
  258. package/dist/cjs/js/src/bl3p.js +0 -447
  259. package/dist/cjs/js/src/blockchaincom.js +0 -1160
  260. package/dist/cjs/js/src/btcalpha.js +0 -929
  261. package/dist/cjs/js/src/btcbox.js +0 -565
  262. package/dist/cjs/js/src/btcmarkets.js +0 -1237
  263. package/dist/cjs/js/src/btcturk.js +0 -929
  264. package/dist/cjs/js/src/bybit.js +0 -7650
  265. package/dist/cjs/js/src/cex.js +0 -1693
  266. package/dist/cjs/js/src/coinbase.js +0 -3424
  267. package/dist/cjs/js/src/coinbasepro.js +0 -1866
  268. package/dist/cjs/js/src/coincheck.js +0 -843
  269. package/dist/cjs/js/src/coinex.js +0 -5417
  270. package/dist/cjs/js/src/coinlist.js +0 -2337
  271. package/dist/cjs/js/src/coinmate.js +0 -989
  272. package/dist/cjs/js/src/coinone.js +0 -1185
  273. package/dist/cjs/js/src/coinsph.js +0 -1933
  274. package/dist/cjs/js/src/coinspot.js +0 -548
  275. package/dist/cjs/js/src/cryptocom.js +0 -3007
  276. package/dist/cjs/js/src/currencycom.js +0 -2015
  277. package/dist/cjs/js/src/delta.js +0 -3262
  278. package/dist/cjs/js/src/deribit.js +0 -3306
  279. package/dist/cjs/js/src/digifinex.js +0 -4307
  280. package/dist/cjs/js/src/exmo.js +0 -2645
  281. package/dist/cjs/js/src/fmfwio.js +0 -34
  282. package/dist/cjs/js/src/gate.js +0 -7077
  283. package/dist/cjs/js/src/gateio.js +0 -16
  284. package/dist/cjs/js/src/gemini.js +0 -1801
  285. package/dist/cjs/js/src/hitbtc.js +0 -3660
  286. package/dist/cjs/js/src/hitbtc3.js +0 -19
  287. package/dist/cjs/js/src/hollaex.js +0 -1882
  288. package/dist/cjs/js/src/htx.js +0 -9174
  289. package/dist/cjs/js/src/huobi.js +0 -16
  290. package/dist/cjs/js/src/huobijp.js +0 -1918
  291. package/dist/cjs/js/src/idex.js +0 -1770
  292. package/dist/cjs/js/src/independentreserve.js +0 -761
  293. package/dist/cjs/js/src/indodax.js +0 -1069
  294. package/dist/cjs/js/src/kraken.js +0 -2891
  295. package/dist/cjs/js/src/krakenfutures.js +0 -2407
  296. package/dist/cjs/js/src/kucoin.js +0 -4494
  297. package/dist/cjs/js/src/kucoinfutures.js +0 -2529
  298. package/dist/cjs/js/src/kuna.js +0 -1949
  299. package/dist/cjs/js/src/latoken.js +0 -1729
  300. package/dist/cjs/js/src/lbank.js +0 -2851
  301. package/dist/cjs/js/src/luno.js +0 -1044
  302. package/dist/cjs/js/src/lykke.js +0 -1303
  303. package/dist/cjs/js/src/mercado.js +0 -897
  304. package/dist/cjs/js/src/mexc.js +0 -5407
  305. package/dist/cjs/js/src/ndax.js +0 -2450
  306. package/dist/cjs/js/src/novadax.js +0 -1556
  307. package/dist/cjs/js/src/oceanex.js +0 -964
  308. package/dist/cjs/js/src/okcoin.js +0 -3115
  309. package/dist/cjs/js/src/okx.js +0 -7331
  310. package/dist/cjs/js/src/p2b.js +0 -1243
  311. package/dist/cjs/js/src/paymium.js +0 -597
  312. package/dist/cjs/js/src/phemex.js +0 -4725
  313. package/dist/cjs/js/src/poloniex.js +0 -2356
  314. package/dist/cjs/js/src/poloniexfutures.js +0 -1794
  315. package/dist/cjs/js/src/pro/alpaca.js +0 -714
  316. package/dist/cjs/js/src/pro/ascendex.js +0 -957
  317. package/dist/cjs/js/src/pro/bequant.js +0 -33
  318. package/dist/cjs/js/src/pro/binance.js +0 -2796
  319. package/dist/cjs/js/src/pro/binancecoinm.js +0 -23
  320. package/dist/cjs/js/src/pro/binanceus.js +0 -51
  321. package/dist/cjs/js/src/pro/binanceusdm.js +0 -32
  322. package/dist/cjs/js/src/pro/bingx.js +0 -944
  323. package/dist/cjs/js/src/pro/bitcoincom.js +0 -29
  324. package/dist/cjs/js/src/pro/bitfinex.js +0 -672
  325. package/dist/cjs/js/src/pro/bitfinex2.js +0 -1159
  326. package/dist/cjs/js/src/pro/bitget.js +0 -1733
  327. package/dist/cjs/js/src/pro/bitmart.js +0 -1486
  328. package/dist/cjs/js/src/pro/bitmex.js +0 -1576
  329. package/dist/cjs/js/src/pro/bitopro.js +0 -327
  330. package/dist/cjs/js/src/pro/bitrue.js +0 -462
  331. package/dist/cjs/js/src/pro/bitstamp.js +0 -547
  332. package/dist/cjs/js/src/pro/bitvavo.js +0 -704
  333. package/dist/cjs/js/src/pro/blockchaincom.js +0 -794
  334. package/dist/cjs/js/src/pro/bybit.js +0 -1843
  335. package/dist/cjs/js/src/pro/cex.js +0 -1510
  336. package/dist/cjs/js/src/pro/coinbase.js +0 -561
  337. package/dist/cjs/js/src/pro/coinbasepro.js +0 -968
  338. package/dist/cjs/js/src/pro/coinex.js +0 -1095
  339. package/dist/cjs/js/src/pro/cryptocom.js +0 -1020
  340. package/dist/cjs/js/src/pro/currencycom.js +0 -563
  341. package/dist/cjs/js/src/pro/deribit.js +0 -825
  342. package/dist/cjs/js/src/pro/exmo.js +0 -658
  343. package/dist/cjs/js/src/pro/gate.js +0 -1316
  344. package/dist/cjs/js/src/pro/gateio.js +0 -16
  345. package/dist/cjs/js/src/pro/gemini.js +0 -649
  346. package/dist/cjs/js/src/pro/hitbtc.js +0 -1294
  347. package/dist/cjs/js/src/pro/hollaex.js +0 -597
  348. package/dist/cjs/js/src/pro/htx.js +0 -2388
  349. package/dist/cjs/js/src/pro/huobi.js +0 -16
  350. package/dist/cjs/js/src/pro/huobijp.js +0 -606
  351. package/dist/cjs/js/src/pro/idex.js +0 -714
  352. package/dist/cjs/js/src/pro/independentreserve.js +0 -280
  353. package/dist/cjs/js/src/pro/kraken.js +0 -1364
  354. package/dist/cjs/js/src/pro/krakenfutures.js +0 -1506
  355. package/dist/cjs/js/src/pro/kucoin.js +0 -1054
  356. package/dist/cjs/js/src/pro/kucoinfutures.js +0 -981
  357. package/dist/cjs/js/src/pro/luno.js +0 -322
  358. package/dist/cjs/js/src/pro/mexc.js +0 -1170
  359. package/dist/cjs/js/src/pro/ndax.js +0 -545
  360. package/dist/cjs/js/src/pro/okcoin.js +0 -760
  361. package/dist/cjs/js/src/pro/okx.js +0 -1608
  362. package/dist/cjs/js/src/pro/phemex.js +0 -1511
  363. package/dist/cjs/js/src/pro/poloniex.js +0 -1253
  364. package/dist/cjs/js/src/pro/poloniexfutures.js +0 -1014
  365. package/dist/cjs/js/src/pro/probit.js +0 -586
  366. package/dist/cjs/js/src/pro/upbit.js +0 -234
  367. package/dist/cjs/js/src/pro/wazirx.js +0 -776
  368. package/dist/cjs/js/src/pro/whitebit.js +0 -927
  369. package/dist/cjs/js/src/pro/woo.js +0 -895
  370. package/dist/cjs/js/src/probit.js +0 -1867
  371. package/dist/cjs/js/src/static_dependencies/fflake/browser.js +0 -401
  372. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +0 -195
  373. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +0 -308
  374. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +0 -554
  375. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +0 -94
  376. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +0 -70
  377. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +0 -91
  378. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +0 -16
  379. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +0 -1760
  380. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +0 -52
  381. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +0 -81
  382. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +0 -376
  383. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +0 -70
  384. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +0 -1580
  385. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +0 -74
  386. package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +0 -24
  387. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +0 -158
  388. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +0 -429
  389. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +0 -176
  390. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +0 -324
  391. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +0 -163
  392. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +0 -245
  393. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +0 -1018
  394. package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +0 -383
  395. package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +0 -258
  396. package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +0 -53
  397. package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +0 -120
  398. package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +0 -69
  399. package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +0 -7
  400. package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +0 -83
  401. package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +0 -240
  402. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +0 -91
  403. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +0 -130
  404. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +0 -214
  405. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +0 -239
  406. package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +0 -93
  407. package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +0 -354
  408. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +0 -16
  409. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +0 -20
  410. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +0 -30
  411. package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +0 -239
  412. package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +0 -372
  413. package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +0 -273
  414. package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +0 -139
  415. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +0 -14
  416. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +0 -16
  417. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +0 -81
  418. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +0 -292
  419. package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +0 -103
  420. package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +0 -140
  421. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +0 -175
  422. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +0 -95
  423. package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +0 -7
  424. package/dist/cjs/js/src/static_dependencies/scure-base/index.js +0 -383
  425. package/dist/cjs/js/src/timex.js +0 -1562
  426. package/dist/cjs/js/src/tokocrypto.js +0 -2542
  427. package/dist/cjs/js/src/upbit.js +0 -1844
  428. package/dist/cjs/js/src/wavesexchange.js +0 -2607
  429. package/dist/cjs/js/src/wazirx.js +0 -953
  430. package/dist/cjs/js/src/whitebit.js +0 -2309
  431. package/dist/cjs/js/src/woo.js +0 -2769
  432. package/dist/cjs/js/src/yobit.js +0 -1314
  433. package/dist/cjs/js/src/zaif.js +0 -736
  434. package/dist/cjs/js/src/zonda.js +0 -1883
  435. package/dist/cjs/src/abstract/bitpanda.js +0 -9
  436. package/test.ts +0 -0
  437. /package/dist/cjs/{js/src/abstract/ace.js → src/abstract/onetrading.js} +0 -0
  438. /package/dist/cjs/{js/src → src}/pro/coinone.js +0 -0
  439. /package/js/src/abstract/{bitpanda.js → onetrading.js} +0 -0
@@ -1,1670 +0,0 @@
1
- 'use strict';
2
-
3
- var bitfinex$1 = require('./abstract/bitfinex.js');
4
- var errors = require('./base/errors.js');
5
- var Precise = require('./base/Precise.js');
6
- var number = require('./base/functions/number.js');
7
- var sha512 = require('./static_dependencies/noble-hashes/sha512.js');
8
-
9
- // ---------------------------------------------------------------------------
10
- // ---------------------------------------------------------------------------
11
- /**
12
- * @class bitfinex
13
- * @augments Exchange
14
- */
15
- class bitfinex extends bitfinex$1 {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'bitfinex',
19
- 'name': 'Bitfinex',
20
- 'countries': ['VG'],
21
- 'version': 'v1',
22
- // cheapest is 90 requests a minute = 1.5 requests per second on average => ( 1000ms / 1.5) = 666.666 ms between requests on average
23
- 'rateLimit': 666.666,
24
- 'pro': true,
25
- // new metainfo interface
26
- 'has': {
27
- 'CORS': undefined,
28
- 'spot': true,
29
- 'margin': undefined,
30
- 'swap': undefined,
31
- 'future': undefined,
32
- 'option': undefined,
33
- 'cancelAllOrders': true,
34
- 'cancelOrder': true,
35
- 'createDepositAddress': true,
36
- 'createOrder': true,
37
- 'editOrder': true,
38
- 'fetchBalance': true,
39
- 'fetchClosedOrders': true,
40
- 'fetchDepositAddress': true,
41
- 'fetchDeposits': false,
42
- 'fetchDepositsWithdrawals': true,
43
- 'fetchDepositWithdrawFee': 'emulated',
44
- 'fetchDepositWithdrawFees': true,
45
- 'fetchIndexOHLCV': false,
46
- 'fetchLeverageTiers': false,
47
- 'fetchMarginMode': false,
48
- 'fetchMarkets': true,
49
- 'fetchMarkOHLCV': false,
50
- 'fetchMyTrades': true,
51
- 'fetchOHLCV': true,
52
- 'fetchOpenOrders': true,
53
- 'fetchOrder': true,
54
- 'fetchOrderBook': true,
55
- 'fetchPositionMode': false,
56
- 'fetchPositions': true,
57
- 'fetchPremiumIndexOHLCV': false,
58
- 'fetchTicker': true,
59
- 'fetchTickers': true,
60
- 'fetchTime': false,
61
- 'fetchTrades': true,
62
- 'fetchTradingFee': false,
63
- 'fetchTradingFees': true,
64
- 'fetchTransactionFees': true,
65
- 'fetchTransactions': 'emulated',
66
- 'transfer': true,
67
- 'withdraw': true,
68
- },
69
- 'timeframes': {
70
- '1m': '1m',
71
- '5m': '5m',
72
- '15m': '15m',
73
- '30m': '30m',
74
- '1h': '1h',
75
- '3h': '3h',
76
- '4h': '4h',
77
- '6h': '6h',
78
- '12h': '12h',
79
- '1d': '1D',
80
- '1w': '7D',
81
- '2w': '14D',
82
- '1M': '1M',
83
- },
84
- 'urls': {
85
- 'logo': 'https://user-images.githubusercontent.com/1294454/27766244-e328a50c-5ed2-11e7-947b-041416579bb3.jpg',
86
- 'api': {
87
- 'v2': 'https://api-pub.bitfinex.com',
88
- 'public': 'https://api.bitfinex.com',
89
- 'private': 'https://api.bitfinex.com',
90
- },
91
- 'www': 'https://www.bitfinex.com',
92
- 'referral': 'https://www.bitfinex.com/?refcode=P61eYxFL',
93
- 'doc': [
94
- 'https://docs.bitfinex.com/v1/docs',
95
- 'https://github.com/bitfinexcom/bitfinex-api-node',
96
- ],
97
- },
98
- 'api': {
99
- // v2 symbol ids require a 't' prefix
100
- // just the public part of it (use bitfinex2 for everything else)
101
- 'v2': {
102
- 'get': {
103
- 'platform/status': 3,
104
- 'tickers': 1,
105
- 'ticker/{symbol}': 1,
106
- 'tickers/hist': 1,
107
- 'trades/{symbol}/hist': 1,
108
- 'book/{symbol}/{precision}': 0.375,
109
- 'book/{symbol}/P0': 0.375,
110
- 'book/{symbol}/P1': 0.375,
111
- 'book/{symbol}/P2': 0.375,
112
- 'book/{symbol}/P3': 0.375,
113
- 'book/{symbol}/R0': 0.375,
114
- 'stats1/{key}:{size}:{symbol}:{side}/{section}': 1,
115
- 'stats1/{key}:{size}:{symbol}/{section}': 1,
116
- 'stats1/{key}:{size}:{symbol}:long/last': 1,
117
- 'stats1/{key}:{size}:{symbol}:long/hist': 1,
118
- 'stats1/{key}:{size}:{symbol}:short/last': 1,
119
- 'stats1/{key}:{size}:{symbol}:short/hist': 1,
120
- 'candles/trade:{timeframe}:{symbol}/{section}': 1,
121
- 'candles/trade:{timeframe}:{symbol}/last': 1,
122
- 'candles/trade:{timeframe}:{symbol}/hist': 1,
123
- },
124
- },
125
- 'public': {
126
- 'get': {
127
- 'book/{symbol}': 1,
128
- // 'candles/{symbol}':0,
129
- 'lendbook/{currency}': 6,
130
- 'lends/{currency}': 3,
131
- 'pubticker/{symbol}': 3,
132
- 'stats/{symbol}': 6,
133
- 'symbols': 18,
134
- 'symbols_details': 18,
135
- 'tickers': 1,
136
- 'trades/{symbol}': 3, // 60 requests a minute = 1 request per second => (1000ms / rateLimit) / 1 = 1.5 ... but only works if set to 3
137
- },
138
- },
139
- 'private': {
140
- 'post': {
141
- 'account_fees': 18,
142
- 'account_infos': 6,
143
- 'balances': 9.036,
144
- 'basket_manage': 6,
145
- 'credits': 6,
146
- 'deposit/new': 18,
147
- 'funding/close': 6,
148
- 'history': 6,
149
- 'history/movements': 6,
150
- 'key_info': 6,
151
- 'margin_infos': 3,
152
- 'mytrades': 3,
153
- 'mytrades_funding': 6,
154
- 'offer/cancel': 6,
155
- 'offer/new': 6,
156
- 'offer/status': 6,
157
- 'offers': 6,
158
- 'offers/hist': 90.03,
159
- 'order/cancel': 0.2,
160
- 'order/cancel/all': 0.2,
161
- 'order/cancel/multi': 0.2,
162
- 'order/cancel/replace': 0.2,
163
- 'order/new': 0.2,
164
- 'order/new/multi': 0.2,
165
- 'order/status': 0.2,
166
- 'orders': 0.2,
167
- 'orders/hist': 90.03,
168
- 'position/claim': 18,
169
- 'position/close': 18,
170
- 'positions': 18,
171
- 'summary': 18,
172
- 'taken_funds': 6,
173
- 'total_taken_funds': 6,
174
- 'transfer': 18,
175
- 'unused_taken_funds': 6,
176
- 'withdraw': 18,
177
- },
178
- },
179
- },
180
- 'fees': {
181
- 'trading': {
182
- 'feeSide': 'get',
183
- 'tierBased': true,
184
- 'percentage': true,
185
- 'maker': this.parseNumber('0.001'),
186
- 'taker': this.parseNumber('0.002'),
187
- 'tiers': {
188
- 'taker': [
189
- [this.parseNumber('0'), this.parseNumber('0.002')],
190
- [this.parseNumber('500000'), this.parseNumber('0.002')],
191
- [this.parseNumber('1000000'), this.parseNumber('0.002')],
192
- [this.parseNumber('2500000'), this.parseNumber('0.002')],
193
- [this.parseNumber('5000000'), this.parseNumber('0.002')],
194
- [this.parseNumber('7500000'), this.parseNumber('0.002')],
195
- [this.parseNumber('10000000'), this.parseNumber('0.0018')],
196
- [this.parseNumber('15000000'), this.parseNumber('0.0016')],
197
- [this.parseNumber('20000000'), this.parseNumber('0.0014')],
198
- [this.parseNumber('25000000'), this.parseNumber('0.0012')],
199
- [this.parseNumber('30000000'), this.parseNumber('0.001')],
200
- ],
201
- 'maker': [
202
- [this.parseNumber('0'), this.parseNumber('0.001')],
203
- [this.parseNumber('500000'), this.parseNumber('0.0008')],
204
- [this.parseNumber('1000000'), this.parseNumber('0.0006')],
205
- [this.parseNumber('2500000'), this.parseNumber('0.0004')],
206
- [this.parseNumber('5000000'), this.parseNumber('0.0002')],
207
- [this.parseNumber('7500000'), this.parseNumber('0')],
208
- [this.parseNumber('10000000'), this.parseNumber('0')],
209
- [this.parseNumber('15000000'), this.parseNumber('0')],
210
- [this.parseNumber('20000000'), this.parseNumber('0')],
211
- [this.parseNumber('25000000'), this.parseNumber('0')],
212
- [this.parseNumber('30000000'), this.parseNumber('0')],
213
- ],
214
- },
215
- },
216
- 'funding': {
217
- 'tierBased': false,
218
- 'percentage': false,
219
- // Actually deposit fees are free for larger deposits (> $1000 USD equivalent)
220
- // these values below are deprecated, we should not hardcode fees and limits anymore
221
- // to be reimplemented with bitfinex funding fees from their API or web endpoints
222
- 'deposit': {},
223
- 'withdraw': {},
224
- },
225
- },
226
- // todo rewrite for https://api-pub.bitfinex.com//v2/conf/pub:map:tx:method
227
- 'commonCurrencies': {
228
- 'ALG': 'ALGO',
229
- 'AMP': 'AMPL',
230
- 'ATO': 'ATOM',
231
- 'BCHABC': 'XEC',
232
- 'BCHN': 'BCH',
233
- 'DAT': 'DATA',
234
- 'DOG': 'MDOGE',
235
- 'DSH': 'DASH',
236
- // https://github.com/ccxt/ccxt/issues/7399
237
- // https://coinmarketcap.com/currencies/pnetwork/
238
- // https://en.cryptonomist.ch/blog/eidoo/the-edo-to-pnt-upgrade-what-you-need-to-know-updated/
239
- 'EDO': 'PNT',
240
- 'EUS': 'EURS',
241
- 'EUT': 'EURT',
242
- 'IDX': 'ID',
243
- 'IOT': 'IOTA',
244
- 'IQX': 'IQ',
245
- 'LUNA': 'LUNC',
246
- 'LUNA2': 'LUNA',
247
- 'MNA': 'MANA',
248
- 'ORS': 'ORS Group',
249
- 'PAS': 'PASS',
250
- 'QSH': 'QASH',
251
- 'QTM': 'QTUM',
252
- 'RBT': 'RBTC',
253
- 'SNG': 'SNGLS',
254
- 'STJ': 'STORJ',
255
- 'TERRAUST': 'USTC',
256
- 'TSD': 'TUSD',
257
- 'YGG': 'YEED',
258
- 'YYW': 'YOYOW',
259
- 'UDC': 'USDC',
260
- 'UST': 'USDT',
261
- 'VSY': 'VSYS',
262
- 'WAX': 'WAXP',
263
- 'XCH': 'XCHF',
264
- 'ZBT': 'ZB',
265
- },
266
- 'exceptions': {
267
- 'exact': {
268
- 'temporarily_unavailable': errors.ExchangeNotAvailable,
269
- 'Order could not be cancelled.': errors.OrderNotFound,
270
- 'No such order found.': errors.OrderNotFound,
271
- 'Order price must be positive.': errors.InvalidOrder,
272
- 'Could not find a key matching the given X-BFX-APIKEY.': errors.AuthenticationError,
273
- 'Key price should be a decimal number, e.g. "123.456"': errors.InvalidOrder,
274
- 'Key amount should be a decimal number, e.g. "123.456"': errors.InvalidOrder,
275
- 'ERR_RATE_LIMIT': errors.RateLimitExceeded,
276
- 'Ratelimit': errors.RateLimitExceeded,
277
- 'Nonce is too small.': errors.InvalidNonce,
278
- 'No summary found.': errors.ExchangeError,
279
- 'Cannot evaluate your available balance, please try again': errors.ExchangeNotAvailable,
280
- 'Unknown symbol': errors.BadSymbol,
281
- 'Cannot complete transfer. Exchange balance insufficient.': errors.InsufficientFunds,
282
- 'Momentary balance check. Please wait few seconds and try the transfer again.': errors.ExchangeError,
283
- },
284
- 'broad': {
285
- 'Invalid X-BFX-SIGNATURE': errors.AuthenticationError,
286
- 'This API key does not have permission': errors.PermissionDenied,
287
- 'not enough exchange balance for ': errors.InsufficientFunds,
288
- 'minimum size for ': errors.InvalidOrder,
289
- 'Invalid order': errors.InvalidOrder,
290
- 'The available balance is only': errors.InsufficientFunds, // {"status":"error","message":"Cannot withdraw 1.0027 ETH from your exchange wallet. The available balance is only 0.0 ETH. If you have limit orders, open positions, unused or active margin funding, this will decrease your available balance. To increase it, you can cancel limit orders or reduce/close your positions.","withdrawal_id":0,"fees":"0.0027"}
291
- },
292
- },
293
- 'precisionMode': number.SIGNIFICANT_DIGITS,
294
- 'options': {
295
- 'currencyNames': {
296
- 'AGI': 'agi',
297
- 'AID': 'aid',
298
- 'AIO': 'aio',
299
- 'ANT': 'ant',
300
- 'AVT': 'aventus',
301
- 'BAT': 'bat',
302
- // https://github.com/ccxt/ccxt/issues/5833
303
- 'BCH': 'bab',
304
- // 'BCH': 'bcash', // undocumented
305
- 'BCI': 'bci',
306
- 'BFT': 'bft',
307
- 'BSV': 'bsv',
308
- 'BTC': 'bitcoin',
309
- 'BTG': 'bgold',
310
- 'CFI': 'cfi',
311
- 'COMP': 'comp',
312
- 'DAI': 'dai',
313
- 'DADI': 'dad',
314
- 'DASH': 'dash',
315
- 'DATA': 'datacoin',
316
- 'DTH': 'dth',
317
- 'EDO': 'eidoo',
318
- 'ELF': 'elf',
319
- 'EOS': 'eos',
320
- 'ETC': 'ethereumc',
321
- 'ETH': 'ethereum',
322
- 'ETP': 'metaverse',
323
- 'FUN': 'fun',
324
- 'GNT': 'golem',
325
- 'IOST': 'ios',
326
- 'IOTA': 'iota',
327
- // https://github.com/ccxt/ccxt/issues/5833
328
- 'LEO': 'let',
329
- // 'LEO': 'les', // EOS chain
330
- 'LINK': 'link',
331
- 'LRC': 'lrc',
332
- 'LTC': 'litecoin',
333
- 'LYM': 'lym',
334
- 'MANA': 'mna',
335
- 'MIT': 'mit',
336
- 'MKR': 'mkr',
337
- 'MTN': 'mtn',
338
- 'NEO': 'neo',
339
- 'ODE': 'ode',
340
- 'OMG': 'omisego',
341
- 'OMNI': 'mastercoin',
342
- 'QASH': 'qash',
343
- 'QTUM': 'qtum',
344
- 'RCN': 'rcn',
345
- 'RDN': 'rdn',
346
- 'REP': 'rep',
347
- 'REQ': 'req',
348
- 'RLC': 'rlc',
349
- 'SAN': 'santiment',
350
- 'SNGLS': 'sng',
351
- 'SNT': 'status',
352
- 'SPANK': 'spk',
353
- 'STORJ': 'stj',
354
- 'TNB': 'tnb',
355
- 'TRX': 'trx',
356
- 'TUSD': 'tsd',
357
- 'USD': 'wire',
358
- 'USDC': 'udc',
359
- 'UTK': 'utk',
360
- 'USDT': 'tetheruso',
361
- // 'USDT': 'tetheruse', // Tether on ERC20
362
- // 'USDT': 'tetherusl', // Tether on Liquid
363
- // 'USDT': 'tetherusx', // Tether on Tron
364
- // 'USDT': 'tetheruss', // Tether on EOS
365
- 'VEE': 'vee',
366
- 'WAX': 'wax',
367
- 'XLM': 'xlm',
368
- 'XMR': 'monero',
369
- 'XRP': 'ripple',
370
- 'XVG': 'xvg',
371
- 'YOYOW': 'yoyow',
372
- 'ZEC': 'zcash',
373
- 'ZRX': 'zrx',
374
- 'XTZ': 'xtz',
375
- },
376
- 'orderTypes': {
377
- 'limit': 'exchange limit',
378
- 'market': 'exchange market',
379
- },
380
- 'fiat': {
381
- 'USD': 'USD',
382
- 'EUR': 'EUR',
383
- 'JPY': 'JPY',
384
- 'GBP': 'GBP',
385
- 'CNH': 'CNH',
386
- },
387
- 'accountsByType': {
388
- 'spot': 'exchange',
389
- 'margin': 'trading',
390
- 'funding': 'deposit',
391
- 'swap': 'trading',
392
- },
393
- },
394
- });
395
- }
396
- async fetchTransactionFees(codes = undefined, params = {}) {
397
- /**
398
- * @method
399
- * @name bitfinex#fetchTransactionFees
400
- * @deprecated
401
- * @description please use fetchDepositWithdrawFees instead
402
- * @see https://docs.bitfinex.com/v1/reference/rest-auth-fees
403
- * @param {string[]|undefined} codes list of unified currency codes
404
- * @param {object} [params] extra parameters specific to the exchange API endpoint
405
- * @returns {object[]} a list of [fees structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
406
- */
407
- await this.loadMarkets();
408
- const result = {};
409
- const response = await this.privatePostAccountFees(params);
410
- //
411
- // {
412
- // "withdraw": {
413
- // "BTC": "0.0004",
414
- // }
415
- // }
416
- //
417
- const fees = this.safeValue(response, 'withdraw');
418
- const ids = Object.keys(fees);
419
- for (let i = 0; i < ids.length; i++) {
420
- const id = ids[i];
421
- const code = this.safeCurrencyCode(id);
422
- if ((codes !== undefined) && !this.inArray(code, codes)) {
423
- continue;
424
- }
425
- result[code] = {
426
- 'withdraw': this.safeNumber(fees, id),
427
- 'deposit': {},
428
- 'info': this.safeNumber(fees, id),
429
- };
430
- }
431
- return result;
432
- }
433
- async fetchDepositWithdrawFees(codes = undefined, params = {}) {
434
- /**
435
- * @method
436
- * @name bitfinex#fetchDepositWithdrawFees
437
- * @description fetch deposit and withdraw fees
438
- * @see https://docs.bitfinex.com/v1/reference/rest-auth-fees
439
- * @param {string[]|undefined} codes list of unified currency codes
440
- * @param {object} [params] extra parameters specific to the exchange API endpoint
441
- * @returns {object[]} a list of [fees structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
442
- */
443
- await this.loadMarkets();
444
- const response = await this.privatePostAccountFees(params);
445
- //
446
- // {
447
- // "withdraw": {
448
- // "BTC": "0.0004",
449
- // ...
450
- // }
451
- // }
452
- //
453
- const withdraw = this.safeValue(response, 'withdraw');
454
- return this.parseDepositWithdrawFees(withdraw, codes);
455
- }
456
- parseDepositWithdrawFee(fee, currency = undefined) {
457
- //
458
- // '0.0004'
459
- //
460
- return {
461
- 'withdraw': {
462
- 'fee': this.parseNumber(fee),
463
- 'percentage': undefined,
464
- },
465
- 'deposit': {
466
- 'fee': undefined,
467
- 'percentage': undefined,
468
- },
469
- 'networks': {},
470
- 'info': fee,
471
- };
472
- }
473
- async fetchTradingFees(params = {}) {
474
- /**
475
- * @method
476
- * @name bitfinex#fetchTradingFees
477
- * @description fetch the trading fees for multiple markets
478
- * @param {object} [params] extra parameters specific to the exchange API endpoint
479
- * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
480
- */
481
- await this.loadMarkets();
482
- const response = await this.privatePostSummary(params);
483
- //
484
- // {
485
- // "time": "2022-02-23T16:05:47.659000Z",
486
- // "status": { resid_hint: null, login_last: "2022-02-23T16:05:48Z" },
487
- // "is_locked": false,
488
- // "leo_lev": "0",
489
- // "leo_amount_avg": "0.0",
490
- // "trade_vol_30d": [
491
- // {
492
- // "curr": "Total (USD)",
493
- // "vol": "0.0",
494
- // "vol_safe": "0.0",
495
- // "vol_maker": "0.0",
496
- // "vol_BFX": "0.0",
497
- // "vol_BFX_safe": "0.0",
498
- // "vol_BFX_maker": "0.0"
499
- // }
500
- // ],
501
- // "fees_funding_30d": {},
502
- // "fees_funding_total_30d": "0",
503
- // "fees_trading_30d": {},
504
- // "fees_trading_total_30d": "0",
505
- // "rebates_trading_30d": {},
506
- // "rebates_trading_total_30d": "0",
507
- // "maker_fee": "0.001",
508
- // "taker_fee": "0.002",
509
- // "maker_fee_2crypto": "0.001",
510
- // "maker_fee_2stablecoin": "0.001",
511
- // "maker_fee_2fiat": "0.001",
512
- // "maker_fee_2deriv": "0.0002",
513
- // "taker_fee_2crypto": "0.002",
514
- // "taker_fee_2stablecoin": "0.002",
515
- // "taker_fee_2fiat": "0.002",
516
- // "taker_fee_2deriv": "0.00065",
517
- // "deriv_maker_rebate": "0.0002",
518
- // "deriv_taker_fee": "0.00065",
519
- // "trade_last": null
520
- // }
521
- //
522
- const result = {};
523
- const fiat = this.safeValue(this.options, 'fiat', {});
524
- const makerFee = this.safeNumber(response, 'maker_fee');
525
- const takerFee = this.safeNumber(response, 'taker_fee');
526
- const makerFee2Fiat = this.safeNumber(response, 'maker_fee_2fiat');
527
- const takerFee2Fiat = this.safeNumber(response, 'taker_fee_2fiat');
528
- const makerFee2Deriv = this.safeNumber(response, 'maker_fee_2deriv');
529
- const takerFee2Deriv = this.safeNumber(response, 'taker_fee_2deriv');
530
- for (let i = 0; i < this.symbols.length; i++) {
531
- const symbol = this.symbols[i];
532
- const market = this.market(symbol);
533
- const fee = {
534
- 'info': response,
535
- 'symbol': symbol,
536
- 'percentage': true,
537
- 'tierBased': true,
538
- };
539
- if (market['quote'] in fiat) {
540
- fee['maker'] = makerFee2Fiat;
541
- fee['taker'] = takerFee2Fiat;
542
- }
543
- else if (market['contract']) {
544
- fee['maker'] = makerFee2Deriv;
545
- fee['taker'] = takerFee2Deriv;
546
- }
547
- else {
548
- fee['maker'] = makerFee;
549
- fee['taker'] = takerFee;
550
- }
551
- result[symbol] = fee;
552
- }
553
- return result;
554
- }
555
- async fetchMarkets(params = {}) {
556
- /**
557
- * @method
558
- * @name bitfinex#fetchMarkets
559
- * @description retrieves data on all markets for bitfinex
560
- * @param {object} [params] extra parameters specific to the exchange API endpoint
561
- * @returns {object[]} an array of objects representing market data
562
- */
563
- const ids = await this.publicGetSymbols();
564
- //
565
- // [ "btcusd", "ltcusd", "ltcbtc" ]
566
- //
567
- const details = await this.publicGetSymbolsDetails();
568
- //
569
- // [
570
- // {
571
- // "pair":"btcusd",
572
- // "price_precision":5,
573
- // "initial_margin":"10.0",
574
- // "minimum_margin":"5.0",
575
- // "maximum_order_size":"2000.0",
576
- // "minimum_order_size":"0.0002",
577
- // "expiration":"NA",
578
- // "margin":true
579
- // },
580
- // ]
581
- //
582
- const result = [];
583
- for (let i = 0; i < details.length; i++) {
584
- const market = details[i];
585
- let id = this.safeString(market, 'pair');
586
- if (!this.inArray(id, ids)) {
587
- continue;
588
- }
589
- id = id.toUpperCase();
590
- let baseId = undefined;
591
- let quoteId = undefined;
592
- if (id.indexOf(':') >= 0) {
593
- const parts = id.split(':');
594
- baseId = parts[0];
595
- quoteId = parts[1];
596
- }
597
- else {
598
- baseId = id.slice(0, 3);
599
- quoteId = id.slice(3, 6);
600
- }
601
- const base = this.safeCurrencyCode(baseId);
602
- const quote = this.safeCurrencyCode(quoteId);
603
- const symbol = base + '/' + quote;
604
- let type = 'spot';
605
- if (id.indexOf('F0') > -1) {
606
- type = 'swap';
607
- }
608
- result.push({
609
- 'id': id,
610
- 'symbol': symbol,
611
- 'base': base,
612
- 'quote': quote,
613
- 'settle': undefined,
614
- 'baseId': baseId,
615
- 'quoteId': quoteId,
616
- 'settleId': undefined,
617
- 'type': type,
618
- 'spot': (type === 'spot'),
619
- 'margin': this.safeValue(market, 'margin'),
620
- 'swap': (type === 'swap'),
621
- 'future': false,
622
- 'option': false,
623
- 'active': true,
624
- 'contract': (type === 'swap'),
625
- 'linear': undefined,
626
- 'inverse': undefined,
627
- 'contractSize': undefined,
628
- 'expiry': undefined,
629
- 'expiryDatetime': undefined,
630
- 'strike': undefined,
631
- 'optionType': undefined,
632
- 'precision': {
633
- // https://docs.bitfinex.com/docs/introduction#amount-precision
634
- // The amount field allows up to 8 decimals.
635
- // Anything exceeding this will be rounded to the 8th decimal.
636
- 'amount': parseInt('8'),
637
- 'price': this.safeInteger(market, 'price_precision'),
638
- },
639
- 'limits': {
640
- 'leverage': {
641
- 'min': undefined,
642
- 'max': undefined,
643
- },
644
- 'amount': {
645
- 'min': this.safeNumber(market, 'minimum_order_size'),
646
- 'max': this.safeNumber(market, 'maximum_order_size'),
647
- },
648
- 'price': {
649
- 'min': this.parseNumber('1e-8'),
650
- 'max': undefined,
651
- },
652
- 'cost': {
653
- 'min': undefined,
654
- 'max': undefined,
655
- },
656
- },
657
- 'created': undefined,
658
- 'info': market,
659
- });
660
- }
661
- return result;
662
- }
663
- amountToPrecision(symbol, amount) {
664
- // https://docs.bitfinex.com/docs/introduction#amount-precision
665
- // The amount field allows up to 8 decimals.
666
- // Anything exceeding this will be rounded to the 8th decimal.
667
- symbol = this.safeSymbol(symbol);
668
- return this.decimalToPrecision(amount, number.TRUNCATE, this.markets[symbol]['precision']['amount'], number.DECIMAL_PLACES);
669
- }
670
- priceToPrecision(symbol, price) {
671
- symbol = this.safeSymbol(symbol);
672
- price = this.decimalToPrecision(price, number.ROUND, this.markets[symbol]['precision']['price'], this.precisionMode);
673
- // https://docs.bitfinex.com/docs/introduction#price-precision
674
- // The precision level of all trading prices is based on significant figures.
675
- // All pairs on Bitfinex use up to 5 significant digits and up to 8 decimals (e.g. 1.2345, 123.45, 1234.5, 0.00012345).
676
- // Prices submit with a precision larger than 5 will be cut by the API.
677
- return this.decimalToPrecision(price, number.TRUNCATE, 8, number.DECIMAL_PLACES);
678
- }
679
- async fetchBalance(params = {}) {
680
- /**
681
- * @method
682
- * @name bitfinex#fetchBalance
683
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
684
- * @param {object} [params] extra parameters specific to the exchange API endpoint
685
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
686
- */
687
- await this.loadMarkets();
688
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
689
- const requestedType = this.safeString(params, 'type', 'exchange');
690
- const accountType = this.safeString(accountsByType, requestedType, requestedType);
691
- if (accountType === undefined) {
692
- const keys = Object.keys(accountsByType);
693
- throw new errors.ExchangeError(this.id + ' fetchBalance() type parameter must be one of ' + keys.join(', '));
694
- }
695
- const query = this.omit(params, 'type');
696
- const response = await this.privatePostBalances(query);
697
- // [ { type: "deposit",
698
- // "currency": "btc",
699
- // "amount": "0.00116721",
700
- // "available": "0.00116721" },
701
- // { type: "exchange",
702
- // "currency": "ust",
703
- // "amount": "0.0000002",
704
- // "available": "0.0000002" },
705
- // { type: "trading",
706
- // "currency": "btc",
707
- // "amount": "0.0005",
708
- // "available": "0.0005" } ],
709
- const result = { 'info': response };
710
- const isDerivative = requestedType === 'derivatives';
711
- for (let i = 0; i < response.length; i++) {
712
- const balance = response[i];
713
- const type = this.safeString(balance, 'type');
714
- const currencyId = this.safeStringLower(balance, 'currency', '');
715
- const start = currencyId.length - 2;
716
- const isDerivativeCode = currencyId.slice(start) === 'f0';
717
- // this will only filter the derivative codes if the requestedType is 'derivatives'
718
- const derivativeCondition = (!isDerivative || isDerivativeCode);
719
- if ((accountType === type) && derivativeCondition) {
720
- const code = this.safeCurrencyCode(currencyId);
721
- // bitfinex had BCH previously, now it's BAB, but the old
722
- // BCH symbol is kept for backward-compatibility
723
- // we need a workaround here so that the old BCH balance
724
- // would not override the new BAB balance (BAB is unified to BCH)
725
- // https://github.com/ccxt/ccxt/issues/4989
726
- if (!(code in result)) {
727
- const account = this.account();
728
- account['free'] = this.safeString(balance, 'available');
729
- account['total'] = this.safeString(balance, 'amount');
730
- result[code] = account;
731
- }
732
- }
733
- }
734
- return this.safeBalance(result);
735
- }
736
- async transfer(code, amount, fromAccount, toAccount, params = {}) {
737
- /**
738
- * @method
739
- * @name bitfinex#transfer
740
- * @description transfer currency internally between wallets on the same account
741
- * @param {string} code unified currency code
742
- * @param {float} amount amount to transfer
743
- * @param {string} fromAccount account to transfer from
744
- * @param {string} toAccount account to transfer to
745
- * @param {object} [params] extra parameters specific to the exchange API endpoint
746
- * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
747
- */
748
- // transferring between derivatives wallet and regular wallet is not documented in their API
749
- // however we support it in CCXT (from just looking at web inspector)
750
- await this.loadMarkets();
751
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
752
- const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
753
- const toId = this.safeString(accountsByType, toAccount, toAccount);
754
- const currency = this.currency(code);
755
- const fromCurrencyId = this.convertDerivativesId(currency['id'], fromAccount);
756
- const toCurrencyId = this.convertDerivativesId(currency['id'], toAccount);
757
- const requestedAmount = this.currencyToPrecision(code, amount);
758
- const request = {
759
- 'amount': requestedAmount,
760
- 'currency': fromCurrencyId,
761
- 'currency_to': toCurrencyId,
762
- 'walletfrom': fromId,
763
- 'walletto': toId,
764
- };
765
- const response = await this.privatePostTransfer(this.extend(request, params));
766
- //
767
- // [
768
- // {
769
- // "status": "success",
770
- // "message": "0.0001 Bitcoin transfered from Margin to Exchange"
771
- // }
772
- // ]
773
- //
774
- const result = this.safeValue(response, 0);
775
- const message = this.safeString(result, 'message');
776
- if (message === undefined) {
777
- throw new errors.ExchangeError(this.id + ' transfer failed');
778
- }
779
- return this.extend(this.parseTransfer(result, currency), {
780
- 'fromAccount': fromAccount,
781
- 'toAccount': toAccount,
782
- 'amount': this.parseNumber(requestedAmount),
783
- });
784
- }
785
- parseTransfer(transfer, currency = undefined) {
786
- //
787
- // {
788
- // "status": "success",
789
- // "message": "0.0001 Bitcoin transfered from Margin to Exchange"
790
- // }
791
- //
792
- return {
793
- 'info': transfer,
794
- 'id': undefined,
795
- 'timestamp': undefined,
796
- 'datetime': undefined,
797
- 'currency': this.safeCurrencyCode(undefined, currency),
798
- 'amount': undefined,
799
- 'fromAccount': undefined,
800
- 'toAccount': undefined,
801
- 'status': this.parseTransferStatus(this.safeString(transfer, 'status')),
802
- };
803
- }
804
- parseTransferStatus(status) {
805
- const statuses = {
806
- 'SUCCESS': 'ok',
807
- };
808
- return this.safeString(statuses, status, status);
809
- }
810
- convertDerivativesId(currencyId, type) {
811
- const start = currencyId.length - 2;
812
- const isDerivativeCode = currencyId.slice(start) === 'F0';
813
- if ((type !== 'derivatives' && type !== 'trading' && type !== 'margin') && isDerivativeCode) {
814
- currencyId = currencyId.slice(0, start);
815
- }
816
- else if (type === 'derivatives' && !isDerivativeCode) {
817
- currencyId = currencyId + 'F0';
818
- }
819
- return currencyId;
820
- }
821
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
822
- /**
823
- * @method
824
- * @name bitfinex#fetchOrderBook
825
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
826
- * @param {string} symbol unified symbol of the market to fetch the order book for
827
- * @param {int} [limit] the maximum amount of order book entries to return
828
- * @param {object} [params] extra parameters specific to the exchange API endpoint
829
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
830
- */
831
- await this.loadMarkets();
832
- const market = this.market(symbol);
833
- const request = {
834
- 'symbol': market['id'],
835
- };
836
- if (limit !== undefined) {
837
- request['limit_bids'] = limit;
838
- request['limit_asks'] = limit;
839
- }
840
- const response = await this.publicGetBookSymbol(this.extend(request, params));
841
- return this.parseOrderBook(response, market['symbol'], undefined, 'bids', 'asks', 'price', 'amount');
842
- }
843
- async fetchTickers(symbols = undefined, params = {}) {
844
- /**
845
- * @method
846
- * @name bitfinex#fetchTickers
847
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
848
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
849
- * @param {object} [params] extra parameters specific to the exchange API endpoint
850
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
851
- */
852
- await this.loadMarkets();
853
- symbols = this.marketSymbols(symbols);
854
- const response = await this.publicGetTickers(params);
855
- const result = {};
856
- for (let i = 0; i < response.length; i++) {
857
- const ticker = this.parseTicker(response[i]);
858
- const symbol = ticker['symbol'];
859
- result[symbol] = ticker;
860
- }
861
- return this.filterByArrayTickers(result, 'symbol', symbols);
862
- }
863
- async fetchTicker(symbol, params = {}) {
864
- /**
865
- * @method
866
- * @name bitfinex#fetchTicker
867
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
868
- * @param {string} symbol unified symbol of the market to fetch the ticker for
869
- * @param {object} [params] extra parameters specific to the exchange API endpoint
870
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
871
- */
872
- await this.loadMarkets();
873
- const market = this.market(symbol);
874
- const request = {
875
- 'symbol': market['id'],
876
- };
877
- const ticker = await this.publicGetPubtickerSymbol(this.extend(request, params));
878
- return this.parseTicker(ticker, market);
879
- }
880
- parseTicker(ticker, market = undefined) {
881
- const timestamp = this.safeTimestamp(ticker, 'timestamp');
882
- const marketId = this.safeString(ticker, 'pair');
883
- market = this.safeMarket(marketId, market);
884
- const symbol = market['symbol'];
885
- const last = this.safeString(ticker, 'last_price');
886
- return this.safeTicker({
887
- 'symbol': symbol,
888
- 'timestamp': timestamp,
889
- 'datetime': this.iso8601(timestamp),
890
- 'high': this.safeString(ticker, 'high'),
891
- 'low': this.safeString(ticker, 'low'),
892
- 'bid': this.safeString(ticker, 'bid'),
893
- 'bidVolume': undefined,
894
- 'ask': this.safeString(ticker, 'ask'),
895
- 'askVolume': undefined,
896
- 'vwap': undefined,
897
- 'open': undefined,
898
- 'close': last,
899
- 'last': last,
900
- 'previousClose': undefined,
901
- 'change': undefined,
902
- 'percentage': undefined,
903
- 'average': this.safeString(ticker, 'mid'),
904
- 'baseVolume': this.safeString(ticker, 'volume'),
905
- 'quoteVolume': undefined,
906
- 'info': ticker,
907
- }, market);
908
- }
909
- parseTrade(trade, market = undefined) {
910
- //
911
- // fetchTrades (public) v1
912
- //
913
- // {
914
- // "timestamp":1637258380,
915
- // "tid":894452833,
916
- // "price":"0.99941",
917
- // "amount":"261.38",
918
- // "exchange":"bitfinex",
919
- // "type":"sell"
920
- // }
921
- //
922
- // fetchMyTrades (private) v1
923
- //
924
- // {
925
- // "price":"0.99941",
926
- // "amount":"261.38",
927
- // "timestamp":"1637258380.0",
928
- // "type":"Sell",
929
- // "fee_currency":"UST",
930
- // "fee_amount":"-0.52245157",
931
- // "tid":894452833,
932
- // "order_id":78819731373
933
- // }
934
- //
935
- // {
936
- // "price":"0.99958",
937
- // "amount":"261.90514",
938
- // "timestamp":"1637258238.0",
939
- // "type":"Buy",
940
- // "fee_currency":"UDC",
941
- // "fee_amount":"-0.52381028",
942
- // "tid":894452800,
943
- // "order_id":78819504838
944
- // }
945
- //
946
- const id = this.safeString(trade, 'tid');
947
- const timestamp = this.safeTimestamp(trade, 'timestamp');
948
- const type = undefined;
949
- const side = this.safeStringLower(trade, 'type');
950
- const orderId = this.safeString(trade, 'order_id');
951
- const priceString = this.safeString(trade, 'price');
952
- const amountString = this.safeString(trade, 'amount');
953
- let fee = undefined;
954
- if ('fee_amount' in trade) {
955
- const feeCostString = Precise["default"].stringNeg(this.safeString(trade, 'fee_amount'));
956
- const feeCurrencyId = this.safeString(trade, 'fee_currency');
957
- const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
958
- fee = {
959
- 'cost': feeCostString,
960
- 'currency': feeCurrencyCode,
961
- };
962
- }
963
- return this.safeTrade({
964
- 'id': id,
965
- 'info': trade,
966
- 'timestamp': timestamp,
967
- 'datetime': this.iso8601(timestamp),
968
- 'symbol': market['symbol'],
969
- 'type': type,
970
- 'order': orderId,
971
- 'side': side,
972
- 'takerOrMaker': undefined,
973
- 'price': priceString,
974
- 'amount': amountString,
975
- 'cost': undefined,
976
- 'fee': fee,
977
- }, market);
978
- }
979
- async fetchTrades(symbol, since = undefined, limit = 50, params = {}) {
980
- /**
981
- * @method
982
- * @name bitfinex#fetchTrades
983
- * @description get the list of most recent trades for a particular symbol
984
- * @param {string} symbol unified symbol of the market to fetch trades for
985
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
986
- * @param {int} [limit] the maximum amount of trades to fetch
987
- * @param {object} [params] extra parameters specific to the exchange API endpoint
988
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
989
- */
990
- await this.loadMarkets();
991
- const market = this.market(symbol);
992
- const request = {
993
- 'symbol': market['id'],
994
- 'limit_trades': limit,
995
- };
996
- if (since !== undefined) {
997
- request['timestamp'] = this.parseToInt(since / 1000);
998
- }
999
- const response = await this.publicGetTradesSymbol(this.extend(request, params));
1000
- //
1001
- // [
1002
- // {
1003
- // "timestamp": "1694284565",
1004
- // "tid": "1415415034",
1005
- // "price": "25862.0",
1006
- // "amount": "0.00020685",
1007
- // "exchange": "bitfinex",
1008
- // "type": "buy"
1009
- // },
1010
- // ]
1011
- //
1012
- return this.parseTrades(response, market, since, limit);
1013
- }
1014
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1015
- /**
1016
- * @method
1017
- * @name bitfinex#fetchMyTrades
1018
- * @description fetch all trades made by the user
1019
- * @param {string} symbol unified market symbol
1020
- * @param {int} [since] the earliest time in ms to fetch trades for
1021
- * @param {int} [limit] the maximum number of trades structures to retrieve
1022
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1023
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1024
- */
1025
- if (symbol === undefined) {
1026
- throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
1027
- }
1028
- await this.loadMarkets();
1029
- const market = this.market(symbol);
1030
- const request = {
1031
- 'symbol': market['id'],
1032
- };
1033
- if (limit !== undefined) {
1034
- request['limit_trades'] = limit;
1035
- }
1036
- if (since !== undefined) {
1037
- request['timestamp'] = this.parseToInt(since / 1000);
1038
- }
1039
- const response = await this.privatePostMytrades(this.extend(request, params));
1040
- return this.parseTrades(response, market, since, limit);
1041
- }
1042
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1043
- /**
1044
- * @method
1045
- * @name bitfinex#createOrder
1046
- * @description create a trade order
1047
- * @param {string} symbol unified symbol of the market to create an order in
1048
- * @param {string} type 'market' or 'limit'
1049
- * @param {string} side 'buy' or 'sell'
1050
- * @param {float} amount how much of currency you want to trade in units of base currency
1051
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1052
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1053
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1054
- */
1055
- await this.loadMarkets();
1056
- const market = this.market(symbol);
1057
- const postOnly = this.safeValue(params, 'postOnly', false);
1058
- type = type.toLowerCase();
1059
- params = this.omit(params, ['postOnly']);
1060
- if (market['spot']) {
1061
- // although they claim that type needs to be 'exchange limit' or 'exchange market'
1062
- // in fact that's not the case for swap markets
1063
- type = this.safeStringLower(this.options['orderTypes'], type, type);
1064
- }
1065
- const request = {
1066
- 'symbol': market['id'],
1067
- 'side': side,
1068
- 'amount': this.amountToPrecision(symbol, amount),
1069
- 'type': type,
1070
- 'ocoorder': false,
1071
- 'buy_price_oco': 0,
1072
- 'sell_price_oco': 0,
1073
- };
1074
- if (type.indexOf('market') > -1) {
1075
- request['price'] = this.nonce().toString();
1076
- }
1077
- else {
1078
- request['price'] = this.priceToPrecision(symbol, price);
1079
- }
1080
- if (postOnly) {
1081
- request['is_postonly'] = true;
1082
- }
1083
- const response = await this.privatePostOrderNew(this.extend(request, params));
1084
- return this.parseOrder(response, market);
1085
- }
1086
- async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1087
- await this.loadMarkets();
1088
- const order = {
1089
- 'order_id': parseInt(id),
1090
- };
1091
- if (price !== undefined) {
1092
- order['price'] = this.priceToPrecision(symbol, price);
1093
- }
1094
- if (amount !== undefined) {
1095
- order['amount'] = this.numberToString(amount);
1096
- }
1097
- if (symbol !== undefined) {
1098
- order['symbol'] = this.marketId(symbol);
1099
- }
1100
- if (side !== undefined) {
1101
- order['side'] = side;
1102
- }
1103
- if (type !== undefined) {
1104
- order['type'] = this.safeString(this.options['orderTypes'], type, type);
1105
- }
1106
- const response = await this.privatePostOrderCancelReplace(this.extend(order, params));
1107
- return this.parseOrder(response);
1108
- }
1109
- async cancelOrder(id, symbol = undefined, params = {}) {
1110
- /**
1111
- * @method
1112
- * @name bitfinex#cancelOrder
1113
- * @description cancels an open order
1114
- * @param {string} id order id
1115
- * @param {string} symbol not used by bitfinex cancelOrder ()
1116
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1117
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1118
- */
1119
- await this.loadMarkets();
1120
- const request = {
1121
- 'order_id': parseInt(id),
1122
- };
1123
- return await this.privatePostOrderCancel(this.extend(request, params));
1124
- }
1125
- async cancelAllOrders(symbol = undefined, params = {}) {
1126
- /**
1127
- * @method
1128
- * @name bitfinex#cancelAllOrders
1129
- * @description cancel all open orders
1130
- * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
1131
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1132
- * @returns {object} response from exchange
1133
- */
1134
- return await this.privatePostOrderCancelAll(params);
1135
- }
1136
- parseOrder(order, market = undefined) {
1137
- //
1138
- // {
1139
- // "id": 57334010955,
1140
- // "cid": 1611584840966,
1141
- // "cid_date": null,
1142
- // "gid": null,
1143
- // "symbol": "ltcbtc",
1144
- // "exchange": null,
1145
- // "price": "0.0042125",
1146
- // "avg_execution_price": "0.0042097",
1147
- // "side": "sell",
1148
- // "type": "exchange market",
1149
- // "timestamp": "1611584841.0",
1150
- // "is_live": false,
1151
- // "is_cancelled": false,
1152
- // "is_hidden": 0,
1153
- // "oco_order": 0,
1154
- // "was_forced": false,
1155
- // "original_amount": "0.205176",
1156
- // "remaining_amount": "0.0",
1157
- // "executed_amount": "0.205176",
1158
- // "src": "web"
1159
- // }
1160
- //
1161
- const side = this.safeString(order, 'side');
1162
- const open = this.safeValue(order, 'is_live');
1163
- const canceled = this.safeValue(order, 'is_cancelled');
1164
- let status = undefined;
1165
- if (open) {
1166
- status = 'open';
1167
- }
1168
- else if (canceled) {
1169
- status = 'canceled';
1170
- }
1171
- else {
1172
- status = 'closed';
1173
- }
1174
- const marketId = this.safeStringUpper(order, 'symbol');
1175
- const symbol = this.safeSymbol(marketId, market);
1176
- let orderType = this.safeString(order, 'type', '');
1177
- const exchange = orderType.indexOf('exchange ') >= 0;
1178
- if (exchange) {
1179
- const parts = order['type'].split(' ');
1180
- orderType = parts[1];
1181
- }
1182
- const timestamp = this.safeTimestamp(order, 'timestamp');
1183
- const id = this.safeString(order, 'id');
1184
- return this.safeOrder({
1185
- 'info': order,
1186
- 'id': id,
1187
- 'clientOrderId': undefined,
1188
- 'timestamp': timestamp,
1189
- 'datetime': this.iso8601(timestamp),
1190
- 'lastTradeTimestamp': undefined,
1191
- 'symbol': symbol,
1192
- 'type': orderType,
1193
- 'timeInForce': undefined,
1194
- 'postOnly': undefined,
1195
- 'side': side,
1196
- 'price': this.safeString(order, 'price'),
1197
- 'stopPrice': undefined,
1198
- 'triggerPrice': undefined,
1199
- 'average': this.safeString(order, 'avg_execution_price'),
1200
- 'amount': this.safeString(order, 'original_amount'),
1201
- 'remaining': this.safeString(order, 'remaining_amount'),
1202
- 'filled': this.safeString(order, 'executed_amount'),
1203
- 'status': status,
1204
- 'fee': undefined,
1205
- 'cost': undefined,
1206
- 'trades': undefined,
1207
- }, market);
1208
- }
1209
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1210
- /**
1211
- * @method
1212
- * @name bitfinex#fetchOpenOrders
1213
- * @description fetch all unfilled currently open orders
1214
- * @param {string} symbol unified market symbol
1215
- * @param {int} [since] the earliest time in ms to fetch open orders for
1216
- * @param {int} [limit] the maximum number of open orders structures to retrieve
1217
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1218
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1219
- */
1220
- await this.loadMarkets();
1221
- if (symbol !== undefined) {
1222
- if (!(symbol in this.markets)) {
1223
- throw new errors.ExchangeError(this.id + ' has no symbol ' + symbol);
1224
- }
1225
- }
1226
- const response = await this.privatePostOrders(params);
1227
- let orders = this.parseOrders(response, undefined, since, limit);
1228
- if (symbol !== undefined) {
1229
- orders = this.filterBy(orders, 'symbol', symbol);
1230
- }
1231
- return orders;
1232
- }
1233
- async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1234
- /**
1235
- * @method
1236
- * @name bitfinex#fetchClosedOrders
1237
- * @description fetches information on multiple closed orders made by the user
1238
- * @param {string} symbol unified market symbol of the market orders were made in
1239
- * @param {int} [since] the earliest time in ms to fetch orders for
1240
- * @param {int} [limit] the maximum number of order structures to retrieve
1241
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1242
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1243
- */
1244
- await this.loadMarkets();
1245
- symbol = this.symbol(symbol);
1246
- const request = {};
1247
- if (limit !== undefined) {
1248
- request['limit'] = limit;
1249
- }
1250
- const response = await this.privatePostOrdersHist(this.extend(request, params));
1251
- let orders = this.parseOrders(response, undefined, since, limit);
1252
- if (symbol !== undefined) {
1253
- orders = this.filterBy(orders, 'symbol', symbol);
1254
- }
1255
- orders = this.filterByArray(orders, 'status', ['closed', 'canceled'], false);
1256
- return orders;
1257
- }
1258
- async fetchOrder(id, symbol = undefined, params = {}) {
1259
- /**
1260
- * @method
1261
- * @name bitfinex#fetchOrder
1262
- * @description fetches information on an order made by the user
1263
- * @param {string} symbol not used by bitfinex fetchOrder
1264
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1265
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1266
- */
1267
- await this.loadMarkets();
1268
- const request = {
1269
- 'order_id': parseInt(id),
1270
- };
1271
- const response = await this.privatePostOrderStatus(this.extend(request, params));
1272
- return this.parseOrder(response);
1273
- }
1274
- parseOHLCV(ohlcv, market = undefined) {
1275
- //
1276
- // [
1277
- // 1457539800000,
1278
- // 0.02594,
1279
- // 0.02594,
1280
- // 0.02594,
1281
- // 0.02594,
1282
- // 0.1
1283
- // ]
1284
- //
1285
- return [
1286
- this.safeInteger(ohlcv, 0),
1287
- this.safeNumber(ohlcv, 1),
1288
- this.safeNumber(ohlcv, 3),
1289
- this.safeNumber(ohlcv, 4),
1290
- this.safeNumber(ohlcv, 2),
1291
- this.safeNumber(ohlcv, 5),
1292
- ];
1293
- }
1294
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1295
- /**
1296
- * @method
1297
- * @name bitfinex#fetchOHLCV
1298
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1299
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1300
- * @param {string} timeframe the length of time each candle represents
1301
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
1302
- * @param {int} [limit] the maximum amount of candles to fetch
1303
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1304
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1305
- */
1306
- await this.loadMarkets();
1307
- if (limit === undefined) {
1308
- limit = 100;
1309
- }
1310
- const market = this.market(symbol);
1311
- const v2id = 't' + market['id'];
1312
- const request = {
1313
- 'symbol': v2id,
1314
- 'timeframe': this.safeString(this.timeframes, timeframe, timeframe),
1315
- 'sort': 1,
1316
- 'limit': limit,
1317
- };
1318
- if (since !== undefined) {
1319
- request['start'] = since;
1320
- }
1321
- const response = await this.v2GetCandlesTradeTimeframeSymbolHist(this.extend(request, params));
1322
- //
1323
- // [
1324
- // [1457539800000,0.02594,0.02594,0.02594,0.02594,0.1],
1325
- // [1457547300000,0.02577,0.02577,0.02577,0.02577,0.01],
1326
- // [1457550240000,0.0255,0.0253,0.0255,0.0252,3.2640000000000002],
1327
- // ]
1328
- //
1329
- return this.parseOHLCVs(response, market, timeframe, since, limit);
1330
- }
1331
- getCurrencyName(code) {
1332
- // todo rewrite for https://api-pub.bitfinex.com//v2/conf/pub:map:tx:method
1333
- if (code in this.options['currencyNames']) {
1334
- return this.options['currencyNames'][code];
1335
- }
1336
- throw new errors.NotSupported(this.id + ' ' + code + ' not supported for withdrawal');
1337
- }
1338
- async createDepositAddress(code, params = {}) {
1339
- /**
1340
- * @method
1341
- * @name bitfinex#createDepositAddress
1342
- * @description create a currency deposit address
1343
- * @param {string} code unified currency code of the currency for the deposit address
1344
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1345
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1346
- */
1347
- await this.loadMarkets();
1348
- const request = {
1349
- 'renew': 1,
1350
- };
1351
- return await this.fetchDepositAddress(code, this.extend(request, params));
1352
- }
1353
- async fetchDepositAddress(code, params = {}) {
1354
- /**
1355
- * @method
1356
- * @name bitfinex#fetchDepositAddress
1357
- * @description fetch the deposit address for a currency associated with this account
1358
- * @param {string} code unified currency code
1359
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1360
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1361
- */
1362
- await this.loadMarkets();
1363
- // todo rewrite for https://api-pub.bitfinex.com//v2/conf/pub:map:tx:method
1364
- const name = this.getCurrencyName(code);
1365
- const request = {
1366
- 'method': name,
1367
- 'wallet_name': 'exchange',
1368
- 'renew': 0, // a value of 1 will generate a new address
1369
- };
1370
- const response = await this.privatePostDepositNew(this.extend(request, params));
1371
- let address = this.safeValue(response, 'address');
1372
- let tag = undefined;
1373
- if ('address_pool' in response) {
1374
- tag = address;
1375
- address = response['address_pool'];
1376
- }
1377
- this.checkAddress(address);
1378
- return {
1379
- 'currency': code,
1380
- 'address': address,
1381
- 'tag': tag,
1382
- 'network': undefined,
1383
- 'info': response,
1384
- };
1385
- }
1386
- async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1387
- /**
1388
- * @method
1389
- * @name bitfinex#fetchDepositsWithdrawals
1390
- * @description fetch history of deposits and withdrawals
1391
- * @param {string} code unified currency code for the currency of the deposit/withdrawals
1392
- * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
1393
- * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
1394
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1395
- * @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1396
- */
1397
- await this.loadMarkets();
1398
- let currencyId = this.safeString(params, 'currency');
1399
- const query = this.omit(params, 'currency');
1400
- let currency = undefined;
1401
- if (currencyId === undefined) {
1402
- if (code === undefined) {
1403
- throw new errors.ArgumentsRequired(this.id + ' fetchDepositsWithdrawals() requires a currency `code` argument or a `currency` parameter');
1404
- }
1405
- else {
1406
- currency = this.currency(code);
1407
- currencyId = currency['id'];
1408
- }
1409
- }
1410
- query['currency'] = currencyId;
1411
- if (since !== undefined) {
1412
- query['since'] = this.parseToInt(since / 1000);
1413
- }
1414
- const response = await this.privatePostHistoryMovements(this.extend(query, params));
1415
- //
1416
- // [
1417
- // {
1418
- // "id": 581183,
1419
- // "txid": 123456,
1420
- // "currency": "BTC",
1421
- // "method": "BITCOIN",
1422
- // "type": "WITHDRAWAL",
1423
- // "amount": ".01",
1424
- // "description": "3QXYWgRGX2BPYBpUDBssGbeWEa5zq6snBZ, offchain transfer ",
1425
- // "address": "3QXYWgRGX2BPYBpUDBssGbeWEa5zq6snBZ",
1426
- // "status": "COMPLETED",
1427
- // "timestamp": "1443833327.0",
1428
- // "timestamp_created": "1443833327.1",
1429
- // "fee": 0.1,
1430
- // }
1431
- // ]
1432
- //
1433
- return this.parseTransactions(response, currency, since, limit);
1434
- }
1435
- parseTransaction(transaction, currency = undefined) {
1436
- //
1437
- // crypto
1438
- //
1439
- // {
1440
- // "id": 12042490,
1441
- // "fee": "-0.02",
1442
- // "txid": "EA5B5A66000B66855865EFF2494D7C8D1921FCBE996482157EBD749F2C85E13D",
1443
- // "type": "DEPOSIT",
1444
- // "amount": "2099.849999",
1445
- // "method": "RIPPLE",
1446
- // "status": "COMPLETED",
1447
- // "address": "2505189261",
1448
- // "currency": "XRP",
1449
- // "timestamp": "1551730524.0",
1450
- // "description": "EA5B5A66000B66855865EFF2494D7C8D1921FCBE996482157EBD749F2C85E13D",
1451
- // "timestamp_created": "1551730523.0"
1452
- // }
1453
- //
1454
- // fiat
1455
- //
1456
- // {
1457
- // "id": 12725095,
1458
- // "fee": "-60.0",
1459
- // "txid": null,
1460
- // "type": "WITHDRAWAL",
1461
- // "amount": "9943.0",
1462
- // "method": "WIRE",
1463
- // "status": "SENDING",
1464
- // "address": null,
1465
- // "currency": "EUR",
1466
- // "timestamp": "1561802484.0",
1467
- // "description": "Name: bob, AccountAddress: some address, Account: someaccountno, Bank: bank address, SWIFT: foo, Country: UK, Details of Payment: withdrawal name, Intermediary Bank Name: , Intermediary Bank Address: , Intermediary Bank City: , Intermediary Bank Country: , Intermediary Bank Account: , Intermediary Bank SWIFT: , Fee: -60.0",
1468
- // "timestamp_created": "1561716066.0"
1469
- // }
1470
- //
1471
- // withdraw
1472
- //
1473
- // {
1474
- // "status": "success",
1475
- // "message": "Your withdrawal request has been successfully submitted.",
1476
- // "withdrawal_id": 586829
1477
- // }
1478
- //
1479
- const timestamp = this.safeTimestamp(transaction, 'timestamp_created');
1480
- const currencyId = this.safeString(transaction, 'currency');
1481
- const code = this.safeCurrencyCode(currencyId, currency);
1482
- let feeCost = this.safeString(transaction, 'fee');
1483
- if (feeCost !== undefined) {
1484
- feeCost = Precise["default"].stringAbs(feeCost);
1485
- }
1486
- return {
1487
- 'info': transaction,
1488
- 'id': this.safeString2(transaction, 'id', 'withdrawal_id'),
1489
- 'txid': this.safeString(transaction, 'txid'),
1490
- 'type': this.safeStringLower(transaction, 'type'),
1491
- 'currency': code,
1492
- 'network': undefined,
1493
- 'amount': this.safeNumber(transaction, 'amount'),
1494
- 'status': this.parseTransactionStatus(this.safeString(transaction, 'status')),
1495
- 'timestamp': timestamp,
1496
- 'datetime': this.iso8601(timestamp),
1497
- 'address': this.safeString(transaction, 'address'),
1498
- 'addressFrom': undefined,
1499
- 'addressTo': undefined,
1500
- 'tag': this.safeString(transaction, 'description'),
1501
- 'tagFrom': undefined,
1502
- 'tagTo': undefined,
1503
- 'updated': this.safeTimestamp(transaction, 'timestamp'),
1504
- 'comment': undefined,
1505
- 'internal': undefined,
1506
- 'fee': {
1507
- 'currency': code,
1508
- 'cost': this.parseNumber(feeCost),
1509
- 'rate': undefined,
1510
- },
1511
- };
1512
- }
1513
- parseTransactionStatus(status) {
1514
- const statuses = {
1515
- 'SENDING': 'pending',
1516
- 'CANCELED': 'canceled',
1517
- 'ZEROCONFIRMED': 'failed',
1518
- 'COMPLETED': 'ok',
1519
- };
1520
- return this.safeString(statuses, status, status);
1521
- }
1522
- async withdraw(code, amount, address, tag = undefined, params = {}) {
1523
- /**
1524
- * @method
1525
- * @name bitfinex#withdraw
1526
- * @description make a withdrawal
1527
- * @param {string} code unified currency code
1528
- * @param {float} amount the amount to withdraw
1529
- * @param {string} address the address to withdraw to
1530
- * @param {string} tag
1531
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1532
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1533
- */
1534
- [tag, params] = this.handleWithdrawTagAndParams(tag, params);
1535
- this.checkAddress(address);
1536
- await this.loadMarkets();
1537
- // todo rewrite for https://api-pub.bitfinex.com//v2/conf/pub:map:tx:method
1538
- const name = this.getCurrencyName(code);
1539
- const currency = this.currency(code);
1540
- const request = {
1541
- 'withdraw_type': name,
1542
- 'walletselected': 'exchange',
1543
- 'amount': this.numberToString(amount),
1544
- 'address': address,
1545
- };
1546
- if (tag !== undefined) {
1547
- request['payment_id'] = tag;
1548
- }
1549
- const responses = await this.privatePostWithdraw(this.extend(request, params));
1550
- //
1551
- // [
1552
- // {
1553
- // "status":"success",
1554
- // "message":"Your withdrawal request has been successfully submitted.",
1555
- // "withdrawal_id":586829
1556
- // }
1557
- // ]
1558
- //
1559
- const response = this.safeValue(responses, 0, {});
1560
- const id = this.safeNumber(response, 'withdrawal_id');
1561
- const message = this.safeString(response, 'message');
1562
- const errorMessage = this.findBroadlyMatchedKey(this.exceptions['broad'], message);
1563
- if (id === 0) {
1564
- if (errorMessage !== undefined) {
1565
- const ExceptionClass = this.exceptions['broad'][errorMessage];
1566
- throw new ExceptionClass(this.id + ' ' + message);
1567
- }
1568
- throw new errors.ExchangeError(this.id + ' withdraw returned an id of zero: ' + this.json(response));
1569
- }
1570
- return this.parseTransaction(response, currency);
1571
- }
1572
- async fetchPositions(symbols = undefined, params = {}) {
1573
- /**
1574
- * @method
1575
- * @name bitfinex#fetchPositions
1576
- * @description fetch all open positions
1577
- * @param {string[]|undefined} symbols list of unified market symbols
1578
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1579
- * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
1580
- */
1581
- await this.loadMarkets();
1582
- const response = await this.privatePostPositions(params);
1583
- //
1584
- // [
1585
- // {
1586
- // "id":943715,
1587
- // "symbol":"btcusd",
1588
- // "status":"ACTIVE",
1589
- // "base":"246.94",
1590
- // "amount":"1.0",
1591
- // "timestamp":"1444141857.0",
1592
- // "swap":"0.0",
1593
- // "pl":"-2.22042"
1594
- // }
1595
- // ]
1596
- //
1597
- // todo unify parsePosition/parsePositions
1598
- return response;
1599
- }
1600
- nonce() {
1601
- return this.milliseconds();
1602
- }
1603
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1604
- let request = '/' + this.implodeParams(path, params);
1605
- if (api === 'v2') {
1606
- request = '/' + api + request;
1607
- }
1608
- else {
1609
- request = '/' + this.version + request;
1610
- }
1611
- let query = this.omit(params, this.extractParams(path));
1612
- let url = this.urls['api'][api] + request;
1613
- if ((api === 'public') || (path.indexOf('/hist') >= 0)) {
1614
- if (Object.keys(query).length) {
1615
- const suffix = '?' + this.urlencode(query);
1616
- url += suffix;
1617
- request += suffix;
1618
- }
1619
- }
1620
- if (api === 'private') {
1621
- this.checkRequiredCredentials();
1622
- const nonce = this.nonce();
1623
- query = this.extend({
1624
- 'nonce': nonce.toString(),
1625
- 'request': request,
1626
- }, query);
1627
- body = this.json(query);
1628
- const payload = this.stringToBase64(body);
1629
- const secret = this.encode(this.secret);
1630
- const signature = this.hmac(this.encode(payload), secret, sha512.sha384);
1631
- headers = {
1632
- 'X-BFX-APIKEY': this.apiKey,
1633
- 'X-BFX-PAYLOAD': payload,
1634
- 'X-BFX-SIGNATURE': signature,
1635
- 'Content-Type': 'application/json',
1636
- };
1637
- }
1638
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1639
- }
1640
- handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1641
- if (response === undefined) {
1642
- return undefined;
1643
- }
1644
- let throwError = false;
1645
- if (code >= 400) {
1646
- if (body[0] === '{') {
1647
- throwError = true;
1648
- }
1649
- }
1650
- else {
1651
- // json response with error, i.e:
1652
- // [{"status":"error","message":"Momentary balance check. Please wait few seconds and try the transfer again."}]
1653
- const responseObject = this.safeValue(response, 0, {});
1654
- const status = this.safeString(responseObject, 'status', '');
1655
- if (status === 'error') {
1656
- throwError = true;
1657
- }
1658
- }
1659
- if (throwError) {
1660
- const feedback = this.id + ' ' + body;
1661
- const message = this.safeString2(response, 'message', 'error');
1662
- this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
1663
- this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
1664
- throw new errors.ExchangeError(feedback); // unknown message
1665
- }
1666
- return undefined;
1667
- }
1668
- }
1669
-
1670
- module.exports = bitfinex;