ccxt 4.2.18 → 4.2.20

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 (446) hide show
  1. package/README.md +100 -100
  2. package/dist/ccxt.browser.js +34240 -33297
  3. package/dist/ccxt.browser.min.js +2 -2
  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 +276 -27
  8. package/dist/cjs/src/bigone.js +434 -168
  9. package/dist/cjs/src/binance.js +165 -35
  10. package/dist/cjs/src/binanceus.js +25 -0
  11. package/dist/cjs/src/bingx.js +185 -42
  12. package/dist/cjs/src/bitfinex.js +2 -3
  13. package/dist/cjs/src/bitget.js +84 -47
  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/bitteam.js +1 -1
  19. package/dist/cjs/src/bybit.js +27 -75
  20. package/dist/cjs/src/coinbase.js +176 -26
  21. package/dist/cjs/src/coincheck.js +1 -0
  22. package/dist/cjs/src/coinex.js +3 -0
  23. package/dist/cjs/src/coinlist.js +13 -6
  24. package/dist/cjs/src/coinone.js +2 -2
  25. package/dist/cjs/src/coinsph.js +4 -5
  26. package/dist/cjs/src/delta.js +7 -19
  27. package/dist/cjs/src/deribit.js +17 -4
  28. package/dist/cjs/src/gate.js +151 -194
  29. package/dist/cjs/src/gemini.js +1 -1
  30. package/dist/cjs/src/hitbtc.js +2 -3
  31. package/dist/cjs/src/htx.js +157 -7
  32. package/dist/cjs/src/huobijp.js +2 -3
  33. package/dist/cjs/src/independentreserve.js +7 -5
  34. package/dist/cjs/src/kraken.js +86 -54
  35. package/dist/cjs/src/kucoin.js +5 -0
  36. package/dist/cjs/src/kucoinfutures.js +140 -86
  37. package/dist/cjs/src/lbank.js +60 -33
  38. package/dist/cjs/src/luno.js +84 -2
  39. package/dist/cjs/src/mexc.js +3 -3
  40. package/dist/cjs/src/oceanex.js +1 -1
  41. package/dist/cjs/src/okx.js +23 -29
  42. package/dist/cjs/{js/src/bitpanda.js → src/onetrading.js} +39 -39
  43. package/dist/cjs/src/phemex.js +37 -27
  44. package/dist/cjs/src/poloniexfutures.js +1 -0
  45. package/dist/cjs/src/pro/binance.js +66 -25
  46. package/dist/cjs/src/pro/bitget.js +1 -1
  47. package/dist/cjs/src/pro/bitpanda.js +5 -1330
  48. package/dist/cjs/src/pro/coinbase.js +4 -1
  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 +11 -2
  67. package/js/ccxt.js +8 -2
  68. package/js/src/abstract/binance.d.ts +1 -0
  69. package/js/src/abstract/binancecoinm.d.ts +1 -0
  70. package/js/src/abstract/binanceus.d.ts +1 -0
  71. package/js/src/abstract/binanceusdm.d.ts +1 -0
  72. package/js/src/abstract/bitpanda.d.ts +4 -4
  73. package/js/src/abstract/bitpanda.js +3 -3
  74. package/js/src/abstract/bitstamp.d.ts +8 -0
  75. package/js/src/abstract/gate.d.ts +1 -0
  76. package/js/src/abstract/gateio.d.ts +1 -0
  77. package/js/src/abstract/htx.d.ts +3 -0
  78. package/js/src/abstract/huobi.d.ts +3 -0
  79. package/js/src/abstract/luno.d.ts +1 -0
  80. package/js/src/abstract/onetrading.d.ts +38 -0
  81. package/js/src/abstract/onetrading.js +11 -0
  82. package/js/src/ascendex.js +2 -0
  83. package/js/src/base/Exchange.d.ts +3 -0
  84. package/js/src/base/Exchange.js +10 -0
  85. package/js/src/binance.js +2 -1
  86. package/js/src/binanceus.js +17 -0
  87. package/js/src/bingx.js +3 -2
  88. package/js/src/bitget.d.ts +1 -1
  89. package/js/src/bitget.js +47 -34
  90. package/js/src/bitpanda.d.ts +2 -72
  91. package/js/src/bitpanda.js +5 -1991
  92. package/js/src/bitstamp.js +8 -0
  93. package/js/src/bitteam.js +1 -1
  94. package/js/src/bybit.d.ts +0 -1
  95. package/js/src/bybit.js +1 -29
  96. package/js/src/delta.d.ts +0 -1
  97. package/js/src/delta.js +0 -18
  98. package/js/src/deribit.js +11 -3
  99. package/js/src/gate.d.ts +1 -1
  100. package/js/src/gate.js +50 -135
  101. package/js/src/htx.js +3 -0
  102. package/js/src/kraken.d.ts +1 -0
  103. package/js/src/kraken.js +39 -38
  104. package/js/src/kucoinfutures.d.ts +6 -6
  105. package/js/src/kucoinfutures.js +9 -9
  106. package/js/src/lbank.js +1 -0
  107. package/js/src/luno.d.ts +3 -1
  108. package/js/src/luno.js +84 -2
  109. package/js/src/mexc.js +1 -2
  110. package/js/src/okx.d.ts +0 -1
  111. package/js/src/okx.js +0 -18
  112. package/js/src/onetrading.d.ts +74 -0
  113. package/js/src/onetrading.js +2003 -0
  114. package/js/src/poloniexfutures.js +1 -0
  115. package/js/src/pro/binance.js +6 -1
  116. package/js/src/pro/bitpanda.d.ts +2 -34
  117. package/js/src/pro/bitpanda.js +5 -1330
  118. package/js/src/pro/lbank.d.ts +29 -0
  119. package/js/src/pro/lbank.js +882 -0
  120. package/js/src/pro/onetrading.d.ts +36 -0
  121. package/js/src/pro/onetrading.js +1339 -0
  122. package/package.json +2 -2
  123. package/rollup.config.js +2 -0
  124. package/skip-tests.json +4 -2
  125. package/test-commonjs.cjs +25 -1
  126. package/dist/cjs/js/ccxt.js +0 -478
  127. package/dist/cjs/js/src/abstract/alpaca.js +0 -9
  128. package/dist/cjs/js/src/abstract/ascendex.js +0 -9
  129. package/dist/cjs/js/src/abstract/bigone.js +0 -9
  130. package/dist/cjs/js/src/abstract/binance.js +0 -9
  131. package/dist/cjs/js/src/abstract/bingx.js +0 -9
  132. package/dist/cjs/js/src/abstract/bit2c.js +0 -9
  133. package/dist/cjs/js/src/abstract/bitbank.js +0 -9
  134. package/dist/cjs/js/src/abstract/bitbns.js +0 -9
  135. package/dist/cjs/js/src/abstract/bitfinex.js +0 -9
  136. package/dist/cjs/js/src/abstract/bitfinex2.js +0 -9
  137. package/dist/cjs/js/src/abstract/bitflyer.js +0 -9
  138. package/dist/cjs/js/src/abstract/bitforex.js +0 -9
  139. package/dist/cjs/js/src/abstract/bitget.js +0 -9
  140. package/dist/cjs/js/src/abstract/bithumb.js +0 -9
  141. package/dist/cjs/js/src/abstract/bitmart.js +0 -9
  142. package/dist/cjs/js/src/abstract/bitmex.js +0 -9
  143. package/dist/cjs/js/src/abstract/bitopro.js +0 -9
  144. package/dist/cjs/js/src/abstract/bitpanda.js +0 -9
  145. package/dist/cjs/js/src/abstract/bitrue.js +0 -9
  146. package/dist/cjs/js/src/abstract/bitso.js +0 -9
  147. package/dist/cjs/js/src/abstract/bitstamp.js +0 -9
  148. package/dist/cjs/js/src/abstract/bitteam.js +0 -9
  149. package/dist/cjs/js/src/abstract/bitvavo.js +0 -9
  150. package/dist/cjs/js/src/abstract/bl3p.js +0 -9
  151. package/dist/cjs/js/src/abstract/blockchaincom.js +0 -9
  152. package/dist/cjs/js/src/abstract/btcalpha.js +0 -9
  153. package/dist/cjs/js/src/abstract/btcbox.js +0 -9
  154. package/dist/cjs/js/src/abstract/btcmarkets.js +0 -9
  155. package/dist/cjs/js/src/abstract/btcturk.js +0 -9
  156. package/dist/cjs/js/src/abstract/bybit.js +0 -9
  157. package/dist/cjs/js/src/abstract/cex.js +0 -9
  158. package/dist/cjs/js/src/abstract/coinbase.js +0 -9
  159. package/dist/cjs/js/src/abstract/coinbasepro.js +0 -9
  160. package/dist/cjs/js/src/abstract/coincheck.js +0 -9
  161. package/dist/cjs/js/src/abstract/coinex.js +0 -9
  162. package/dist/cjs/js/src/abstract/coinlist.js +0 -9
  163. package/dist/cjs/js/src/abstract/coinmate.js +0 -9
  164. package/dist/cjs/js/src/abstract/coinone.js +0 -9
  165. package/dist/cjs/js/src/abstract/coinsph.js +0 -9
  166. package/dist/cjs/js/src/abstract/coinspot.js +0 -9
  167. package/dist/cjs/js/src/abstract/cryptocom.js +0 -9
  168. package/dist/cjs/js/src/abstract/currencycom.js +0 -9
  169. package/dist/cjs/js/src/abstract/delta.js +0 -9
  170. package/dist/cjs/js/src/abstract/deribit.js +0 -9
  171. package/dist/cjs/js/src/abstract/digifinex.js +0 -9
  172. package/dist/cjs/js/src/abstract/exmo.js +0 -9
  173. package/dist/cjs/js/src/abstract/gate.js +0 -9
  174. package/dist/cjs/js/src/abstract/gemini.js +0 -9
  175. package/dist/cjs/js/src/abstract/hitbtc.js +0 -9
  176. package/dist/cjs/js/src/abstract/hollaex.js +0 -9
  177. package/dist/cjs/js/src/abstract/htx.js +0 -9
  178. package/dist/cjs/js/src/abstract/huobijp.js +0 -9
  179. package/dist/cjs/js/src/abstract/idex.js +0 -9
  180. package/dist/cjs/js/src/abstract/independentreserve.js +0 -9
  181. package/dist/cjs/js/src/abstract/indodax.js +0 -9
  182. package/dist/cjs/js/src/abstract/kraken.js +0 -9
  183. package/dist/cjs/js/src/abstract/krakenfutures.js +0 -9
  184. package/dist/cjs/js/src/abstract/kucoin.js +0 -9
  185. package/dist/cjs/js/src/abstract/kucoinfutures.js +0 -9
  186. package/dist/cjs/js/src/abstract/kuna.js +0 -9
  187. package/dist/cjs/js/src/abstract/latoken.js +0 -9
  188. package/dist/cjs/js/src/abstract/lbank.js +0 -9
  189. package/dist/cjs/js/src/abstract/luno.js +0 -9
  190. package/dist/cjs/js/src/abstract/lykke.js +0 -9
  191. package/dist/cjs/js/src/abstract/mercado.js +0 -9
  192. package/dist/cjs/js/src/abstract/mexc.js +0 -9
  193. package/dist/cjs/js/src/abstract/ndax.js +0 -9
  194. package/dist/cjs/js/src/abstract/novadax.js +0 -9
  195. package/dist/cjs/js/src/abstract/oceanex.js +0 -9
  196. package/dist/cjs/js/src/abstract/okcoin.js +0 -9
  197. package/dist/cjs/js/src/abstract/okx.js +0 -9
  198. package/dist/cjs/js/src/abstract/p2b.js +0 -9
  199. package/dist/cjs/js/src/abstract/paymium.js +0 -9
  200. package/dist/cjs/js/src/abstract/phemex.js +0 -9
  201. package/dist/cjs/js/src/abstract/poloniex.js +0 -9
  202. package/dist/cjs/js/src/abstract/poloniexfutures.js +0 -9
  203. package/dist/cjs/js/src/abstract/probit.js +0 -9
  204. package/dist/cjs/js/src/abstract/timex.js +0 -9
  205. package/dist/cjs/js/src/abstract/tokocrypto.js +0 -9
  206. package/dist/cjs/js/src/abstract/upbit.js +0 -9
  207. package/dist/cjs/js/src/abstract/wavesexchange.js +0 -9
  208. package/dist/cjs/js/src/abstract/wazirx.js +0 -9
  209. package/dist/cjs/js/src/abstract/whitebit.js +0 -9
  210. package/dist/cjs/js/src/abstract/woo.js +0 -9
  211. package/dist/cjs/js/src/abstract/yobit.js +0 -9
  212. package/dist/cjs/js/src/abstract/zaif.js +0 -9
  213. package/dist/cjs/js/src/abstract/zonda.js +0 -9
  214. package/dist/cjs/js/src/ace.js +0 -1058
  215. package/dist/cjs/js/src/alpaca.js +0 -1125
  216. package/dist/cjs/js/src/ascendex.js +0 -3365
  217. package/dist/cjs/js/src/base/Exchange.js +0 -5260
  218. package/dist/cjs/js/src/base/Precise.js +0 -263
  219. package/dist/cjs/js/src/base/errors.js +0 -299
  220. package/dist/cjs/js/src/base/functions/crypto.js +0 -78
  221. package/dist/cjs/js/src/base/functions/encode.js +0 -44
  222. package/dist/cjs/js/src/base/functions/generic.js +0 -193
  223. package/dist/cjs/js/src/base/functions/misc.js +0 -96
  224. package/dist/cjs/js/src/base/functions/number.js +0 -297
  225. package/dist/cjs/js/src/base/functions/platform.js +0 -28
  226. package/dist/cjs/js/src/base/functions/rsa.js +0 -34
  227. package/dist/cjs/js/src/base/functions/string.js +0 -48
  228. package/dist/cjs/js/src/base/functions/throttle.js +0 -66
  229. package/dist/cjs/js/src/base/functions/time.js +0 -187
  230. package/dist/cjs/js/src/base/functions/totp.js +0 -24
  231. package/dist/cjs/js/src/base/functions/type.js +0 -162
  232. package/dist/cjs/js/src/base/functions.js +0 -157
  233. package/dist/cjs/js/src/base/ws/Cache.js +0 -254
  234. package/dist/cjs/js/src/base/ws/Client.js +0 -299
  235. package/dist/cjs/js/src/base/ws/Future.js +0 -34
  236. package/dist/cjs/js/src/base/ws/OrderBook.js +0 -107
  237. package/dist/cjs/js/src/base/ws/OrderBookSide.js +0 -281
  238. package/dist/cjs/js/src/base/ws/WsClient.js +0 -69
  239. package/dist/cjs/js/src/bequant.js +0 -33
  240. package/dist/cjs/js/src/bigone.js +0 -2213
  241. package/dist/cjs/js/src/binance.js +0 -9851
  242. package/dist/cjs/js/src/binancecoinm.js +0 -45
  243. package/dist/cjs/js/src/binanceus.js +0 -92
  244. package/dist/cjs/js/src/binanceusdm.js +0 -58
  245. package/dist/cjs/js/src/bingx.js +0 -3872
  246. package/dist/cjs/js/src/bit2c.js +0 -916
  247. package/dist/cjs/js/src/bitbank.js +0 -1000
  248. package/dist/cjs/js/src/bitbay.js +0 -17
  249. package/dist/cjs/js/src/bitbns.js +0 -1220
  250. package/dist/cjs/js/src/bitcoincom.js +0 -17
  251. package/dist/cjs/js/src/bitfinex.js +0 -1670
  252. package/dist/cjs/js/src/bitfinex2.js +0 -2990
  253. package/dist/cjs/js/src/bitflyer.js +0 -1045
  254. package/dist/cjs/js/src/bitforex.js +0 -852
  255. package/dist/cjs/js/src/bitget.js +0 -8295
  256. package/dist/cjs/js/src/bithumb.js +0 -1090
  257. package/dist/cjs/js/src/bitmart.js +0 -4454
  258. package/dist/cjs/js/src/bitmex.js +0 -2881
  259. package/dist/cjs/js/src/bitopro.js +0 -1724
  260. package/dist/cjs/js/src/bitrue.js +0 -3253
  261. package/dist/cjs/js/src/bitso.js +0 -1753
  262. package/dist/cjs/js/src/bitstamp.js +0 -2188
  263. package/dist/cjs/js/src/bitteam.js +0 -2309
  264. package/dist/cjs/js/src/bitvavo.js +0 -1968
  265. package/dist/cjs/js/src/bl3p.js +0 -447
  266. package/dist/cjs/js/src/blockchaincom.js +0 -1160
  267. package/dist/cjs/js/src/btcalpha.js +0 -929
  268. package/dist/cjs/js/src/btcbox.js +0 -565
  269. package/dist/cjs/js/src/btcmarkets.js +0 -1237
  270. package/dist/cjs/js/src/btcturk.js +0 -929
  271. package/dist/cjs/js/src/bybit.js +0 -7624
  272. package/dist/cjs/js/src/cex.js +0 -1693
  273. package/dist/cjs/js/src/coinbase.js +0 -3424
  274. package/dist/cjs/js/src/coinbasepro.js +0 -1866
  275. package/dist/cjs/js/src/coincheck.js +0 -844
  276. package/dist/cjs/js/src/coinex.js +0 -5417
  277. package/dist/cjs/js/src/coinlist.js +0 -2337
  278. package/dist/cjs/js/src/coinmate.js +0 -989
  279. package/dist/cjs/js/src/coinone.js +0 -1185
  280. package/dist/cjs/js/src/coinsph.js +0 -1933
  281. package/dist/cjs/js/src/coinspot.js +0 -548
  282. package/dist/cjs/js/src/cryptocom.js +0 -3007
  283. package/dist/cjs/js/src/currencycom.js +0 -2015
  284. package/dist/cjs/js/src/delta.js +0 -3262
  285. package/dist/cjs/js/src/deribit.js +0 -3310
  286. package/dist/cjs/js/src/digifinex.js +0 -4307
  287. package/dist/cjs/js/src/exmo.js +0 -2645
  288. package/dist/cjs/js/src/fmfwio.js +0 -34
  289. package/dist/cjs/js/src/gate.js +0 -7077
  290. package/dist/cjs/js/src/gateio.js +0 -16
  291. package/dist/cjs/js/src/gemini.js +0 -1801
  292. package/dist/cjs/js/src/hitbtc.js +0 -3660
  293. package/dist/cjs/js/src/hitbtc3.js +0 -19
  294. package/dist/cjs/js/src/hollaex.js +0 -1882
  295. package/dist/cjs/js/src/htx.js +0 -9174
  296. package/dist/cjs/js/src/huobi.js +0 -16
  297. package/dist/cjs/js/src/huobijp.js +0 -1918
  298. package/dist/cjs/js/src/idex.js +0 -1770
  299. package/dist/cjs/js/src/independentreserve.js +0 -761
  300. package/dist/cjs/js/src/indodax.js +0 -1069
  301. package/dist/cjs/js/src/kraken.js +0 -2891
  302. package/dist/cjs/js/src/krakenfutures.js +0 -2407
  303. package/dist/cjs/js/src/kucoin.js +0 -4494
  304. package/dist/cjs/js/src/kucoinfutures.js +0 -2529
  305. package/dist/cjs/js/src/kuna.js +0 -1949
  306. package/dist/cjs/js/src/latoken.js +0 -1729
  307. package/dist/cjs/js/src/lbank.js +0 -2851
  308. package/dist/cjs/js/src/luno.js +0 -1044
  309. package/dist/cjs/js/src/lykke.js +0 -1303
  310. package/dist/cjs/js/src/mercado.js +0 -897
  311. package/dist/cjs/js/src/mexc.js +0 -5407
  312. package/dist/cjs/js/src/ndax.js +0 -2450
  313. package/dist/cjs/js/src/novadax.js +0 -1556
  314. package/dist/cjs/js/src/oceanex.js +0 -964
  315. package/dist/cjs/js/src/okcoin.js +0 -3115
  316. package/dist/cjs/js/src/okx.js +0 -7331
  317. package/dist/cjs/js/src/p2b.js +0 -1243
  318. package/dist/cjs/js/src/paymium.js +0 -597
  319. package/dist/cjs/js/src/phemex.js +0 -4725
  320. package/dist/cjs/js/src/poloniex.js +0 -2356
  321. package/dist/cjs/js/src/poloniexfutures.js +0 -1794
  322. package/dist/cjs/js/src/pro/alpaca.js +0 -714
  323. package/dist/cjs/js/src/pro/ascendex.js +0 -957
  324. package/dist/cjs/js/src/pro/bequant.js +0 -33
  325. package/dist/cjs/js/src/pro/binance.js +0 -2796
  326. package/dist/cjs/js/src/pro/binancecoinm.js +0 -23
  327. package/dist/cjs/js/src/pro/binanceus.js +0 -51
  328. package/dist/cjs/js/src/pro/binanceusdm.js +0 -32
  329. package/dist/cjs/js/src/pro/bingx.js +0 -944
  330. package/dist/cjs/js/src/pro/bitcoincom.js +0 -29
  331. package/dist/cjs/js/src/pro/bitfinex.js +0 -672
  332. package/dist/cjs/js/src/pro/bitfinex2.js +0 -1159
  333. package/dist/cjs/js/src/pro/bitget.js +0 -1733
  334. package/dist/cjs/js/src/pro/bitmart.js +0 -1486
  335. package/dist/cjs/js/src/pro/bitmex.js +0 -1576
  336. package/dist/cjs/js/src/pro/bitopro.js +0 -327
  337. package/dist/cjs/js/src/pro/bitrue.js +0 -462
  338. package/dist/cjs/js/src/pro/bitstamp.js +0 -547
  339. package/dist/cjs/js/src/pro/bitvavo.js +0 -704
  340. package/dist/cjs/js/src/pro/blockchaincom.js +0 -794
  341. package/dist/cjs/js/src/pro/bybit.js +0 -1843
  342. package/dist/cjs/js/src/pro/cex.js +0 -1510
  343. package/dist/cjs/js/src/pro/coinbase.js +0 -561
  344. package/dist/cjs/js/src/pro/coinbasepro.js +0 -968
  345. package/dist/cjs/js/src/pro/coinex.js +0 -1095
  346. package/dist/cjs/js/src/pro/cryptocom.js +0 -1020
  347. package/dist/cjs/js/src/pro/currencycom.js +0 -563
  348. package/dist/cjs/js/src/pro/deribit.js +0 -825
  349. package/dist/cjs/js/src/pro/exmo.js +0 -658
  350. package/dist/cjs/js/src/pro/gate.js +0 -1316
  351. package/dist/cjs/js/src/pro/gateio.js +0 -16
  352. package/dist/cjs/js/src/pro/gemini.js +0 -649
  353. package/dist/cjs/js/src/pro/hitbtc.js +0 -1294
  354. package/dist/cjs/js/src/pro/hollaex.js +0 -597
  355. package/dist/cjs/js/src/pro/htx.js +0 -2388
  356. package/dist/cjs/js/src/pro/huobi.js +0 -16
  357. package/dist/cjs/js/src/pro/huobijp.js +0 -606
  358. package/dist/cjs/js/src/pro/idex.js +0 -714
  359. package/dist/cjs/js/src/pro/independentreserve.js +0 -280
  360. package/dist/cjs/js/src/pro/kraken.js +0 -1364
  361. package/dist/cjs/js/src/pro/krakenfutures.js +0 -1506
  362. package/dist/cjs/js/src/pro/kucoin.js +0 -1062
  363. package/dist/cjs/js/src/pro/kucoinfutures.js +0 -989
  364. package/dist/cjs/js/src/pro/luno.js +0 -322
  365. package/dist/cjs/js/src/pro/mexc.js +0 -1170
  366. package/dist/cjs/js/src/pro/ndax.js +0 -545
  367. package/dist/cjs/js/src/pro/okcoin.js +0 -760
  368. package/dist/cjs/js/src/pro/okx.js +0 -1608
  369. package/dist/cjs/js/src/pro/phemex.js +0 -1511
  370. package/dist/cjs/js/src/pro/poloniex.js +0 -1253
  371. package/dist/cjs/js/src/pro/poloniexfutures.js +0 -1022
  372. package/dist/cjs/js/src/pro/probit.js +0 -586
  373. package/dist/cjs/js/src/pro/upbit.js +0 -234
  374. package/dist/cjs/js/src/pro/wazirx.js +0 -776
  375. package/dist/cjs/js/src/pro/whitebit.js +0 -927
  376. package/dist/cjs/js/src/pro/woo.js +0 -895
  377. package/dist/cjs/js/src/probit.js +0 -1867
  378. package/dist/cjs/js/src/static_dependencies/fflake/browser.js +0 -401
  379. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +0 -195
  380. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +0 -308
  381. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +0 -554
  382. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +0 -94
  383. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +0 -70
  384. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +0 -91
  385. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +0 -16
  386. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +0 -1760
  387. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +0 -52
  388. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +0 -81
  389. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +0 -376
  390. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +0 -70
  391. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +0 -1580
  392. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +0 -74
  393. package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +0 -24
  394. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +0 -158
  395. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +0 -429
  396. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +0 -176
  397. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +0 -324
  398. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +0 -163
  399. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +0 -245
  400. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +0 -1018
  401. package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +0 -383
  402. package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +0 -258
  403. package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +0 -53
  404. package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +0 -120
  405. package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +0 -69
  406. package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +0 -7
  407. package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +0 -83
  408. package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +0 -240
  409. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +0 -91
  410. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +0 -130
  411. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +0 -214
  412. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +0 -239
  413. package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +0 -93
  414. package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +0 -354
  415. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +0 -16
  416. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +0 -20
  417. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +0 -30
  418. package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +0 -239
  419. package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +0 -372
  420. package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +0 -273
  421. package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +0 -139
  422. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +0 -14
  423. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +0 -16
  424. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +0 -81
  425. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +0 -292
  426. package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +0 -103
  427. package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +0 -140
  428. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +0 -175
  429. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +0 -95
  430. package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +0 -7
  431. package/dist/cjs/js/src/static_dependencies/scure-base/index.js +0 -383
  432. package/dist/cjs/js/src/timex.js +0 -1562
  433. package/dist/cjs/js/src/tokocrypto.js +0 -2542
  434. package/dist/cjs/js/src/upbit.js +0 -1844
  435. package/dist/cjs/js/src/wavesexchange.js +0 -2607
  436. package/dist/cjs/js/src/wazirx.js +0 -953
  437. package/dist/cjs/js/src/whitebit.js +0 -2310
  438. package/dist/cjs/js/src/woo.js +0 -2769
  439. package/dist/cjs/js/src/yobit.js +0 -1314
  440. package/dist/cjs/js/src/zaif.js +0 -736
  441. package/dist/cjs/js/src/zonda.js +0 -1883
  442. package/dist/cjs/src/abstract/bitpanda.js +0 -9
  443. package/test.ts +0 -0
  444. /package/dist/cjs/{js/src/abstract/ace.js → src/abstract/onetrading.js} +0 -0
  445. /package/dist/cjs/{js/src → src}/pro/coincheck.js +0 -0
  446. /package/dist/cjs/{js/src → src}/pro/coinone.js +0 -0
@@ -1,2769 +0,0 @@
1
- 'use strict';
2
-
3
- var woo$1 = require('./abstract/woo.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 sha256 = require('./static_dependencies/noble-hashes/sha256.js');
8
-
9
- // ---------------------------------------------------------------------------
10
- // ---------------------------------------------------------------------------
11
- /**
12
- * @class woo
13
- * @augments Exchange
14
- */
15
- class woo extends woo$1 {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'woo',
19
- 'name': 'WOO X',
20
- 'countries': ['KY'],
21
- 'rateLimit': 100,
22
- 'version': 'v1',
23
- 'certified': true,
24
- 'pro': true,
25
- 'hostname': 'woo.org',
26
- 'has': {
27
- 'CORS': undefined,
28
- 'spot': true,
29
- 'margin': true,
30
- 'swap': true,
31
- 'future': false,
32
- 'option': false,
33
- 'addMargin': false,
34
- 'cancelAllOrders': true,
35
- 'cancelOrder': true,
36
- 'cancelWithdraw': false,
37
- 'closeAllPositions': false,
38
- 'closePosition': false,
39
- 'createDepositAddress': false,
40
- 'createMarketBuyOrderWithCost': true,
41
- 'createMarketOrder': false,
42
- 'createMarketOrderWithCost': false,
43
- 'createMarketSellOrderWithCost': false,
44
- 'createOrder': true,
45
- 'createOrderWithTakeProfitAndStopLoss': true,
46
- 'createReduceOnlyOrder': true,
47
- 'createStopLimitOrder': false,
48
- 'createStopLossOrder': true,
49
- 'createStopMarketOrder': false,
50
- 'createStopOrder': false,
51
- 'createTakeProfitOrder': true,
52
- 'createTrailingAmountOrder': true,
53
- 'createTrailingPercentOrder': true,
54
- 'createTriggerOrder': true,
55
- 'fetchAccounts': true,
56
- 'fetchBalance': true,
57
- 'fetchCanceledOrders': false,
58
- 'fetchClosedOrder': false,
59
- 'fetchClosedOrders': false,
60
- 'fetchCurrencies': true,
61
- 'fetchDepositAddress': false,
62
- 'fetchDeposits': true,
63
- 'fetchDepositsWithdrawals': true,
64
- 'fetchFundingHistory': true,
65
- 'fetchFundingRate': true,
66
- 'fetchFundingRateHistory': true,
67
- 'fetchFundingRates': true,
68
- 'fetchIndexOHLCV': false,
69
- 'fetchLedger': true,
70
- 'fetchLeverage': true,
71
- 'fetchMarginMode': false,
72
- 'fetchMarkets': true,
73
- 'fetchMarkOHLCV': false,
74
- 'fetchMyTrades': true,
75
- 'fetchOHLCV': true,
76
- 'fetchOpenInterestHistory': false,
77
- 'fetchOpenOrder': false,
78
- 'fetchOpenOrders': false,
79
- 'fetchOrder': true,
80
- 'fetchOrderBook': true,
81
- 'fetchOrders': true,
82
- 'fetchOrderTrades': true,
83
- 'fetchPosition': true,
84
- 'fetchPositionMode': false,
85
- 'fetchPositions': true,
86
- 'fetchPremiumIndexOHLCV': false,
87
- 'fetchStatus': false,
88
- 'fetchTicker': false,
89
- 'fetchTickers': false,
90
- 'fetchTime': false,
91
- 'fetchTrades': true,
92
- 'fetchTradingFee': false,
93
- 'fetchTradingFees': true,
94
- 'fetchTransactions': 'emulated',
95
- 'fetchTransfers': true,
96
- 'fetchWithdrawals': true,
97
- 'reduceMargin': false,
98
- 'setLeverage': true,
99
- 'setMargin': false,
100
- 'transfer': true,
101
- 'withdraw': true, // exchange have that endpoint disabled atm, but was once implemented in ccxt per old docs: https://kronosresearch.github.io/wootrade-documents/#token-withdraw
102
- },
103
- 'timeframes': {
104
- '1m': '1m',
105
- '5m': '5m',
106
- '15m': '15m',
107
- '30m': '30m',
108
- '1h': '1h',
109
- '4h': '4h',
110
- '12h': '12h',
111
- '1d': '1d',
112
- '1w': '1w',
113
- '1M': '1mon',
114
- '1y': '1y',
115
- },
116
- 'urls': {
117
- 'logo': 'https://user-images.githubusercontent.com/1294454/150730761-1a00e5e0-d28c-480f-9e65-089ce3e6ef3b.jpg',
118
- 'api': {
119
- 'pub': 'https://api-pub.woo.org',
120
- 'public': 'https://api.{hostname}',
121
- 'private': 'https://api.{hostname}',
122
- },
123
- 'test': {
124
- 'pub': 'https://api-pub.staging.woo.org',
125
- 'public': 'https://api.staging.woo.org',
126
- 'private': 'https://api.staging.woo.org',
127
- },
128
- 'www': 'https://woo.org/',
129
- 'doc': [
130
- 'https://docs.woo.org/',
131
- ],
132
- 'fees': [
133
- 'https://support.woo.org/hc/en-001/articles/4404611795353--Trading-Fees',
134
- ],
135
- 'referral': {
136
- 'url': 'https://x.woo.org/register?ref=YWOWC96B',
137
- 'discount': 0.35,
138
- },
139
- },
140
- 'api': {
141
- 'v1': {
142
- 'pub': {
143
- 'get': {
144
- 'hist/kline': 10,
145
- 'hist/trades': 1,
146
- },
147
- },
148
- 'public': {
149
- 'get': {
150
- 'info': 1,
151
- 'info/{symbol}': 1,
152
- 'system_info': 1,
153
- 'market_trades': 1,
154
- 'token': 1,
155
- 'token_network': 1,
156
- 'funding_rates': 1,
157
- 'funding_rate/{symbol}': 1,
158
- 'funding_rate_history': 1,
159
- 'futures': 1,
160
- 'futures/{symbol}': 1,
161
- 'orderbook/{symbol}': 1,
162
- 'kline': 1,
163
- },
164
- },
165
- 'private': {
166
- 'get': {
167
- 'client/token': 1,
168
- 'order/{oid}': 1,
169
- 'client/order/{client_order_id}': 1,
170
- 'orders': 1,
171
- 'client/trade/{tid}': 1,
172
- 'order/{oid}/trades': 1,
173
- 'client/trades': 1,
174
- 'asset/deposit': 10,
175
- 'asset/history': 60,
176
- 'sub_account/all': 60,
177
- 'sub_account/assets': 60,
178
- 'token_interest': 60,
179
- 'token_interest/{token}': 60,
180
- 'interest/history': 60,
181
- 'interest/repay': 60,
182
- 'funding_fee/history': 30,
183
- 'positions': 3.33,
184
- 'position/{symbol}': 3.33,
185
- 'client/transaction_history': 60,
186
- },
187
- 'post': {
188
- 'order': 5,
189
- 'asset/main_sub_transfer': 30,
190
- 'asset/withdraw': 30,
191
- 'interest/repay': 60,
192
- 'client/account_mode': 120,
193
- 'client/leverage': 120,
194
- },
195
- 'delete': {
196
- 'order': 1,
197
- 'client/order': 1,
198
- 'orders': 1,
199
- 'asset/withdraw': 120, // implemented in ccxt, disabled on the exchange side https://kronosresearch.github.io/wootrade-documents/#cancel-withdraw-request
200
- },
201
- },
202
- },
203
- 'v2': {
204
- 'private': {
205
- 'get': {
206
- 'client/holding': 1,
207
- },
208
- },
209
- },
210
- 'v3': {
211
- 'public': {
212
- 'get': {
213
- 'insuranceFund': 3,
214
- },
215
- },
216
- 'private': {
217
- 'get': {
218
- 'algo/order/{oid}': 1,
219
- 'algo/orders': 1,
220
- 'balances': 1,
221
- 'accountinfo': 60,
222
- 'positions': 3.33,
223
- 'buypower': 1,
224
- 'referrals': 60,
225
- 'referral_rewards': 60,
226
- 'convert/exchangeInfo': 1,
227
- 'convert/assetInfo': 1,
228
- 'convert/rfq': 60,
229
- 'convert/trade': 1,
230
- 'convert/trades': 1,
231
- },
232
- 'post': {
233
- 'algo/order': 5,
234
- 'convert/rft': 60,
235
- },
236
- 'put': {
237
- 'order/{oid}': 2,
238
- 'order/client/{client_order_id}': 2,
239
- 'algo/order/{oid}': 2,
240
- 'algo/order/client/{client_order_id}': 2,
241
- },
242
- 'delete': {
243
- 'algo/order/{order_id}': 1,
244
- 'algo/orders/pending': 1,
245
- 'algo/orders/pending/{symbol}': 1,
246
- 'orders/pending': 1,
247
- },
248
- },
249
- },
250
- },
251
- 'fees': {
252
- 'trading': {
253
- 'tierBased': true,
254
- 'percentage': true,
255
- 'maker': this.parseNumber('0.0002'),
256
- 'taker': this.parseNumber('0.0005'),
257
- },
258
- },
259
- 'options': {
260
- 'sandboxMode': false,
261
- 'createMarketBuyOrderRequiresPrice': true,
262
- // these network aliases require manual mapping here
263
- 'network-aliases-for-tokens': {
264
- 'HT': 'ERC20',
265
- 'OMG': 'ERC20',
266
- 'UATOM': 'ATOM',
267
- 'ZRX': 'ZRX',
268
- },
269
- 'networks': {
270
- 'TRX': 'TRON',
271
- 'TRC20': 'TRON',
272
- 'ERC20': 'ETH',
273
- 'BEP20': 'BSC',
274
- },
275
- // override defaultNetworkCodePriorities for a specific currency
276
- 'defaultNetworkCodeForCurrencies': {
277
- // 'USDT': 'TRC20',
278
- // 'BTC': 'BTC',
279
- },
280
- 'transfer': {
281
- 'fillResponseFromRequest': true,
282
- },
283
- 'brokerId': 'bc830de7-50f3-460b-9ee0-f430f83f9dad',
284
- },
285
- 'commonCurrencies': {},
286
- 'exceptions': {
287
- 'exact': {
288
- '-1000': errors.ExchangeError,
289
- '-1001': errors.AuthenticationError,
290
- '-1002': errors.AuthenticationError,
291
- '-1003': errors.RateLimitExceeded,
292
- '-1004': errors.BadRequest,
293
- '-1005': errors.BadRequest,
294
- '-1006': errors.BadRequest,
295
- '-1007': errors.BadRequest,
296
- '-1008': errors.InvalidOrder,
297
- '-1009': errors.BadRequest,
298
- '-1011': errors.ExchangeError,
299
- '-1012': errors.BadRequest,
300
- '-1101': errors.InvalidOrder,
301
- '-1102': errors.InvalidOrder,
302
- '-1103': errors.InvalidOrder,
303
- '-1104': errors.InvalidOrder,
304
- '-1105': errors.InvalidOrder, // { "code": -1105, "message": "Price is X% too high or X% too low from the mid price." }
305
- },
306
- 'broad': {
307
- 'symbol must not be blank': errors.BadRequest,
308
- 'The token is not supported': errors.BadRequest,
309
- 'Your order and symbol are not valid or already canceled': errors.BadRequest,
310
- 'Insufficient WOO. Please enable margin trading for leverage trading': errors.BadRequest, // when selling insufficent token [-1012]
311
- },
312
- },
313
- 'precisionMode': number.TICK_SIZE,
314
- });
315
- }
316
- async fetchMarkets(params = {}) {
317
- /**
318
- * @method
319
- * @name woo#fetchMarkets
320
- * @description retrieves data on all markets for woo
321
- * @param {object} [params] extra parameters specific to the exchange API endpoint
322
- * @returns {object[]} an array of objects representing market data
323
- */
324
- const response = await this.v1PublicGetInfo(params);
325
- //
326
- // {
327
- // "rows": [
328
- // {
329
- // "symbol": "SPOT_AAVE_USDT",
330
- // "quote_min": 0,
331
- // "quote_max": 100000,
332
- // "quote_tick": 0.01,
333
- // "base_min": 0.01,
334
- // "base_max": 7284,
335
- // "base_tick": 0.0001,
336
- // "min_notional": 10,
337
- // "price_range": 0.1,
338
- // "created_time": "0",
339
- // "updated_time": "1639107647.988",
340
- // "is_stable": 0
341
- // },
342
- // ...
343
- // "success": true
344
- // }
345
- //
346
- const data = this.safeValue(response, 'rows', []);
347
- return this.parseMarkets(data);
348
- }
349
- parseMarket(market) {
350
- const marketId = this.safeString(market, 'symbol');
351
- const parts = marketId.split('_');
352
- const first = this.safeString(parts, 0);
353
- let marketType;
354
- let spot = false;
355
- let swap = false;
356
- if (first === 'SPOT') {
357
- spot = true;
358
- marketType = 'spot';
359
- }
360
- else if (first === 'PERP') {
361
- swap = true;
362
- marketType = 'swap';
363
- }
364
- const baseId = this.safeString(parts, 1);
365
- const quoteId = this.safeString(parts, 2);
366
- const base = this.safeCurrencyCode(baseId);
367
- const quote = this.safeCurrencyCode(quoteId);
368
- let settleId = undefined;
369
- let settle = undefined;
370
- let symbol = base + '/' + quote;
371
- let contractSize = undefined;
372
- let linear = undefined;
373
- let margin = true;
374
- const contract = swap;
375
- if (contract) {
376
- margin = false;
377
- settleId = this.safeString(parts, 2);
378
- settle = this.safeCurrencyCode(settleId);
379
- symbol = base + '/' + quote + ':' + settle;
380
- contractSize = this.parseNumber('1');
381
- linear = true;
382
- }
383
- return {
384
- 'id': marketId,
385
- 'symbol': symbol,
386
- 'base': base,
387
- 'quote': quote,
388
- 'settle': settle,
389
- 'baseId': baseId,
390
- 'quoteId': quoteId,
391
- 'settleId': settleId,
392
- 'type': marketType,
393
- 'spot': spot,
394
- 'margin': margin,
395
- 'swap': swap,
396
- 'future': false,
397
- 'option': false,
398
- 'active': undefined,
399
- 'contract': contract,
400
- 'linear': linear,
401
- 'inverse': undefined,
402
- 'contractSize': contractSize,
403
- 'expiry': undefined,
404
- 'expiryDatetime': undefined,
405
- 'strike': undefined,
406
- 'optionType': undefined,
407
- 'precision': {
408
- 'amount': this.safeNumber(market, 'base_tick'),
409
- 'price': this.safeNumber(market, 'quote_tick'),
410
- },
411
- 'limits': {
412
- 'leverage': {
413
- 'min': undefined,
414
- 'max': undefined,
415
- },
416
- 'amount': {
417
- 'min': this.safeNumber(market, 'base_min'),
418
- 'max': this.safeNumber(market, 'base_max'),
419
- },
420
- 'price': {
421
- 'min': this.safeNumber(market, 'quote_min'),
422
- 'max': this.safeNumber(market, 'quote_max'),
423
- },
424
- 'cost': {
425
- 'min': this.safeNumber(market, 'min_notional'),
426
- 'max': undefined,
427
- },
428
- },
429
- 'created': this.safeTimestamp(market, 'created_time'),
430
- 'info': market,
431
- };
432
- }
433
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
434
- /**
435
- * @method
436
- * @name woo#fetchTrades
437
- * @description get the list of most recent trades for a particular symbol
438
- * @param {string} symbol unified symbol of the market to fetch trades for
439
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
440
- * @param {int} [limit] the maximum amount of trades to fetch
441
- * @param {object} [params] extra parameters specific to the exchange API endpoint
442
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
443
- */
444
- await this.loadMarkets();
445
- const market = this.market(symbol);
446
- const request = {
447
- 'symbol': market['id'],
448
- };
449
- if (limit !== undefined) {
450
- request['limit'] = limit;
451
- }
452
- const response = await this.v1PublicGetMarketTrades(this.extend(request, params));
453
- //
454
- // {
455
- // "success": true,
456
- // "rows": [
457
- // {
458
- // "symbol": "SPOT_BTC_USDT",
459
- // "side": "SELL",
460
- // "executed_price": 46222.35,
461
- // "executed_quantity": 0.0012,
462
- // "executed_timestamp": "1641241162.329"
463
- // },
464
- // {
465
- // "symbol": "SPOT_BTC_USDT",
466
- // "side": "SELL",
467
- // "executed_price": 46222.35,
468
- // "executed_quantity": 0.0012,
469
- // "executed_timestamp": "1641241162.329"
470
- // },
471
- // {
472
- // "symbol": "SPOT_BTC_USDT",
473
- // "side": "BUY",
474
- // "executed_price": 46224.32,
475
- // "executed_quantity": 0.00039,
476
- // "executed_timestamp": "1641241162.287"
477
- // },
478
- // ...
479
- // ]
480
- // }
481
- //
482
- const resultResponse = this.safeValue(response, 'rows', {});
483
- return this.parseTrades(resultResponse, market, since, limit);
484
- }
485
- parseTrade(trade, market = undefined) {
486
- //
487
- // public/market_trades
488
- //
489
- // {
490
- // "symbol": "SPOT_BTC_USDT",
491
- // "side": "SELL",
492
- // "executed_price": 46222.35,
493
- // "executed_quantity": 0.0012,
494
- // "executed_timestamp": "1641241162.329"
495
- // }
496
- //
497
- // fetchOrderTrades, fetchOrder
498
- //
499
- // {
500
- // "id": "99119876",
501
- // "symbol": "SPOT_WOO_USDT",
502
- // "fee": "0.0024",
503
- // "side": "BUY",
504
- // "executed_timestamp": "1641481113.084",
505
- // "order_id": "87001234",
506
- // "order_tag": "default", <-- this param only in "fetchOrderTrades"
507
- // "executed_price": "1",
508
- // "executed_quantity": "12",
509
- // "fee_asset": "WOO",
510
- // "is_maker": "1"
511
- // }
512
- //
513
- const isFromFetchOrder = ('id' in trade);
514
- const timestamp = this.safeTimestamp(trade, 'executed_timestamp');
515
- const marketId = this.safeString(trade, 'symbol');
516
- market = this.safeMarket(marketId, market);
517
- const symbol = market['symbol'];
518
- const price = this.safeString(trade, 'executed_price');
519
- const amount = this.safeString(trade, 'executed_quantity');
520
- const order_id = this.safeString(trade, 'order_id');
521
- const fee = this.parseTokenAndFeeTemp(trade, 'fee_asset', 'fee');
522
- const cost = Precise["default"].stringMul(price, amount);
523
- const side = this.safeStringLower(trade, 'side');
524
- const id = this.safeString(trade, 'id');
525
- let takerOrMaker = undefined;
526
- if (isFromFetchOrder) {
527
- const isMaker = this.safeString(trade, 'is_maker') === '1';
528
- takerOrMaker = isMaker ? 'maker' : 'taker';
529
- }
530
- return this.safeTrade({
531
- 'id': id,
532
- 'timestamp': timestamp,
533
- 'datetime': this.iso8601(timestamp),
534
- 'symbol': symbol,
535
- 'side': side,
536
- 'price': price,
537
- 'amount': amount,
538
- 'cost': cost,
539
- 'order': order_id,
540
- 'takerOrMaker': takerOrMaker,
541
- 'type': undefined,
542
- 'fee': fee,
543
- 'info': trade,
544
- }, market);
545
- }
546
- parseTokenAndFeeTemp(item, feeTokenKey, feeAmountKey) {
547
- const feeCost = this.safeString(item, feeAmountKey);
548
- let fee = undefined;
549
- if (feeCost !== undefined) {
550
- const feeCurrencyId = this.safeString(item, feeTokenKey);
551
- const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
552
- fee = {
553
- 'cost': feeCost,
554
- 'currency': feeCurrencyCode,
555
- };
556
- }
557
- return fee;
558
- }
559
- async fetchTradingFees(params = {}) {
560
- /**
561
- * @method
562
- * @name woo#fetchTradingFees
563
- * @description fetch the trading fees for multiple markets
564
- * @see https://docs.woo.org/#get-account-information-new
565
- * @param {object} [params] extra parameters specific to the exchange API endpoint
566
- * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
567
- */
568
- await this.loadMarkets();
569
- const response = await this.v3PrivateGetAccountinfo(params);
570
- //
571
- // {
572
- // "success": true,
573
- // "data": {
574
- // "applicationId": "dsa",
575
- // "account": "dsa",
576
- // "alias": "haha",
577
- // "accountMode": "MARGIN",
578
- // "leverage": 1,
579
- // "takerFeeRate": 1,
580
- // "makerFeeRate": 1,
581
- // "interestRate": 1,
582
- // "futuresTakerFeeRate": 1,
583
- // "futuresMakerFeeRate": 1,
584
- // "otpauth": true,
585
- // "marginRatio": 1,
586
- // "openMarginRatio": 1,
587
- // "initialMarginRatio": 1,
588
- // "maintenanceMarginRatio": 1,
589
- // "totalCollateral": 1,
590
- // "freeCollateral": 1,
591
- // "totalAccountValue": 1,
592
- // "totalVaultValue": 1,
593
- // "totalStakingValue": 1
594
- // },
595
- // "timestamp": 1673323685109
596
- // }
597
- //
598
- const data = this.safeValue(response, 'data', {});
599
- const maker = this.safeString(data, 'makerFeeRate');
600
- const taker = this.safeString(data, 'takerFeeRate');
601
- const result = {};
602
- for (let i = 0; i < this.symbols.length; i++) {
603
- const symbol = this.symbols[i];
604
- result[symbol] = {
605
- 'info': response,
606
- 'symbol': symbol,
607
- 'maker': this.parseNumber(Precise["default"].stringDiv(maker, '10000')),
608
- 'taker': this.parseNumber(Precise["default"].stringDiv(taker, '10000')),
609
- 'percentage': true,
610
- 'tierBased': true,
611
- };
612
- }
613
- return result;
614
- }
615
- async fetchCurrencies(params = {}) {
616
- /**
617
- * @method
618
- * @name woo#fetchCurrencies
619
- * @description fetches all available currencies on an exchange
620
- * @param {object} [params] extra parameters specific to the exchange API endpoint
621
- * @returns {object} an associative dictionary of currencies
622
- */
623
- const result = {};
624
- const tokenResponse = await this.v1PublicGetToken(params);
625
- //
626
- // {
627
- // "rows": [
628
- // {
629
- // "token": "ETH_USDT",
630
- // "fullname": "Tether",
631
- // "decimals": 6,
632
- // "balance_token": "USDT",
633
- // "created_time": "0",
634
- // "updated_time": "0"
635
- // },
636
- // {
637
- // "token": "BSC_USDT",
638
- // "fullname": "Tether",
639
- // "decimals": 18,
640
- // "balance_token": "USDT",
641
- // "created_time": "0",
642
- // "updated_time": "0"
643
- // },
644
- // {
645
- // "token": "ZEC",
646
- // "fullname": "ZCash",
647
- // "decimals": 8,
648
- // "balance_token": "ZEC",
649
- // "created_time": "0",
650
- // "updated_time": "0"
651
- // },
652
- // ...
653
- // ],
654
- // "success": true
655
- // }
656
- //
657
- // only make one request for currrencies...
658
- // const tokenNetworkResponse = await this.v1PublicGetTokenNetwork (params);
659
- //
660
- // {
661
- // "rows": [
662
- // {
663
- // "protocol": "ERC20",
664
- // "token": "USDT",
665
- // "name": "Ethereum",
666
- // "minimum_withdrawal": 30,
667
- // "withdrawal_fee": 25,
668
- // "allow_deposit": 1,
669
- // "allow_withdraw": 1
670
- // },
671
- // {
672
- // "protocol": "TRC20",
673
- // "token": "USDT",
674
- // "name": "Tron",
675
- // "minimum_withdrawal": 30,
676
- // "withdrawal_fee": 1,
677
- // "allow_deposit": 1,
678
- // "allow_withdraw": 1
679
- // },
680
- // ...
681
- // ],
682
- // "success": true
683
- // }
684
- //
685
- const tokenRows = this.safeValue(tokenResponse, 'rows', []);
686
- const networksByCurrencyId = this.groupBy(tokenRows, 'balance_token');
687
- const currencyIds = Object.keys(networksByCurrencyId);
688
- for (let i = 0; i < currencyIds.length; i++) {
689
- const currencyId = currencyIds[i];
690
- const networks = networksByCurrencyId[currencyId];
691
- const code = this.safeCurrencyCode(currencyId);
692
- let name = undefined;
693
- let minPrecision = undefined;
694
- const resultingNetworks = {};
695
- for (let j = 0; j < networks.length; j++) {
696
- const network = networks[j];
697
- name = this.safeString(network, 'fullname');
698
- const networkId = this.safeString(network, 'token');
699
- const splitted = networkId.split('_');
700
- const unifiedNetwork = splitted[0];
701
- const precision = this.parsePrecision(this.safeString(network, 'decimals'));
702
- if (precision !== undefined) {
703
- minPrecision = (minPrecision === undefined) ? precision : Precise["default"].stringMin(precision, minPrecision);
704
- }
705
- resultingNetworks[unifiedNetwork] = {
706
- 'id': networkId,
707
- 'network': unifiedNetwork,
708
- 'limits': {
709
- 'withdraw': {
710
- 'min': undefined,
711
- 'max': undefined,
712
- },
713
- 'deposit': {
714
- 'min': undefined,
715
- 'max': undefined,
716
- },
717
- },
718
- 'active': undefined,
719
- 'deposit': undefined,
720
- 'withdraw': undefined,
721
- 'fee': undefined,
722
- 'precision': this.parseNumber(precision),
723
- 'info': network,
724
- };
725
- }
726
- result[code] = {
727
- 'id': currencyId,
728
- 'name': name,
729
- 'code': code,
730
- 'precision': this.parseNumber(minPrecision),
731
- 'active': undefined,
732
- 'fee': undefined,
733
- 'networks': resultingNetworks,
734
- 'deposit': undefined,
735
- 'withdraw': undefined,
736
- 'limits': {
737
- 'deposit': {
738
- 'min': undefined,
739
- 'max': undefined,
740
- },
741
- 'withdraw': {
742
- 'min': undefined,
743
- 'max': undefined,
744
- },
745
- },
746
- 'info': networks,
747
- };
748
- }
749
- return result;
750
- }
751
- async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
752
- /**
753
- * @method
754
- * @name woo#createMarketBuyOrderWithCost
755
- * @description create a market buy order by providing the symbol and cost
756
- * @see https://docs.woo.org/#send-order
757
- * @param {string} symbol unified symbol of the market to create an order in
758
- * @param {float} cost how much you want to trade in units of the quote currency
759
- * @param {object} [params] extra parameters specific to the exchange API endpoint
760
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
761
- */
762
- await this.loadMarkets();
763
- const market = this.market(symbol);
764
- if (!market['spot']) {
765
- throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
766
- }
767
- params['createMarketBuyOrderRequiresPrice'] = false;
768
- return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
769
- }
770
- async createTrailingAmountOrder(symbol, type, side, amount, price = undefined, trailingAmount = undefined, trailingTriggerPrice = undefined, params = {}) {
771
- /**
772
- * @method
773
- * @name woo#createTrailingAmountOrder
774
- * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
775
- * @param {string} symbol unified symbol of the market to create an order in
776
- * @param {string} type 'market' or 'limit'
777
- * @param {string} side 'buy' or 'sell'
778
- * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
779
- * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
780
- * @param {float} trailingAmount the quote amount to trail away from the current market price
781
- * @param {float} trailingTriggerPrice the price to activate a trailing order, default uses the price argument
782
- * @param {object} [params] extra parameters specific to the exchange API endpoint
783
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
784
- */
785
- if (trailingAmount === undefined) {
786
- throw new errors.ArgumentsRequired(this.id + ' createTrailingAmountOrder() requires a trailingAmount argument');
787
- }
788
- if (trailingTriggerPrice === undefined) {
789
- throw new errors.ArgumentsRequired(this.id + ' createTrailingAmountOrder() requires a trailingTriggerPrice argument');
790
- }
791
- params['trailingAmount'] = trailingAmount;
792
- params['trailingTriggerPrice'] = trailingTriggerPrice;
793
- return await this.createOrder(symbol, type, side, amount, price, params);
794
- }
795
- async createTrailingPercentOrder(symbol, type, side, amount, price = undefined, trailingPercent = undefined, trailingTriggerPrice = undefined, params = {}) {
796
- /**
797
- * @method
798
- * @name woo#createTrailingPercentOrder
799
- * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
800
- * @param {string} symbol unified symbol of the market to create an order in
801
- * @param {string} type 'market' or 'limit'
802
- * @param {string} side 'buy' or 'sell'
803
- * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
804
- * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
805
- * @param {float} trailingPercent the percent to trail away from the current market price
806
- * @param {float} trailingTriggerPrice the price to activate a trailing order, default uses the price argument
807
- * @param {object} [params] extra parameters specific to the exchange API endpoint
808
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
809
- */
810
- if (trailingPercent === undefined) {
811
- throw new errors.ArgumentsRequired(this.id + ' createTrailingPercentOrder() requires a trailingPercent argument');
812
- }
813
- if (trailingTriggerPrice === undefined) {
814
- throw new errors.ArgumentsRequired(this.id + ' createTrailingPercentOrder() requires a trailingTriggerPrice argument');
815
- }
816
- params['trailingPercent'] = trailingPercent;
817
- params['trailingTriggerPrice'] = trailingTriggerPrice;
818
- return await this.createOrder(symbol, type, side, amount, price, params);
819
- }
820
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
821
- /**
822
- * @method
823
- * @name woo#createOrder
824
- * @description create a trade order
825
- * @see https://docs.woo.org/#send-order
826
- * @see https://docs.woo.org/#send-algo-order
827
- * @param {string} symbol unified symbol of the market to create an order in
828
- * @param {string} type 'market' or 'limit'
829
- * @param {string} side 'buy' or 'sell'
830
- * @param {float} amount how much of currency you want to trade in units of base currency
831
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
832
- * @param {object} [params] extra parameters specific to the exchange API endpoint
833
- * @param {float} [params.triggerPrice] The price a trigger order is triggered at
834
- * @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
835
- * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
836
- * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
837
- * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
838
- * @param {float} [params.algoType] 'STOP'or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
839
- * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
840
- * @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
841
- * @param {string} [params.trailingPercent] the percent to trail away from the current market price
842
- * @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
843
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
844
- */
845
- const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
846
- params = this.omit(params, ['reduceOnly', 'reduce_only']);
847
- const orderType = type.toUpperCase();
848
- await this.loadMarkets();
849
- const market = this.market(symbol);
850
- const orderSide = side.toUpperCase();
851
- const request = {
852
- 'symbol': market['id'],
853
- 'side': orderSide,
854
- };
855
- const stopPrice = this.safeNumber2(params, 'triggerPrice', 'stopPrice');
856
- const stopLoss = this.safeValue(params, 'stopLoss');
857
- const takeProfit = this.safeValue(params, 'takeProfit');
858
- const algoType = this.safeString(params, 'algoType');
859
- const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', price);
860
- const trailingAmount = this.safeString2(params, 'trailingAmount', 'callbackValue');
861
- const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
862
- const isTrailingAmountOrder = trailingAmount !== undefined;
863
- const isTrailingPercentOrder = trailingPercent !== undefined;
864
- const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
865
- const isStop = isTrailing || stopPrice !== undefined || stopLoss !== undefined || takeProfit !== undefined || (this.safeValue(params, 'childOrders') !== undefined);
866
- const isMarket = orderType === 'MARKET';
867
- const timeInForce = this.safeStringLower(params, 'timeInForce');
868
- const postOnly = this.isPostOnly(isMarket, undefined, params);
869
- const reduceOnlyKey = isStop ? 'reduceOnly' : 'reduce_only';
870
- const clientOrderIdKey = isStop ? 'clientOrderId' : 'client_order_id';
871
- const orderQtyKey = isStop ? 'quantity' : 'order_quantity';
872
- const priceKey = isStop ? 'price' : 'order_price';
873
- const typeKey = isStop ? 'type' : 'order_type';
874
- request[typeKey] = orderType; // LIMIT/MARKET/IOC/FOK/POST_ONLY/ASK/BID
875
- if (!isStop) {
876
- if (postOnly) {
877
- request['order_type'] = 'POST_ONLY';
878
- }
879
- else if (timeInForce === 'fok') {
880
- request['order_type'] = 'FOK';
881
- }
882
- else if (timeInForce === 'ioc') {
883
- request['order_type'] = 'IOC';
884
- }
885
- }
886
- if (reduceOnly) {
887
- request[reduceOnlyKey] = reduceOnly;
888
- }
889
- if (price !== undefined) {
890
- request[priceKey] = this.priceToPrecision(symbol, price);
891
- }
892
- if (isMarket && !isStop) {
893
- // for market buy it requires the amount of quote currency to spend
894
- if (market['spot'] && orderSide === 'BUY') {
895
- let quoteAmount = undefined;
896
- let createMarketBuyOrderRequiresPrice = true;
897
- [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
898
- const cost = this.safeNumber2(params, 'cost', 'order_amount');
899
- params = this.omit(params, ['cost', 'order_amount']);
900
- if (cost !== undefined) {
901
- quoteAmount = this.costToPrecision(symbol, cost);
902
- }
903
- else if (createMarketBuyOrderRequiresPrice) {
904
- if (price === undefined) {
905
- throw new errors.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument');
906
- }
907
- else {
908
- const amountString = this.numberToString(amount);
909
- const priceString = this.numberToString(price);
910
- const costRequest = Precise["default"].stringMul(amountString, priceString);
911
- quoteAmount = this.costToPrecision(symbol, costRequest);
912
- }
913
- }
914
- else {
915
- quoteAmount = this.costToPrecision(symbol, amount);
916
- }
917
- request['order_amount'] = quoteAmount;
918
- }
919
- else {
920
- request['order_quantity'] = this.amountToPrecision(symbol, amount);
921
- }
922
- }
923
- else if (algoType !== 'POSITIONAL_TP_SL') {
924
- request[orderQtyKey] = this.amountToPrecision(symbol, amount);
925
- }
926
- const clientOrderId = this.safeStringN(params, ['clOrdID', 'clientOrderId', 'client_order_id']);
927
- if (clientOrderId !== undefined) {
928
- request[clientOrderIdKey] = clientOrderId;
929
- }
930
- if (isTrailing) {
931
- if (trailingTriggerPrice === undefined) {
932
- throw new errors.ArgumentsRequired(this.id + ' createOrder() requires a trailingTriggerPrice parameter for trailing orders');
933
- }
934
- request['activatedPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
935
- request['algoType'] = 'TRAILING_STOP';
936
- if (isTrailingAmountOrder) {
937
- request['callbackValue'] = trailingAmount;
938
- }
939
- else if (isTrailingPercentOrder) {
940
- const convertedTrailingPercent = Precise["default"].stringDiv(trailingPercent, '100');
941
- request['callbackRate'] = convertedTrailingPercent;
942
- }
943
- }
944
- else if (stopPrice !== undefined) {
945
- if (algoType !== 'TRAILING_STOP') {
946
- request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
947
- request['algoType'] = 'STOP';
948
- }
949
- }
950
- else if ((stopLoss !== undefined) || (takeProfit !== undefined)) {
951
- request['algoType'] = 'BRACKET';
952
- const outterOrder = {
953
- 'symbol': market['id'],
954
- 'reduceOnly': false,
955
- 'algoType': 'POSITIONAL_TP_SL',
956
- 'childOrders': [],
957
- };
958
- const closeSide = (orderSide === 'BUY') ? 'SELL' : 'BUY';
959
- if (stopLoss !== undefined) {
960
- const stopLossPrice = this.safeNumber2(stopLoss, 'triggerPrice', 'price', stopLoss);
961
- const stopLossOrder = {
962
- 'side': closeSide,
963
- 'algoType': 'STOP_LOSS',
964
- 'triggerPrice': this.priceToPrecision(symbol, stopLossPrice),
965
- 'type': 'CLOSE_POSITION',
966
- 'reduceOnly': true,
967
- };
968
- outterOrder['childOrders'].push(stopLossOrder);
969
- }
970
- if (takeProfit !== undefined) {
971
- const takeProfitPrice = this.safeNumber2(takeProfit, 'triggerPrice', 'price', takeProfit);
972
- const takeProfitOrder = {
973
- 'side': closeSide,
974
- 'algoType': 'TAKE_PROFIT',
975
- 'triggerPrice': this.priceToPrecision(symbol, takeProfitPrice),
976
- 'type': 'CLOSE_POSITION',
977
- 'reduceOnly': true,
978
- };
979
- outterOrder['childOrders'].push(takeProfitOrder);
980
- }
981
- request['childOrders'] = [outterOrder];
982
- }
983
- params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingPercent', 'trailingAmount', 'trailingTriggerPrice']);
984
- let response = undefined;
985
- if (isStop) {
986
- response = await this.v3PrivatePostAlgoOrder(this.extend(request, params));
987
- }
988
- else {
989
- response = await this.v1PrivatePostOrder(this.extend(request, params));
990
- }
991
- // {
992
- // "success": true,
993
- // "timestamp": "1641383206.489",
994
- // "order_id": "86980774",
995
- // "order_type": "LIMIT",
996
- // "order_price": "1", // null for "MARKET" order
997
- // "order_quantity": "12", // null for "MARKET" order
998
- // "order_amount": null, // NOT-null for "MARKET" order
999
- // "client_order_id": "0"
1000
- // }
1001
- // stop orders
1002
- // {
1003
- // "success": true,
1004
- // "data": {
1005
- // "rows": [
1006
- // {
1007
- // "orderId": "1578938",
1008
- // "clientOrderId": "0",
1009
- // "algoType": "STOP_LOSS",
1010
- // "quantity": "0.1"
1011
- // }
1012
- // ]
1013
- // },
1014
- // "timestamp": "1686149372216"
1015
- // }
1016
- const data = this.safeValue(response, 'data');
1017
- if (data !== undefined) {
1018
- const rows = this.safeValue(data, 'rows', []);
1019
- return this.parseOrder(rows[0], market);
1020
- }
1021
- const order = this.parseOrder(response, market);
1022
- order['type'] = type;
1023
- return order;
1024
- }
1025
- async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1026
- /**
1027
- * @method
1028
- * @name woo#editOrder
1029
- * @description edit a trade order
1030
- * @see https://docs.woo.org/#edit-order
1031
- * @see https://docs.woo.org/#edit-order-by-client_order_id
1032
- * @see https://docs.woo.org/#edit-algo-order
1033
- * @see https://docs.woo.org/#edit-algo-order-by-client_order_id
1034
- * @param {string} id order id
1035
- * @param {string} symbol unified symbol of the market to create an order in
1036
- * @param {string} type 'market' or 'limit'
1037
- * @param {string} side 'buy' or 'sell'
1038
- * @param {float} amount how much of currency you want to trade in units of base currency
1039
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1040
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1041
- * @param {float} [params.triggerPrice] The price a trigger order is triggered at
1042
- * @param {float} [params.stopLossPrice] price to trigger stop-loss orders
1043
- * @param {float} [params.takeProfitPrice] price to trigger take-profit orders
1044
- * @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
1045
- * @param {string} [params.trailingPercent] the percent to trail away from the current market price
1046
- * @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
1047
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1048
- */
1049
- await this.loadMarkets();
1050
- const market = this.market(symbol);
1051
- const request = {
1052
- // 'quantity': this.amountToPrecision (symbol, amount),
1053
- // 'price': this.priceToPrecision (symbol, price),
1054
- };
1055
- if (price !== undefined) {
1056
- request['price'] = this.priceToPrecision(symbol, price);
1057
- }
1058
- if (amount !== undefined) {
1059
- request['quantity'] = this.amountToPrecision(symbol, amount);
1060
- }
1061
- const clientOrderIdUnified = this.safeString2(params, 'clOrdID', 'clientOrderId');
1062
- const clientOrderIdExchangeSpecific = this.safeString(params, 'client_order_id', clientOrderIdUnified);
1063
- const isByClientOrder = clientOrderIdExchangeSpecific !== undefined;
1064
- const stopPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'takeProfitPrice', 'stopLossPrice']);
1065
- if (stopPrice !== undefined) {
1066
- request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
1067
- }
1068
- const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', price);
1069
- const trailingAmount = this.safeString2(params, 'trailingAmount', 'callbackValue');
1070
- const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
1071
- const isTrailingAmountOrder = trailingAmount !== undefined;
1072
- const isTrailingPercentOrder = trailingPercent !== undefined;
1073
- const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
1074
- if (isTrailing) {
1075
- if (trailingTriggerPrice !== undefined) {
1076
- request['activatedPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
1077
- }
1078
- if (isTrailingAmountOrder) {
1079
- request['callbackValue'] = trailingAmount;
1080
- }
1081
- else if (isTrailingPercentOrder) {
1082
- const convertedTrailingPercent = Precise["default"].stringDiv(trailingPercent, '100');
1083
- request['callbackRate'] = convertedTrailingPercent;
1084
- }
1085
- }
1086
- params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'stopPrice', 'triggerPrice', 'takeProfitPrice', 'stopLossPrice', 'trailingTriggerPrice', 'trailingAmount', 'trailingPercent']);
1087
- const isStop = isTrailing || (stopPrice !== undefined) || (this.safeValue(params, 'childOrders') !== undefined);
1088
- let response = undefined;
1089
- if (isByClientOrder) {
1090
- request['client_order_id'] = clientOrderIdExchangeSpecific;
1091
- if (isStop) {
1092
- response = await this.v3PrivatePutAlgoOrderClientClientOrderId(this.extend(request, params));
1093
- }
1094
- else {
1095
- response = await this.v3PrivatePutOrderClientClientOrderId(this.extend(request, params));
1096
- }
1097
- }
1098
- else {
1099
- request['oid'] = id;
1100
- if (isStop) {
1101
- response = await this.v3PrivatePutAlgoOrderOid(this.extend(request, params));
1102
- }
1103
- else {
1104
- response = await this.v3PrivatePutOrderOid(this.extend(request, params));
1105
- }
1106
- }
1107
- //
1108
- // {
1109
- // "code": 0,
1110
- // "data": {
1111
- // "status": "string",
1112
- // "success": true
1113
- // },
1114
- // "message": "string",
1115
- // "success": true,
1116
- // "timestamp": 0
1117
- // }
1118
- //
1119
- const data = this.safeValue(response, 'data', {});
1120
- return this.parseOrder(data, market);
1121
- }
1122
- async cancelOrder(id, symbol = undefined, params = {}) {
1123
- /**
1124
- * @method
1125
- * @name woo#cancelOrder
1126
- * @see https://docs.woo.org/#cancel-algo-order
1127
- * @see https://docs.woo.org/#cancel-order
1128
- * @see https://docs.woo.org/#cancel-order-by-client_order_id
1129
- * @description cancels an open order
1130
- * @param {string} id order id
1131
- * @param {string} symbol unified symbol of the market the order was made in
1132
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1133
- * @param {boolean} [params.stop] whether the order is a stop/algo order
1134
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1135
- */
1136
- const stop = this.safeValue(params, 'stop', false);
1137
- params = this.omit(params, 'stop');
1138
- if (!stop && (symbol === undefined)) {
1139
- throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
1140
- }
1141
- await this.loadMarkets();
1142
- let market = undefined;
1143
- if (symbol !== undefined) {
1144
- market = this.market(symbol);
1145
- }
1146
- const request = {};
1147
- const clientOrderIdUnified = this.safeString2(params, 'clOrdID', 'clientOrderId');
1148
- const clientOrderIdExchangeSpecific = this.safeString(params, 'client_order_id', clientOrderIdUnified);
1149
- const isByClientOrder = clientOrderIdExchangeSpecific !== undefined;
1150
- let response = undefined;
1151
- if (stop) {
1152
- request['order_id'] = id;
1153
- response = await this.v3PrivateDeleteAlgoOrderOrderId(this.extend(request, params));
1154
- }
1155
- else {
1156
- request['symbol'] = market['id'];
1157
- if (isByClientOrder) {
1158
- request['client_order_id'] = clientOrderIdExchangeSpecific;
1159
- params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id']);
1160
- response = await this.v1PrivateDeleteClientOrder(this.extend(request, params));
1161
- }
1162
- else {
1163
- request['order_id'] = id;
1164
- response = await this.v1PrivateDeleteOrder(this.extend(request, params));
1165
- }
1166
- }
1167
- //
1168
- // { success: true, status: "CANCEL_SENT" }
1169
- //
1170
- const extendParams = { 'symbol': symbol };
1171
- if (isByClientOrder) {
1172
- extendParams['client_order_id'] = clientOrderIdExchangeSpecific;
1173
- }
1174
- else {
1175
- extendParams['id'] = id;
1176
- }
1177
- return this.extend(this.parseOrder(response), extendParams);
1178
- }
1179
- async cancelAllOrders(symbol = undefined, params = {}) {
1180
- /**
1181
- * @method
1182
- * @name woo#cancelAllOrders
1183
- * @see https://docs.woo.org/#cancel-all-pending-orders
1184
- * @see https://docs.woo.org/#cancel-orders
1185
- * @see https://docs.woo.org/#cancel-all-pending-algo-orders
1186
- * @description cancel all open orders in a market
1187
- * @param {string} symbol unified market symbol
1188
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1189
- * @param {boolean} [params.stop] whether the order is a stop/algo order
1190
- * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1191
- */
1192
- await this.loadMarkets();
1193
- const stop = this.safeValue(params, 'stop');
1194
- params = this.omit(params, 'stop');
1195
- if (stop) {
1196
- return await this.v3PrivateDeleteAlgoOrdersPending(params);
1197
- }
1198
- if (symbol === undefined) {
1199
- throw new errors.ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
1200
- }
1201
- const market = this.market(symbol);
1202
- const request = {
1203
- 'symbol': market['id'],
1204
- };
1205
- const response = await this.v1PrivateDeleteOrders(this.extend(request, params));
1206
- //
1207
- // {
1208
- // "success":true,
1209
- // "status":"CANCEL_ALL_SENT"
1210
- // }
1211
- //
1212
- return response;
1213
- }
1214
- async fetchOrder(id, symbol = undefined, params = {}) {
1215
- /**
1216
- * @method
1217
- * @name woo#fetchOrder
1218
- * @see https://docs.woo.org/#get-algo-order
1219
- * @see https://docs.woo.org/#get-order
1220
- * @description fetches information on an order made by the user
1221
- * @param {string} symbol unified symbol of the market the order was made in
1222
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1223
- * @param {boolean} [params.stop] whether the order is a stop/algo order
1224
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1225
- */
1226
- await this.loadMarkets();
1227
- const market = (symbol !== undefined) ? this.market(symbol) : undefined;
1228
- const stop = this.safeValue(params, 'stop');
1229
- params = this.omit(params, 'stop');
1230
- const request = {};
1231
- const clientOrderId = this.safeString2(params, 'clOrdID', 'clientOrderId');
1232
- let response = undefined;
1233
- if (stop) {
1234
- request['oid'] = id;
1235
- response = await this.v3PrivateGetAlgoOrderOid(this.extend(request, params));
1236
- }
1237
- else if (clientOrderId) {
1238
- request['client_order_id'] = clientOrderId;
1239
- response = await this.v1PrivateGetClientOrderClientOrderId(this.extend(request, params));
1240
- }
1241
- else {
1242
- request['oid'] = id;
1243
- response = await this.v1PrivateGetOrderOid(this.extend(request, params));
1244
- }
1245
- //
1246
- // {
1247
- // "success": true,
1248
- // "symbol": "SPOT_WOO_USDT",
1249
- // "status": "FILLED", // FILLED, NEW
1250
- // "side": "BUY",
1251
- // "created_time": "1641480933.000",
1252
- // "order_id": "87541111",
1253
- // "order_tag": "default",
1254
- // "price": "1",
1255
- // "type": "LIMIT",
1256
- // "quantity": "12",
1257
- // "amount": null,
1258
- // "visible": "12",
1259
- // "executed": "12", // or any partial amount
1260
- // "total_fee": "0.0024",
1261
- // "fee_asset": "WOO",
1262
- // "client_order_id": null,
1263
- // "average_executed_price": "1",
1264
- // "Transactions": [
1265
- // {
1266
- // "id": "99111647",
1267
- // "symbol": "SPOT_WOO_USDT",
1268
- // "fee": "0.0024",
1269
- // "side": "BUY",
1270
- // "executed_timestamp": "1641482113.084",
1271
- // "order_id": "87541111",
1272
- // "executed_price": "1",
1273
- // "executed_quantity": "12",
1274
- // "fee_asset": "WOO",
1275
- // "is_maker": "1"
1276
- // }
1277
- // ]
1278
- // }
1279
- //
1280
- const orders = this.safeValue(response, 'data', response);
1281
- return this.parseOrder(orders, market);
1282
- }
1283
- async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1284
- /**
1285
- * @method
1286
- * @name woo#fetchOrders
1287
- * @description fetches information on multiple orders made by the user
1288
- * @see https://docs.woo.org/#get-orders
1289
- * @see https://docs.woo.org/#get-algo-orders
1290
- * @param {string} symbol unified market symbol of the market orders were made in
1291
- * @param {int} [since] the earliest time in ms to fetch orders for
1292
- * @param {int} [limit] the maximum number of order structures to retrieve
1293
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1294
- * @param {boolean} [params.stop] whether the order is a stop/algo order
1295
- * @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
1296
- * @param {string} [params.side] 'buy' or 'sell'
1297
- * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
1298
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1299
- */
1300
- await this.loadMarkets();
1301
- const request = {};
1302
- let market = undefined;
1303
- const stop = this.safeValue(params, 'stop');
1304
- const trailing = this.safeValue(params, 'trailing', false);
1305
- params = this.omit(params, ['stop', 'trailing']);
1306
- if (symbol !== undefined) {
1307
- market = this.market(symbol);
1308
- request['symbol'] = market['id'];
1309
- }
1310
- if (since !== undefined) {
1311
- if (stop || trailing) {
1312
- request['createdTimeStart'] = since;
1313
- }
1314
- else {
1315
- request['start_t'] = since;
1316
- }
1317
- }
1318
- if (stop) {
1319
- request['algoType'] = 'stop';
1320
- }
1321
- else if (trailing) {
1322
- request['algoType'] = 'TRAILING_STOP';
1323
- }
1324
- let response = undefined;
1325
- if (stop || trailing) {
1326
- response = await this.v3PrivateGetAlgoOrders(this.extend(request, params));
1327
- }
1328
- else {
1329
- response = await this.v1PrivateGetOrders(this.extend(request, params));
1330
- }
1331
- //
1332
- // {
1333
- // "success":true,
1334
- // "meta":{
1335
- // "total":1,
1336
- // "records_per_page":100,
1337
- // "current_page":1
1338
- // },
1339
- // "rows":[
1340
- // {
1341
- // "symbol":"PERP_BTC_USDT",
1342
- // "status":"FILLED",
1343
- // "side":"SELL",
1344
- // "created_time":"1611617776.000",
1345
- // "updated_time":"1611617776.000",
1346
- // "order_id":52121167,
1347
- // "order_tag":"default",
1348
- // "price":null,
1349
- // "type":"MARKET",
1350
- // "quantity":0.002,
1351
- // "amount":null,
1352
- // "visible":0,
1353
- // "executed":0.002,
1354
- // "total_fee":0.01732885,
1355
- // "fee_asset":"USDT",
1356
- // "client_order_id":null,
1357
- // "average_executed_price":28881.41
1358
- // }
1359
- // ]
1360
- // }
1361
- //
1362
- const data = this.safeValue(response, 'data', response);
1363
- const orders = this.safeValue(data, 'rows');
1364
- return this.parseOrders(orders, market, since, limit, params);
1365
- }
1366
- parseTimeInForce(timeInForce) {
1367
- const timeInForces = {
1368
- 'ioc': 'IOC',
1369
- 'fok': 'FOK',
1370
- 'post_only': 'PO',
1371
- };
1372
- return this.safeString(timeInForces, timeInForce, undefined);
1373
- }
1374
- parseOrder(order, market = undefined) {
1375
- //
1376
- // Possible input functions:
1377
- // * createOrder
1378
- // * cancelOrder
1379
- // * fetchOrder
1380
- // * fetchOrders
1381
- // const isFromFetchOrder = ('order_tag' in order); TO_DO
1382
- //
1383
- // stop order after creating it:
1384
- // {
1385
- // "orderId": "1578938",
1386
- // "clientOrderId": "0",
1387
- // "algoType": "STOP_LOSS",
1388
- // "quantity": "0.1"
1389
- // }
1390
- // stop order after fetching it:
1391
- // {
1392
- // "algoOrderId": "1578958",
1393
- // "clientOrderId": "0",
1394
- // "rootAlgoOrderId": "1578958",
1395
- // "parentAlgoOrderId": "0",
1396
- // "symbol": "SPOT_LTC_USDT",
1397
- // "orderTag": "default",
1398
- // "algoType": "STOP_LOSS",
1399
- // "side": "BUY",
1400
- // "quantity": "0.1",
1401
- // "isTriggered": false,
1402
- // "triggerPrice": "100",
1403
- // "triggerStatus": "USELESS",
1404
- // "type": "LIMIT",
1405
- // "rootAlgoStatus": "CANCELLED",
1406
- // "algoStatus": "CANCELLED",
1407
- // "triggerPriceType": "MARKET_PRICE",
1408
- // "price": "75",
1409
- // "triggerTime": "0",
1410
- // "totalExecutedQuantity": "0",
1411
- // "averageExecutedPrice": "0",
1412
- // "totalFee": "0",
1413
- // "feeAsset": '',
1414
- // "reduceOnly": false,
1415
- // "createdTime": "1686149609.744",
1416
- // "updatedTime": "1686149903.362"
1417
- // }
1418
- //
1419
- const timestamp = this.safeTimestampN(order, ['timestamp', 'created_time', 'createdTime']);
1420
- const orderId = this.safeStringN(order, ['order_id', 'orderId', 'algoOrderId']);
1421
- const clientOrderId = this.omitZero(this.safeString2(order, 'client_order_id', 'clientOrderId')); // Somehow, this always returns 0 for limit order
1422
- const marketId = this.safeString(order, 'symbol');
1423
- market = this.safeMarket(marketId, market);
1424
- const symbol = market['symbol'];
1425
- const price = this.safeString2(order, 'order_price', 'price');
1426
- const amount = this.safeString2(order, 'order_quantity', 'quantity'); // This is base amount
1427
- const cost = this.safeString2(order, 'order_amount', 'amount'); // This is quote amount
1428
- const orderType = this.safeStringLower2(order, 'order_type', 'type');
1429
- const status = this.safeValue2(order, 'status', 'algoStatus');
1430
- const side = this.safeStringLower(order, 'side');
1431
- const filled = this.omitZero(this.safeValue2(order, 'executed', 'totalExecutedQuantity'));
1432
- const average = this.omitZero(this.safeString2(order, 'average_executed_price', 'averageExecutedPrice'));
1433
- const remaining = Precise["default"].stringSub(cost, filled);
1434
- const fee = this.safeValue2(order, 'total_fee', 'totalFee');
1435
- const feeCurrency = this.safeString2(order, 'fee_asset', 'feeAsset');
1436
- const transactions = this.safeValue(order, 'Transactions');
1437
- const stopPrice = this.safeNumber(order, 'triggerPrice');
1438
- let takeProfitPrice = undefined;
1439
- let stopLossPrice = undefined;
1440
- const childOrders = this.safeValue(order, 'childOrders');
1441
- if (childOrders !== undefined) {
1442
- const first = this.safeValue(childOrders, 0);
1443
- const innerChildOrders = this.safeValue(first, 'childOrders', []);
1444
- const innerChildOrdersLength = innerChildOrders.length;
1445
- if (innerChildOrdersLength > 0) {
1446
- const takeProfitOrder = this.safeValue(innerChildOrders, 0);
1447
- const stopLossOrder = this.safeValue(innerChildOrders, 1);
1448
- takeProfitPrice = this.safeNumber(takeProfitOrder, 'triggerPrice');
1449
- stopLossPrice = this.safeNumber(stopLossOrder, 'triggerPrice');
1450
- }
1451
- }
1452
- const lastUpdateTimestamp = this.safeTimestamp2(order, 'updatedTime', 'updated_time');
1453
- return this.safeOrder({
1454
- 'id': orderId,
1455
- 'clientOrderId': clientOrderId,
1456
- 'timestamp': timestamp,
1457
- 'datetime': this.iso8601(timestamp),
1458
- 'lastTradeTimestamp': undefined,
1459
- 'lastUpdateTimestamp': lastUpdateTimestamp,
1460
- 'status': this.parseOrderStatus(status),
1461
- 'symbol': symbol,
1462
- 'type': orderType,
1463
- 'timeInForce': this.parseTimeInForce(orderType),
1464
- 'postOnly': undefined,
1465
- 'reduceOnly': this.safeValue(order, 'reduce_only'),
1466
- 'side': side,
1467
- 'price': price,
1468
- 'stopPrice': stopPrice,
1469
- 'triggerPrice': stopPrice,
1470
- 'takeProfitPrice': takeProfitPrice,
1471
- 'stopLossPrice': stopLossPrice,
1472
- 'average': average,
1473
- 'amount': amount,
1474
- 'filled': filled,
1475
- 'remaining': remaining,
1476
- 'cost': cost,
1477
- 'trades': transactions,
1478
- 'fee': {
1479
- 'cost': fee,
1480
- 'currency': feeCurrency,
1481
- },
1482
- 'info': order,
1483
- }, market);
1484
- }
1485
- parseOrderStatus(status) {
1486
- if (status !== undefined) {
1487
- const statuses = {
1488
- 'NEW': 'open',
1489
- 'FILLED': 'closed',
1490
- 'CANCEL_SENT': 'canceled',
1491
- 'CANCEL_ALL_SENT': 'canceled',
1492
- 'CANCELLED': 'canceled',
1493
- 'PARTIAL_FILLED': 'open',
1494
- 'REJECTED': 'rejected',
1495
- 'INCOMPLETE': 'open',
1496
- 'COMPLETED': 'closed',
1497
- };
1498
- return this.safeString(statuses, status, status);
1499
- }
1500
- return status;
1501
- }
1502
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
1503
- /**
1504
- * @method
1505
- * @name woo#fetchOrderBook
1506
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1507
- * @param {string} symbol unified symbol of the market to fetch the order book for
1508
- * @param {int} [limit] the maximum amount of order book entries to return
1509
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1510
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
1511
- */
1512
- await this.loadMarkets();
1513
- const market = this.market(symbol);
1514
- const request = {
1515
- 'symbol': market['id'],
1516
- };
1517
- if (limit !== undefined) {
1518
- limit = Math.min(limit, 1000);
1519
- request['max_level'] = limit;
1520
- }
1521
- const response = await this.v1PublicGetOrderbookSymbol(this.extend(request, params));
1522
- //
1523
- // {
1524
- // "success": true,
1525
- // "timestamp": "1641562961192",
1526
- // "asks": [
1527
- // { price: '0.921', quantity: "76.01" },
1528
- // { price: '0.933', quantity: "477.10" },
1529
- // ...
1530
- // ],
1531
- // "bids": [
1532
- // { price: '0.940', quantity: "13502.47" },
1533
- // { price: '0.932', quantity: "43.91" },
1534
- // ...
1535
- // ]
1536
- // }
1537
- //
1538
- const timestamp = this.safeInteger(response, 'timestamp');
1539
- return this.parseOrderBook(response, symbol, timestamp, 'bids', 'asks', 'price', 'quantity');
1540
- }
1541
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1542
- /**
1543
- * @method
1544
- * @name woo#fetchOHLCV
1545
- * @see https://docs.woo.org/#kline-public
1546
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1547
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1548
- * @param {string} timeframe the length of time each candle represents
1549
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
1550
- * @param {int} [limit] the maximum amount of candles to fetch
1551
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1552
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1553
- */
1554
- await this.loadMarkets();
1555
- const market = this.market(symbol);
1556
- const request = {
1557
- 'symbol': market['id'],
1558
- 'type': this.safeString(this.timeframes, timeframe, timeframe),
1559
- };
1560
- if (limit !== undefined) {
1561
- request['limit'] = Math.min(limit, 1000);
1562
- }
1563
- const response = await this.v1PublicGetKline(this.extend(request, params));
1564
- // {
1565
- // "success": true,
1566
- // "rows": [
1567
- // {
1568
- // "open": "0.94238",
1569
- // "close": "0.94271",
1570
- // "low": "0.94238",
1571
- // "high": "0.94296",
1572
- // "volume": "73.55",
1573
- // "amount": "69.32040520",
1574
- // "symbol": "SPOT_WOO_USDT",
1575
- // "type": "1m",
1576
- // "start_timestamp": "1641584700000",
1577
- // "end_timestamp": "1641584760000"
1578
- // },
1579
- // {
1580
- // "open": "0.94186",
1581
- // "close": "0.94186",
1582
- // "low": "0.94186",
1583
- // "high": "0.94186",
1584
- // "volume": "64.00",
1585
- // "amount": "60.27904000",
1586
- // "symbol": "SPOT_WOO_USDT",
1587
- // "type": "1m",
1588
- // "start_timestamp": "1641584640000",
1589
- // "end_timestamp": "1641584700000"
1590
- // },
1591
- // ...
1592
- // ]
1593
- // }
1594
- const data = this.safeValue(response, 'rows', []);
1595
- return this.parseOHLCVs(data, market, timeframe, since, limit);
1596
- }
1597
- parseOHLCV(ohlcv, market = undefined) {
1598
- // example response in fetchOHLCV
1599
- return [
1600
- this.safeInteger(ohlcv, 'start_timestamp'),
1601
- this.safeNumber(ohlcv, 'open'),
1602
- this.safeNumber(ohlcv, 'high'),
1603
- this.safeNumber(ohlcv, 'low'),
1604
- this.safeNumber(ohlcv, 'close'),
1605
- this.safeNumber(ohlcv, 'volume'),
1606
- ];
1607
- }
1608
- async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
1609
- /**
1610
- * @method
1611
- * @name woo#fetchOrderTrades
1612
- * @description fetch all the trades made from a single order
1613
- * @param {string} id order id
1614
- * @param {string} symbol unified market symbol
1615
- * @param {int} [since] the earliest time in ms to fetch trades for
1616
- * @param {int} [limit] the maximum number of trades to retrieve
1617
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1618
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1619
- */
1620
- await this.loadMarkets();
1621
- let market = undefined;
1622
- if (symbol !== undefined) {
1623
- market = this.market(symbol);
1624
- }
1625
- const request = {
1626
- 'oid': id,
1627
- };
1628
- const response = await this.v1PrivateGetOrderOidTrades(this.extend(request, params));
1629
- // {
1630
- // "success": true,
1631
- // "rows": [
1632
- // {
1633
- // "id": "99111647",
1634
- // "symbol": "SPOT_WOO_USDT",
1635
- // "fee": "0.0024",
1636
- // "side": "BUY",
1637
- // "executed_timestamp": "1641482113.084",
1638
- // "order_id": "87541111",
1639
- // "order_tag": "default",
1640
- // "executed_price": "1",
1641
- // "executed_quantity": "12",
1642
- // "fee_asset": "WOO",
1643
- // "is_maker": "1"
1644
- // }
1645
- // ]
1646
- // }
1647
- const trades = this.safeValue(response, 'rows', []);
1648
- return this.parseTrades(trades, market, since, limit, params);
1649
- }
1650
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1651
- /**
1652
- * @method
1653
- * @name woo#fetchMyTrades
1654
- * @description fetch all trades made by the user
1655
- * @param {string} symbol unified market symbol
1656
- * @param {int} [since] the earliest time in ms to fetch trades for
1657
- * @param {int} [limit] the maximum number of trades structures to retrieve
1658
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1659
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1660
- */
1661
- await this.loadMarkets();
1662
- const request = {};
1663
- let market = undefined;
1664
- if (symbol !== undefined) {
1665
- market = this.market(symbol);
1666
- request['symbol'] = market['id'];
1667
- }
1668
- if (since !== undefined) {
1669
- request['start_t'] = since;
1670
- }
1671
- const response = await this.v1PrivateGetClientTrades(this.extend(request, params));
1672
- // {
1673
- // "success": true,
1674
- // "meta": {
1675
- // "records_per_page": 25,
1676
- // "current_page": 1
1677
- // },
1678
- // "rows": [
1679
- // {
1680
- // "id": 5,
1681
- // "symbol": "SPOT_BTC_USDT",
1682
- // "order_id": 211,
1683
- // "order_tag": "default",
1684
- // "executed_price": 10892.84,
1685
- // "executed_quantity": 0.002,
1686
- // "is_maker": 0,
1687
- // "side": "SELL",
1688
- // "fee": 0,
1689
- // "fee_asset": "USDT",
1690
- // "executed_timestamp": "1566264290.250"
1691
- // },
1692
- // ...
1693
- // ]
1694
- // }
1695
- const trades = this.safeValue(response, 'rows', []);
1696
- return this.parseTrades(trades, market, since, limit, params);
1697
- }
1698
- async fetchAccounts(params = {}) {
1699
- /**
1700
- * @method
1701
- * @name woo#fetchAccounts
1702
- * @description fetch all the accounts associated with a profile
1703
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1704
- * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
1705
- */
1706
- const response = await this.v1PrivateGetSubAccountAssets(params);
1707
- //
1708
- // {
1709
- // "rows": [{
1710
- // "application_id": "13e4fc34-e2ff-4cb7-b1e4-4c22fee7d365",
1711
- // "account": "Main",
1712
- // "usdt_balance": "4.0"
1713
- // },
1714
- // {
1715
- // "application_id": "432952aa-a401-4e26-aff6-972920aebba3",
1716
- // "account": "subaccount",
1717
- // "usdt_balance": "1.0"
1718
- // }
1719
- // ],
1720
- // "success": true
1721
- // }
1722
- //
1723
- const rows = this.safeValue(response, 'rows', []);
1724
- return this.parseAccounts(rows, params);
1725
- }
1726
- parseAccount(account) {
1727
- //
1728
- // {
1729
- // "application_id": "336952aa-a401-4e26-aff6-972920aebba3",
1730
- // "account": "subaccount",
1731
- // "usdt_balance": "1.0",
1732
- // }
1733
- //
1734
- const accountId = this.safeString(account, 'account');
1735
- return {
1736
- 'info': account,
1737
- 'id': this.safeString(account, 'application_id'),
1738
- 'name': accountId,
1739
- 'code': undefined,
1740
- 'type': accountId === 'Main' ? 'main' : 'subaccount',
1741
- };
1742
- }
1743
- async fetchBalance(params = {}) {
1744
- /**
1745
- * @method
1746
- * @name woo#fetchBalance
1747
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
1748
- * @see https://docs.woo.org/#get-current-holding-get-balance-new
1749
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1750
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1751
- */
1752
- await this.loadMarkets();
1753
- const response = await this.v3PrivateGetBalances(params);
1754
- //
1755
- // {
1756
- // "success": true,
1757
- // "data": {
1758
- // "holding": [
1759
- // {
1760
- // "token": "0_token",
1761
- // "holding": 1,
1762
- // "frozen": 0,
1763
- // "staked": 0,
1764
- // "unbonding": 0,
1765
- // "vault": 0,
1766
- // "interest": 0,
1767
- // "pendingShortQty": 0,
1768
- // "pendingLongQty": 0,
1769
- // "availableBalance": 0,
1770
- // "updatedTime": 312321.121
1771
- // }
1772
- // ]
1773
- // },
1774
- // "timestamp": 1673323746259
1775
- // }
1776
- //
1777
- const data = this.safeValue(response, 'data');
1778
- return this.parseBalance(data);
1779
- }
1780
- parseBalance(response) {
1781
- const result = {
1782
- 'info': response,
1783
- };
1784
- const balances = this.safeValue(response, 'holding', []);
1785
- for (let i = 0; i < balances.length; i++) {
1786
- const balance = balances[i];
1787
- const code = this.safeCurrencyCode(this.safeString(balance, 'token'));
1788
- const account = this.account();
1789
- account['total'] = this.safeString(balance, 'holding');
1790
- account['free'] = this.safeString(balance, 'availableBalance');
1791
- result[code] = account;
1792
- }
1793
- return this.safeBalance(result);
1794
- }
1795
- async fetchDepositAddress(code, params = {}) {
1796
- /**
1797
- * @method
1798
- * @name woo#fetchDepositAddress
1799
- * @description fetch the deposit address for a currency associated with this account
1800
- * @param {string} code unified currency code
1801
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1802
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1803
- */
1804
- // this method is TODO because of networks unification
1805
- await this.loadMarkets();
1806
- const currency = this.currency(code);
1807
- const networkCodeDefault = this.defaultNetworkCodeForCurrency(code);
1808
- const networkCode = this.safeString(params, 'network', networkCodeDefault);
1809
- params = this.omit(params, 'network');
1810
- const codeForExchange = networkCode + '_' + currency['code'];
1811
- const request = {
1812
- 'token': codeForExchange,
1813
- };
1814
- const response = await this.v1PrivateGetAssetDeposit(this.extend(request, params));
1815
- // {
1816
- // "success": true,
1817
- // "address": "3Jmtjx5544T4smrit9Eroe4PCrRkpDeKjP",
1818
- // "extra": ''
1819
- // }
1820
- const tag = this.safeString(response, 'extra');
1821
- const address = this.safeString(response, 'address');
1822
- this.checkAddress(address);
1823
- return {
1824
- 'currency': code,
1825
- 'address': address,
1826
- 'tag': tag,
1827
- 'network': networkCode,
1828
- 'info': response,
1829
- };
1830
- }
1831
- async getAssetHistoryRows(code = undefined, since = undefined, limit = undefined, params = {}) {
1832
- await this.loadMarkets();
1833
- const request = {};
1834
- let currency = undefined;
1835
- if (code !== undefined) {
1836
- currency = this.currency(code);
1837
- request['balance_token'] = currency['id'];
1838
- }
1839
- if (since !== undefined) {
1840
- request['start_t'] = since;
1841
- }
1842
- if (limit !== undefined) {
1843
- request['pageSize'] = limit;
1844
- }
1845
- const transactionType = this.safeString(params, 'type');
1846
- params = this.omit(params, 'type');
1847
- if (transactionType !== undefined) {
1848
- request['type'] = transactionType;
1849
- }
1850
- const response = await this.v1PrivateGetAssetHistory(this.extend(request, params));
1851
- // {
1852
- // "rows": [
1853
- // {
1854
- // "id": "22010508193900165",
1855
- // "token": "TRON_USDT",
1856
- // "extra": '',
1857
- // "amount": "13.75848500",
1858
- // "status": "COMPLETED",
1859
- // "account": null,
1860
- // "description": null,
1861
- // "user_id": "42222",
1862
- // "application_id": "6ad2b303-f354-45c0-8105-9f5f19d0e335",
1863
- // "external_id": "220105081900134",
1864
- // "target_address": "TXnyFSnAYad3YCaqtwMw9jvXKkeU39NLnK",
1865
- // "source_address": "TYDzsYUEpvnYmQk4zGP9sWWcTEd2MiAtW6",
1866
- // "type": "BALANCE",
1867
- // "token_side": "DEPOSIT",
1868
- // "tx_id": "35b0004022f6b3ad07f39a0b7af199f6b258c2c3e2c7cdc93c67efa74fd625ee",
1869
- // "fee_token": '',
1870
- // "fee_amount": "0.00000000",
1871
- // "created_time": "1641370779.442",
1872
- // "updated_time": "1641370779.465",
1873
- // "is_new_target_address": null,
1874
- // "confirmed_number": "29",
1875
- // "confirming_threshold": "27",
1876
- // "audit_tag": "1",
1877
- // "audit_result": "0",
1878
- // "balance_token": null, // TODO -write to support, that this seems broken. here should be the token id
1879
- // "network_name": null // TODO -write to support, that this seems broken. here should be the network id
1880
- // }
1881
- // ],
1882
- // "meta": { total: '1', records_per_page: "25", current_page: "1" },
1883
- // "success": true
1884
- // }
1885
- return [currency, this.safeValue(response, 'rows', {})];
1886
- }
1887
- async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1888
- /**
1889
- * @method
1890
- * @name woo#fetchLedger
1891
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1892
- * @param {string} code unified currency code, default is undefined
1893
- * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1894
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
1895
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1896
- * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
1897
- */
1898
- const [currency, rows] = await this.getAssetHistoryRows(code, since, limit, params);
1899
- return this.parseLedger(rows, currency, since, limit, params);
1900
- }
1901
- parseLedgerEntry(item, currency = undefined) {
1902
- const networkizedCode = this.safeString(item, 'token');
1903
- const currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency);
1904
- const code = currencyDefined['code'];
1905
- const amount = this.safeNumber(item, 'amount');
1906
- const side = this.safeString(item, 'token_side');
1907
- const direction = (side === 'DEPOSIT') ? 'in' : 'out';
1908
- const timestamp = this.safeTimestamp(item, 'created_time');
1909
- const fee = this.parseTokenAndFeeTemp(item, 'fee_token', 'fee_amount');
1910
- return {
1911
- 'id': this.safeString(item, 'id'),
1912
- 'currency': code,
1913
- 'account': this.safeString(item, 'account'),
1914
- 'referenceAccount': undefined,
1915
- 'referenceId': this.safeString(item, 'tx_id'),
1916
- 'status': this.parseTransactionStatus(this.safeString(item, 'status')),
1917
- 'amount': amount,
1918
- 'before': undefined,
1919
- 'after': undefined,
1920
- 'fee': fee,
1921
- 'direction': direction,
1922
- 'timestamp': timestamp,
1923
- 'datetime': this.iso8601(timestamp),
1924
- 'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
1925
- 'info': item,
1926
- };
1927
- }
1928
- parseLedgerEntryType(type) {
1929
- const types = {
1930
- 'BALANCE': 'transaction',
1931
- 'COLLATERAL': 'transfer', // Funds moved between portfolios
1932
- };
1933
- return this.safeString(types, type, type);
1934
- }
1935
- getCurrencyFromChaincode(networkizedCode, currency) {
1936
- if (currency !== undefined) {
1937
- return currency;
1938
- }
1939
- else {
1940
- const parts = networkizedCode.split('_');
1941
- const partsLength = parts.length;
1942
- const firstPart = this.safeString(parts, 0);
1943
- let currencyId = this.safeString(parts, 1, firstPart);
1944
- if (partsLength > 2) {
1945
- currencyId += '_' + this.safeString(parts, 2);
1946
- }
1947
- currency = this.safeCurrency(currencyId);
1948
- }
1949
- return currency;
1950
- }
1951
- async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
1952
- /**
1953
- * @method
1954
- * @name woo#fetchDeposits
1955
- * @description fetch all deposits made to an account
1956
- * @param {string} code unified currency code
1957
- * @param {int} [since] the earliest time in ms to fetch deposits for
1958
- * @param {int} [limit] the maximum number of deposits structures to retrieve
1959
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1960
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1961
- */
1962
- const request = {
1963
- 'token_side': 'DEPOSIT',
1964
- };
1965
- return await this.fetchDepositsWithdrawals(code, since, limit, this.extend(request, params));
1966
- }
1967
- async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1968
- /**
1969
- * @method
1970
- * @name woo#fetchWithdrawals
1971
- * @description fetch all withdrawals made from an account
1972
- * @param {string} code unified currency code
1973
- * @param {int} [since] the earliest time in ms to fetch withdrawals for
1974
- * @param {int} [limit] the maximum number of withdrawals structures to retrieve
1975
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1976
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1977
- */
1978
- const request = {
1979
- 'token_side': 'WITHDRAW',
1980
- };
1981
- return await this.fetchDepositsWithdrawals(code, since, limit, this.extend(request, params));
1982
- }
1983
- async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1984
- /**
1985
- * @method
1986
- * @name woo#fetchDepositsWithdrawals
1987
- * @description fetch history of deposits and withdrawals
1988
- * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
1989
- * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
1990
- * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
1991
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1992
- * @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1993
- */
1994
- const request = {
1995
- 'type': 'BALANCE',
1996
- };
1997
- const [currency, rows] = await this.getAssetHistoryRows(code, since, limit, this.extend(request, params));
1998
- //
1999
- // {
2000
- // "rows":[],
2001
- // "meta":{
2002
- // "total":0,
2003
- // "records_per_page":25,
2004
- // "current_page":1
2005
- // },
2006
- // "success":true
2007
- // }
2008
- //
2009
- return this.parseTransactions(rows, currency, since, limit, params);
2010
- }
2011
- parseTransaction(transaction, currency = undefined) {
2012
- // example in fetchLedger
2013
- const networkizedCode = this.safeString(transaction, 'token');
2014
- const currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency);
2015
- const code = currencyDefined['code'];
2016
- let movementDirection = this.safeStringLower(transaction, 'token_side');
2017
- if (movementDirection === 'withdraw') {
2018
- movementDirection = 'withdrawal';
2019
- }
2020
- const fee = this.parseTokenAndFeeTemp(transaction, 'fee_token', 'fee_amount');
2021
- const addressTo = this.safeString(transaction, 'target_address');
2022
- const addressFrom = this.safeString(transaction, 'source_address');
2023
- const timestamp = this.safeTimestamp(transaction, 'created_time');
2024
- return {
2025
- 'info': transaction,
2026
- 'id': this.safeString2(transaction, 'id', 'withdraw_id'),
2027
- 'txid': this.safeString(transaction, 'tx_id'),
2028
- 'timestamp': timestamp,
2029
- 'datetime': this.iso8601(timestamp),
2030
- 'address': undefined,
2031
- 'addressFrom': addressFrom,
2032
- 'addressTo': addressTo,
2033
- 'tag': this.safeString(transaction, 'extra'),
2034
- 'tagFrom': undefined,
2035
- 'tagTo': undefined,
2036
- 'type': movementDirection,
2037
- 'amount': this.safeNumber(transaction, 'amount'),
2038
- 'currency': code,
2039
- 'status': this.parseTransactionStatus(this.safeString(transaction, 'status')),
2040
- 'updated': this.safeTimestamp(transaction, 'updated_time'),
2041
- 'comment': undefined,
2042
- 'internal': undefined,
2043
- 'fee': fee,
2044
- 'network': undefined,
2045
- };
2046
- }
2047
- parseTransactionStatus(status) {
2048
- const statuses = {
2049
- 'NEW': 'pending',
2050
- 'CONFIRMING': 'pending',
2051
- 'PROCESSING': 'pending',
2052
- 'COMPLETED': 'ok',
2053
- 'CANCELED': 'canceled',
2054
- };
2055
- return this.safeString(statuses, status, status);
2056
- }
2057
- async transfer(code, amount, fromAccount, toAccount, params = {}) {
2058
- /**
2059
- * @method
2060
- * @name woo#transfer
2061
- * @description transfer currency internally between wallets on the same account
2062
- * @param {string} code unified currency code
2063
- * @param {float} amount amount to transfer
2064
- * @param {string} fromAccount account to transfer from
2065
- * @param {string} toAccount account to transfer to
2066
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2067
- * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
2068
- */
2069
- await this.loadMarkets();
2070
- const currency = this.currency(code);
2071
- const request = {
2072
- 'token': currency['id'],
2073
- 'amount': this.parseNumber(amount),
2074
- 'from_application_id': fromAccount,
2075
- 'to_application_id': toAccount,
2076
- };
2077
- const response = await this.v1PrivatePostAssetMainSubTransfer(this.extend(request, params));
2078
- //
2079
- // {
2080
- // "success": true,
2081
- // "id": 200
2082
- // }
2083
- //
2084
- const transfer = this.parseTransfer(response, currency);
2085
- const transferOptions = this.safeValue(this.options, 'transfer', {});
2086
- const fillResponseFromRequest = this.safeValue(transferOptions, 'fillResponseFromRequest', true);
2087
- if (fillResponseFromRequest) {
2088
- transfer['amount'] = amount;
2089
- transfer['fromAccount'] = fromAccount;
2090
- transfer['toAccount'] = toAccount;
2091
- }
2092
- return transfer;
2093
- }
2094
- async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
2095
- /**
2096
- * @method
2097
- * @name woo#fetchTransfers
2098
- * @description fetch a history of internal transfers made on an account
2099
- * @param {string} code unified currency code of the currency transferred
2100
- * @param {int} [since] the earliest time in ms to fetch transfers for
2101
- * @param {int} [limit] the maximum number of transfers structures to retrieve
2102
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2103
- * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
2104
- */
2105
- const request = {
2106
- 'type': 'COLLATERAL',
2107
- };
2108
- const [currency, rows] = await this.getAssetHistoryRows(code, since, limit, this.extend(request, params));
2109
- return this.parseTransfers(rows, currency, since, limit, params);
2110
- }
2111
- parseTransfer(transfer, currency = undefined) {
2112
- //
2113
- // getAssetHistoryRows
2114
- // {
2115
- // "created_time": "1579399877.041", // Unix epoch time in seconds
2116
- // "updated_time": "1579399877.041", // Unix epoch time in seconds
2117
- // "id": "202029292829292",
2118
- // "external_id": "202029292829292",
2119
- // "application_id": null,
2120
- // "token": "ETH",
2121
- // "target_address": "0x31d64B3230f8baDD91dE1710A65DF536aF8f7cDa",
2122
- // "source_address": "0x70fd25717f769c7f9a46b319f0f9103c0d887af0",
2123
- // "extra": "",
2124
- // "type": "BALANCE",
2125
- // "token_side": "DEPOSIT",
2126
- // "amount": 1000,
2127
- // "tx_id": "0x8a74c517bc104c8ebad0c3c3f64b1f302ed5f8bca598ae4459c63419038106b6",
2128
- // "fee_token": null,
2129
- // "fee_amount": null,
2130
- // "status": "CONFIRMING"
2131
- // }
2132
- //
2133
- // v1PrivatePostAssetMainSubTransfer
2134
- // {
2135
- // "success": true,
2136
- // "id": 200
2137
- // }
2138
- //
2139
- const networkizedCode = this.safeString(transfer, 'token');
2140
- const currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency);
2141
- const code = currencyDefined['code'];
2142
- let movementDirection = this.safeStringLower(transfer, 'token_side');
2143
- if (movementDirection === 'withdraw') {
2144
- movementDirection = 'withdrawal';
2145
- }
2146
- let fromAccount = undefined;
2147
- let toAccount = undefined;
2148
- if (movementDirection === 'withdraw') {
2149
- fromAccount = undefined;
2150
- toAccount = 'spot';
2151
- }
2152
- else if (movementDirection === 'deposit') {
2153
- fromAccount = 'spot';
2154
- toAccount = undefined;
2155
- }
2156
- const timestamp = this.safeTimestamp(transfer, 'created_time');
2157
- const success = this.safeValue(transfer, 'success');
2158
- let status = undefined;
2159
- if (success !== undefined) {
2160
- status = success ? 'ok' : 'failed';
2161
- }
2162
- return {
2163
- 'id': this.safeString(transfer, 'id'),
2164
- 'timestamp': timestamp,
2165
- 'datetime': this.iso8601(timestamp),
2166
- 'currency': code,
2167
- 'amount': this.safeNumber(transfer, 'amount'),
2168
- 'fromAccount': fromAccount,
2169
- 'toAccount': toAccount,
2170
- 'status': this.parseTransferStatus(this.safeString(transfer, 'status', status)),
2171
- 'info': transfer,
2172
- };
2173
- }
2174
- parseTransferStatus(status) {
2175
- const statuses = {
2176
- 'NEW': 'pending',
2177
- 'CONFIRMING': 'pending',
2178
- 'PROCESSING': 'pending',
2179
- 'COMPLETED': 'ok',
2180
- 'CANCELED': 'canceled',
2181
- };
2182
- return this.safeString(statuses, status, status);
2183
- }
2184
- async withdraw(code, amount, address, tag = undefined, params = {}) {
2185
- /**
2186
- * @method
2187
- * @name woo#withdraw
2188
- * @description make a withdrawal
2189
- * @param {string} code unified currency code
2190
- * @param {float} amount the amount to withdraw
2191
- * @param {string} address the address to withdraw to
2192
- * @param {string} tag
2193
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2194
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2195
- */
2196
- [tag, params] = this.handleWithdrawTagAndParams(tag, params);
2197
- await this.loadMarkets();
2198
- this.checkAddress(address);
2199
- const currency = this.currency(code);
2200
- const request = {
2201
- 'amount': amount,
2202
- 'address': address,
2203
- };
2204
- if (tag !== undefined) {
2205
- request['extra'] = tag;
2206
- }
2207
- const networks = this.safeValue(this.options, 'networks', {});
2208
- const currencyNetworks = this.safeValue(currency, 'networks', {});
2209
- const network = this.safeStringUpper(params, 'network');
2210
- const networkId = this.safeString(networks, network, network);
2211
- const coinNetwork = this.safeValue(currencyNetworks, networkId, {});
2212
- const coinNetworkId = this.safeString(coinNetwork, 'id');
2213
- if (coinNetworkId === undefined) {
2214
- throw new errors.BadRequest(this.id + ' withdraw() require network parameter');
2215
- }
2216
- request['token'] = coinNetworkId;
2217
- const response = await this.v1PrivatePostAssetWithdraw(this.extend(request, params));
2218
- //
2219
- // {
2220
- // "success": true,
2221
- // "withdraw_id": "20200119145703654"
2222
- // }
2223
- //
2224
- return this.parseTransaction(response, currency);
2225
- }
2226
- async repayMargin(code, amount, symbol = undefined, params = {}) {
2227
- /**
2228
- * @method
2229
- * @name woo#repayMargin
2230
- * @description repay borrowed margin and interest
2231
- * @see https://docs.woo.org/#repay-interest
2232
- * @param {string} code unified currency code of the currency to repay
2233
- * @param {float} amount the amount to repay
2234
- * @param {string} symbol not used by woo.repayMargin ()
2235
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2236
- * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
2237
- */
2238
- await this.loadMarkets();
2239
- let market = undefined;
2240
- if (symbol !== undefined) {
2241
- market = this.market(symbol);
2242
- symbol = market['symbol'];
2243
- }
2244
- const currency = this.currency(code);
2245
- const request = {
2246
- 'token': currency['id'],
2247
- 'amount': this.currencyToPrecision(code, amount),
2248
- };
2249
- const response = await this.v1PrivatePostInterestRepay(this.extend(request, params));
2250
- //
2251
- // {
2252
- // "success": true,
2253
- // }
2254
- //
2255
- const transaction = this.parseMarginLoan(response, currency);
2256
- return this.extend(transaction, {
2257
- 'amount': amount,
2258
- 'symbol': symbol,
2259
- });
2260
- }
2261
- parseMarginLoan(info, currency = undefined) {
2262
- //
2263
- // {
2264
- // "success": true,
2265
- // }
2266
- //
2267
- return {
2268
- 'id': undefined,
2269
- 'currency': this.safeCurrencyCode(undefined, currency),
2270
- 'amount': undefined,
2271
- 'symbol': undefined,
2272
- 'timestamp': undefined,
2273
- 'datetime': undefined,
2274
- 'info': info,
2275
- };
2276
- }
2277
- nonce() {
2278
- return this.milliseconds();
2279
- }
2280
- sign(path, section = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
2281
- const version = section[0];
2282
- const access = section[1];
2283
- const pathWithParams = this.implodeParams(path, params);
2284
- let url = this.implodeHostname(this.urls['api'][access]);
2285
- url += '/' + version + '/';
2286
- params = this.omit(params, this.extractParams(path));
2287
- params = this.keysort(params);
2288
- if (access === 'public') {
2289
- url += access + '/' + pathWithParams;
2290
- if (Object.keys(params).length) {
2291
- url += '?' + this.urlencode(params);
2292
- }
2293
- }
2294
- else {
2295
- this.checkRequiredCredentials();
2296
- if (method === 'POST' && (path === 'algo/order' || path === 'order')) {
2297
- const isSandboxMode = this.safeValue(this.options, 'sandboxMode', false);
2298
- if (!isSandboxMode) {
2299
- const applicationId = 'bc830de7-50f3-460b-9ee0-f430f83f9dad';
2300
- const brokerId = this.safeString(this.options, 'brokerId', applicationId);
2301
- const isStop = path.indexOf('algo') > -1;
2302
- if (isStop) {
2303
- params['brokerId'] = brokerId;
2304
- }
2305
- else {
2306
- params['broker_id'] = brokerId;
2307
- }
2308
- }
2309
- params = this.keysort(params);
2310
- }
2311
- let auth = '';
2312
- const ts = this.nonce().toString();
2313
- url += pathWithParams;
2314
- headers = {
2315
- 'x-api-key': this.apiKey,
2316
- 'x-api-timestamp': ts,
2317
- };
2318
- if (version === 'v3') {
2319
- auth = ts + method + '/' + version + '/' + pathWithParams;
2320
- if (method === 'POST' || method === 'PUT' || method === 'DELETE') {
2321
- body = this.json(params);
2322
- auth += body;
2323
- }
2324
- else {
2325
- if (Object.keys(params).length) {
2326
- const query = this.urlencode(params);
2327
- url += '?' + query;
2328
- auth += '?' + query;
2329
- }
2330
- }
2331
- headers['content-type'] = 'application/json';
2332
- }
2333
- else {
2334
- auth = this.urlencode(params);
2335
- if (method === 'POST' || method === 'PUT' || method === 'DELETE') {
2336
- body = auth;
2337
- }
2338
- else {
2339
- url += '?' + auth;
2340
- }
2341
- auth += '|' + ts;
2342
- headers['content-type'] = 'application/x-www-form-urlencoded';
2343
- }
2344
- headers['x-api-signature'] = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
2345
- }
2346
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
2347
- }
2348
- handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
2349
- if (!response) {
2350
- return undefined; // fallback to default error handler
2351
- }
2352
- //
2353
- // 400 Bad Request {"success":false,"code":-1012,"message":"Amount is required for buy market orders when margin disabled."}
2354
- //
2355
- const success = this.safeValue(response, 'success');
2356
- const errorCode = this.safeString(response, 'code');
2357
- if (!success) {
2358
- const feedback = this.id + ' ' + this.json(response);
2359
- this.throwBroadlyMatchedException(this.exceptions['broad'], body, feedback);
2360
- this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
2361
- }
2362
- return undefined;
2363
- }
2364
- parseIncome(income, market = undefined) {
2365
- //
2366
- // {
2367
- // "id":666666,
2368
- // "symbol":"PERP_BTC_USDT",
2369
- // "funding_rate":0.00001198,
2370
- // "mark_price":28941.04000000,
2371
- // "funding_fee":0.00069343,
2372
- // "payment_type":"Pay",
2373
- // "status":"COMPLETED",
2374
- // "created_time":"1653616000.666",
2375
- // "updated_time":"1653616000.605"
2376
- // }
2377
- //
2378
- const marketId = this.safeString(income, 'symbol');
2379
- const symbol = this.safeSymbol(marketId, market);
2380
- const amount = this.safeNumber(income, 'funding_fee');
2381
- const code = this.safeCurrencyCode('USD');
2382
- const id = this.safeString(income, 'id');
2383
- const timestamp = this.safeTimestamp(income, 'updated_time');
2384
- const rate = this.safeNumber(income, 'funding_rate');
2385
- return {
2386
- 'info': income,
2387
- 'symbol': symbol,
2388
- 'code': code,
2389
- 'timestamp': timestamp,
2390
- 'datetime': this.iso8601(timestamp),
2391
- 'id': id,
2392
- 'amount': amount,
2393
- 'rate': rate,
2394
- };
2395
- }
2396
- async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2397
- await this.loadMarkets();
2398
- const request = {};
2399
- let market = undefined;
2400
- if (symbol !== undefined) {
2401
- market = this.market(symbol);
2402
- request['symbol'] = market['id'];
2403
- }
2404
- if (since !== undefined) {
2405
- request['start_t'] = since;
2406
- }
2407
- const response = await this.v1PrivateGetFundingFeeHistory(this.extend(request, params));
2408
- //
2409
- // {
2410
- // "rows":[
2411
- // {
2412
- // "id":666666,
2413
- // "symbol":"PERP_BTC_USDT",
2414
- // "funding_rate":0.00001198,
2415
- // "mark_price":28941.04000000,
2416
- // "funding_fee":0.00069343,
2417
- // "payment_type":"Pay",
2418
- // "status":"COMPLETED",
2419
- // "created_time":"1653616000.666",
2420
- // "updated_time":"1653616000.605"
2421
- // }
2422
- // ],
2423
- // "meta":{
2424
- // "total":235,
2425
- // "records_per_page":25,
2426
- // "current_page":1
2427
- // },
2428
- // "success":true
2429
- // }
2430
- //
2431
- const result = this.safeValue(response, 'rows', []);
2432
- return this.parseIncomes(result, market, since, limit);
2433
- }
2434
- parseFundingRate(fundingRate, market = undefined) {
2435
- //
2436
- // {
2437
- // "symbol":"PERP_AAVE_USDT",
2438
- // "est_funding_rate":-0.00003447,
2439
- // "est_funding_rate_timestamp":1653633959001,
2440
- // "last_funding_rate":-0.00002094,
2441
- // "last_funding_rate_timestamp":1653631200000,
2442
- // "next_funding_time":1653634800000
2443
- // }
2444
- //
2445
- //
2446
- const symbol = this.safeString(fundingRate, 'symbol');
2447
- market = this.market(symbol);
2448
- const nextFundingTimestamp = this.safeInteger(fundingRate, 'next_funding_time');
2449
- const estFundingRateTimestamp = this.safeInteger(fundingRate, 'est_funding_rate_timestamp');
2450
- const lastFundingRateTimestamp = this.safeInteger(fundingRate, 'last_funding_rate_timestamp');
2451
- return {
2452
- 'info': fundingRate,
2453
- 'symbol': market['symbol'],
2454
- 'markPrice': undefined,
2455
- 'indexPrice': undefined,
2456
- 'interestRate': this.parseNumber('0'),
2457
- 'estimatedSettlePrice': undefined,
2458
- 'timestamp': estFundingRateTimestamp,
2459
- 'datetime': this.iso8601(estFundingRateTimestamp),
2460
- 'fundingRate': this.safeNumber(fundingRate, 'est_funding_rate'),
2461
- 'fundingTimestamp': nextFundingTimestamp,
2462
- 'fundingDatetime': this.iso8601(nextFundingTimestamp),
2463
- 'nextFundingRate': undefined,
2464
- 'nextFundingTimestamp': undefined,
2465
- 'nextFundingDatetime': undefined,
2466
- 'previousFundingRate': this.safeNumber(fundingRate, 'last_funding_rate'),
2467
- 'previousFundingTimestamp': lastFundingRateTimestamp,
2468
- 'previousFundingDatetime': this.iso8601(lastFundingRateTimestamp),
2469
- };
2470
- }
2471
- async fetchFundingRate(symbol, params = {}) {
2472
- await this.loadMarkets();
2473
- const market = this.market(symbol);
2474
- const request = {
2475
- 'symbol': market['id'],
2476
- };
2477
- const response = await this.v1PublicGetFundingRateSymbol(this.extend(request, params));
2478
- //
2479
- // {
2480
- // "success":true,
2481
- // "timestamp":1653640572711,
2482
- // "symbol":"PERP_BTC_USDT",
2483
- // "est_funding_rate":0.00000738,
2484
- // "est_funding_rate_timestamp":1653640559003,
2485
- // "last_funding_rate":0.00000629,
2486
- // "last_funding_rate_timestamp":1653638400000,
2487
- // "next_funding_time":1653642000000
2488
- // }
2489
- //
2490
- return this.parseFundingRate(response, market);
2491
- }
2492
- async fetchFundingRates(symbols = undefined, params = {}) {
2493
- await this.loadMarkets();
2494
- symbols = this.marketSymbols(symbols);
2495
- const response = await this.v1PublicGetFundingRates(params);
2496
- //
2497
- // {
2498
- // "success":true,
2499
- // "rows":[
2500
- // {
2501
- // "symbol":"PERP_AAVE_USDT",
2502
- // "est_funding_rate":-0.00003447,
2503
- // "est_funding_rate_timestamp":1653633959001,
2504
- // "last_funding_rate":-0.00002094,
2505
- // "last_funding_rate_timestamp":1653631200000,
2506
- // "next_funding_time":1653634800000
2507
- // }
2508
- // ],
2509
- // "timestamp":1653633985646
2510
- // }
2511
- //
2512
- const rows = this.safeValue(response, 'rows', {});
2513
- const result = this.parseFundingRates(rows);
2514
- return this.filterByArray(result, 'symbol', symbols);
2515
- }
2516
- async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2517
- /**
2518
- * @method
2519
- * @name woo#fetchFundingRateHistory
2520
- * @description fetches historical funding rate prices
2521
- * @see https://docs.woo.org/#get-funding-rate-history-for-one-market-public
2522
- * @param {string} symbol unified symbol of the market to fetch the funding rate history for
2523
- * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
2524
- * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
2525
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2526
- * @param {int} [params.until] timestamp in ms of the latest funding rate
2527
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2528
- * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
2529
- */
2530
- await this.loadMarkets();
2531
- let paginate = false;
2532
- [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
2533
- if (paginate) {
2534
- return await this.fetchPaginatedCallIncremental('fetchFundingRateHistory', symbol, since, limit, params, 'page', 25);
2535
- }
2536
- let request = {};
2537
- if (symbol !== undefined) {
2538
- const market = this.market(symbol);
2539
- symbol = market['symbol'];
2540
- request['symbol'] = market['id'];
2541
- }
2542
- if (since !== undefined) {
2543
- request['start_t'] = this.parseToInt(since / 1000);
2544
- }
2545
- [request, params] = this.handleUntilOption('end_t', request, params, 0.001);
2546
- const response = await this.v1PublicGetFundingRateHistory(this.extend(request, params));
2547
- //
2548
- // {
2549
- // "success":true,
2550
- // "meta":{
2551
- // "total":2464,
2552
- // "records_per_page":25,
2553
- // "current_page":1
2554
- // },
2555
- // "rows":[
2556
- // {
2557
- // "symbol":"PERP_BTC_USDT",
2558
- // "funding_rate":0.00000629,
2559
- // "funding_rate_timestamp":1653638400000,
2560
- // "next_funding_time":1653642000000
2561
- // }
2562
- // ],
2563
- // "timestamp":1653640814885
2564
- // }
2565
- //
2566
- const result = this.safeValue(response, 'rows');
2567
- const rates = [];
2568
- for (let i = 0; i < result.length; i++) {
2569
- const entry = result[i];
2570
- const marketId = this.safeString(entry, 'symbol');
2571
- const timestamp = this.safeInteger(entry, 'funding_rate_timestamp');
2572
- rates.push({
2573
- 'info': entry,
2574
- 'symbol': this.safeSymbol(marketId),
2575
- 'fundingRate': this.safeNumber(entry, 'funding_rate'),
2576
- 'timestamp': timestamp,
2577
- 'datetime': this.iso8601(timestamp),
2578
- });
2579
- }
2580
- const sorted = this.sortBy(rates, 'timestamp');
2581
- return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
2582
- }
2583
- async fetchLeverage(symbol, params = {}) {
2584
- await this.loadMarkets();
2585
- const response = await this.v3PrivateGetAccountinfo(params);
2586
- //
2587
- // {
2588
- // "success": true,
2589
- // "data": {
2590
- // "applicationId": "dsa",
2591
- // "account": "dsa",
2592
- // "alias": "haha",
2593
- // "accountMode": "MARGIN",
2594
- // "leverage": 1,
2595
- // "takerFeeRate": 1,
2596
- // "makerFeeRate": 1,
2597
- // "interestRate": 1,
2598
- // "futuresTakerFeeRate": 1,
2599
- // "futuresMakerFeeRate": 1,
2600
- // "otpauth": true,
2601
- // "marginRatio": 1,
2602
- // "openMarginRatio": 1,
2603
- // "initialMarginRatio": 1,
2604
- // "maintenanceMarginRatio": 1,
2605
- // "totalCollateral": 1,
2606
- // "freeCollateral": 1,
2607
- // "totalAccountValue": 1,
2608
- // "totalVaultValue": 1,
2609
- // "totalStakingValue": 1
2610
- // },
2611
- // "timestamp": 1673323685109
2612
- // }
2613
- //
2614
- const result = this.safeValue(response, 'data');
2615
- const leverage = this.safeNumber(result, 'leverage');
2616
- return {
2617
- 'info': response,
2618
- 'leverage': leverage,
2619
- };
2620
- }
2621
- async setLeverage(leverage, symbol = undefined, params = {}) {
2622
- await this.loadMarkets();
2623
- if ((leverage < 1) || (leverage > 20)) {
2624
- throw new errors.BadRequest(this.id + ' leverage should be between 1 and 20');
2625
- }
2626
- const request = {
2627
- 'leverage': leverage,
2628
- };
2629
- return await this.v1PrivatePostClientLeverage(this.extend(request, params));
2630
- }
2631
- async fetchPosition(symbol = undefined, params = {}) {
2632
- await this.loadMarkets();
2633
- const market = this.market(symbol);
2634
- const request = {
2635
- 'symbol': market['id'],
2636
- };
2637
- const response = await this.v1PrivateGetPositionSymbol(this.extend(request, params));
2638
- //
2639
- // {
2640
- // "symbol":"PERP_ETC_USDT",
2641
- // "holding":0.0,
2642
- // "pnl_24_h":0,
2643
- // "settle_price":0.0,
2644
- // "average_open_price":0,
2645
- // "success":true,
2646
- // "mark_price":22.6955,
2647
- // "pending_short_qty":0.0,
2648
- // "pending_long_qty":0.0,
2649
- // "fee_24_h":0,
2650
- // "timestamp":"1652231044.920"
2651
- // }
2652
- //
2653
- return this.parsePosition(response, market);
2654
- }
2655
- async fetchPositions(symbols = undefined, params = {}) {
2656
- await this.loadMarkets();
2657
- const response = await this.v3PrivateGetPositions(params);
2658
- //
2659
- // {
2660
- // "success": true,
2661
- // "data": {
2662
- // "positions": [
2663
- // {
2664
- // "symbol": "0_symbol",
2665
- // "holding": 1,
2666
- // "pendingLongQty": 0,
2667
- // "pendingShortQty": 1,
2668
- // "settlePrice": 1,
2669
- // "averageOpenPrice": 1,
2670
- // "pnl24H": 1,
2671
- // "fee24H": 1,
2672
- // "markPrice": 1,
2673
- // "estLiqPrice": 1,
2674
- // "timestamp": 12321321
2675
- // }
2676
- // ]
2677
- // },
2678
- // "timestamp": 1673323880342
2679
- // }
2680
- //
2681
- const result = this.safeValue(response, 'data', {});
2682
- const positions = this.safeValue(result, 'positions', []);
2683
- return this.parsePositions(positions, symbols);
2684
- }
2685
- parsePosition(position, market = undefined) {
2686
- //
2687
- // {
2688
- // "symbol": "0_symbol",
2689
- // "holding": 1,
2690
- // "pendingLongQty": 0,
2691
- // "pendingShortQty": 1,
2692
- // "settlePrice": 1,
2693
- // "averageOpenPrice": 1,
2694
- // "pnl24H": 1,
2695
- // "fee24H": 1,
2696
- // "markPrice": 1,
2697
- // "estLiqPrice": 1,
2698
- // "timestamp": 12321321
2699
- // }
2700
- //
2701
- const contract = this.safeString(position, 'symbol');
2702
- market = this.safeMarket(contract, market);
2703
- let size = this.safeString(position, 'holding');
2704
- let side = undefined;
2705
- if (Precise["default"].stringGt(size, '0')) {
2706
- side = 'long';
2707
- }
2708
- else {
2709
- side = 'short';
2710
- }
2711
- const contractSize = this.safeString(market, 'contractSize');
2712
- const markPrice = this.safeString(position, 'markPrice');
2713
- const timestamp = this.safeTimestamp(position, 'timestamp');
2714
- const entryPrice = this.safeString(position, 'averageOpenPrice');
2715
- const priceDifference = Precise["default"].stringSub(markPrice, entryPrice);
2716
- const unrealisedPnl = Precise["default"].stringMul(priceDifference, size);
2717
- size = Precise["default"].stringAbs(size);
2718
- const notional = Precise["default"].stringMul(size, markPrice);
2719
- return this.safePosition({
2720
- 'info': position,
2721
- 'id': undefined,
2722
- 'symbol': this.safeString(market, 'symbol'),
2723
- 'timestamp': timestamp,
2724
- 'datetime': this.iso8601(timestamp),
2725
- 'lastUpdateTimestamp': undefined,
2726
- 'initialMargin': undefined,
2727
- 'initialMarginPercentage': undefined,
2728
- 'maintenanceMargin': undefined,
2729
- 'maintenanceMarginPercentage': undefined,
2730
- 'entryPrice': this.parseNumber(entryPrice),
2731
- 'notional': this.parseNumber(notional),
2732
- 'leverage': undefined,
2733
- 'unrealizedPnl': this.parseNumber(unrealisedPnl),
2734
- 'contracts': this.parseNumber(size),
2735
- 'contractSize': this.parseNumber(contractSize),
2736
- 'marginRatio': undefined,
2737
- 'liquidationPrice': this.safeNumber(position, 'estLiqPrice'),
2738
- 'markPrice': this.parseNumber(markPrice),
2739
- 'lastPrice': undefined,
2740
- 'collateral': undefined,
2741
- 'marginMode': 'cross',
2742
- 'marginType': undefined,
2743
- 'side': side,
2744
- 'percentage': undefined,
2745
- 'hedged': undefined,
2746
- 'stopLossPrice': undefined,
2747
- 'takeProfitPrice': undefined,
2748
- });
2749
- }
2750
- defaultNetworkCodeForCurrency(code) {
2751
- const currencyItem = this.currency(code);
2752
- const networks = currencyItem['networks'];
2753
- const networkKeys = Object.keys(networks);
2754
- for (let i = 0; i < networkKeys.length; i++) {
2755
- const network = networkKeys[i];
2756
- if (network === 'ETH') {
2757
- return network;
2758
- }
2759
- }
2760
- // if it was not returned according to above options, then return the first network of currency
2761
- return this.safeValue(networkKeys, 0);
2762
- }
2763
- setSandboxMode(enable) {
2764
- super.setSandboxMode(enable);
2765
- this.options['sandboxMode'] = enable;
2766
- }
2767
- }
2768
-
2769
- module.exports = woo;