ccxt-ir 4.9.32 → 4.11.0

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 (1059) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +7 -1
  4. package/dist/cjs/package.json +1 -1
  5. package/dist/cjs/src/abstract/asretether.js +11 -0
  6. package/dist/cjs/src/abstract/bidarz.js +11 -0
  7. package/dist/cjs/src/asretether.js +325 -0
  8. package/dist/cjs/src/bidarz.js +337 -0
  9. package/dist/cjs/src/bit24.js +4 -3
  10. package/dist/cjs/src/raastin.js +144 -16
  11. package/js/ccxt.d.ts +8 -2
  12. package/js/ccxt.js +6 -2
  13. package/js/src/abstract/asretether.d.ts +8 -0
  14. package/js/src/abstract/asretether.js +11 -0
  15. package/js/src/abstract/bidarz.d.ts +9 -0
  16. package/js/src/abstract/bidarz.js +11 -0
  17. package/js/src/abstract/raastin.d.ts +1 -0
  18. package/js/src/asretether.d.ts +21 -0
  19. package/js/src/asretether.js +324 -0
  20. package/js/src/bidarz.d.ts +22 -0
  21. package/js/src/bidarz.js +336 -0
  22. package/js/src/bit24.js +4 -3
  23. package/js/src/raastin.d.ts +2 -0
  24. package/js/src/raastin.js +144 -16
  25. package/js/src/src/abantether.d.ts +21 -0
  26. package/js/src/src/abantether.js +353 -0
  27. package/js/src/src/abstract/abantether.d.ts +8 -0
  28. package/js/src/src/abstract/abantether.js +11 -0
  29. package/js/src/src/abstract/afratether.d.ts +9 -0
  30. package/js/src/src/abstract/afratether.js +11 -0
  31. package/js/src/src/abstract/alpaca.d.ts +77 -0
  32. package/js/src/src/abstract/alpaca.js +11 -0
  33. package/js/src/src/abstract/apex.d.ts +34 -0
  34. package/js/src/src/abstract/apex.js +11 -0
  35. package/js/src/src/abstract/arzinja.d.ts +8 -0
  36. package/js/src/src/abstract/arzinja.js +11 -0
  37. package/js/src/src/abstract/arzplus.d.ts +11 -0
  38. package/js/src/src/abstract/arzplus.js +11 -0
  39. package/js/src/src/abstract/ascendex.d.ts +80 -0
  40. package/js/src/src/abstract/ascendex.js +11 -0
  41. package/js/src/src/abstract/asretether.d.ts +8 -0
  42. package/js/src/src/abstract/asretether.js +11 -0
  43. package/js/src/src/abstract/bidarz.d.ts +9 -0
  44. package/js/src/src/abstract/bidarz.js +11 -0
  45. package/js/src/src/abstract/bigone.d.ts +48 -0
  46. package/js/src/src/abstract/bigone.js +11 -0
  47. package/js/src/src/abstract/binance.d.ts +773 -0
  48. package/js/src/src/abstract/binance.js +11 -0
  49. package/js/src/src/abstract/bingx.d.ts +165 -0
  50. package/js/src/src/abstract/bingx.js +11 -0
  51. package/js/src/src/abstract/bit24.d.ts +9 -0
  52. package/js/src/src/abstract/bit24.js +11 -0
  53. package/js/src/src/abstract/bit2c.d.ts +30 -0
  54. package/js/src/src/abstract/bit2c.js +11 -0
  55. package/js/src/src/abstract/bitbank.d.ts +35 -0
  56. package/js/src/src/abstract/bitbank.js +11 -0
  57. package/js/src/src/abstract/bitbarg.d.ts +8 -0
  58. package/js/src/src/abstract/bitbarg.js +11 -0
  59. package/js/src/src/abstract/bitbns.d.ts +43 -0
  60. package/js/src/src/abstract/bitbns.js +11 -0
  61. package/js/src/src/abstract/bitfinex.d.ts +143 -0
  62. package/js/src/src/abstract/bitfinex.js +11 -0
  63. package/js/src/src/abstract/bitflyer.d.ts +42 -0
  64. package/js/src/src/abstract/bitflyer.js +11 -0
  65. package/js/src/src/abstract/bitget.d.ts +578 -0
  66. package/js/src/src/abstract/bitget.js +11 -0
  67. package/js/src/src/abstract/bithumb.d.ts +35 -0
  68. package/js/src/src/abstract/bithumb.js +11 -0
  69. package/js/src/src/abstract/bitimen.d.ts +10 -0
  70. package/js/src/src/abstract/bitimen.js +11 -0
  71. package/js/src/src/abstract/bitir.d.ts +10 -0
  72. package/js/src/src/abstract/bitir.js +11 -0
  73. package/js/src/src/abstract/bitmart.d.ts +120 -0
  74. package/js/src/src/abstract/bitmart.js +11 -0
  75. package/js/src/src/abstract/bitmex.d.ts +100 -0
  76. package/js/src/src/abstract/bitmex.js +11 -0
  77. package/js/src/src/abstract/bitopro.d.ts +33 -0
  78. package/js/src/src/abstract/bitopro.js +11 -0
  79. package/js/src/src/abstract/bitpin.d.ts +11 -0
  80. package/js/src/src/abstract/bitpin.js +11 -0
  81. package/js/src/src/abstract/bitrue.d.ts +75 -0
  82. package/js/src/src/abstract/bitrue.js +11 -0
  83. package/js/src/src/abstract/bitso.d.ts +46 -0
  84. package/js/src/src/abstract/bitso.js +11 -0
  85. package/js/src/src/abstract/bitstamp.d.ts +262 -0
  86. package/js/src/src/abstract/bitstamp.js +11 -0
  87. package/js/src/src/abstract/bitteam.d.ts +32 -0
  88. package/js/src/src/abstract/bitteam.js +11 -0
  89. package/js/src/src/abstract/bittrade.d.ts +117 -0
  90. package/js/src/src/abstract/bittrade.js +11 -0
  91. package/js/src/src/abstract/bitunix.d.ts +9 -0
  92. package/js/src/src/abstract/bitunix.js +11 -0
  93. package/js/src/src/abstract/bitvavo.d.ts +30 -0
  94. package/js/src/src/abstract/bitvavo.js +11 -0
  95. package/js/src/src/abstract/blockchaincom.d.ts +31 -0
  96. package/js/src/src/abstract/blockchaincom.js +11 -0
  97. package/js/src/src/abstract/blofin.d.ts +70 -0
  98. package/js/src/src/abstract/blofin.js +11 -0
  99. package/js/src/src/abstract/btcalpha.d.ts +21 -0
  100. package/js/src/src/abstract/btcalpha.js +11 -0
  101. package/js/src/src/abstract/btcbox.d.ts +18 -0
  102. package/js/src/src/abstract/btcbox.js +11 -0
  103. package/js/src/src/abstract/btcmarkets.d.ts +42 -0
  104. package/js/src/src/abstract/btcmarkets.js +11 -0
  105. package/js/src/src/abstract/btcturk.d.ts +23 -0
  106. package/js/src/src/abstract/btcturk.js +11 -0
  107. package/js/src/src/abstract/bybit.d.ts +316 -0
  108. package/js/src/src/abstract/bybit.js +11 -0
  109. package/js/src/src/abstract/bydfi.d.ts +11 -0
  110. package/js/src/src/abstract/bydfi.js +11 -0
  111. package/js/src/src/abstract/cafearz.d.ts +8 -0
  112. package/js/src/src/abstract/cafearz.js +11 -0
  113. package/js/src/src/abstract/cex.d.ts +35 -0
  114. package/js/src/src/abstract/cex.js +11 -0
  115. package/js/src/src/abstract/coinbase.d.ts +97 -0
  116. package/js/src/src/abstract/coinbase.js +11 -0
  117. package/js/src/src/abstract/coinbaseexchange.d.ts +71 -0
  118. package/js/src/src/abstract/coinbaseexchange.js +11 -0
  119. package/js/src/src/abstract/coinbaseinternational.d.ts +42 -0
  120. package/js/src/src/abstract/coinbaseinternational.js +11 -0
  121. package/js/src/src/abstract/coincatch.d.ts +97 -0
  122. package/js/src/src/abstract/coincatch.js +11 -0
  123. package/js/src/src/abstract/coincheck.d.ts +36 -0
  124. package/js/src/src/abstract/coincheck.js +11 -0
  125. package/js/src/src/abstract/coinex.d.ts +240 -0
  126. package/js/src/src/abstract/coinex.js +11 -0
  127. package/js/src/src/abstract/coinmate.d.ts +65 -0
  128. package/js/src/src/abstract/coinmate.js +11 -0
  129. package/js/src/src/abstract/coinmetro.d.ts +37 -0
  130. package/js/src/src/abstract/coinmetro.js +11 -0
  131. package/js/src/src/abstract/coinone.d.ts +70 -0
  132. package/js/src/src/abstract/coinone.js +11 -0
  133. package/js/src/src/abstract/coinsph.d.ts +57 -0
  134. package/js/src/src/abstract/coinsph.js +11 -0
  135. package/js/src/src/abstract/coinspot.d.ts +31 -0
  136. package/js/src/src/abstract/coinspot.js +11 -0
  137. package/js/src/src/abstract/cryptocom.d.ts +126 -0
  138. package/js/src/src/abstract/cryptocom.js +11 -0
  139. package/js/src/src/abstract/cryptomus.d.ts +23 -0
  140. package/js/src/src/abstract/cryptomus.js +11 -0
  141. package/js/src/src/abstract/defx.d.ts +72 -0
  142. package/js/src/src/abstract/defx.js +11 -0
  143. package/js/src/src/abstract/delta.d.ts +53 -0
  144. package/js/src/src/abstract/delta.js +11 -0
  145. package/js/src/src/abstract/deribit.d.ts +129 -0
  146. package/js/src/src/abstract/deribit.js +11 -0
  147. package/js/src/src/abstract/derive.d.ts +120 -0
  148. package/js/src/src/abstract/derive.js +11 -0
  149. package/js/src/src/abstract/digifinex.d.ts +95 -0
  150. package/js/src/src/abstract/digifinex.js +11 -0
  151. package/js/src/src/abstract/ellipx.d.ts +28 -0
  152. package/js/src/src/abstract/ellipx.js +11 -0
  153. package/js/src/src/abstract/eterex.d.ts +8 -0
  154. package/js/src/src/abstract/eterex.js +11 -0
  155. package/js/src/src/abstract/excoino.d.ts +10 -0
  156. package/js/src/src/abstract/excoino.js +11 -0
  157. package/js/src/src/abstract/exir.d.ts +11 -0
  158. package/js/src/src/abstract/exir.js +11 -0
  159. package/js/src/src/abstract/exmo.d.ts +58 -0
  160. package/js/src/src/abstract/exmo.js +11 -0
  161. package/js/src/src/abstract/exnovin.d.ts +9 -0
  162. package/js/src/src/abstract/exnovin.js +11 -0
  163. package/js/src/src/abstract/farhadexchange.d.ts +8 -0
  164. package/js/src/src/abstract/farhadexchange.js +11 -0
  165. package/js/src/src/abstract/foxbit.d.ts +29 -0
  166. package/js/src/src/abstract/foxbit.js +11 -0
  167. package/js/src/src/abstract/gate.d.ts +287 -0
  168. package/js/src/src/abstract/gate.js +11 -0
  169. package/js/src/src/abstract/gemini.d.ts +62 -0
  170. package/js/src/src/abstract/gemini.js +11 -0
  171. package/js/src/src/abstract/hamtapay.d.ts +9 -0
  172. package/js/src/src/abstract/hamtapay.js +11 -0
  173. package/js/src/src/abstract/hashkey.d.ts +70 -0
  174. package/js/src/src/abstract/hashkey.js +11 -0
  175. package/js/src/src/abstract/hibachi.d.ts +29 -0
  176. package/js/src/src/abstract/hibachi.js +11 -0
  177. package/js/src/src/abstract/hitbtc.d.ts +118 -0
  178. package/js/src/src/abstract/hitbtc.js +11 -0
  179. package/js/src/src/abstract/hitobit.d.ts +11 -0
  180. package/js/src/src/abstract/hitobit.js +11 -0
  181. package/js/src/src/abstract/hollaex.d.ts +36 -0
  182. package/js/src/src/abstract/hollaex.js +11 -0
  183. package/js/src/src/abstract/htx.d.ts +551 -0
  184. package/js/src/src/abstract/htx.js +11 -0
  185. package/js/src/src/abstract/hyperliquid.d.ts +9 -0
  186. package/js/src/src/abstract/hyperliquid.js +11 -0
  187. package/js/src/src/abstract/independentreserve.d.ts +46 -0
  188. package/js/src/src/abstract/independentreserve.js +11 -0
  189. package/js/src/src/abstract/indodax.d.ts +29 -0
  190. package/js/src/src/abstract/indodax.js +11 -0
  191. package/js/src/src/abstract/iranexchange.d.ts +9 -0
  192. package/js/src/src/abstract/iranexchange.js +11 -0
  193. package/js/src/src/abstract/jibitex.d.ts +10 -0
  194. package/js/src/src/abstract/jibitex.js +11 -0
  195. package/js/src/src/abstract/kcex.d.ts +10 -0
  196. package/js/src/src/abstract/kcex.js +11 -0
  197. package/js/src/src/abstract/kifpoolme.d.ts +9 -0
  198. package/js/src/src/abstract/kifpoolme.js +11 -0
  199. package/js/src/src/abstract/kraken.d.ts +61 -0
  200. package/js/src/src/abstract/kraken.js +11 -0
  201. package/js/src/src/abstract/krakenfutures.d.ts +45 -0
  202. package/js/src/src/abstract/krakenfutures.js +11 -0
  203. package/js/src/src/abstract/kucoin.d.ts +227 -0
  204. package/js/src/src/abstract/kucoin.js +11 -0
  205. package/js/src/src/abstract/kucoinfutures.d.ts +254 -0
  206. package/js/src/src/abstract/kucoinfutures.js +11 -0
  207. package/js/src/src/abstract/latoken.d.ts +59 -0
  208. package/js/src/src/abstract/latoken.js +11 -0
  209. package/js/src/src/abstract/lbank.d.ts +65 -0
  210. package/js/src/src/abstract/lbank.js +11 -0
  211. package/js/src/src/abstract/luno.d.ts +41 -0
  212. package/js/src/src/abstract/luno.js +11 -0
  213. package/js/src/src/abstract/mazdax.d.ts +11 -0
  214. package/js/src/src/abstract/mazdax.js +11 -0
  215. package/js/src/src/abstract/mercado.d.ts +28 -0
  216. package/js/src/src/abstract/mercado.js +11 -0
  217. package/js/src/src/abstract/mexc.d.ts +183 -0
  218. package/js/src/src/abstract/mexc.js +11 -0
  219. package/js/src/src/abstract/modetrade.d.ts +122 -0
  220. package/js/src/src/abstract/modetrade.js +11 -0
  221. package/js/src/src/abstract/ndax.d.ts +100 -0
  222. package/js/src/src/abstract/ndax.js +11 -0
  223. package/js/src/src/abstract/nobitex.d.ts +10 -0
  224. package/js/src/src/abstract/nobitex.js +11 -0
  225. package/js/src/src/abstract/novadax.d.ts +32 -0
  226. package/js/src/src/abstract/novadax.js +11 -0
  227. package/js/src/src/abstract/oceanex.d.ts +30 -0
  228. package/js/src/src/abstract/oceanex.js +11 -0
  229. package/js/src/src/abstract/okcoin.d.ts +77 -0
  230. package/js/src/src/abstract/okcoin.js +11 -0
  231. package/js/src/src/abstract/okexchange.d.ts +11 -0
  232. package/js/src/src/abstract/okexchange.js +11 -0
  233. package/js/src/src/abstract/okx.d.ts +352 -0
  234. package/js/src/src/abstract/okx.js +11 -0
  235. package/js/src/src/abstract/ompfinex.d.ts +10 -0
  236. package/js/src/src/abstract/ompfinex.js +11 -0
  237. package/js/src/src/abstract/onetrading.d.ts +26 -0
  238. package/js/src/src/abstract/onetrading.js +11 -0
  239. package/js/src/src/abstract/oxfun.d.ts +37 -0
  240. package/js/src/src/abstract/oxfun.js +11 -0
  241. package/js/src/src/abstract/p2b.d.ts +25 -0
  242. package/js/src/src/abstract/p2b.js +11 -0
  243. package/js/src/src/abstract/paradex.d.ts +66 -0
  244. package/js/src/src/abstract/paradex.js +11 -0
  245. package/js/src/src/abstract/paymium.d.ts +31 -0
  246. package/js/src/src/abstract/paymium.js +11 -0
  247. package/js/src/src/abstract/phemex.d.ts +120 -0
  248. package/js/src/src/abstract/phemex.js +11 -0
  249. package/js/src/src/abstract/pingi.d.ts +9 -0
  250. package/js/src/src/abstract/pingi.js +11 -0
  251. package/js/src/src/abstract/poloniex.d.ts +108 -0
  252. package/js/src/src/abstract/poloniex.js +11 -0
  253. package/js/src/src/abstract/pooleno.d.ts +8 -0
  254. package/js/src/src/abstract/pooleno.js +11 -0
  255. package/js/src/src/abstract/probit.d.ts +26 -0
  256. package/js/src/src/abstract/probit.js +11 -0
  257. package/js/src/src/abstract/raastin.d.ts +11 -0
  258. package/js/src/src/abstract/raastin.js +11 -0
  259. package/js/src/src/abstract/ramzinex.d.ts +10 -0
  260. package/js/src/src/abstract/ramzinex.js +11 -0
  261. package/js/src/src/abstract/sarmayex.d.ts +8 -0
  262. package/js/src/src/abstract/sarmayex.js +11 -0
  263. package/js/src/src/abstract/sarrafex.d.ts +10 -0
  264. package/js/src/src/abstract/sarrafex.js +11 -0
  265. package/js/src/src/abstract/tabdeal.d.ts +10 -0
  266. package/js/src/src/abstract/tabdeal.js +11 -0
  267. package/js/src/src/abstract/tehran_exchange.d.ts +9 -0
  268. package/js/src/src/abstract/tehran_exchange.js +11 -0
  269. package/js/src/src/abstract/tetherland.d.ts +8 -0
  270. package/js/src/src/abstract/tetherland.js +11 -0
  271. package/js/src/src/abstract/timex.d.ts +65 -0
  272. package/js/src/src/abstract/timex.js +11 -0
  273. package/js/src/src/abstract/tokocrypto.d.ts +40 -0
  274. package/js/src/src/abstract/tokocrypto.js +11 -0
  275. package/js/src/src/abstract/toobit.d.ts +10 -0
  276. package/js/src/src/abstract/toobit.js +11 -0
  277. package/js/src/src/abstract/tradeogre.d.ts +21 -0
  278. package/js/src/src/abstract/tradeogre.js +11 -0
  279. package/js/src/src/abstract/twox.d.ts +8 -0
  280. package/js/src/src/abstract/twox.js +11 -0
  281. package/js/src/src/abstract/ubitex.d.ts +10 -0
  282. package/js/src/src/abstract/ubitex.js +11 -0
  283. package/js/src/src/abstract/upbit.d.ts +58 -0
  284. package/js/src/src/abstract/upbit.js +11 -0
  285. package/js/src/src/abstract/vertex.d.ts +22 -0
  286. package/js/src/src/abstract/vertex.js +11 -0
  287. package/js/src/src/abstract/wallex.d.ts +11 -0
  288. package/js/src/src/abstract/wallex.js +11 -0
  289. package/js/src/src/abstract/wavesexchange.d.ts +157 -0
  290. package/js/src/src/abstract/wavesexchange.js +11 -0
  291. package/js/src/src/abstract/whitebit.d.ts +117 -0
  292. package/js/src/src/abstract/whitebit.js +11 -0
  293. package/js/src/src/abstract/woo.d.ts +144 -0
  294. package/js/src/src/abstract/woo.js +11 -0
  295. package/js/src/src/abstract/woofipro.d.ts +122 -0
  296. package/js/src/src/abstract/woofipro.js +11 -0
  297. package/js/src/src/abstract/xt.d.ts +160 -0
  298. package/js/src/src/abstract/xt.js +11 -0
  299. package/js/src/src/abstract/yobit.d.ts +19 -0
  300. package/js/src/src/abstract/yobit.js +11 -0
  301. package/js/src/src/abstract/zaif.d.ts +41 -0
  302. package/js/src/src/abstract/zaif.js +11 -0
  303. package/js/src/src/abstract/zonda.d.ts +56 -0
  304. package/js/src/src/abstract/zonda.js +11 -0
  305. package/js/src/src/afratether.d.ts +21 -0
  306. package/js/src/src/afratether.js +356 -0
  307. package/js/src/src/alpaca.d.ts +332 -0
  308. package/js/src/src/alpaca.js +1908 -0
  309. package/js/src/src/apex.d.ts +333 -0
  310. package/js/src/src/apex.js +1942 -0
  311. package/js/src/src/arzinja.d.ts +21 -0
  312. package/js/src/src/arzinja.js +298 -0
  313. package/js/src/src/arzplus.d.ts +26 -0
  314. package/js/src/src/arzplus.js +581 -0
  315. package/js/src/src/ascendex.d.ts +424 -0
  316. package/js/src/src/ascendex.js +3699 -0
  317. package/js/src/src/asretether.d.ts +21 -0
  318. package/js/src/src/asretether.js +324 -0
  319. package/js/src/src/base/Exchange.d.ts +926 -0
  320. package/js/src/src/base/Exchange.js +7399 -0
  321. package/js/src/src/base/Precise.d.ts +42 -0
  322. package/js/src/src/base/Precise.js +275 -0
  323. package/js/src/src/base/errors.d.ts +168 -0
  324. package/js/src/src/base/errors.js +255 -0
  325. package/js/src/src/base/functions/crypto.d.ts +16 -0
  326. package/js/src/src/base/functions/crypto.js +131 -0
  327. package/js/src/src/base/functions/encode.d.ts +4 -0
  328. package/js/src/src/base/functions/encode.js +32 -0
  329. package/js/src/src/base/functions/generic.d.ts +29 -0
  330. package/js/src/src/base/functions/generic.js +203 -0
  331. package/js/src/src/base/functions/misc.d.ts +9 -0
  332. package/js/src/src/base/functions/misc.js +101 -0
  333. package/js/src/src/base/functions/number.d.ts +27 -0
  334. package/js/src/src/base/functions/number.js +313 -0
  335. package/js/src/src/base/functions/platform.d.ts +7 -0
  336. package/js/src/src/base/functions/platform.js +27 -0
  337. package/js/src/src/base/functions/rsa.d.ts +5 -0
  338. package/js/src/src/base/functions/rsa.js +49 -0
  339. package/js/src/src/base/functions/string.d.ts +7 -0
  340. package/js/src/src/base/functions/string.js +44 -0
  341. package/js/src/src/base/functions/throttle.d.ts +6 -0
  342. package/js/src/src/base/functions/throttle.js +67 -0
  343. package/js/src/src/base/functions/time.d.ts +21 -0
  344. package/js/src/src/base/functions/time.js +171 -0
  345. package/js/src/src/base/functions/totp.d.ts +3 -0
  346. package/js/src/src/base/functions/totp.js +25 -0
  347. package/js/src/src/base/functions/type.d.ts +37 -0
  348. package/js/src/src/base/functions/type.js +179 -0
  349. package/js/src/src/base/functions.d.ts +10 -0
  350. package/js/src/src/base/functions.js +18 -0
  351. package/js/src/src/base/types.d.ts +586 -0
  352. package/js/src/src/base/types.js +7 -0
  353. package/js/src/src/base/ws/Cache.d.ts +27 -0
  354. package/js/src/src/base/ws/Cache.js +260 -0
  355. package/js/src/src/base/ws/Client.d.ts +53 -0
  356. package/js/src/src/base/ws/Client.js +307 -0
  357. package/js/src/src/base/ws/Future.d.ts +8 -0
  358. package/js/src/src/base/ws/Future.js +35 -0
  359. package/js/src/src/base/ws/OrderBook.d.ts +25 -0
  360. package/js/src/src/base/ws/OrderBook.js +130 -0
  361. package/js/src/src/base/ws/OrderBookSide.d.ts +40 -0
  362. package/js/src/src/base/ws/OrderBookSide.js +286 -0
  363. package/js/src/src/base/ws/WsClient.d.ts +11 -0
  364. package/js/src/src/base/ws/WsClient.js +69 -0
  365. package/js/src/src/bequant.d.ts +4 -0
  366. package/js/src/src/bequant.js +35 -0
  367. package/js/src/src/bidarz.d.ts +16 -0
  368. package/js/src/src/bidarz.js +327 -0
  369. package/js/src/src/bigone.d.ts +296 -0
  370. package/js/src/src/bigone.js +2340 -0
  371. package/js/src/src/binance.d.ts +1667 -0
  372. package/js/src/src/binance.js +14400 -0
  373. package/js/src/src/binancecoinm.d.ts +6 -0
  374. package/js/src/src/binancecoinm.js +51 -0
  375. package/js/src/src/binanceus.d.ts +4 -0
  376. package/js/src/src/binanceus.js +225 -0
  377. package/js/src/src/binanceusdm.d.ts +6 -0
  378. package/js/src/src/binanceusdm.js +63 -0
  379. package/js/src/src/bingx.d.ts +778 -0
  380. package/js/src/src/bingx.js +6705 -0
  381. package/js/src/src/bit24.d.ts +24 -0
  382. package/js/src/src/bit24.js +520 -0
  383. package/js/src/src/bit2c.d.ts +146 -0
  384. package/js/src/src/bit2c.js +1029 -0
  385. package/js/src/src/bitbank.d.ts +181 -0
  386. package/js/src/src/bitbank.js +1146 -0
  387. package/js/src/src/bitbarg.d.ts +21 -0
  388. package/js/src/src/bitbarg.js +312 -0
  389. package/js/src/src/bitbns.d.ts +184 -0
  390. package/js/src/src/bitbns.js +1288 -0
  391. package/js/src/src/bitfinex.d.ts +516 -0
  392. package/js/src/src/bitfinex.js +3951 -0
  393. package/js/src/src/bitflyer.d.ts +229 -0
  394. package/js/src/src/bitflyer.js +1209 -0
  395. package/js/src/src/bitget.d.ts +1109 -0
  396. package/js/src/src/bitget.js +11033 -0
  397. package/js/src/src/bithumb.d.ts +165 -0
  398. package/js/src/src/bithumb.js +1257 -0
  399. package/js/src/src/bitimen.d.ts +23 -0
  400. package/js/src/src/bitimen.js +424 -0
  401. package/js/src/src/bitir.d.ts +23 -0
  402. package/js/src/src/bitir.js +521 -0
  403. package/js/src/src/bitmart.d.ts +736 -0
  404. package/js/src/src/bitmart.js +5639 -0
  405. package/js/src/src/bitmex.d.ts +395 -0
  406. package/js/src/src/bitmex.js +3088 -0
  407. package/js/src/src/bitopro.d.ts +295 -0
  408. package/js/src/src/bitopro.js +1892 -0
  409. package/js/src/src/bitpin.d.ts +23 -0
  410. package/js/src/src/bitpin.js +487 -0
  411. package/js/src/src/bitrue.d.ts +384 -0
  412. package/js/src/src/bitrue.js +3382 -0
  413. package/js/src/src/bitso.d.ts +270 -0
  414. package/js/src/src/bitso.js +1881 -0
  415. package/js/src/src/bitstamp.d.ts +355 -0
  416. package/js/src/src/bitstamp.js +2445 -0
  417. package/js/src/src/bitteam.d.ts +229 -0
  418. package/js/src/src/bitteam.js +2420 -0
  419. package/js/src/src/bittrade.d.ts +298 -0
  420. package/js/src/src/bittrade.js +2050 -0
  421. package/js/src/src/bitunix.d.ts +21 -0
  422. package/js/src/src/bitunix.js +326 -0
  423. package/js/src/src/bitvavo.d.ts +311 -0
  424. package/js/src/src/bitvavo.js +2204 -0
  425. package/js/src/src/blockchaincom.d.ts +256 -0
  426. package/js/src/src/blockchaincom.js +1259 -0
  427. package/js/src/src/blofin.d.ts +439 -0
  428. package/js/src/src/blofin.js +2576 -0
  429. package/js/src/src/btcalpha.d.ts +209 -0
  430. package/js/src/src/btcalpha.js +1056 -0
  431. package/js/src/src/btcbox.d.ts +144 -0
  432. package/js/src/src/btcbox.js +834 -0
  433. package/js/src/src/btcmarkets.d.ts +253 -0
  434. package/js/src/src/btcmarkets.js +1418 -0
  435. package/js/src/src/btcturk.d.ts +161 -0
  436. package/js/src/src/btcturk.js +1058 -0
  437. package/js/src/src/bybit.d.ts +1097 -0
  438. package/js/src/src/bybit.js +9382 -0
  439. package/js/src/src/bydfi.d.ts +23 -0
  440. package/js/src/src/bydfi.js +434 -0
  441. package/js/src/src/cafearz.d.ts +21 -0
  442. package/js/src/src/cafearz.js +346 -0
  443. package/js/src/src/cex.d.ts +286 -0
  444. package/js/src/src/cex.js +1799 -0
  445. package/js/src/src/coinbase.d.ts +623 -0
  446. package/js/src/src/coinbase.js +5220 -0
  447. package/js/src/src/coinbaseadvanced.d.ts +4 -0
  448. package/js/src/src/coinbaseadvanced.js +18 -0
  449. package/js/src/src/coinbaseexchange.d.ts +334 -0
  450. package/js/src/src/coinbaseexchange.js +2127 -0
  451. package/js/src/src/coinbaseinternational.d.ts +443 -0
  452. package/js/src/src/coinbaseinternational.js +2336 -0
  453. package/js/src/src/coincatch.d.ts +786 -0
  454. package/js/src/src/coincatch.js +5492 -0
  455. package/js/src/src/coincheck.d.ts +147 -0
  456. package/js/src/src/coincheck.js +962 -0
  457. package/js/src/src/coinex.d.ts +719 -0
  458. package/js/src/src/coinex.js +6166 -0
  459. package/js/src/src/coinmate.d.ts +202 -0
  460. package/js/src/src/coinmate.js +1215 -0
  461. package/js/src/src/coinmetro.d.ts +244 -0
  462. package/js/src/src/coinmetro.js +2024 -0
  463. package/js/src/src/coinone.d.ts +158 -0
  464. package/js/src/src/coinone.js +1278 -0
  465. package/js/src/src/coinsph.d.ts +310 -0
  466. package/js/src/src/coinsph.js +2203 -0
  467. package/js/src/src/coinspot.d.ts +108 -0
  468. package/js/src/src/coinspot.js +653 -0
  469. package/js/src/src/cryptocom.d.ts +463 -0
  470. package/js/src/src/cryptocom.js +3549 -0
  471. package/js/src/src/cryptomus.d.ts +158 -0
  472. package/js/src/src/cryptomus.js +1169 -0
  473. package/js/src/src/defx.d.ts +348 -0
  474. package/js/src/src/defx.js +2139 -0
  475. package/js/src/src/delta.d.ts +407 -0
  476. package/js/src/src/delta.js +3654 -0
  477. package/js/src/src/deribit.d.ts +516 -0
  478. package/js/src/src/deribit.js +3790 -0
  479. package/js/src/src/derive.d.ts +324 -0
  480. package/js/src/src/derive.js +2655 -0
  481. package/js/src/src/digifinex.d.ts +544 -0
  482. package/js/src/src/digifinex.js +4453 -0
  483. package/js/src/src/ellipx.d.ts +237 -0
  484. package/js/src/src/ellipx.js +2071 -0
  485. package/js/src/src/eterex.d.ts +21 -0
  486. package/js/src/src/eterex.js +299 -0
  487. package/js/src/src/excoino.d.ts +23 -0
  488. package/js/src/src/excoino.js +426 -0
  489. package/js/src/src/exir.d.ts +23 -0
  490. package/js/src/src/exir.js +403 -0
  491. package/js/src/src/exmo.d.ts +426 -0
  492. package/js/src/src/exmo.js +2825 -0
  493. package/js/src/src/exnovin.d.ts +22 -0
  494. package/js/src/src/exnovin.js +378 -0
  495. package/js/src/src/farhadexchange.d.ts +21 -0
  496. package/js/src/src/farhadexchange.js +280 -0
  497. package/js/src/src/fmfwio.d.ts +4 -0
  498. package/js/src/src/fmfwio.js +35 -0
  499. package/js/src/src/foxbit.d.ts +352 -0
  500. package/js/src/src/foxbit.js +2016 -0
  501. package/js/src/src/gate.d.ts +1071 -0
  502. package/js/src/src/gate.js +8282 -0
  503. package/js/src/src/gateio.d.ts +4 -0
  504. package/js/src/src/gateio.js +17 -0
  505. package/js/src/src/gemini.d.ts +257 -0
  506. package/js/src/src/gemini.js +2006 -0
  507. package/js/src/src/hamtapay.d.ts +21 -0
  508. package/js/src/src/hamtapay.js +303 -0
  509. package/js/src/src/hashkey.d.ts +628 -0
  510. package/js/src/src/hashkey.js +4363 -0
  511. package/js/src/src/hibachi.d.ts +346 -0
  512. package/js/src/src/hibachi.js +2137 -0
  513. package/js/src/src/hitbtc.d.ts +558 -0
  514. package/js/src/src/hitbtc.js +3847 -0
  515. package/js/src/src/hitobit.d.ts +23 -0
  516. package/js/src/src/hitobit.js +412 -0
  517. package/js/src/src/hollaex.d.ts +305 -0
  518. package/js/src/src/hollaex.js +2046 -0
  519. package/js/src/src/htx.d.ts +961 -0
  520. package/js/src/src/htx.js +9668 -0
  521. package/js/src/src/huobi.d.ts +4 -0
  522. package/js/src/src/huobi.js +17 -0
  523. package/js/src/src/hyperliquid.d.ts +651 -0
  524. package/js/src/src/hyperliquid.js +3937 -0
  525. package/js/src/src/independentreserve.d.ts +169 -0
  526. package/js/src/src/independentreserve.js +1115 -0
  527. package/js/src/src/indodax.d.ts +217 -0
  528. package/js/src/src/indodax.js +1454 -0
  529. package/js/src/src/iranexchange.d.ts +21 -0
  530. package/js/src/src/iranexchange.js +399 -0
  531. package/js/src/src/jibitex.d.ts +23 -0
  532. package/js/src/src/jibitex.js +416 -0
  533. package/js/src/src/kcex.d.ts +21 -0
  534. package/js/src/src/kcex.js +335 -0
  535. package/js/src/src/kifpoolme.d.ts +23 -0
  536. package/js/src/src/kifpoolme.js +410 -0
  537. package/js/src/src/kraken.d.ts +484 -0
  538. package/js/src/src/kraken.js +3518 -0
  539. package/js/src/src/krakenfutures.d.ts +362 -0
  540. package/js/src/src/krakenfutures.js +2885 -0
  541. package/js/src/src/kucoin.d.ts +759 -0
  542. package/js/src/src/kucoin.js +5153 -0
  543. package/js/src/src/kucoinfutures.d.ts +521 -0
  544. package/js/src/src/kucoinfutures.js +3381 -0
  545. package/js/src/src/latoken.d.ts +274 -0
  546. package/js/src/src/latoken.js +1824 -0
  547. package/js/src/src/lbank.d.ts +350 -0
  548. package/js/src/src/lbank.js +3146 -0
  549. package/js/src/src/luno.d.ts +252 -0
  550. package/js/src/src/luno.js +1479 -0
  551. package/js/src/src/mazdax.d.ts +23 -0
  552. package/js/src/src/mazdax.js +534 -0
  553. package/js/src/src/mercado.d.ts +160 -0
  554. package/js/src/src/mercado.js +1011 -0
  555. package/js/src/src/mexc.d.ts +768 -0
  556. package/js/src/src/mexc.js +6102 -0
  557. package/js/src/src/modetrade.d.ts +496 -0
  558. package/js/src/src/modetrade.js +2936 -0
  559. package/js/src/src/myokx.d.ts +4 -0
  560. package/js/src/src/myokx.js +54 -0
  561. package/js/src/src/ndax.d.ts +285 -0
  562. package/js/src/src/ndax.js +2598 -0
  563. package/js/src/src/nobitex.d.ts +23 -0
  564. package/js/src/src/nobitex.js +454 -0
  565. package/js/src/src/novadax.d.ts +279 -0
  566. package/js/src/src/novadax.js +1676 -0
  567. package/js/src/src/oceanex.d.ts +231 -0
  568. package/js/src/src/oceanex.js +1123 -0
  569. package/js/src/src/okcoin.d.ts +346 -0
  570. package/js/src/src/okcoin.js +3211 -0
  571. package/js/src/src/okexchange.d.ts +23 -0
  572. package/js/src/src/okexchange.js +373 -0
  573. package/js/src/src/okx.d.ts +1125 -0
  574. package/js/src/src/okx.js +9009 -0
  575. package/js/src/src/okxus.d.ts +4 -0
  576. package/js/src/src/okxus.js +54 -0
  577. package/js/src/src/ompfinex.d.ts +23 -0
  578. package/js/src/src/ompfinex.js +510 -0
  579. package/js/src/src/onetrading.d.ts +228 -0
  580. package/js/src/src/onetrading.js +1769 -0
  581. package/js/src/src/oxfun.d.ts +442 -0
  582. package/js/src/src/oxfun.js +2920 -0
  583. package/js/src/src/p2b.d.ts +189 -0
  584. package/js/src/src/p2b.js +1344 -0
  585. package/js/src/src/paradex.d.ts +389 -0
  586. package/js/src/src/paradex.js +2607 -0
  587. package/js/src/src/paymium.d.ts +133 -0
  588. package/js/src/src/paymium.js +644 -0
  589. package/js/src/src/phemex.d.ts +497 -0
  590. package/js/src/src/phemex.js +5333 -0
  591. package/js/src/src/pingi.d.ts +22 -0
  592. package/js/src/src/pingi.js +446 -0
  593. package/js/src/src/poloniex.d.ts +441 -0
  594. package/js/src/src/poloniex.js +3681 -0
  595. package/js/src/src/pooleno.d.ts +21 -0
  596. package/js/src/src/pooleno.js +347 -0
  597. package/js/src/src/pro/alpaca.d.ts +95 -0
  598. package/js/src/src/pro/alpaca.js +724 -0
  599. package/js/src/src/pro/apex.d.ts +160 -0
  600. package/js/src/src/pro/apex.js +1044 -0
  601. package/js/src/src/pro/ascendex.d.ts +99 -0
  602. package/js/src/src/pro/ascendex.js +1012 -0
  603. package/js/src/src/pro/bequant.d.ts +4 -0
  604. package/js/src/src/pro/bequant.js +42 -0
  605. package/js/src/src/pro/binance.d.ts +796 -0
  606. package/js/src/src/pro/binance.js +4373 -0
  607. package/js/src/src/pro/binancecoinm.d.ts +4 -0
  608. package/js/src/src/pro/binancecoinm.js +32 -0
  609. package/js/src/src/pro/binanceus.d.ts +4 -0
  610. package/js/src/src/pro/binanceus.js +52 -0
  611. package/js/src/src/pro/binanceusdm.d.ts +4 -0
  612. package/js/src/src/pro/binanceusdm.js +37 -0
  613. package/js/src/src/pro/bingx.d.ts +151 -0
  614. package/js/src/src/pro/bingx.js +1568 -0
  615. package/js/src/src/pro/bitfinex.d.ts +99 -0
  616. package/js/src/src/pro/bitfinex.js +1165 -0
  617. package/js/src/src/pro/bitget.d.ts +257 -0
  618. package/js/src/src/pro/bitget.js +2327 -0
  619. package/js/src/src/pro/bithumb.d.ts +59 -0
  620. package/js/src/src/pro/bithumb.js +395 -0
  621. package/js/src/src/pro/bitmart.d.ts +168 -0
  622. package/js/src/src/pro/bitmart.js +1686 -0
  623. package/js/src/src/pro/bitmex.d.ts +170 -0
  624. package/js/src/src/pro/bitmex.js +1760 -0
  625. package/js/src/src/pro/bitopro.d.ts +69 -0
  626. package/js/src/src/pro/bitopro.js +477 -0
  627. package/js/src/src/pro/bitrue.d.ts +40 -0
  628. package/js/src/src/pro/bitrue.js +461 -0
  629. package/js/src/src/pro/bitstamp.d.ts +53 -0
  630. package/js/src/src/pro/bitstamp.js +587 -0
  631. package/js/src/src/pro/bittrade.d.ts +66 -0
  632. package/js/src/src/pro/bittrade.js +606 -0
  633. package/js/src/src/pro/bitvavo.d.ts +321 -0
  634. package/js/src/src/pro/bitvavo.js +1451 -0
  635. package/js/src/src/pro/blockchaincom.d.ts +89 -0
  636. package/js/src/src/pro/blockchaincom.js +777 -0
  637. package/js/src/src/pro/blofin.d.ts +174 -0
  638. package/js/src/src/pro/blofin.js +743 -0
  639. package/js/src/src/pro/bybit.d.ts +397 -0
  640. package/js/src/src/pro/bybit.js +2519 -0
  641. package/js/src/src/pro/cex.d.ts +220 -0
  642. package/js/src/src/pro/cex.js +1535 -0
  643. package/js/src/src/pro/coinbase.d.ts +119 -0
  644. package/js/src/src/pro/coinbase.js +736 -0
  645. package/js/src/src/pro/coinbaseadvanced.d.ts +4 -0
  646. package/js/src/src/pro/coinbaseadvanced.js +18 -0
  647. package/js/src/src/pro/coinbaseexchange.d.ts +133 -0
  648. package/js/src/src/pro/coinbaseexchange.js +969 -0
  649. package/js/src/src/pro/coinbaseinternational.d.ts +143 -0
  650. package/js/src/src/pro/coinbaseinternational.js +804 -0
  651. package/js/src/src/pro/coincatch.d.ts +207 -0
  652. package/js/src/src/pro/coincatch.js +1562 -0
  653. package/js/src/src/pro/coincheck.d.ts +33 -0
  654. package/js/src/src/pro/coincheck.js +210 -0
  655. package/js/src/src/pro/coinex.d.ts +147 -0
  656. package/js/src/src/pro/coinex.js +1426 -0
  657. package/js/src/src/pro/coinone.d.ts +51 -0
  658. package/js/src/src/pro/coinone.js +413 -0
  659. package/js/src/src/pro/cryptocom.d.ts +300 -0
  660. package/js/src/src/pro/cryptocom.js +1414 -0
  661. package/js/src/src/pro/defx.d.ts +236 -0
  662. package/js/src/src/pro/defx.js +865 -0
  663. package/js/src/src/pro/deribit.d.ts +163 -0
  664. package/js/src/src/pro/deribit.js +1066 -0
  665. package/js/src/src/pro/derive.d.ts +100 -0
  666. package/js/src/src/pro/derive.js +753 -0
  667. package/js/src/src/pro/exmo.d.ts +97 -0
  668. package/js/src/src/pro/exmo.js +903 -0
  669. package/js/src/src/pro/gate.d.ts +360 -0
  670. package/js/src/src/pro/gate.js +2119 -0
  671. package/js/src/src/pro/gateio.d.ts +4 -0
  672. package/js/src/src/pro/gateio.js +17 -0
  673. package/js/src/src/pro/gemini.d.ts +106 -0
  674. package/js/src/src/pro/gemini.js +932 -0
  675. package/js/src/src/pro/hashkey.d.ts +121 -0
  676. package/js/src/src/pro/hashkey.js +843 -0
  677. package/js/src/src/pro/hitbtc.d.ts +235 -0
  678. package/js/src/src/pro/hitbtc.js +1400 -0
  679. package/js/src/src/pro/hollaex.d.ts +77 -0
  680. package/js/src/src/pro/hollaex.js +604 -0
  681. package/js/src/src/pro/htx.d.ts +141 -0
  682. package/js/src/src/pro/htx.js +2415 -0
  683. package/js/src/src/pro/huobi.d.ts +4 -0
  684. package/js/src/src/pro/huobi.js +17 -0
  685. package/js/src/src/pro/hyperliquid.d.ts +218 -0
  686. package/js/src/src/pro/hyperliquid.js +1126 -0
  687. package/js/src/src/pro/independentreserve.d.ts +36 -0
  688. package/js/src/src/pro/independentreserve.js +287 -0
  689. package/js/src/src/pro/kraken.d.ts +233 -0
  690. package/js/src/src/pro/kraken.js +1785 -0
  691. package/js/src/src/pro/krakenfutures.d.ts +178 -0
  692. package/js/src/src/pro/krakenfutures.js +1592 -0
  693. package/js/src/src/pro/kucoin.d.ts +221 -0
  694. package/js/src/src/pro/kucoin.js +1430 -0
  695. package/js/src/src/pro/kucoinfutures.d.ts +205 -0
  696. package/js/src/src/pro/kucoinfutures.js +1295 -0
  697. package/js/src/src/pro/lbank.d.ts +134 -0
  698. package/js/src/src/pro/lbank.js +950 -0
  699. package/js/src/src/pro/luno.d.ts +44 -0
  700. package/js/src/src/pro/luno.js +322 -0
  701. package/js/src/src/pro/mexc.d.ts +210 -0
  702. package/js/src/src/pro/mexc.js +2009 -0
  703. package/js/src/src/pro/modetrade.d.ts +155 -0
  704. package/js/src/src/pro/modetrade.js +1335 -0
  705. package/js/src/src/pro/myokx.d.ts +4 -0
  706. package/js/src/src/pro/myokx.js +39 -0
  707. package/js/src/src/pro/ndax.d.ts +60 -0
  708. package/js/src/src/pro/ndax.js +545 -0
  709. package/js/src/src/pro/okcoin.d.ts +91 -0
  710. package/js/src/src/pro/okcoin.js +763 -0
  711. package/js/src/src/pro/okx.d.ts +408 -0
  712. package/js/src/src/pro/okx.js +2479 -0
  713. package/js/src/src/pro/okxus.d.ts +4 -0
  714. package/js/src/src/pro/okxus.js +39 -0
  715. package/js/src/src/pro/onetrading.d.ts +107 -0
  716. package/js/src/src/pro/onetrading.js +1343 -0
  717. package/js/src/src/pro/oxfun.d.ts +234 -0
  718. package/js/src/src/pro/oxfun.js +1112 -0
  719. package/js/src/src/pro/p2b.d.ts +104 -0
  720. package/js/src/src/pro/p2b.js +506 -0
  721. package/js/src/src/pro/paradex.d.ts +54 -0
  722. package/js/src/src/pro/paradex.js +370 -0
  723. package/js/src/src/pro/phemex.d.ts +129 -0
  724. package/js/src/src/pro/phemex.js +1569 -0
  725. package/js/src/src/pro/poloniex.d.ts +214 -0
  726. package/js/src/src/pro/poloniex.js +1318 -0
  727. package/js/src/src/pro/probit.d.ts +91 -0
  728. package/js/src/src/pro/probit.js +593 -0
  729. package/js/src/src/pro/tradeogre.d.ts +49 -0
  730. package/js/src/src/pro/tradeogre.js +284 -0
  731. package/js/src/src/pro/upbit.d.ts +124 -0
  732. package/js/src/src/pro/upbit.js +689 -0
  733. package/js/src/src/pro/vertex.d.ts +104 -0
  734. package/js/src/src/pro/vertex.js +999 -0
  735. package/js/src/src/pro/whitebit.d.ts +123 -0
  736. package/js/src/src/pro/whitebit.js +971 -0
  737. package/js/src/src/pro/woo.d.ts +161 -0
  738. package/js/src/src/pro/woo.js +1351 -0
  739. package/js/src/src/pro/woofipro.d.ts +155 -0
  740. package/js/src/src/pro/woofipro.js +1335 -0
  741. package/js/src/src/pro/xt.d.ts +165 -0
  742. package/js/src/src/pro/xt.js +1230 -0
  743. package/js/src/src/probit.d.ts +283 -0
  744. package/js/src/src/probit.js +1935 -0
  745. package/js/src/src/protobuf/mexc/compiled.cjs +7186 -0
  746. package/js/src/src/protobuf/mexc/compiled.d.cts +8 -0
  747. package/js/src/src/raastin.d.ts +24 -0
  748. package/js/src/src/raastin.js +494 -0
  749. package/js/src/src/ramzinex.d.ts +23 -0
  750. package/js/src/src/ramzinex.js +510 -0
  751. package/js/src/src/sarmayex.d.ts +21 -0
  752. package/js/src/src/sarmayex.js +376 -0
  753. package/js/src/src/sarrafex.d.ts +23 -0
  754. package/js/src/src/sarrafex.js +501 -0
  755. package/js/src/src/static_dependencies/ethers/abi-coder.d.ts +50 -0
  756. package/js/src/src/static_dependencies/ethers/abi-coder.js +148 -0
  757. package/js/src/src/static_dependencies/ethers/address/address.d.ts +55 -0
  758. package/js/src/src/static_dependencies/ethers/address/address.js +162 -0
  759. package/js/src/src/static_dependencies/ethers/address/checks.d.ts +80 -0
  760. package/js/src/src/static_dependencies/ethers/address/checks.js +119 -0
  761. package/js/src/src/static_dependencies/ethers/address/contract-address.d.ts +47 -0
  762. package/js/src/src/static_dependencies/ethers/address/contract-address.js +73 -0
  763. package/js/src/src/static_dependencies/ethers/address/index.d.ts +48 -0
  764. package/js/src/src/static_dependencies/ethers/address/index.js +24 -0
  765. package/js/src/src/static_dependencies/ethers/bytes32.d.ts +14 -0
  766. package/js/src/src/static_dependencies/ethers/bytes32.js +45 -0
  767. package/js/src/src/static_dependencies/ethers/coders/abstract-coder.d.ts +120 -0
  768. package/js/src/src/static_dependencies/ethers/coders/abstract-coder.js +424 -0
  769. package/js/src/src/static_dependencies/ethers/coders/address.d.ts +12 -0
  770. package/js/src/src/static_dependencies/ethers/coders/address.js +34 -0
  771. package/js/src/src/static_dependencies/ethers/coders/anonymous.d.ts +14 -0
  772. package/js/src/src/static_dependencies/ethers/coders/anonymous.js +27 -0
  773. package/js/src/src/static_dependencies/ethers/coders/array.d.ts +24 -0
  774. package/js/src/src/static_dependencies/ethers/coders/array.js +162 -0
  775. package/js/src/src/static_dependencies/ethers/coders/boolean.d.ts +12 -0
  776. package/js/src/src/static_dependencies/ethers/coders/boolean.js +26 -0
  777. package/js/src/src/static_dependencies/ethers/coders/bytes.d.ts +18 -0
  778. package/js/src/src/static_dependencies/ethers/coders/bytes.js +39 -0
  779. package/js/src/src/static_dependencies/ethers/coders/fixed-bytes.d.ts +14 -0
  780. package/js/src/src/static_dependencies/ethers/coders/fixed-bytes.js +32 -0
  781. package/js/src/src/static_dependencies/ethers/coders/null.d.ts +11 -0
  782. package/js/src/src/static_dependencies/ethers/coders/null.js +29 -0
  783. package/js/src/src/static_dependencies/ethers/coders/number.d.ts +15 -0
  784. package/js/src/src/static_dependencies/ethers/coders/number.js +48 -0
  785. package/js/src/src/static_dependencies/ethers/coders/string.d.ts +12 -0
  786. package/js/src/src/static_dependencies/ethers/coders/string.js +26 -0
  787. package/js/src/src/static_dependencies/ethers/coders/tuple.d.ts +15 -0
  788. package/js/src/src/static_dependencies/ethers/coders/tuple.js +67 -0
  789. package/js/src/src/static_dependencies/ethers/fragments.d.ts +458 -0
  790. package/js/src/src/static_dependencies/ethers/fragments.js +1252 -0
  791. package/js/src/src/static_dependencies/ethers/hash/index.d.ts +10 -0
  792. package/js/src/src/static_dependencies/ethers/hash/index.js +15 -0
  793. package/js/src/src/static_dependencies/ethers/hash/solidity.d.ts +30 -0
  794. package/js/src/src/static_dependencies/ethers/hash/solidity.js +107 -0
  795. package/js/src/src/static_dependencies/ethers/hash/typed-data.d.ts +144 -0
  796. package/js/src/src/static_dependencies/ethers/hash/typed-data.js +490 -0
  797. package/js/src/src/static_dependencies/ethers/index.d.ts +19 -0
  798. package/js/src/src/static_dependencies/ethers/index.js +22 -0
  799. package/js/src/src/static_dependencies/ethers/interface.d.ts +380 -0
  800. package/js/src/src/static_dependencies/ethers/interface.js +990 -0
  801. package/js/src/src/static_dependencies/ethers/typed.d.ts +569 -0
  802. package/js/src/src/static_dependencies/ethers/typed.js +608 -0
  803. package/js/src/src/static_dependencies/ethers/utils/base58.d.ts +22 -0
  804. package/js/src/src/static_dependencies/ethers/utils/base58.js +68 -0
  805. package/js/src/src/static_dependencies/ethers/utils/base64.d.ts +39 -0
  806. package/js/src/src/static_dependencies/ethers/utils/base64.js +58 -0
  807. package/js/src/src/static_dependencies/ethers/utils/data.d.ts +92 -0
  808. package/js/src/src/static_dependencies/ethers/utils/data.js +175 -0
  809. package/js/src/src/static_dependencies/ethers/utils/errors.d.ts +509 -0
  810. package/js/src/src/static_dependencies/ethers/utils/errors.js +227 -0
  811. package/js/src/src/static_dependencies/ethers/utils/events.d.ts +76 -0
  812. package/js/src/src/static_dependencies/ethers/utils/events.js +52 -0
  813. package/js/src/src/static_dependencies/ethers/utils/fixednumber.d.ts +251 -0
  814. package/js/src/src/static_dependencies/ethers/utils/fixednumber.js +529 -0
  815. package/js/src/src/static_dependencies/ethers/utils/index.d.ts +30 -0
  816. package/js/src/src/static_dependencies/ethers/utils/index.js +38 -0
  817. package/js/src/src/static_dependencies/ethers/utils/maths.d.ts +65 -0
  818. package/js/src/src/static_dependencies/ethers/utils/maths.js +220 -0
  819. package/js/src/src/static_dependencies/ethers/utils/properties.d.ts +22 -0
  820. package/js/src/src/static_dependencies/ethers/utils/properties.js +59 -0
  821. package/js/src/src/static_dependencies/ethers/utils/rlp-decode.d.ts +5 -0
  822. package/js/src/src/static_dependencies/ethers/utils/rlp-decode.js +84 -0
  823. package/js/src/src/static_dependencies/ethers/utils/rlp-encode.d.ts +5 -0
  824. package/js/src/src/static_dependencies/ethers/utils/rlp-encode.js +54 -0
  825. package/js/src/src/static_dependencies/ethers/utils/rlp.d.ts +16 -0
  826. package/js/src/src/static_dependencies/ethers/utils/rlp.js +14 -0
  827. package/js/src/src/static_dependencies/ethers/utils/units.d.ts +23 -0
  828. package/js/src/src/static_dependencies/ethers/utils/units.js +88 -0
  829. package/js/src/src/static_dependencies/ethers/utils/utf8.d.ts +95 -0
  830. package/js/src/src/static_dependencies/ethers/utils/utf8.js +225 -0
  831. package/js/src/src/static_dependencies/ethers/utils/uuid.d.ts +7 -0
  832. package/js/src/src/static_dependencies/ethers/utils/uuid.js +35 -0
  833. package/js/src/src/static_dependencies/fflake/browser.d.ts +222 -0
  834. package/js/src/src/static_dependencies/fflake/browser.js +2578 -0
  835. package/js/src/src/static_dependencies/jsencrypt/JSEncrypt.d.ts +116 -0
  836. package/js/src/src/static_dependencies/jsencrypt/JSEncrypt.js +194 -0
  837. package/js/src/src/static_dependencies/jsencrypt/JSEncryptRSAKey.d.ts +142 -0
  838. package/js/src/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +307 -0
  839. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/asn1.d.ts +51 -0
  840. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +565 -0
  841. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/base64.d.ts +5 -0
  842. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +94 -0
  843. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/hex.d.ts +3 -0
  844. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +70 -0
  845. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/int10.d.ts +9 -0
  846. package/js/src/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +91 -0
  847. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/base64.d.ts +3 -0
  848. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +25 -0
  849. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +101 -0
  850. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1757 -0
  851. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/prng4.d.ts +10 -0
  852. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +50 -0
  853. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rng.d.ts +3 -0
  854. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +80 -0
  855. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rsa.d.ts +23 -0
  856. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +377 -0
  857. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/util.d.ts +7 -0
  858. package/js/src/src/static_dependencies/jsencrypt/lib/jsbn/util.js +64 -0
  859. package/js/src/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.d.ts +24 -0
  860. package/js/src/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1627 -0
  861. package/js/src/src/static_dependencies/noble-curves/_shortw_utils.d.ts +60 -0
  862. package/js/src/src/static_dependencies/noble-curves/_shortw_utils.js +22 -0
  863. package/js/src/src/static_dependencies/noble-curves/abstract/curve.d.ts +67 -0
  864. package/js/src/src/static_dependencies/noble-curves/abstract/curve.js +157 -0
  865. package/js/src/src/static_dependencies/noble-curves/abstract/edwards.d.ts +79 -0
  866. package/js/src/src/static_dependencies/noble-curves/abstract/edwards.js +432 -0
  867. package/js/src/src/static_dependencies/noble-curves/abstract/hash-to-curve.d.ts +56 -0
  868. package/js/src/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +171 -0
  869. package/js/src/src/static_dependencies/noble-curves/abstract/modular.d.ts +68 -0
  870. package/js/src/src/static_dependencies/noble-curves/abstract/modular.js +351 -0
  871. package/js/src/src/static_dependencies/noble-curves/abstract/montgomery.d.ts +25 -0
  872. package/js/src/src/static_dependencies/noble-curves/abstract/montgomery.js +162 -0
  873. package/js/src/src/static_dependencies/noble-curves/abstract/poseidon.d.ts +29 -0
  874. package/js/src/src/static_dependencies/noble-curves/abstract/poseidon.js +115 -0
  875. package/js/src/src/static_dependencies/noble-curves/abstract/utils.d.ts +53 -0
  876. package/js/src/src/static_dependencies/noble-curves/abstract/utils.js +227 -0
  877. package/js/src/src/static_dependencies/noble-curves/abstract/weierstrass.d.ts +204 -0
  878. package/js/src/src/static_dependencies/noble-curves/abstract/weierstrass.js +1016 -0
  879. package/js/src/src/static_dependencies/noble-curves/ed25519.d.ts +53 -0
  880. package/js/src/src/static_dependencies/noble-curves/ed25519.js +402 -0
  881. package/js/src/src/static_dependencies/noble-curves/p256.d.ts +103 -0
  882. package/js/src/src/static_dependencies/noble-curves/p256.js +47 -0
  883. package/js/src/src/static_dependencies/noble-curves/secp256k1.d.ts +91 -0
  884. package/js/src/src/static_dependencies/noble-curves/secp256k1.js +257 -0
  885. package/js/src/src/static_dependencies/noble-hashes/_assert.d.ts +21 -0
  886. package/js/src/src/static_dependencies/noble-hashes/_assert.js +48 -0
  887. package/js/src/src/static_dependencies/noble-hashes/_sha2.d.ts +23 -0
  888. package/js/src/src/static_dependencies/noble-hashes/_sha2.js +119 -0
  889. package/js/src/src/static_dependencies/noble-hashes/_u64.d.ts +35 -0
  890. package/js/src/src/static_dependencies/noble-hashes/_u64.js +66 -0
  891. package/js/src/src/static_dependencies/noble-hashes/crypto.d.ts +1 -0
  892. package/js/src/src/static_dependencies/noble-hashes/crypto.js +7 -0
  893. package/js/src/src/static_dependencies/noble-hashes/hmac.d.ts +26 -0
  894. package/js/src/src/static_dependencies/noble-hashes/hmac.js +82 -0
  895. package/js/src/src/static_dependencies/noble-hashes/md5.d.ts +18 -0
  896. package/js/src/src/static_dependencies/noble-hashes/md5.js +242 -0
  897. package/js/src/src/static_dependencies/noble-hashes/sha1.d.ts +21 -0
  898. package/js/src/src/static_dependencies/noble-hashes/sha1.js +90 -0
  899. package/js/src/src/static_dependencies/noble-hashes/sha256.d.ts +34 -0
  900. package/js/src/src/static_dependencies/noble-hashes/sha256.js +129 -0
  901. package/js/src/src/static_dependencies/noble-hashes/sha3.d.ts +97 -0
  902. package/js/src/src/static_dependencies/noble-hashes/sha3.js +211 -0
  903. package/js/src/src/static_dependencies/noble-hashes/sha512.d.ts +66 -0
  904. package/js/src/src/static_dependencies/noble-hashes/sha512.js +236 -0
  905. package/js/src/src/static_dependencies/noble-hashes/utils.d.ts +77 -0
  906. package/js/src/src/static_dependencies/noble-hashes/utils.js +147 -0
  907. package/js/src/src/static_dependencies/proxies/agent-base/helpers.d.ts +14 -0
  908. package/js/src/src/static_dependencies/proxies/agent-base/helpers.js +42 -0
  909. package/js/src/src/static_dependencies/proxies/agent-base/index.d.ts +33 -0
  910. package/js/src/src/static_dependencies/proxies/agent-base/index.js +82 -0
  911. package/js/src/src/static_dependencies/proxies/http-proxy-agent/index.d.ts +40 -0
  912. package/js/src/src/static_dependencies/proxies/http-proxy-agent/index.js +119 -0
  913. package/js/src/src/static_dependencies/proxies/https-proxy-agent/index.d.ts +45 -0
  914. package/js/src/src/static_dependencies/proxies/https-proxy-agent/index.js +150 -0
  915. package/js/src/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.d.ts +15 -0
  916. package/js/src/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +95 -0
  917. package/js/src/src/static_dependencies/qs/formats.cjs +22 -0
  918. package/js/src/src/static_dependencies/qs/formats.d.cts +14 -0
  919. package/js/src/src/static_dependencies/qs/index.cjs +15 -0
  920. package/js/src/src/static_dependencies/qs/index.d.cts +10 -0
  921. package/js/src/src/static_dependencies/qs/parse.cjs +208 -0
  922. package/js/src/src/static_dependencies/qs/parse.d.cts +8 -0
  923. package/js/src/src/static_dependencies/qs/stringify.cjs +192 -0
  924. package/js/src/src/static_dependencies/qs/stringify.d.cts +8 -0
  925. package/js/src/src/static_dependencies/qs/utils.cjs +202 -0
  926. package/js/src/src/static_dependencies/qs/utils.d.cts +15 -0
  927. package/js/src/src/static_dependencies/scure-base/index.d.ts +92 -0
  928. package/js/src/src/static_dependencies/scure-base/index.js +420 -0
  929. package/js/src/src/static_dependencies/scure-starknet/index.d.ts +79 -0
  930. package/js/src/src/static_dependencies/scure-starknet/index.js +323 -0
  931. package/js/src/src/static_dependencies/starknet/constants.d.ts +61 -0
  932. package/js/src/src/static_dependencies/starknet/constants.js +67 -0
  933. package/js/src/src/static_dependencies/starknet/index.d.ts +3 -0
  934. package/js/src/src/static_dependencies/starknet/index.js +9 -0
  935. package/js/src/src/static_dependencies/starknet/types/cairoEnum.d.ts +2 -0
  936. package/js/src/src/static_dependencies/starknet/types/cairoEnum.js +7 -0
  937. package/js/src/src/static_dependencies/starknet/types/calldata.d.ts +19 -0
  938. package/js/src/src/static_dependencies/starknet/types/calldata.js +28 -0
  939. package/js/src/src/static_dependencies/starknet/types/index.d.ts +13 -0
  940. package/js/src/src/static_dependencies/starknet/types/index.js +16 -0
  941. package/js/src/src/static_dependencies/starknet/types/lib/contract/abi.d.ts +71 -0
  942. package/js/src/src/static_dependencies/starknet/types/lib/contract/abi.js +13 -0
  943. package/js/src/src/static_dependencies/starknet/types/lib/contract/index.d.ts +24 -0
  944. package/js/src/src/static_dependencies/starknet/types/lib/contract/index.js +16 -0
  945. package/js/src/src/static_dependencies/starknet/types/lib/contract/legacy.d.ts +33 -0
  946. package/js/src/src/static_dependencies/starknet/types/lib/contract/legacy.js +7 -0
  947. package/js/src/src/static_dependencies/starknet/types/lib/contract/sierra.d.ts +52 -0
  948. package/js/src/src/static_dependencies/starknet/types/lib/contract/sierra.js +7 -0
  949. package/js/src/src/static_dependencies/starknet/types/lib/index.d.ts +248 -0
  950. package/js/src/src/static_dependencies/starknet/types/lib/index.js +52 -0
  951. package/js/src/src/static_dependencies/starknet/types/typedData.d.ts +44 -0
  952. package/js/src/src/static_dependencies/starknet/types/typedData.js +19 -0
  953. package/js/src/src/static_dependencies/starknet/utils/assert.d.ts +7 -0
  954. package/js/src/src/static_dependencies/starknet/utils/assert.js +17 -0
  955. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/felt.d.ts +6 -0
  956. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +43 -0
  957. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.d.ts +72 -0
  958. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +117 -0
  959. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.d.ts +76 -0
  960. package/js/src/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +136 -0
  961. package/js/src/src/static_dependencies/starknet/utils/calldata/byteArray.d.ts +32 -0
  962. package/js/src/src/static_dependencies/starknet/utils/calldata/byteArray.js +59 -0
  963. package/js/src/src/static_dependencies/starknet/utils/calldata/cairo.d.ts +183 -0
  964. package/js/src/src/static_dependencies/starknet/utils/calldata/cairo.js +229 -0
  965. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.d.ts +38 -0
  966. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +57 -0
  967. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.d.ts +35 -0
  968. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +64 -0
  969. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.d.ts +34 -0
  970. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +63 -0
  971. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/index.d.ts +3 -0
  972. package/js/src/src/static_dependencies/starknet/utils/calldata/enum/index.js +9 -0
  973. package/js/src/src/static_dependencies/starknet/utils/calldata/formatter.d.ts +9 -0
  974. package/js/src/src/static_dependencies/starknet/utils/calldata/formatter.js +67 -0
  975. package/js/src/src/static_dependencies/starknet/utils/calldata/index.d.ts +89 -0
  976. package/js/src/src/static_dependencies/starknet/utils/calldata/index.js +280 -0
  977. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -0
  978. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/index.js +30 -0
  979. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/interface.d.ts +20 -0
  980. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/interface.js +8 -0
  981. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.d.ts +24 -0
  982. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +36 -0
  983. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.d.ts +23 -0
  984. package/js/src/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +40 -0
  985. package/js/src/src/static_dependencies/starknet/utils/calldata/propertyOrder.d.ts +2 -0
  986. package/js/src/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +155 -0
  987. package/js/src/src/static_dependencies/starknet/utils/calldata/requestParser.d.ts +11 -0
  988. package/js/src/src/static_dependencies/starknet/utils/calldata/requestParser.js +248 -0
  989. package/js/src/src/static_dependencies/starknet/utils/calldata/responseParser.d.ts +11 -0
  990. package/js/src/src/static_dependencies/starknet/utils/calldata/responseParser.js +214 -0
  991. package/js/src/src/static_dependencies/starknet/utils/calldata/tuple.d.ts +6 -0
  992. package/js/src/src/static_dependencies/starknet/utils/calldata/tuple.js +113 -0
  993. package/js/src/src/static_dependencies/starknet/utils/calldata/validate.d.ts +6 -0
  994. package/js/src/src/static_dependencies/starknet/utils/calldata/validate.js +208 -0
  995. package/js/src/src/static_dependencies/starknet/utils/encode.d.ts +207 -0
  996. package/js/src/src/static_dependencies/starknet/utils/encode.js +282 -0
  997. package/js/src/src/static_dependencies/starknet/utils/hash/classHash.d.ts +57 -0
  998. package/js/src/src/static_dependencies/starknet/utils/hash/classHash.js +223 -0
  999. package/js/src/src/static_dependencies/starknet/utils/hash/index.d.ts +6 -0
  1000. package/js/src/src/static_dependencies/starknet/utils/hash/index.js +13 -0
  1001. package/js/src/src/static_dependencies/starknet/utils/merkle.d.ts +35 -0
  1002. package/js/src/src/static_dependencies/starknet/utils/merkle.js +84 -0
  1003. package/js/src/src/static_dependencies/starknet/utils/num.d.ts +182 -0
  1004. package/js/src/src/static_dependencies/starknet/utils/num.js +244 -0
  1005. package/js/src/src/static_dependencies/starknet/utils/selector.d.ts +48 -0
  1006. package/js/src/src/static_dependencies/starknet/utils/selector.js +85 -0
  1007. package/js/src/src/static_dependencies/starknet/utils/shortString.d.ts +57 -0
  1008. package/js/src/src/static_dependencies/starknet/utils/shortString.js +96 -0
  1009. package/js/src/src/static_dependencies/starknet/utils/typedData.d.ts +54 -0
  1010. package/js/src/src/static_dependencies/starknet/utils/typedData.js +321 -0
  1011. package/js/src/src/static_dependencies/watchable/src/types.d.ts +28 -0
  1012. package/js/src/src/static_dependencies/watchable/src/types.js +8 -0
  1013. package/js/src/src/static_dependencies/watchable/src/unpromise.d.ts +120 -0
  1014. package/js/src/src/static_dependencies/watchable/src/unpromise.js +297 -0
  1015. package/js/src/src/static_dependencies/zklink/zklink-sdk-web.d.ts +1279 -0
  1016. package/js/src/src/static_dependencies/zklink/zklink-sdk-web.js +4282 -0
  1017. package/js/src/src/tabdeal.d.ts +23 -0
  1018. package/js/src/src/tabdeal.js +387 -0
  1019. package/js/src/src/tehran_exchange.d.ts +21 -0
  1020. package/js/src/src/tehran_exchange.js +333 -0
  1021. package/js/src/src/tetherland.d.ts +21 -0
  1022. package/js/src/src/tetherland.js +367 -0
  1023. package/js/src/src/timex.d.ts +247 -0
  1024. package/js/src/src/timex.js +1792 -0
  1025. package/js/src/src/tokocrypto.d.ts +261 -0
  1026. package/js/src/src/tokocrypto.js +2641 -0
  1027. package/js/src/src/toobit.d.ts +22 -0
  1028. package/js/src/src/toobit.js +445 -0
  1029. package/js/src/src/tradeogre.d.ts +149 -0
  1030. package/js/src/src/tradeogre.js +878 -0
  1031. package/js/src/src/twox.d.ts +21 -0
  1032. package/js/src/src/twox.js +371 -0
  1033. package/js/src/src/ubitex.d.ts +23 -0
  1034. package/js/src/src/ubitex.js +433 -0
  1035. package/js/src/src/upbit.d.ts +377 -0
  1036. package/js/src/src/upbit.js +2340 -0
  1037. package/js/src/src/vertex.d.ts +346 -0
  1038. package/js/src/src/vertex.js +3146 -0
  1039. package/js/src/src/wallex.d.ts +23 -0
  1040. package/js/src/src/wallex.js +467 -0
  1041. package/js/src/src/wavesexchange.d.ts +244 -0
  1042. package/js/src/src/wavesexchange.js +2747 -0
  1043. package/js/src/src/whitebit.d.ts +571 -0
  1044. package/js/src/src/whitebit.js +3437 -0
  1045. package/js/src/src/woo.d.ts +727 -0
  1046. package/js/src/src/woo.js +4183 -0
  1047. package/js/src/src/woofipro.d.ts +497 -0
  1048. package/js/src/src/woofipro.js +2941 -0
  1049. package/js/src/src/xt.d.ts +568 -0
  1050. package/js/src/src/xt.js +5184 -0
  1051. package/js/src/src/yobit.d.ts +197 -0
  1052. package/js/src/src/yobit.js +1453 -0
  1053. package/js/src/src/zaif.d.ts +136 -0
  1054. package/js/src/src/zaif.js +821 -0
  1055. package/js/src/src/zonda.d.ts +214 -0
  1056. package/js/src/src/zonda.js +1984 -0
  1057. package/js/test.d.ts +1 -1
  1058. package/js/test.js +33 -33
  1059. package/package.json +1 -1
@@ -0,0 +1,3088 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ // ---------------------------------------------------------------------------
8
+ import Exchange from './abstract/bitmex.js';
9
+ import { TICK_SIZE } from './base/functions/number.js';
10
+ import { AuthenticationError, BadRequest, DDoSProtection, ExchangeError, ExchangeNotAvailable, InsufficientFunds, InvalidOrder, OrderNotFound, PermissionDenied, ArgumentsRequired, BadSymbol } from './base/errors.js';
11
+ import { Precise } from './base/Precise.js';
12
+ import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
13
+ import { totp } from './base/functions/totp.js';
14
+ // ---------------------------------------------------------------------------
15
+ /**
16
+ * @class bitmex
17
+ * @augments Exchange
18
+ */
19
+ export default class bitmex extends Exchange {
20
+ describe() {
21
+ return this.deepExtend(super.describe(), {
22
+ 'id': 'bitmex',
23
+ 'name': 'BitMEX',
24
+ 'countries': ['SC'],
25
+ 'version': 'v1',
26
+ 'userAgent': undefined,
27
+ // cheapest endpoints are 10 requests per second (trading)
28
+ // 10 per second => rateLimit = 1000ms / 10 = 100ms
29
+ // 120 per minute => 2 per second => weight = 5 (authenticated)
30
+ // 30 per minute => 0.5 per second => weight = 20 (unauthenticated)
31
+ 'rateLimit': 100,
32
+ 'certified': true,
33
+ 'pro': true,
34
+ 'has': {
35
+ 'CORS': undefined,
36
+ 'spot': true,
37
+ 'margin': false,
38
+ 'swap': true,
39
+ 'future': true,
40
+ 'option': false,
41
+ 'addMargin': undefined,
42
+ 'cancelAllOrders': true,
43
+ 'cancelAllOrdersAfter': true,
44
+ 'cancelOrder': true,
45
+ 'cancelOrders': true,
46
+ 'closeAllPositions': false,
47
+ 'closePosition': true,
48
+ 'createOrder': true,
49
+ 'createReduceOnlyOrder': true,
50
+ 'createStopOrder': true,
51
+ 'createTrailingAmountOrder': true,
52
+ 'createTriggerOrder': true,
53
+ 'editOrder': true,
54
+ 'fetchBalance': true,
55
+ 'fetchClosedOrders': true,
56
+ 'fetchCurrencies': true,
57
+ 'fetchDepositAddress': true,
58
+ 'fetchDepositAddresses': false,
59
+ 'fetchDepositAddressesByNetwork': false,
60
+ 'fetchDepositsWithdrawals': 'emulated',
61
+ 'fetchDepositWithdrawFee': 'emulated',
62
+ 'fetchDepositWithdrawFees': true,
63
+ 'fetchFundingHistory': false,
64
+ 'fetchFundingRate': 'emulated',
65
+ 'fetchFundingRateHistory': true,
66
+ 'fetchFundingRates': true,
67
+ 'fetchIndexOHLCV': false,
68
+ 'fetchLedger': true,
69
+ 'fetchLeverage': 'emulated',
70
+ 'fetchLeverages': true,
71
+ 'fetchLeverageTiers': false,
72
+ 'fetchLiquidations': true,
73
+ 'fetchMarginAdjustmentHistory': false,
74
+ 'fetchMarketLeverageTiers': false,
75
+ 'fetchMarkets': true,
76
+ 'fetchMarkOHLCV': false,
77
+ 'fetchMyLiquidations': false,
78
+ 'fetchMyTrades': true,
79
+ 'fetchOHLCV': true,
80
+ 'fetchOpenOrders': true,
81
+ 'fetchOrder': true,
82
+ 'fetchOrderBook': true,
83
+ 'fetchOrders': true,
84
+ 'fetchPosition': false,
85
+ 'fetchPositionHistory': false,
86
+ 'fetchPositions': true,
87
+ 'fetchPositionsHistory': false,
88
+ 'fetchPositionsRisk': false,
89
+ 'fetchPremiumIndexOHLCV': false,
90
+ 'fetchTicker': true,
91
+ 'fetchTickers': true,
92
+ 'fetchTrades': true,
93
+ 'fetchTransactions': 'emulated',
94
+ 'fetchTransfer': false,
95
+ 'fetchTransfers': false,
96
+ 'index': true,
97
+ 'reduceMargin': undefined,
98
+ 'sandbox': true,
99
+ 'setLeverage': true,
100
+ 'setMargin': undefined,
101
+ 'setMarginMode': true,
102
+ 'setPositionMode': false,
103
+ 'transfer': false,
104
+ 'withdraw': true,
105
+ },
106
+ 'timeframes': {
107
+ '1m': '1m',
108
+ '5m': '5m',
109
+ '1h': '1h',
110
+ '1d': '1d',
111
+ },
112
+ 'urls': {
113
+ 'test': {
114
+ 'public': 'https://testnet.bitmex.com',
115
+ 'private': 'https://testnet.bitmex.com',
116
+ },
117
+ 'logo': 'https://github.com/user-attachments/assets/c78425ab-78d5-49d6-bd14-db7734798f04',
118
+ 'api': {
119
+ 'public': 'https://www.bitmex.com',
120
+ 'private': 'https://www.bitmex.com',
121
+ },
122
+ 'www': 'https://www.bitmex.com',
123
+ 'doc': [
124
+ 'https://www.bitmex.com/app/apiOverview',
125
+ 'https://github.com/BitMEX/api-connectors/tree/master/official-http',
126
+ ],
127
+ 'fees': 'https://www.bitmex.com/app/fees',
128
+ 'referral': {
129
+ 'url': 'https://www.bitmex.com/app/register/NZTR1q',
130
+ 'discount': 0.1,
131
+ },
132
+ },
133
+ 'api': {
134
+ 'public': {
135
+ 'get': {
136
+ 'announcement': 5,
137
+ 'announcement/urgent': 5,
138
+ 'chat': 5,
139
+ 'chat/channels': 5,
140
+ 'chat/connected': 5,
141
+ 'chat/pinned': 5,
142
+ 'funding': 5,
143
+ 'guild': 5,
144
+ 'instrument': 5,
145
+ 'instrument/active': 5,
146
+ 'instrument/activeAndIndices': 5,
147
+ 'instrument/activeIntervals': 5,
148
+ 'instrument/compositeIndex': 5,
149
+ 'instrument/indices': 5,
150
+ 'instrument/usdVolume': 5,
151
+ 'insurance': 5,
152
+ 'leaderboard': 5,
153
+ 'liquidation': 5,
154
+ 'orderBook/L2': 5,
155
+ 'porl/nonce': 5,
156
+ 'quote': 5,
157
+ 'quote/bucketed': 5,
158
+ 'schema': 5,
159
+ 'schema/websocketHelp': 5,
160
+ 'settlement': 5,
161
+ 'stats': 5,
162
+ 'stats/history': 5,
163
+ 'stats/historyUSD': 5,
164
+ 'trade': 5,
165
+ 'trade/bucketed': 5,
166
+ 'wallet/assets': 5,
167
+ 'wallet/networks': 5,
168
+ },
169
+ },
170
+ 'private': {
171
+ 'get': {
172
+ 'address': 5,
173
+ 'apiKey': 5,
174
+ 'execution': 5,
175
+ 'execution/tradeHistory': 5,
176
+ 'globalNotification': 5,
177
+ 'leaderboard/name': 5,
178
+ 'order': 5,
179
+ 'porl/snapshots': 5,
180
+ 'position': 5,
181
+ 'user': 5,
182
+ 'user/affiliateStatus': 5,
183
+ 'user/checkReferralCode': 5,
184
+ 'user/commission': 5,
185
+ 'user/csa': 5,
186
+ 'user/depositAddress': 5,
187
+ 'user/executionHistory': 5,
188
+ 'user/getWalletTransferAccounts': 5,
189
+ 'user/margin': 5,
190
+ 'user/quoteFillRatio': 5,
191
+ 'user/quoteValueRatio': 5,
192
+ 'user/staking': 5,
193
+ 'user/staking/instruments': 5,
194
+ 'user/staking/tiers': 5,
195
+ 'user/tradingVolume': 5,
196
+ 'user/unstakingRequests': 5,
197
+ 'user/wallet': 5,
198
+ 'user/walletHistory': 5,
199
+ 'user/walletSummary': 5,
200
+ 'userAffiliates': 5,
201
+ 'userEvent': 5,
202
+ },
203
+ 'post': {
204
+ 'address': 5,
205
+ 'chat': 5,
206
+ 'guild': 5,
207
+ 'guild/archive': 5,
208
+ 'guild/join': 5,
209
+ 'guild/kick': 5,
210
+ 'guild/leave': 5,
211
+ 'guild/sharesTrades': 5,
212
+ 'order': 1,
213
+ 'order/cancelAllAfter': 5,
214
+ 'order/closePosition': 5,
215
+ 'position/isolate': 1,
216
+ 'position/leverage': 1,
217
+ 'position/riskLimit': 5,
218
+ 'position/transferMargin': 1,
219
+ 'user/addSubaccount': 5,
220
+ 'user/cancelWithdrawal': 5,
221
+ 'user/communicationToken': 5,
222
+ 'user/confirmEmail': 5,
223
+ 'user/confirmWithdrawal': 5,
224
+ 'user/logout': 5,
225
+ 'user/preferences': 5,
226
+ 'user/requestWithdrawal': 5,
227
+ 'user/unstakingRequests': 5,
228
+ 'user/updateSubaccount': 5,
229
+ 'user/walletTransfer': 5,
230
+ },
231
+ 'put': {
232
+ 'guild': 5,
233
+ 'order': 1,
234
+ },
235
+ 'delete': {
236
+ 'order': 1,
237
+ 'order/all': 1,
238
+ 'user/unstakingRequests': 5,
239
+ },
240
+ },
241
+ },
242
+ 'exceptions': {
243
+ 'exact': {
244
+ 'Invalid API Key.': AuthenticationError,
245
+ 'This key is disabled.': PermissionDenied,
246
+ 'Access Denied': PermissionDenied,
247
+ 'Duplicate clOrdID': InvalidOrder,
248
+ 'orderQty is invalid': InvalidOrder,
249
+ 'Invalid price': InvalidOrder,
250
+ 'Invalid stopPx for ordType': InvalidOrder,
251
+ 'Account is restricted': PermissionDenied, // {"error":{"message":"Account is restricted","name":"HTTPError"}}
252
+ },
253
+ 'broad': {
254
+ 'Signature not valid': AuthenticationError,
255
+ 'overloaded': ExchangeNotAvailable,
256
+ 'Account has insufficient Available Balance': InsufficientFunds,
257
+ 'Service unavailable': ExchangeNotAvailable,
258
+ 'Server Error': ExchangeError,
259
+ 'Unable to cancel order due to existing state': InvalidOrder,
260
+ 'We require all new traders to verify': PermissionDenied, // {"message":"We require all new traders to verify their identity before their first deposit. Please visit bitmex.com/verify to complete the process.","name":"HTTPError"}
261
+ },
262
+ },
263
+ 'precisionMode': TICK_SIZE,
264
+ 'options': {
265
+ // https://blog.bitmex.com/api_announcement/deprecation-of-api-nonce-header/
266
+ // https://github.com/ccxt/ccxt/issues/4789
267
+ 'api-expires': 5,
268
+ 'fetchOHLCVOpenTimestamp': true,
269
+ 'oldPrecision': false,
270
+ 'networks': {
271
+ 'BTC': 'btc',
272
+ 'ERC20': 'eth',
273
+ 'BEP20': 'bsc',
274
+ 'TRC20': 'tron',
275
+ 'AVAXC': 'avax',
276
+ 'NEAR': 'near',
277
+ 'XTZ': 'xtz',
278
+ 'DOT': 'dot',
279
+ 'SOL': 'sol',
280
+ 'ADA': 'ada',
281
+ },
282
+ },
283
+ 'features': {
284
+ 'default': {
285
+ 'sandbox': true,
286
+ 'createOrder': {
287
+ 'marginMode': true,
288
+ 'triggerPrice': true,
289
+ 'triggerPriceType': {
290
+ 'last': true,
291
+ 'mark': true,
292
+ },
293
+ 'triggerDirection': true,
294
+ 'stopLossPrice': false,
295
+ 'takeProfitPrice': false,
296
+ 'attachedStopLossTakeProfit': undefined,
297
+ 'timeInForce': {
298
+ 'IOC': true,
299
+ 'FOK': true,
300
+ 'PO': true,
301
+ 'GTD': false,
302
+ },
303
+ 'hedged': false,
304
+ 'trailing': true,
305
+ 'marketBuyRequiresPrice': false,
306
+ 'marketBuyByCost': false,
307
+ // exchange-supported features
308
+ // 'selfTradePrevention': true,
309
+ // 'twap': false,
310
+ // 'iceberg': false,
311
+ // 'oco': false,
312
+ },
313
+ 'createOrders': undefined,
314
+ 'fetchMyTrades': {
315
+ 'marginMode': false,
316
+ 'limit': 500,
317
+ 'daysBack': undefined,
318
+ 'untilDays': 1000000,
319
+ 'symbolRequired': false,
320
+ },
321
+ 'fetchOrder': {
322
+ 'marginMode': false,
323
+ 'trigger': false,
324
+ 'trailing': false,
325
+ 'symbolRequired': false,
326
+ },
327
+ 'fetchOpenOrders': {
328
+ 'marginMode': false,
329
+ 'limit': 500,
330
+ 'trigger': false,
331
+ 'trailing': false,
332
+ 'symbolRequired': false,
333
+ },
334
+ 'fetchOrders': {
335
+ 'marginMode': false,
336
+ 'limit': 500,
337
+ 'daysBack': undefined,
338
+ 'untilDays': 1000000,
339
+ 'trigger': false,
340
+ 'trailing': false,
341
+ 'symbolRequired': false,
342
+ },
343
+ 'fetchClosedOrders': {
344
+ 'marginMode': false,
345
+ 'limit': 500,
346
+ 'daysBack': undefined,
347
+ 'daysBackCanceled': undefined,
348
+ 'untilDays': 1000000,
349
+ 'trigger': false,
350
+ 'trailing': false,
351
+ 'symbolRequired': false,
352
+ },
353
+ 'fetchOHLCV': {
354
+ 'limit': 10000,
355
+ },
356
+ },
357
+ 'spot': {
358
+ 'extends': 'default',
359
+ 'createOrder': {
360
+ 'triggerPriceType': {
361
+ 'index': false,
362
+ },
363
+ },
364
+ },
365
+ 'derivatives': {
366
+ 'extends': 'default',
367
+ 'createOrder': {
368
+ 'triggerPriceType': {
369
+ 'index': true,
370
+ },
371
+ },
372
+ },
373
+ 'swap': {
374
+ 'linear': {
375
+ 'extends': 'derivatives',
376
+ },
377
+ 'inverse': {
378
+ 'extends': 'derivatives',
379
+ },
380
+ },
381
+ 'future': {
382
+ 'linear': {
383
+ 'extends': 'derivatives',
384
+ },
385
+ 'inverse': {
386
+ 'extends': 'derivatives',
387
+ },
388
+ },
389
+ },
390
+ 'commonCurrencies': {
391
+ 'USDt': 'USDT',
392
+ 'XBt': 'BTC',
393
+ 'XBT': 'BTC',
394
+ 'Gwei': 'ETH',
395
+ 'GWEI': 'ETH',
396
+ 'LAMP': 'SOL',
397
+ 'LAMp': 'SOL',
398
+ },
399
+ });
400
+ }
401
+ /**
402
+ * @method
403
+ * @name bitmex#fetchCurrencies
404
+ * @description fetches all available currencies on an exchange
405
+ * @see https://www.bitmex.com/api/explorer/#!/Wallet/Wallet_getAssetsConfig
406
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
407
+ * @returns {object} an associative dictionary of currencies
408
+ */
409
+ async fetchCurrencies(params = {}) {
410
+ const response = await this.publicGetWalletAssets(params);
411
+ //
412
+ // {
413
+ // "XBt": {
414
+ // "asset": "XBT",
415
+ // "currency": "XBt",
416
+ // "majorCurrency": "XBT",
417
+ // "name": "Bitcoin",
418
+ // "currencyType": "Crypto",
419
+ // "scale": "8",
420
+ // // "mediumPrecision": "8",
421
+ // // "shorterPrecision": "4",
422
+ // // "symbol": "₿",
423
+ // // "tickLog": "0",
424
+ // // "weight": "1",
425
+ // "enabled": true,
426
+ // "isMarginCurrency": true,
427
+ // "minDepositAmount": "10000",
428
+ // "minWithdrawalAmount": "1000",
429
+ // "maxWithdrawalAmount": "100000000000000",
430
+ // "networks": [
431
+ // {
432
+ // "asset": "btc",
433
+ // "tokenAddress": "",
434
+ // "depositEnabled": true,
435
+ // "withdrawalEnabled": true,
436
+ // "withdrawalFee": "20000",
437
+ // "minFee": "20000",
438
+ // "maxFee": "10000000"
439
+ // }
440
+ // ]
441
+ // },
442
+ // }
443
+ //
444
+ const result = {};
445
+ for (let i = 0; i < response.length; i++) {
446
+ const currency = response[i];
447
+ const asset = this.safeString(currency, 'asset');
448
+ const code = this.safeCurrencyCode(asset);
449
+ const id = this.safeString(currency, 'currency');
450
+ const name = this.safeString(currency, 'name');
451
+ const chains = this.safeValue(currency, 'networks', []);
452
+ let depositEnabled = false;
453
+ let withdrawEnabled = false;
454
+ const networks = {};
455
+ const scale = this.safeString(currency, 'scale');
456
+ const precisionString = this.parsePrecision(scale);
457
+ const precision = this.parseNumber(precisionString);
458
+ for (let j = 0; j < chains.length; j++) {
459
+ const chain = chains[j];
460
+ const networkId = this.safeString(chain, 'asset');
461
+ const network = this.networkIdToCode(networkId);
462
+ const withdrawalFeeRaw = this.safeString(chain, 'withdrawalFee');
463
+ const withdrawalFee = this.parseNumber(Precise.stringMul(withdrawalFeeRaw, precisionString));
464
+ const isDepositEnabled = this.safeBool(chain, 'depositEnabled', false);
465
+ const isWithdrawEnabled = this.safeBool(chain, 'withdrawalEnabled', false);
466
+ const active = (isDepositEnabled && isWithdrawEnabled);
467
+ if (isDepositEnabled) {
468
+ depositEnabled = true;
469
+ }
470
+ if (isWithdrawEnabled) {
471
+ withdrawEnabled = true;
472
+ }
473
+ networks[network] = {
474
+ 'info': chain,
475
+ 'id': networkId,
476
+ 'network': network,
477
+ 'active': active,
478
+ 'deposit': isDepositEnabled,
479
+ 'withdraw': isWithdrawEnabled,
480
+ 'fee': withdrawalFee,
481
+ 'precision': undefined,
482
+ 'limits': {
483
+ 'withdraw': {
484
+ 'min': undefined,
485
+ 'max': undefined,
486
+ },
487
+ 'deposit': {
488
+ 'min': undefined,
489
+ 'max': undefined,
490
+ },
491
+ },
492
+ };
493
+ }
494
+ const currencyEnabled = this.safeValue(currency, 'enabled');
495
+ const currencyActive = currencyEnabled || (depositEnabled || withdrawEnabled);
496
+ const minWithdrawalString = this.safeString(currency, 'minWithdrawalAmount');
497
+ const minWithdrawal = this.parseNumber(Precise.stringMul(minWithdrawalString, precisionString));
498
+ const maxWithdrawalString = this.safeString(currency, 'maxWithdrawalAmount');
499
+ const maxWithdrawal = this.parseNumber(Precise.stringMul(maxWithdrawalString, precisionString));
500
+ const minDepositString = this.safeString(currency, 'minDepositAmount');
501
+ const minDeposit = this.parseNumber(Precise.stringMul(minDepositString, precisionString));
502
+ const isCrypto = this.safeString(currency, 'currencyType') === 'Crypto';
503
+ result[code] = {
504
+ 'id': id,
505
+ 'code': code,
506
+ 'info': currency,
507
+ 'name': name,
508
+ 'active': currencyActive,
509
+ 'deposit': depositEnabled,
510
+ 'withdraw': withdrawEnabled,
511
+ 'fee': undefined,
512
+ 'precision': precision,
513
+ 'limits': {
514
+ 'amount': {
515
+ 'min': undefined,
516
+ 'max': undefined,
517
+ },
518
+ 'withdraw': {
519
+ 'min': minWithdrawal,
520
+ 'max': maxWithdrawal,
521
+ },
522
+ 'deposit': {
523
+ 'min': minDeposit,
524
+ 'max': undefined,
525
+ },
526
+ },
527
+ 'networks': networks,
528
+ 'type': isCrypto ? 'crypto' : 'other',
529
+ };
530
+ }
531
+ return result;
532
+ }
533
+ convertFromRealAmount(code, amount) {
534
+ const currency = this.currency(code);
535
+ const precision = this.safeString(currency, 'precision');
536
+ const amountString = this.numberToString(amount);
537
+ const finalAmount = Precise.stringDiv(amountString, precision);
538
+ return this.parseNumber(finalAmount);
539
+ }
540
+ convertToRealAmount(code, amount) {
541
+ if (code === undefined) {
542
+ return amount;
543
+ }
544
+ else if (amount === undefined) {
545
+ return undefined;
546
+ }
547
+ const currency = this.currency(code);
548
+ const precision = this.safeString(currency, 'precision');
549
+ return Precise.stringMul(amount, precision);
550
+ }
551
+ amountToPrecision(symbol, amount) {
552
+ symbol = this.safeSymbol(symbol);
553
+ const market = this.market(symbol);
554
+ const oldPrecision = this.safeValue(this.options, 'oldPrecision');
555
+ if (market['spot'] && !oldPrecision) {
556
+ amount = this.convertFromRealAmount(market['base'], amount);
557
+ }
558
+ return super.amountToPrecision(symbol, amount);
559
+ }
560
+ convertFromRawQuantity(symbol, rawQuantity, currencySide = 'base') {
561
+ if (this.safeValue(this.options, 'oldPrecision')) {
562
+ return this.parseNumber(rawQuantity);
563
+ }
564
+ symbol = this.safeSymbol(symbol);
565
+ const marketExists = this.inArray(symbol, this.symbols);
566
+ if (!marketExists) {
567
+ return this.parseNumber(rawQuantity);
568
+ }
569
+ const market = this.market(symbol);
570
+ if (market['spot']) {
571
+ return this.parseNumber(this.convertToRealAmount(market[currencySide], rawQuantity));
572
+ }
573
+ return this.parseNumber(rawQuantity);
574
+ }
575
+ convertFromRawCost(symbol, rawQuantity) {
576
+ return this.convertFromRawQuantity(symbol, rawQuantity, 'quote');
577
+ }
578
+ /**
579
+ * @method
580
+ * @name bitmex#fetchMarkets
581
+ * @description retrieves data on all markets for bitmex
582
+ * @see https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_getActive
583
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
584
+ * @returns {object[]} an array of objects representing market data
585
+ */
586
+ async fetchMarkets(params = {}) {
587
+ const response = await this.publicGetInstrumentActive(params);
588
+ //
589
+ // [
590
+ // {
591
+ // "symbol": "LTCUSDT",
592
+ // "rootSymbol": "LTC",
593
+ // "state": "Open",
594
+ // "typ": "FFWCSX",
595
+ // "listing": "2021-11-10T04:00:00.000Z",
596
+ // "front": "2021-11-10T04:00:00.000Z",
597
+ // "expiry": null,
598
+ // "settle": null,
599
+ // "listedSettle": null,
600
+ // "relistInterval": null,
601
+ // "inverseLeg": "",
602
+ // "sellLeg": "",
603
+ // "buyLeg": "",
604
+ // "optionStrikePcnt": null,
605
+ // "optionStrikeRound": null,
606
+ // "optionStrikePrice": null,
607
+ // "optionMultiplier": null,
608
+ // "positionCurrency": "LTC", // can be empty for spot markets
609
+ // "underlying": "LTC",
610
+ // "quoteCurrency": "USDT",
611
+ // "underlyingSymbol": "LTCT=", // can be empty for spot markets
612
+ // "reference": "BMEX",
613
+ // "referenceSymbol": ".BLTCT", // can be empty for spot markets
614
+ // "calcInterval": null,
615
+ // "publishInterval": null,
616
+ // "publishTime": null,
617
+ // "maxOrderQty": 1000000000,
618
+ // "maxPrice": 1000000,
619
+ // "lotSize": 1000,
620
+ // "tickSize": 0.01,
621
+ // "multiplier": 100,
622
+ // "settlCurrency": "USDt", // can be empty for spot markets
623
+ // "underlyingToPositionMultiplier": 10000,
624
+ // "underlyingToSettleMultiplier": null,
625
+ // "quoteToSettleMultiplier": 1000000,
626
+ // "isQuanto": false,
627
+ // "isInverse": false,
628
+ // "initMargin": 0.03,
629
+ // "maintMargin": 0.015,
630
+ // "riskLimit": 1000000000000, // can be null for spot markets
631
+ // "riskStep": 1000000000000, // can be null for spot markets
632
+ // "limit": null,
633
+ // "capped": false,
634
+ // "taxed": true,
635
+ // "deleverage": true,
636
+ // "makerFee": -0.0001,
637
+ // "takerFee": 0.0005,
638
+ // "settlementFee": 0,
639
+ // "insuranceFee": 0,
640
+ // "fundingBaseSymbol": ".LTCBON8H", // can be empty for spot markets
641
+ // "fundingQuoteSymbol": ".USDTBON8H", // can be empty for spot markets
642
+ // "fundingPremiumSymbol": ".LTCUSDTPI8H", // can be empty for spot markets
643
+ // "fundingTimestamp": "2022-01-14T20:00:00.000Z",
644
+ // "fundingInterval": "2000-01-01T08:00:00.000Z",
645
+ // "fundingRate": 0.0001,
646
+ // "indicativeFundingRate": 0.0001,
647
+ // "rebalanceTimestamp": null,
648
+ // "rebalanceInterval": null,
649
+ // "openingTimestamp": "2022-01-14T17:00:00.000Z",
650
+ // "closingTimestamp": "2022-01-14T18:00:00.000Z",
651
+ // "sessionInterval": "2000-01-01T01:00:00.000Z",
652
+ // "prevClosePrice": 138.511,
653
+ // "limitDownPrice": null,
654
+ // "limitUpPrice": null,
655
+ // "bankruptLimitDownPrice": null,
656
+ // "bankruptLimitUpPrice": null,
657
+ // "prevTotalVolume": 12699024000,
658
+ // "totalVolume": 12702160000,
659
+ // "volume": 3136000,
660
+ // "volume24h": 114251000,
661
+ // "prevTotalTurnover": 232418052349000,
662
+ // "totalTurnover": 232463353260000,
663
+ // "turnover": 45300911000,
664
+ // "turnover24h": 1604331340000,
665
+ // "homeNotional24h": 11425.1,
666
+ // "foreignNotional24h": 1604331.3400000003,
667
+ // "prevPrice24h": 135.48,
668
+ // "vwap": 140.42165,
669
+ // "highPrice": 146.42,
670
+ // "lowPrice": 135.08,
671
+ // "lastPrice": 144.36,
672
+ // "lastPriceProtected": 144.36,
673
+ // "lastTickDirection": "MinusTick",
674
+ // "lastChangePcnt": 0.0655,
675
+ // "bidPrice": 143.75,
676
+ // "midPrice": 143.855,
677
+ // "askPrice": 143.96,
678
+ // "impactBidPrice": 143.75,
679
+ // "impactMidPrice": 143.855,
680
+ // "impactAskPrice": 143.96,
681
+ // "hasLiquidity": true,
682
+ // "openInterest": 38103000,
683
+ // "openValue": 547963053300,
684
+ // "fairMethod": "FundingRate",
685
+ // "fairBasisRate": 0.1095,
686
+ // "fairBasis": 0.004,
687
+ // "fairPrice": 143.811,
688
+ // "markMethod": "FairPrice",
689
+ // "markPrice": 143.811,
690
+ // "indicativeTaxRate": null,
691
+ // "indicativeSettlePrice": 143.807,
692
+ // "optionUnderlyingPrice": null,
693
+ // "settledPriceAdjustmentRate": null,
694
+ // "settledPrice": null,
695
+ // "timestamp": "2022-01-14T17:49:55.000Z"
696
+ // }
697
+ // ]
698
+ //
699
+ return this.parseMarkets(response);
700
+ }
701
+ parseMarket(market) {
702
+ const id = this.safeString(market, 'symbol');
703
+ let baseId = this.safeString(market, 'underlying');
704
+ let quoteId = this.safeString(market, 'quoteCurrency');
705
+ const settleId = this.safeString(market, 'settlCurrency');
706
+ const settle = this.safeCurrencyCode(settleId);
707
+ // 'positionCurrency' may be empty ("", as Bitmex currently returns for ETHUSD)
708
+ // so let's take the settlCurrency first and then adjust if needed
709
+ const typ = this.safeString(market, 'typ'); // type definitions at: https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_get
710
+ let type;
711
+ let swap = false;
712
+ let spot = false;
713
+ let future = false;
714
+ if (typ === 'FFWCSX') {
715
+ type = 'swap';
716
+ swap = true;
717
+ }
718
+ else if (typ === 'IFXXXP') {
719
+ type = 'spot';
720
+ spot = true;
721
+ }
722
+ else if (typ === 'FFCCSX') {
723
+ type = 'future';
724
+ future = true;
725
+ }
726
+ else if (typ === 'FFICSX') {
727
+ // prediction markets (without any volume)
728
+ quoteId = baseId;
729
+ baseId = this.safeString(market, 'rootSymbol');
730
+ type = 'future';
731
+ future = true;
732
+ }
733
+ const base = this.safeCurrencyCode(baseId);
734
+ const quote = this.safeCurrencyCode(quoteId);
735
+ const contract = swap || future;
736
+ let contractSize = undefined;
737
+ let isInverse = this.safeValue(market, 'isInverse'); // this is true when BASE and SETTLE are same, i.e. BTC/XXX:BTC
738
+ let isQuanto = this.safeValue(market, 'isQuanto'); // this is true when BASE and SETTLE are different, i.e. AXS/XXX:BTC
739
+ let linear = contract ? (!isInverse && !isQuanto) : undefined;
740
+ const status = this.safeString(market, 'state');
741
+ const active = status === 'Open'; // Open, Settled, Unlisted
742
+ let expiry = undefined;
743
+ let expiryDatetime = undefined;
744
+ let symbol = undefined;
745
+ if (spot) {
746
+ symbol = base + '/' + quote;
747
+ }
748
+ else if (contract) {
749
+ symbol = base + '/' + quote + ':' + settle;
750
+ if (linear) {
751
+ const multiplierString = this.safeString2(market, 'underlyingToPositionMultiplier', 'underlyingToSettleMultiplier');
752
+ contractSize = this.parseNumber(Precise.stringDiv('1', multiplierString));
753
+ }
754
+ else {
755
+ const multiplierString = Precise.stringAbs(this.safeString(market, 'multiplier'));
756
+ contractSize = this.parseNumber(multiplierString);
757
+ }
758
+ expiryDatetime = this.safeString(market, 'expiry');
759
+ expiry = this.parse8601(expiryDatetime);
760
+ if (expiry !== undefined) {
761
+ symbol = symbol + '-' + this.yymmdd(expiry);
762
+ }
763
+ }
764
+ else {
765
+ // for index/exotic markets, default to id
766
+ symbol = id;
767
+ }
768
+ const positionId = this.safeString2(market, 'positionCurrency', 'underlying');
769
+ const position = this.safeCurrencyCode(positionId);
770
+ const positionIsQuote = (position === quote);
771
+ const maxOrderQty = this.safeNumber(market, 'maxOrderQty');
772
+ const initMargin = this.safeString(market, 'initMargin', '1');
773
+ const maxLeverage = this.parseNumber(Precise.stringDiv('1', initMargin));
774
+ // subtype should be undefined for spot markets
775
+ if (spot) {
776
+ isInverse = undefined;
777
+ isQuanto = undefined;
778
+ linear = undefined;
779
+ }
780
+ return {
781
+ 'id': id,
782
+ 'symbol': symbol,
783
+ 'base': base,
784
+ 'quote': quote,
785
+ 'settle': settle,
786
+ 'baseId': baseId,
787
+ 'quoteId': quoteId,
788
+ 'settleId': settleId,
789
+ 'type': type,
790
+ 'spot': spot,
791
+ 'margin': false,
792
+ 'swap': swap,
793
+ 'future': future,
794
+ 'option': false,
795
+ 'active': active,
796
+ 'contract': contract,
797
+ 'linear': linear,
798
+ 'inverse': isInverse,
799
+ 'quanto': isQuanto,
800
+ 'taker': this.safeNumber(market, 'takerFee'),
801
+ 'maker': this.safeNumber(market, 'makerFee'),
802
+ 'contractSize': contractSize,
803
+ 'expiry': expiry,
804
+ 'expiryDatetime': expiryDatetime,
805
+ 'strike': this.safeNumber(market, 'optionStrikePrice'),
806
+ 'optionType': undefined,
807
+ 'precision': {
808
+ 'amount': this.safeNumber(market, 'lotSize'),
809
+ 'price': this.safeNumber(market, 'tickSize'),
810
+ },
811
+ 'limits': {
812
+ 'leverage': {
813
+ 'min': contract ? this.parseNumber('1') : undefined,
814
+ 'max': contract ? maxLeverage : undefined,
815
+ },
816
+ 'amount': {
817
+ 'min': undefined,
818
+ 'max': positionIsQuote ? undefined : maxOrderQty,
819
+ },
820
+ 'price': {
821
+ 'min': undefined,
822
+ 'max': this.safeNumber(market, 'maxPrice'),
823
+ },
824
+ 'cost': {
825
+ 'min': undefined,
826
+ 'max': positionIsQuote ? maxOrderQty : undefined,
827
+ },
828
+ },
829
+ 'created': undefined,
830
+ 'info': market,
831
+ };
832
+ }
833
+ parseBalance(response) {
834
+ //
835
+ // [
836
+ // {
837
+ // "account":1455728,
838
+ // "currency":"XBt",
839
+ // "riskLimit":1000000000000,
840
+ // "prevState":"",
841
+ // "state":"",
842
+ // "action":"",
843
+ // "amount":263542,
844
+ // "pendingCredit":0,
845
+ // "pendingDebit":0,
846
+ // "confirmedDebit":0,
847
+ // "prevRealisedPnl":0,
848
+ // "prevUnrealisedPnl":0,
849
+ // "grossComm":0,
850
+ // "grossOpenCost":0,
851
+ // "grossOpenPremium":0,
852
+ // "grossExecCost":0,
853
+ // "grossMarkValue":0,
854
+ // "riskValue":0,
855
+ // "taxableMargin":0,
856
+ // "initMargin":0,
857
+ // "maintMargin":0,
858
+ // "sessionMargin":0,
859
+ // "targetExcessMargin":0,
860
+ // "varMargin":0,
861
+ // "realisedPnl":0,
862
+ // "unrealisedPnl":0,
863
+ // "indicativeTax":0,
864
+ // "unrealisedProfit":0,
865
+ // "syntheticMargin":null,
866
+ // "walletBalance":263542,
867
+ // "marginBalance":263542,
868
+ // "marginBalancePcnt":1,
869
+ // "marginLeverage":0,
870
+ // "marginUsedPcnt":0,
871
+ // "excessMargin":263542,
872
+ // "excessMarginPcnt":1,
873
+ // "availableMargin":263542,
874
+ // "withdrawableMargin":263542,
875
+ // "timestamp":"2020-08-03T12:01:01.246Z",
876
+ // "grossLastValue":0,
877
+ // "commission":null
878
+ // }
879
+ // ]
880
+ //
881
+ const result = { 'info': response };
882
+ for (let i = 0; i < response.length; i++) {
883
+ const balance = response[i];
884
+ const currencyId = this.safeString(balance, 'currency');
885
+ const code = this.safeCurrencyCode(currencyId);
886
+ const account = this.account();
887
+ const free = this.safeString(balance, 'availableMargin');
888
+ const total = this.safeString(balance, 'marginBalance');
889
+ account['free'] = this.convertToRealAmount(code, free);
890
+ account['total'] = this.convertToRealAmount(code, total);
891
+ result[code] = account;
892
+ }
893
+ return this.safeBalance(result);
894
+ }
895
+ /**
896
+ * @method
897
+ * @name bitmex#fetchBalance
898
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
899
+ * @see https://www.bitmex.com/api/explorer/#!/User/User_getMargin
900
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
901
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
902
+ */
903
+ async fetchBalance(params = {}) {
904
+ await this.loadMarkets();
905
+ const request = {
906
+ 'currency': 'all',
907
+ };
908
+ const response = await this.privateGetUserMargin(this.extend(request, params));
909
+ //
910
+ // [
911
+ // {
912
+ // "account":1455728,
913
+ // "currency":"XBt",
914
+ // "riskLimit":1000000000000,
915
+ // "prevState":"",
916
+ // "state":"",
917
+ // "action":"",
918
+ // "amount":263542,
919
+ // "pendingCredit":0,
920
+ // "pendingDebit":0,
921
+ // "confirmedDebit":0,
922
+ // "prevRealisedPnl":0,
923
+ // "prevUnrealisedPnl":0,
924
+ // "grossComm":0,
925
+ // "grossOpenCost":0,
926
+ // "grossOpenPremium":0,
927
+ // "grossExecCost":0,
928
+ // "grossMarkValue":0,
929
+ // "riskValue":0,
930
+ // "taxableMargin":0,
931
+ // "initMargin":0,
932
+ // "maintMargin":0,
933
+ // "sessionMargin":0,
934
+ // "targetExcessMargin":0,
935
+ // "varMargin":0,
936
+ // "realisedPnl":0,
937
+ // "unrealisedPnl":0,
938
+ // "indicativeTax":0,
939
+ // "unrealisedProfit":0,
940
+ // "syntheticMargin":null,
941
+ // "walletBalance":263542,
942
+ // "marginBalance":263542,
943
+ // "marginBalancePcnt":1,
944
+ // "marginLeverage":0,
945
+ // "marginUsedPcnt":0,
946
+ // "excessMargin":263542,
947
+ // "excessMarginPcnt":1,
948
+ // "availableMargin":263542,
949
+ // "withdrawableMargin":263542,
950
+ // "timestamp":"2020-08-03T12:01:01.246Z",
951
+ // "grossLastValue":0,
952
+ // "commission":null
953
+ // }
954
+ // ]
955
+ //
956
+ return this.parseBalance(response);
957
+ }
958
+ /**
959
+ * @method
960
+ * @name bitmex#fetchOrderBook
961
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
962
+ * @see https://www.bitmex.com/api/explorer/#!/OrderBook/OrderBook_getL2
963
+ * @param {string} symbol unified symbol of the market to fetch the order book for
964
+ * @param {int} [limit] the maximum amount of order book entries to return
965
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
966
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
967
+ */
968
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
969
+ await this.loadMarkets();
970
+ const market = this.market(symbol);
971
+ const request = {
972
+ 'symbol': market['id'],
973
+ };
974
+ if (limit !== undefined) {
975
+ request['depth'] = limit;
976
+ }
977
+ const response = await this.publicGetOrderBookL2(this.extend(request, params));
978
+ const result = {
979
+ 'symbol': symbol,
980
+ 'bids': [],
981
+ 'asks': [],
982
+ 'timestamp': undefined,
983
+ 'datetime': undefined,
984
+ 'nonce': undefined,
985
+ };
986
+ for (let i = 0; i < response.length; i++) {
987
+ const order = response[i];
988
+ const side = (order['side'] === 'Sell') ? 'asks' : 'bids';
989
+ const amount = this.convertFromRawQuantity(symbol, this.safeString(order, 'size'));
990
+ const price = this.safeNumber(order, 'price');
991
+ // https://github.com/ccxt/ccxt/issues/4926
992
+ // https://github.com/ccxt/ccxt/issues/4927
993
+ // the exchange sometimes returns null price in the orderbook
994
+ if (price !== undefined) {
995
+ const resultSide = result[side];
996
+ resultSide.push([price, amount]);
997
+ }
998
+ }
999
+ result['bids'] = this.sortBy(result['bids'], 0, true);
1000
+ result['asks'] = this.sortBy(result['asks'], 0);
1001
+ return result;
1002
+ }
1003
+ /**
1004
+ * @method
1005
+ * @name bitmex#fetchOrder
1006
+ * @description fetches information on an order made by the user
1007
+ * @see https://www.bitmex.com/api/explorer/#!/Order/Order_getOrders
1008
+ * @param {string} id the order id
1009
+ * @param {string} symbol unified symbol of the market the order was made in
1010
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1011
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1012
+ */
1013
+ async fetchOrder(id, symbol = undefined, params = {}) {
1014
+ const filter = {
1015
+ 'filter': {
1016
+ 'orderID': id,
1017
+ },
1018
+ };
1019
+ const response = await this.fetchOrders(symbol, undefined, undefined, this.deepExtend(filter, params));
1020
+ const numResults = response.length;
1021
+ if (numResults === 1) {
1022
+ return response[0];
1023
+ }
1024
+ throw new OrderNotFound(this.id + ': The order ' + id + ' not found.');
1025
+ }
1026
+ /**
1027
+ * @method
1028
+ * @name bitmex#fetchOrders
1029
+ * @see https://www.bitmex.com/api/explorer/#!/Order/Order_getOrders
1030
+ * @description fetches information on multiple orders made by the user
1031
+ * @param {string} symbol unified market symbol of the market orders were made in
1032
+ * @param {int} [since] the earliest time in ms to fetch orders for
1033
+ * @param {int} [limit] the maximum number of order structures to retrieve
1034
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1035
+ * @param {int} [params.until] the earliest time in ms to fetch orders for
1036
+ * @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)
1037
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1038
+ */
1039
+ async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1040
+ await this.loadMarkets();
1041
+ let paginate = false;
1042
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
1043
+ if (paginate) {
1044
+ return await this.fetchPaginatedCallDynamic('fetchOrders', symbol, since, limit, params, 100);
1045
+ }
1046
+ let market = undefined;
1047
+ let request = {};
1048
+ if (symbol !== undefined) {
1049
+ market = this.market(symbol);
1050
+ request['symbol'] = market['id'];
1051
+ }
1052
+ if (since !== undefined) {
1053
+ request['startTime'] = this.iso8601(since);
1054
+ }
1055
+ if (limit !== undefined) {
1056
+ request['count'] = limit;
1057
+ }
1058
+ const until = this.safeInteger2(params, 'until', 'endTime');
1059
+ if (until !== undefined) {
1060
+ params = this.omit(params, ['until']);
1061
+ request['endTime'] = this.iso8601(until);
1062
+ }
1063
+ request = this.deepExtend(request, params);
1064
+ // why the hassle? urlencode in python is kinda broken for nested dicts.
1065
+ // E.g. self.urlencode({"filter": {"open": True}}) will return "filter={'open':+True}"
1066
+ // Bitmex doesn't like that. Hence resorting to this hack.
1067
+ if ('filter' in request) {
1068
+ request['filter'] = this.json(request['filter']);
1069
+ }
1070
+ const response = await this.privateGetOrder(request);
1071
+ return this.parseOrders(response, market, since, limit);
1072
+ }
1073
+ /**
1074
+ * @method
1075
+ * @name bitmex#fetchOpenOrders
1076
+ * @description fetch all unfilled currently open orders
1077
+ * @see https://www.bitmex.com/api/explorer/#!/Order/Order_getOrders
1078
+ * @param {string} symbol unified market symbol
1079
+ * @param {int} [since] the earliest time in ms to fetch open orders for
1080
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
1081
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1082
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1083
+ */
1084
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1085
+ const request = {
1086
+ 'filter': {
1087
+ 'open': true,
1088
+ },
1089
+ };
1090
+ return await this.fetchOrders(symbol, since, limit, this.deepExtend(request, params));
1091
+ }
1092
+ /**
1093
+ * @method
1094
+ * @name bitmex#fetchClosedOrders
1095
+ * @description fetches information on multiple closed orders made by the user
1096
+ * @see https://www.bitmex.com/api/explorer/#!/Order/Order_getOrders
1097
+ * @param {string} symbol unified market symbol of the market orders were made in
1098
+ * @param {int} [since] the earliest time in ms to fetch orders for
1099
+ * @param {int} [limit] the maximum number of order structures to retrieve
1100
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1101
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1102
+ */
1103
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1104
+ // Bitmex barfs if you set 'open': false in the filter...
1105
+ const orders = await this.fetchOrders(symbol, since, limit, params);
1106
+ return this.filterByArray(orders, 'status', ['closed', 'canceled'], false);
1107
+ }
1108
+ /**
1109
+ * @method
1110
+ * @name bitmex#fetchMyTrades
1111
+ * @description fetch all trades made by the user
1112
+ * @see https://www.bitmex.com/api/explorer/#!/Execution/Execution_getTradeHistory
1113
+ * @param {string} symbol unified market symbol
1114
+ * @param {int} [since] the earliest time in ms to fetch trades for
1115
+ * @param {int} [limit] the maximum number of trades structures to retrieve
1116
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1117
+ * @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)
1118
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1119
+ */
1120
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1121
+ await this.loadMarkets();
1122
+ let paginate = false;
1123
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
1124
+ if (paginate) {
1125
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params, 100);
1126
+ }
1127
+ let market = undefined;
1128
+ let request = {};
1129
+ if (symbol !== undefined) {
1130
+ market = this.market(symbol);
1131
+ request['symbol'] = market['id'];
1132
+ }
1133
+ if (since !== undefined) {
1134
+ request['startTime'] = this.iso8601(since);
1135
+ }
1136
+ if (limit !== undefined) {
1137
+ request['count'] = Math.min(500, limit);
1138
+ }
1139
+ const until = this.safeInteger2(params, 'until', 'endTime');
1140
+ if (until !== undefined) {
1141
+ params = this.omit(params, ['until']);
1142
+ request['endTime'] = this.iso8601(until);
1143
+ }
1144
+ request = this.deepExtend(request, params);
1145
+ // why the hassle? urlencode in python is kinda broken for nested dicts.
1146
+ // E.g. self.urlencode({"filter": {"open": True}}) will return "filter={'open':+True}"
1147
+ // Bitmex doesn't like that. Hence resorting to this hack.
1148
+ if ('filter' in request) {
1149
+ request['filter'] = this.json(request['filter']);
1150
+ }
1151
+ const response = await this.privateGetExecutionTradeHistory(request);
1152
+ //
1153
+ // [
1154
+ // {
1155
+ // "execID": "string",
1156
+ // "orderID": "string",
1157
+ // "clOrdID": "string",
1158
+ // "clOrdLinkID": "string",
1159
+ // "account": 0,
1160
+ // "symbol": "string",
1161
+ // "side": "string",
1162
+ // "lastQty": 0,
1163
+ // "lastPx": 0,
1164
+ // "underlyingLastPx": 0,
1165
+ // "lastMkt": "string",
1166
+ // "lastLiquidityInd": "string",
1167
+ // "simpleOrderQty": 0,
1168
+ // "orderQty": 0,
1169
+ // "price": 0,
1170
+ // "displayQty": 0,
1171
+ // "stopPx": 0,
1172
+ // "pegOffsetValue": 0,
1173
+ // "pegPriceType": "string",
1174
+ // "currency": "string",
1175
+ // "settlCurrency": "string",
1176
+ // "execType": "string",
1177
+ // "ordType": "string",
1178
+ // "timeInForce": "string",
1179
+ // "execInst": "string",
1180
+ // "contingencyType": "string",
1181
+ // "exDestination": "string",
1182
+ // "ordStatus": "string",
1183
+ // "triggered": "string",
1184
+ // "workingIndicator": true,
1185
+ // "ordRejReason": "string",
1186
+ // "simpleLeavesQty": 0,
1187
+ // "leavesQty": 0,
1188
+ // "simpleCumQty": 0,
1189
+ // "cumQty": 0,
1190
+ // "avgPx": 0,
1191
+ // "commission": 0,
1192
+ // "tradePublishIndicator": "string",
1193
+ // "multiLegReportingType": "string",
1194
+ // "text": "string",
1195
+ // "trdMatchID": "string",
1196
+ // "execCost": 0,
1197
+ // "execComm": 0,
1198
+ // "homeNotional": 0,
1199
+ // "foreignNotional": 0,
1200
+ // "transactTime": "2019-03-05T12:47:02.762Z",
1201
+ // "timestamp": "2019-03-05T12:47:02.762Z"
1202
+ // }
1203
+ // ]
1204
+ //
1205
+ return this.parseTrades(response, market, since, limit);
1206
+ }
1207
+ parseLedgerEntryType(type) {
1208
+ const types = {
1209
+ 'Withdrawal': 'transaction',
1210
+ 'RealisedPNL': 'margin',
1211
+ 'UnrealisedPNL': 'margin',
1212
+ 'Deposit': 'transaction',
1213
+ 'Transfer': 'transfer',
1214
+ 'AffiliatePayout': 'referral',
1215
+ 'SpotTrade': 'trade',
1216
+ };
1217
+ return this.safeString(types, type, type);
1218
+ }
1219
+ parseLedgerEntry(item, currency = undefined) {
1220
+ //
1221
+ // {
1222
+ // "transactID": "69573da3-7744-5467-3207-89fd6efe7a47",
1223
+ // "account": 24321,
1224
+ // "currency": "XBt",
1225
+ // "transactType": "Withdrawal", // "AffiliatePayout", "Transfer", "Deposit", "RealisedPNL", ...
1226
+ // "amount": -1000000,
1227
+ // "fee": 300000,
1228
+ // "transactStatus": "Completed", // "Canceled", ...
1229
+ // "address": "1Ex4fkF4NhQaQdRWNoYpqiPbDBbq18Kdd9",
1230
+ // "tx": "3BMEX91ZhhKoWtsH9QRb5dNXnmnGpiEetA",
1231
+ // "text": "",
1232
+ // "transactTime": "2017-03-21T20:05:14.388Z",
1233
+ // "walletBalance": 0, // balance after
1234
+ // "marginBalance": null,
1235
+ // "timestamp": "2017-03-22T13:09:23.514Z"
1236
+ // }
1237
+ //
1238
+ // ButMEX returns the unrealized pnl from the wallet history endpoint.
1239
+ // The unrealized pnl transaction has an empty timestamp.
1240
+ // It is not related to historical pnl it has status set to "Pending".
1241
+ // Therefore it's not a part of the history at all.
1242
+ // https://github.com/ccxt/ccxt/issues/6047
1243
+ //
1244
+ // {
1245
+ // "transactID":"00000000-0000-0000-0000-000000000000",
1246
+ // "account":121210,
1247
+ // "currency":"XBt",
1248
+ // "transactType":"UnrealisedPNL",
1249
+ // "amount":-5508,
1250
+ // "fee":0,
1251
+ // "transactStatus":"Pending",
1252
+ // "address":"XBTUSD",
1253
+ // "tx":"",
1254
+ // "text":"",
1255
+ // "transactTime":null, # ←---------------------------- null
1256
+ // "walletBalance":139198767,
1257
+ // "marginBalance":139193259,
1258
+ // "timestamp":null # ←---------------------------- null
1259
+ // }
1260
+ //
1261
+ const id = this.safeString(item, 'transactID');
1262
+ const account = this.safeString(item, 'account');
1263
+ const referenceId = this.safeString(item, 'tx');
1264
+ const referenceAccount = undefined;
1265
+ const type = this.parseLedgerEntryType(this.safeString(item, 'transactType'));
1266
+ const currencyId = this.safeString(item, 'currency');
1267
+ const code = this.safeCurrencyCode(currencyId, currency);
1268
+ currency = this.safeCurrency(currencyId, currency);
1269
+ const amountString = this.safeString(item, 'amount');
1270
+ let amount = this.convertToRealAmount(code, amountString);
1271
+ let timestamp = this.parse8601(this.safeString(item, 'transactTime'));
1272
+ if (timestamp === undefined) {
1273
+ // https://github.com/ccxt/ccxt/issues/6047
1274
+ // set the timestamp to zero, 1970 Jan 1 00:00:00
1275
+ // for unrealized pnl and other transactions without a timestamp
1276
+ timestamp = 0; // see comments above
1277
+ }
1278
+ let fee = undefined;
1279
+ let feeCost = this.safeString(item, 'fee');
1280
+ if (feeCost !== undefined) {
1281
+ feeCost = this.convertToRealAmount(code, feeCost);
1282
+ fee = {
1283
+ 'cost': this.parseNumber(feeCost),
1284
+ 'currency': code,
1285
+ };
1286
+ }
1287
+ let after = this.safeString(item, 'walletBalance');
1288
+ if (after !== undefined) {
1289
+ after = this.convertToRealAmount(code, after);
1290
+ }
1291
+ const before = this.parseNumber(Precise.stringSub(this.numberToString(after), this.numberToString(amount)));
1292
+ let direction = undefined;
1293
+ if (Precise.stringLt(amountString, '0')) {
1294
+ direction = 'out';
1295
+ amount = this.convertToRealAmount(code, Precise.stringAbs(amountString));
1296
+ }
1297
+ else {
1298
+ direction = 'in';
1299
+ }
1300
+ const status = this.parseTransactionStatus(this.safeString(item, 'transactStatus'));
1301
+ return this.safeLedgerEntry({
1302
+ 'info': item,
1303
+ 'id': id,
1304
+ 'timestamp': timestamp,
1305
+ 'datetime': this.iso8601(timestamp),
1306
+ 'direction': direction,
1307
+ 'account': account,
1308
+ 'referenceId': referenceId,
1309
+ 'referenceAccount': referenceAccount,
1310
+ 'type': type,
1311
+ 'currency': code,
1312
+ 'amount': this.parseNumber(amount),
1313
+ 'before': before,
1314
+ 'after': this.parseNumber(after),
1315
+ 'status': status,
1316
+ 'fee': fee,
1317
+ }, currency);
1318
+ }
1319
+ /**
1320
+ * @method
1321
+ * @name bitmex#fetchLedger
1322
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
1323
+ * @see https://www.bitmex.com/api/explorer/#!/User/User_getWalletHistory
1324
+ * @param {string} [code] unified currency code, default is undefined
1325
+ * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1326
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
1327
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1328
+ * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger}
1329
+ */
1330
+ async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1331
+ await this.loadMarkets();
1332
+ const request = {
1333
+ // 'start': 123,
1334
+ };
1335
+ //
1336
+ // if (since !== undefined) {
1337
+ // // date-based pagination not supported
1338
+ // }
1339
+ //
1340
+ if (limit !== undefined) {
1341
+ request['count'] = limit;
1342
+ }
1343
+ let currency = undefined;
1344
+ if (code !== undefined) {
1345
+ currency = this.currency(code);
1346
+ request['currency'] = currency['id'];
1347
+ }
1348
+ const response = await this.privateGetUserWalletHistory(this.extend(request, params));
1349
+ //
1350
+ // [
1351
+ // {
1352
+ // "transactID": "69573da3-7744-5467-3207-89fd6efe7a47",
1353
+ // "account": 24321,
1354
+ // "currency": "XBt",
1355
+ // "transactType": "Withdrawal", // "AffiliatePayout", "Transfer", "Deposit", "RealisedPNL", ...
1356
+ // "amount": -1000000,
1357
+ // "fee": 300000,
1358
+ // "transactStatus": "Completed", // "Canceled", ...
1359
+ // "address": "1Ex4fkF4NhQaQdRWNoYpqiPbDBbq18Kdd9",
1360
+ // "tx": "3BMEX91ZhhKoWtsH9QRb5dNXnmnGpiEetA",
1361
+ // "text": "",
1362
+ // "transactTime": "2017-03-21T20:05:14.388Z",
1363
+ // "walletBalance": 0, // balance after
1364
+ // "marginBalance": null,
1365
+ // "timestamp": "2017-03-22T13:09:23.514Z"
1366
+ // }
1367
+ // ]
1368
+ //
1369
+ return this.parseLedger(response, currency, since, limit);
1370
+ }
1371
+ /**
1372
+ * @method
1373
+ * @name bitmex#fetchDepositsWithdrawals
1374
+ * @description fetch history of deposits and withdrawals
1375
+ * @see https://www.bitmex.com/api/explorer/#!/User/User_getWalletHistory
1376
+ * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
1377
+ * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
1378
+ * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
1379
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1380
+ * @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1381
+ */
1382
+ async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1383
+ await this.loadMarkets();
1384
+ const request = {
1385
+ 'currency': 'all',
1386
+ // 'start': 123,
1387
+ };
1388
+ //
1389
+ // if (since !== undefined) {
1390
+ // // date-based pagination not supported
1391
+ // }
1392
+ //
1393
+ let currency = undefined;
1394
+ if (code !== undefined) {
1395
+ currency = this.currency(code);
1396
+ request['currency'] = currency['id'];
1397
+ }
1398
+ if (limit !== undefined) {
1399
+ request['count'] = limit;
1400
+ }
1401
+ const response = await this.privateGetUserWalletHistory(this.extend(request, params));
1402
+ const transactions = this.filterByArray(response, 'transactType', ['Withdrawal', 'Deposit'], false);
1403
+ return this.parseTransactions(transactions, currency, since, limit);
1404
+ }
1405
+ parseTransactionStatus(status) {
1406
+ const statuses = {
1407
+ 'Confirmed': 'pending',
1408
+ 'Canceled': 'canceled',
1409
+ 'Completed': 'ok',
1410
+ 'Pending': 'pending',
1411
+ };
1412
+ return this.safeString(statuses, status, status);
1413
+ }
1414
+ parseTransaction(transaction, currency = undefined) {
1415
+ //
1416
+ // {
1417
+ // "transactID": "ffe699c2-95ee-4c13-91f9-0faf41daec25",
1418
+ // "account": 123456,
1419
+ // "currency": "XBt",
1420
+ // "network":'', // "tron" for USDt, etc...
1421
+ // "transactType": "Withdrawal",
1422
+ // "amount": -100100000,
1423
+ // "fee": 100000,
1424
+ // "transactStatus": "Completed",
1425
+ // "address": "385cR5DM96n1HvBDMzLHPYcw89fZAXULJP",
1426
+ // "tx": "3BMEXabcdefghijklmnopqrstuvwxyz123",
1427
+ // "text": '',
1428
+ // "transactTime": "2019-01-02T01:00:00.000Z",
1429
+ // "walletBalance": 99900000, // this field might be inexistent
1430
+ // "marginBalance": None, // this field might be inexistent
1431
+ // "timestamp": "2019-01-02T13:00:00.000Z"
1432
+ // }
1433
+ //
1434
+ const currencyId = this.safeString(transaction, 'currency');
1435
+ currency = this.safeCurrency(currencyId, currency);
1436
+ // For deposits, transactTime == timestamp
1437
+ // For withdrawals, transactTime is submission, timestamp is processed
1438
+ const transactTime = this.parse8601(this.safeString(transaction, 'transactTime'));
1439
+ const timestamp = this.parse8601(this.safeString(transaction, 'timestamp'));
1440
+ const type = this.safeStringLower(transaction, 'transactType');
1441
+ // Deposits have no from address or to address, withdrawals have both
1442
+ let address = undefined;
1443
+ let addressFrom = undefined;
1444
+ let addressTo = undefined;
1445
+ if (type === 'withdrawal') {
1446
+ address = this.safeString(transaction, 'address');
1447
+ addressFrom = this.safeString(transaction, 'tx');
1448
+ addressTo = address;
1449
+ }
1450
+ else if (type === 'deposit') {
1451
+ addressTo = this.safeString(transaction, 'address');
1452
+ addressFrom = this.safeString(transaction, 'tx');
1453
+ }
1454
+ const amountString = this.safeString(transaction, 'amount');
1455
+ const amountStringAbs = Precise.stringAbs(amountString);
1456
+ const amount = this.convertToRealAmount(currency['code'], amountStringAbs);
1457
+ const feeCostString = this.safeString(transaction, 'fee');
1458
+ const feeCost = this.convertToRealAmount(currency['code'], feeCostString);
1459
+ let status = this.safeString(transaction, 'transactStatus');
1460
+ if (status !== undefined) {
1461
+ status = this.parseTransactionStatus(status);
1462
+ }
1463
+ return {
1464
+ 'info': transaction,
1465
+ 'id': this.safeString(transaction, 'transactID'),
1466
+ 'txid': this.safeString(transaction, 'tx'),
1467
+ 'type': type,
1468
+ 'currency': currency['code'],
1469
+ 'network': this.networkIdToCode(this.safeString(transaction, 'network'), currency['code']),
1470
+ 'amount': this.parseNumber(amount),
1471
+ 'status': status,
1472
+ 'timestamp': transactTime,
1473
+ 'datetime': this.iso8601(transactTime),
1474
+ 'address': address,
1475
+ 'addressFrom': addressFrom,
1476
+ 'addressTo': addressTo,
1477
+ 'tag': undefined,
1478
+ 'tagFrom': undefined,
1479
+ 'tagTo': undefined,
1480
+ 'updated': timestamp,
1481
+ 'internal': undefined,
1482
+ 'comment': undefined,
1483
+ 'fee': {
1484
+ 'currency': currency['code'],
1485
+ 'cost': this.parseNumber(feeCost),
1486
+ 'rate': undefined,
1487
+ },
1488
+ };
1489
+ }
1490
+ /**
1491
+ * @method
1492
+ * @name bitmex#fetchTicker
1493
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1494
+ * @see https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_get
1495
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
1496
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1497
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1498
+ */
1499
+ async fetchTicker(symbol, params = {}) {
1500
+ await this.loadMarkets();
1501
+ const market = this.market(symbol);
1502
+ const request = {
1503
+ 'symbol': market['id'],
1504
+ };
1505
+ const response = await this.publicGetInstrument(this.extend(request, params));
1506
+ const ticker = this.safeValue(response, 0);
1507
+ if (ticker === undefined) {
1508
+ throw new BadSymbol(this.id + ' fetchTicker() symbol ' + symbol + ' not found');
1509
+ }
1510
+ return this.parseTicker(ticker, market);
1511
+ }
1512
+ /**
1513
+ * @method
1514
+ * @name bitmex#fetchTickers
1515
+ * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1516
+ * @see https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_getActiveAndIndices
1517
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1518
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1519
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1520
+ */
1521
+ async fetchTickers(symbols = undefined, params = {}) {
1522
+ await this.loadMarkets();
1523
+ symbols = this.marketSymbols(symbols);
1524
+ const response = await this.publicGetInstrumentActiveAndIndices(params);
1525
+ // same response as under "fetchMarkets"
1526
+ const result = {};
1527
+ for (let i = 0; i < response.length; i++) {
1528
+ const ticker = this.parseTicker(response[i]);
1529
+ const symbol = this.safeString(ticker, 'symbol');
1530
+ if (symbol !== undefined) {
1531
+ result[symbol] = ticker;
1532
+ }
1533
+ }
1534
+ return this.filterByArrayTickers(result, 'symbol', symbols);
1535
+ }
1536
+ parseTicker(ticker, market = undefined) {
1537
+ // see response sample under "fetchMarkets" because same endpoint is being used here
1538
+ const marketId = this.safeString(ticker, 'symbol');
1539
+ const symbol = this.safeSymbol(marketId, market);
1540
+ const timestamp = this.parse8601(this.safeString(ticker, 'timestamp'));
1541
+ const open = this.safeString(ticker, 'prevPrice24h');
1542
+ const last = this.safeString(ticker, 'lastPrice');
1543
+ return this.safeTicker({
1544
+ 'symbol': symbol,
1545
+ 'timestamp': timestamp,
1546
+ 'datetime': this.iso8601(timestamp),
1547
+ 'high': this.safeString(ticker, 'highPrice'),
1548
+ 'low': this.safeString(ticker, 'lowPrice'),
1549
+ 'bid': this.safeString(ticker, 'bidPrice'),
1550
+ 'bidVolume': undefined,
1551
+ 'ask': this.safeString(ticker, 'askPrice'),
1552
+ 'askVolume': undefined,
1553
+ 'vwap': this.safeString(ticker, 'vwap'),
1554
+ 'open': open,
1555
+ 'close': last,
1556
+ 'last': last,
1557
+ 'previousClose': undefined,
1558
+ 'change': undefined,
1559
+ 'percentage': undefined,
1560
+ 'average': undefined,
1561
+ 'baseVolume': this.safeString(ticker, 'homeNotional24h'),
1562
+ 'quoteVolume': this.safeString(ticker, 'foreignNotional24h'),
1563
+ 'markPrice': this.safeString(ticker, 'markPrice'),
1564
+ 'info': ticker,
1565
+ }, market);
1566
+ }
1567
+ parseOHLCV(ohlcv, market = undefined) {
1568
+ //
1569
+ // {
1570
+ // "timestamp":"2015-09-25T13:38:00.000Z",
1571
+ // "symbol":"XBTUSD",
1572
+ // "open":237.45,
1573
+ // "high":237.45,
1574
+ // "low":237.45,
1575
+ // "close":237.45,
1576
+ // "trades":0,
1577
+ // "volume":0,
1578
+ // "vwap":null,
1579
+ // "lastSize":null,
1580
+ // "turnover":0,
1581
+ // "homeNotional":0,
1582
+ // "foreignNotional":0
1583
+ // }
1584
+ //
1585
+ const marketId = this.safeString(ohlcv, 'symbol');
1586
+ market = this.safeMarket(marketId, market);
1587
+ const volume = this.convertFromRawQuantity(market['symbol'], this.safeString(ohlcv, 'volume'));
1588
+ return [
1589
+ this.parse8601(this.safeString(ohlcv, 'timestamp')),
1590
+ this.safeNumber(ohlcv, 'open'),
1591
+ this.safeNumber(ohlcv, 'high'),
1592
+ this.safeNumber(ohlcv, 'low'),
1593
+ this.safeNumber(ohlcv, 'close'),
1594
+ volume,
1595
+ ];
1596
+ }
1597
+ /**
1598
+ * @method
1599
+ * @name bitmex#fetchOHLCV
1600
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1601
+ * @see https://www.bitmex.com/api/explorer/#!/Trade/Trade_getBucketed
1602
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1603
+ * @param {string} timeframe the length of time each candle represents
1604
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
1605
+ * @param {int} [limit] the maximum amount of candles to fetch
1606
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1607
+ * @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)
1608
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1609
+ */
1610
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1611
+ await this.loadMarkets();
1612
+ let paginate = false;
1613
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
1614
+ if (paginate) {
1615
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params);
1616
+ }
1617
+ // send JSON key/value pairs, such as {"key": "value"}
1618
+ // filter by individual fields and do advanced queries on timestamps
1619
+ // let filter: Dict = { 'key': 'value' };
1620
+ // send a bare series (e.g. XBU) to nearest expiring contract in that series
1621
+ // you can also send a timeframe, e.g. XBU:monthly
1622
+ // timeframes: daily, weekly, monthly, quarterly, and biquarterly
1623
+ const market = this.market(symbol);
1624
+ const request = {
1625
+ 'symbol': market['id'],
1626
+ 'binSize': this.safeString(this.timeframes, timeframe, timeframe),
1627
+ 'partial': true, // true == include yet-incomplete current bins
1628
+ // 'filter': filter, // filter by individual fields and do advanced queries
1629
+ // 'columns': [], // will return all columns if omitted
1630
+ // 'start': 0, // starting point for results (wtf?)
1631
+ // 'reverse': false, // true == newest first
1632
+ // 'endTime': '', // ending date filter for results
1633
+ };
1634
+ if (limit !== undefined) {
1635
+ request['count'] = limit; // default 100, max 500
1636
+ }
1637
+ const until = this.safeInteger(params, 'until');
1638
+ if (until !== undefined) {
1639
+ params = this.omit(params, ['until']);
1640
+ request['endTime'] = this.iso8601(until);
1641
+ }
1642
+ const duration = this.parseTimeframe(timeframe) * 1000;
1643
+ const fetchOHLCVOpenTimestamp = this.safeBool(this.options, 'fetchOHLCVOpenTimestamp', true);
1644
+ // if since is not set, they will return candles starting from 2017-01-01
1645
+ if (since !== undefined) {
1646
+ let timestamp = since;
1647
+ if (fetchOHLCVOpenTimestamp) {
1648
+ timestamp = this.sum(timestamp, duration);
1649
+ }
1650
+ const startTime = this.iso8601(timestamp);
1651
+ request['startTime'] = startTime; // starting date filter for results
1652
+ }
1653
+ else {
1654
+ request['reverse'] = true;
1655
+ }
1656
+ const response = await this.publicGetTradeBucketed(this.extend(request, params));
1657
+ //
1658
+ // [
1659
+ // {"timestamp":"2015-09-25T13:38:00.000Z","symbol":"XBTUSD","open":237.45,"high":237.45,"low":237.45,"close":237.45,"trades":0,"volume":0,"vwap":null,"lastSize":null,"turnover":0,"homeNotional":0,"foreignNotional":0},
1660
+ // {"timestamp":"2015-09-25T13:39:00.000Z","symbol":"XBTUSD","open":237.45,"high":237.45,"low":237.45,"close":237.45,"trades":0,"volume":0,"vwap":null,"lastSize":null,"turnover":0,"homeNotional":0,"foreignNotional":0},
1661
+ // {"timestamp":"2015-09-25T13:40:00.000Z","symbol":"XBTUSD","open":237.45,"high":237.45,"low":237.45,"close":237.45,"trades":0,"volume":0,"vwap":null,"lastSize":null,"turnover":0,"homeNotional":0,"foreignNotional":0}
1662
+ // ]
1663
+ //
1664
+ const result = this.parseOHLCVs(response, market, timeframe, since, limit);
1665
+ if (fetchOHLCVOpenTimestamp) {
1666
+ // bitmex returns the candle's close timestamp - https://github.com/ccxt/ccxt/issues/4446
1667
+ // we can emulate the open timestamp by shifting all the timestamps one place
1668
+ // so the previous close becomes the current open, and we drop the first candle
1669
+ for (let i = 0; i < result.length; i++) {
1670
+ result[i][0] = result[i][0] - duration;
1671
+ }
1672
+ }
1673
+ return result;
1674
+ }
1675
+ parseTrade(trade, market = undefined) {
1676
+ //
1677
+ // fetchTrades (public)
1678
+ //
1679
+ // {
1680
+ // "timestamp": "2018-08-28T00:00:02.735Z",
1681
+ // "symbol": "XBTUSD",
1682
+ // "side": "Buy",
1683
+ // "size": 2000,
1684
+ // "price": 6906.5,
1685
+ // "tickDirection": "PlusTick",
1686
+ // "trdMatchID": "b9a42432-0a46-6a2f-5ecc-c32e9ca4baf8",
1687
+ // "grossValue": 28958000,
1688
+ // "homeNotional": 0.28958,
1689
+ // "foreignNotional": 2000
1690
+ // }
1691
+ //
1692
+ // fetchMyTrades (private)
1693
+ //
1694
+ // {
1695
+ // "execID": "string",
1696
+ // "orderID": "string",
1697
+ // "clOrdID": "string",
1698
+ // "clOrdLinkID": "string",
1699
+ // "account": 0,
1700
+ // "symbol": "string",
1701
+ // "side": "string",
1702
+ // "lastQty": 0,
1703
+ // "lastPx": 0,
1704
+ // "underlyingLastPx": 0,
1705
+ // "lastMkt": "string",
1706
+ // "lastLiquidityInd": "string",
1707
+ // "simpleOrderQty": 0,
1708
+ // "orderQty": 0,
1709
+ // "price": 0,
1710
+ // "displayQty": 0,
1711
+ // "stopPx": 0,
1712
+ // "pegOffsetValue": 0,
1713
+ // "pegPriceType": "string",
1714
+ // "currency": "string",
1715
+ // "settlCurrency": "string",
1716
+ // "execType": "string",
1717
+ // "ordType": "string",
1718
+ // "timeInForce": "string",
1719
+ // "execInst": "string",
1720
+ // "contingencyType": "string",
1721
+ // "exDestination": "string",
1722
+ // "ordStatus": "string",
1723
+ // "triggered": "string",
1724
+ // "workingIndicator": true,
1725
+ // "ordRejReason": "string",
1726
+ // "simpleLeavesQty": 0,
1727
+ // "leavesQty": 0,
1728
+ // "simpleCumQty": 0,
1729
+ // "cumQty": 0,
1730
+ // "avgPx": 0,
1731
+ // "commission": 0,
1732
+ // "tradePublishIndicator": "string",
1733
+ // "multiLegReportingType": "string",
1734
+ // "text": "string",
1735
+ // "trdMatchID": "string",
1736
+ // "execCost": 0,
1737
+ // "execComm": 0,
1738
+ // "homeNotional": 0,
1739
+ // "foreignNotional": 0,
1740
+ // "transactTime": "2019-03-05T12:47:02.762Z",
1741
+ // "timestamp": "2019-03-05T12:47:02.762Z"
1742
+ // }
1743
+ //
1744
+ const marketId = this.safeString(trade, 'symbol');
1745
+ const symbol = this.safeSymbol(marketId, market);
1746
+ const timestamp = this.parse8601(this.safeString(trade, 'timestamp'));
1747
+ const priceString = this.safeString2(trade, 'avgPx', 'price');
1748
+ const amountString = this.convertFromRawQuantity(symbol, this.safeString2(trade, 'size', 'lastQty'));
1749
+ const execCost = this.numberToString(this.convertFromRawCost(symbol, this.safeString(trade, 'execCost')));
1750
+ const id = this.safeString(trade, 'trdMatchID');
1751
+ const order = this.safeString(trade, 'orderID');
1752
+ const side = this.safeStringLower(trade, 'side');
1753
+ // price * amount doesn't work for all symbols (e.g. XBT, ETH)
1754
+ let fee = undefined;
1755
+ const feeCostString = this.numberToString(this.convertFromRawCost(symbol, this.safeString(trade, 'execComm')));
1756
+ if (feeCostString !== undefined) {
1757
+ const currencyId = this.safeString2(trade, 'settlCurrency', 'currency');
1758
+ fee = {
1759
+ 'cost': feeCostString,
1760
+ 'currency': this.safeCurrencyCode(currencyId),
1761
+ 'rate': this.safeString(trade, 'commission'),
1762
+ };
1763
+ }
1764
+ // Trade or Funding
1765
+ const execType = this.safeString(trade, 'execType');
1766
+ let takerOrMaker = undefined;
1767
+ if (feeCostString !== undefined && execType === 'Trade') {
1768
+ takerOrMaker = Precise.stringLt(feeCostString, '0') ? 'maker' : 'taker';
1769
+ }
1770
+ const type = this.safeStringLower(trade, 'ordType');
1771
+ return this.safeTrade({
1772
+ 'info': trade,
1773
+ 'timestamp': timestamp,
1774
+ 'datetime': this.iso8601(timestamp),
1775
+ 'symbol': symbol,
1776
+ 'id': id,
1777
+ 'order': order,
1778
+ 'type': type,
1779
+ 'takerOrMaker': takerOrMaker,
1780
+ 'side': side,
1781
+ 'price': priceString,
1782
+ 'cost': Precise.stringAbs(execCost),
1783
+ 'amount': amountString,
1784
+ 'fee': fee,
1785
+ }, market);
1786
+ }
1787
+ parseOrderStatus(status) {
1788
+ const statuses = {
1789
+ 'New': 'open',
1790
+ 'PartiallyFilled': 'open',
1791
+ 'Filled': 'closed',
1792
+ 'DoneForDay': 'open',
1793
+ 'Canceled': 'canceled',
1794
+ 'PendingCancel': 'open',
1795
+ 'PendingNew': 'open',
1796
+ 'Rejected': 'rejected',
1797
+ 'Expired': 'expired',
1798
+ 'Stopped': 'open',
1799
+ 'Untriggered': 'open',
1800
+ 'Triggered': 'open',
1801
+ };
1802
+ return this.safeString(statuses, status, status);
1803
+ }
1804
+ parseTimeInForce(timeInForce) {
1805
+ const timeInForces = {
1806
+ 'Day': 'Day',
1807
+ 'GoodTillCancel': 'GTC',
1808
+ 'ImmediateOrCancel': 'IOC',
1809
+ 'FillOrKill': 'FOK',
1810
+ };
1811
+ return this.safeString(timeInForces, timeInForce, timeInForce);
1812
+ }
1813
+ parseOrder(order, market = undefined) {
1814
+ //
1815
+ // {
1816
+ // "orderID":"56222c7a-9956-413a-82cf-99f4812c214b",
1817
+ // "clOrdID":"",
1818
+ // "clOrdLinkID":"",
1819
+ // "account":1455728,
1820
+ // "symbol":"XBTUSD",
1821
+ // "side":"Sell",
1822
+ // "simpleOrderQty":null,
1823
+ // "orderQty":1,
1824
+ // "price":40000,
1825
+ // "displayQty":null,
1826
+ // "stopPx":null,
1827
+ // "pegOffsetValue":null,
1828
+ // "pegPriceType":"",
1829
+ // "currency":"USD",
1830
+ // "settlCurrency":"XBt",
1831
+ // "ordType":"Limit",
1832
+ // "timeInForce":"GoodTillCancel",
1833
+ // "execInst":"",
1834
+ // "contingencyType":"",
1835
+ // "exDestination":"XBME",
1836
+ // "ordStatus":"New",
1837
+ // "triggered":"",
1838
+ // "workingIndicator":true,
1839
+ // "ordRejReason":"",
1840
+ // "simpleLeavesQty":null,
1841
+ // "leavesQty":1,
1842
+ // "simpleCumQty":null,
1843
+ // "cumQty":0,
1844
+ // "avgPx":null,
1845
+ // "multiLegReportingType":"SingleSecurity",
1846
+ // "text":"Submitted via API.",
1847
+ // "transactTime":"2021-01-02T21:38:49.246Z",
1848
+ // "timestamp":"2021-01-02T21:38:49.246Z"
1849
+ // }
1850
+ //
1851
+ const marketId = this.safeString(order, 'symbol');
1852
+ market = this.safeMarket(marketId, market);
1853
+ const symbol = market['symbol'];
1854
+ const qty = this.safeString(order, 'orderQty');
1855
+ let cost = undefined;
1856
+ let amount = undefined;
1857
+ let isInverse = false;
1858
+ if (marketId === undefined) {
1859
+ const defaultSubType = this.safeString(this.options, 'defaultSubType', 'linear');
1860
+ isInverse = (defaultSubType === 'inverse');
1861
+ }
1862
+ else {
1863
+ isInverse = this.safeBool(market, 'inverse', false);
1864
+ }
1865
+ if (isInverse) {
1866
+ cost = this.convertFromRawQuantity(symbol, qty);
1867
+ }
1868
+ else {
1869
+ amount = this.convertFromRawQuantity(symbol, qty);
1870
+ }
1871
+ const average = this.safeString(order, 'avgPx');
1872
+ let filled = undefined;
1873
+ const cumQty = this.numberToString(this.convertFromRawQuantity(symbol, this.safeString(order, 'cumQty')));
1874
+ if (isInverse) {
1875
+ filled = Precise.stringDiv(cumQty, average);
1876
+ }
1877
+ else {
1878
+ filled = cumQty;
1879
+ }
1880
+ const execInst = this.safeString(order, 'execInst');
1881
+ let postOnly = undefined;
1882
+ if (execInst !== undefined) {
1883
+ postOnly = (execInst === 'ParticipateDoNotInitiate');
1884
+ }
1885
+ const timestamp = this.parse8601(this.safeString(order, 'timestamp'));
1886
+ const triggerPrice = this.safeNumber(order, 'stopPx');
1887
+ const remaining = this.safeString(order, 'leavesQty');
1888
+ return this.safeOrder({
1889
+ 'info': order,
1890
+ 'id': this.safeString(order, 'orderID'),
1891
+ 'clientOrderId': this.safeString(order, 'clOrdID'),
1892
+ 'timestamp': timestamp,
1893
+ 'datetime': this.iso8601(timestamp),
1894
+ 'lastTradeTimestamp': this.parse8601(this.safeString(order, 'transactTime')),
1895
+ 'symbol': symbol,
1896
+ 'type': this.safeStringLower(order, 'ordType'),
1897
+ 'timeInForce': this.parseTimeInForce(this.safeString(order, 'timeInForce')),
1898
+ 'postOnly': postOnly,
1899
+ 'side': this.safeStringLower(order, 'side'),
1900
+ 'price': this.safeString(order, 'price'),
1901
+ 'triggerPrice': triggerPrice,
1902
+ 'amount': amount,
1903
+ 'cost': cost,
1904
+ 'average': average,
1905
+ 'filled': filled,
1906
+ 'remaining': this.convertFromRawQuantity(symbol, remaining),
1907
+ 'status': this.parseOrderStatus(this.safeString(order, 'ordStatus')),
1908
+ 'fee': undefined,
1909
+ 'trades': undefined,
1910
+ }, market);
1911
+ }
1912
+ /**
1913
+ * @method
1914
+ * @name bitmex#fetchTrades
1915
+ * @description get the list of most recent trades for a particular symbol
1916
+ * @see https://www.bitmex.com/api/explorer/#!/Trade/Trade_get
1917
+ * @param {string} symbol unified symbol of the market to fetch trades for
1918
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
1919
+ * @param {int} [limit] the maximum amount of trades to fetch
1920
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1921
+ * @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)
1922
+ * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1923
+ */
1924
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1925
+ await this.loadMarkets();
1926
+ let paginate = false;
1927
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTrades', 'paginate');
1928
+ if (paginate) {
1929
+ return await this.fetchPaginatedCallDynamic('fetchTrades', symbol, since, limit, params);
1930
+ }
1931
+ const market = this.market(symbol);
1932
+ const request = {
1933
+ 'symbol': market['id'],
1934
+ };
1935
+ if (since !== undefined) {
1936
+ request['startTime'] = this.iso8601(since);
1937
+ }
1938
+ else {
1939
+ // by default reverse=false, i.e. trades are fetched since the time of market inception (year 2015 for XBTUSD)
1940
+ request['reverse'] = true;
1941
+ }
1942
+ if (limit !== undefined) {
1943
+ request['count'] = Math.min(limit, 1000); // api maximum 1000
1944
+ }
1945
+ const until = this.safeInteger2(params, 'until', 'endTime');
1946
+ if (until !== undefined) {
1947
+ params = this.omit(params, ['until']);
1948
+ request['endTime'] = this.iso8601(until);
1949
+ }
1950
+ const response = await this.publicGetTrade(this.extend(request, params));
1951
+ //
1952
+ // [
1953
+ // {
1954
+ // "timestamp": "2018-08-28T00:00:02.735Z",
1955
+ // "symbol": "XBTUSD",
1956
+ // "side": "Buy",
1957
+ // "size": 2000,
1958
+ // "price": 6906.5,
1959
+ // "tickDirection": "PlusTick",
1960
+ // "trdMatchID": "b9a42432-0a46-6a2f-5ecc-c32e9ca4baf8",
1961
+ // "grossValue": 28958000,
1962
+ // "homeNotional": 0.28958,
1963
+ // "foreignNotional": 2000
1964
+ // },
1965
+ // {
1966
+ // "timestamp": "2018-08-28T00:00:03.778Z",
1967
+ // "symbol": "XBTUSD",
1968
+ // "side": "Sell",
1969
+ // "size": 1000,
1970
+ // "price": 6906,
1971
+ // "tickDirection": "MinusTick",
1972
+ // "trdMatchID": "0d4f1682-5270-a800-569b-4a0eb92db97c",
1973
+ // "grossValue": 14480000,
1974
+ // "homeNotional": 0.1448,
1975
+ // "foreignNotional": 1000
1976
+ // },
1977
+ // ]
1978
+ //
1979
+ return this.parseTrades(response, market, since, limit);
1980
+ }
1981
+ /**
1982
+ * @method
1983
+ * @name bitmex#createOrder
1984
+ * @description create a trade order
1985
+ * @see https://www.bitmex.com/api/explorer/#!/Order/Order_new
1986
+ * @param {string} symbol unified symbol of the market to create an order in
1987
+ * @param {string} type 'market' or 'limit'
1988
+ * @param {string} side 'buy' or 'sell'
1989
+ * @param {float} amount how much of currency you want to trade in units of base currency
1990
+ * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1991
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1992
+ * @param {object} [params.triggerPrice] the price at which a trigger order is triggered at
1993
+ * @param {object} [params.triggerDirection] the direction whenever the trigger happens with relation to price - 'ascending' or 'descending'
1994
+ * @param {float} [params.trailingAmount] the quote amount to trail away from the current market price
1995
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1996
+ */
1997
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1998
+ await this.loadMarkets();
1999
+ const market = this.market(symbol);
2000
+ let orderType = this.capitalize(type);
2001
+ const reduceOnly = this.safeValue(params, 'reduceOnly');
2002
+ if (reduceOnly !== undefined) {
2003
+ if ((!market['swap']) && (!market['future'])) {
2004
+ throw new InvalidOrder(this.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap and future markets only');
2005
+ }
2006
+ }
2007
+ const brokerId = this.safeString(this.options, 'brokerId', 'CCXT');
2008
+ const qty = this.parseToInt(this.amountToPrecision(symbol, amount));
2009
+ const request = {
2010
+ 'symbol': market['id'],
2011
+ 'side': this.capitalize(side),
2012
+ 'orderQty': qty,
2013
+ 'ordType': orderType,
2014
+ 'text': brokerId,
2015
+ };
2016
+ // support for unified trigger format
2017
+ const triggerPrice = this.safeNumberN(params, ['triggerPrice', 'stopPx', 'stopPrice']);
2018
+ let trailingAmount = this.safeString2(params, 'trailingAmount', 'pegOffsetValue');
2019
+ const isTriggerOrder = triggerPrice !== undefined;
2020
+ const isTrailingAmountOrder = trailingAmount !== undefined;
2021
+ if (isTriggerOrder || isTrailingAmountOrder) {
2022
+ const triggerDirection = this.safeString(params, 'triggerDirection');
2023
+ const triggerAbove = ((triggerDirection === 'ascending') || (triggerDirection === 'above'));
2024
+ if ((type === 'limit') || (type === 'market')) {
2025
+ this.checkRequiredArgument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below']);
2026
+ }
2027
+ if (type === 'limit') {
2028
+ if (side === 'buy') {
2029
+ orderType = triggerAbove ? 'StopLimit' : 'LimitIfTouched';
2030
+ }
2031
+ else {
2032
+ orderType = triggerAbove ? 'LimitIfTouched' : 'StopLimit';
2033
+ }
2034
+ }
2035
+ else if (type === 'market') {
2036
+ if (side === 'buy') {
2037
+ orderType = triggerAbove ? 'Stop' : 'MarketIfTouched';
2038
+ }
2039
+ else {
2040
+ orderType = triggerAbove ? 'MarketIfTouched' : 'Stop';
2041
+ }
2042
+ }
2043
+ if (isTrailingAmountOrder) {
2044
+ const isStopSellOrder = (side === 'sell') && ((orderType === 'Stop') || (orderType === 'StopLimit'));
2045
+ const isBuyIfTouchedOrder = (side === 'buy') && ((orderType === 'MarketIfTouched') || (orderType === 'LimitIfTouched'));
2046
+ if (isStopSellOrder || isBuyIfTouchedOrder) {
2047
+ trailingAmount = '-' + trailingAmount;
2048
+ }
2049
+ request['pegOffsetValue'] = this.parseToNumeric(trailingAmount);
2050
+ request['pegPriceType'] = 'TrailingStopPeg';
2051
+ }
2052
+ else {
2053
+ if (triggerPrice === undefined) {
2054
+ // if exchange specific trigger types were provided
2055
+ throw new ArgumentsRequired(this.id + ' createOrder() requires a triggerPrice parameter for the ' + orderType + ' order type');
2056
+ }
2057
+ request['stopPx'] = this.parseToNumeric(this.priceToPrecision(symbol, triggerPrice));
2058
+ }
2059
+ request['ordType'] = orderType;
2060
+ params = this.omit(params, ['triggerPrice', 'stopPrice', 'stopPx', 'triggerDirection', 'trailingAmount']);
2061
+ }
2062
+ if ((orderType === 'Limit') || (orderType === 'StopLimit') || (orderType === 'LimitIfTouched')) {
2063
+ request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
2064
+ }
2065
+ const clientOrderId = this.safeString2(params, 'clOrdID', 'clientOrderId');
2066
+ if (clientOrderId !== undefined) {
2067
+ request['clOrdID'] = clientOrderId;
2068
+ params = this.omit(params, ['clOrdID', 'clientOrderId']);
2069
+ }
2070
+ const response = await this.privatePostOrder(this.extend(request, params));
2071
+ return this.parseOrder(response, market);
2072
+ }
2073
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
2074
+ await this.loadMarkets();
2075
+ const request = {};
2076
+ let trailingAmount = this.safeString2(params, 'trailingAmount', 'pegOffsetValue');
2077
+ const isTrailingAmountOrder = trailingAmount !== undefined;
2078
+ if (isTrailingAmountOrder) {
2079
+ const triggerDirection = this.safeString(params, 'triggerDirection');
2080
+ const triggerAbove = ((triggerDirection === 'ascending') || (triggerDirection === 'above'));
2081
+ if ((type === 'limit') || (type === 'market')) {
2082
+ this.checkRequiredArgument('createOrder', triggerDirection, 'triggerDirection', ['above', 'below']);
2083
+ }
2084
+ let orderType = undefined;
2085
+ if (type === 'limit') {
2086
+ if (side === 'buy') {
2087
+ orderType = triggerAbove ? 'StopLimit' : 'LimitIfTouched';
2088
+ }
2089
+ else {
2090
+ orderType = triggerAbove ? 'LimitIfTouched' : 'StopLimit';
2091
+ }
2092
+ }
2093
+ else if (type === 'market') {
2094
+ if (side === 'buy') {
2095
+ orderType = triggerAbove ? 'Stop' : 'MarketIfTouched';
2096
+ }
2097
+ else {
2098
+ orderType = triggerAbove ? 'MarketIfTouched' : 'Stop';
2099
+ }
2100
+ }
2101
+ const isStopSellOrder = (side === 'sell') && ((orderType === 'Stop') || (orderType === 'StopLimit'));
2102
+ const isBuyIfTouchedOrder = (side === 'buy') && ((orderType === 'MarketIfTouched') || (orderType === 'LimitIfTouched'));
2103
+ if (isStopSellOrder || isBuyIfTouchedOrder) {
2104
+ trailingAmount = '-' + trailingAmount;
2105
+ }
2106
+ request['pegOffsetValue'] = this.parseToNumeric(trailingAmount);
2107
+ params = this.omit(params, ['triggerDirection', 'trailingAmount']);
2108
+ }
2109
+ const origClOrdID = this.safeString2(params, 'origClOrdID', 'clientOrderId');
2110
+ if (origClOrdID !== undefined) {
2111
+ request['origClOrdID'] = origClOrdID;
2112
+ const clientOrderId = this.safeString(params, 'clOrdID', 'clientOrderId');
2113
+ if (clientOrderId !== undefined) {
2114
+ request['clOrdID'] = clientOrderId;
2115
+ }
2116
+ params = this.omit(params, ['origClOrdID', 'clOrdID', 'clientOrderId']);
2117
+ }
2118
+ else {
2119
+ request['orderID'] = id;
2120
+ }
2121
+ if (amount !== undefined) {
2122
+ const qty = this.parseToInt(this.amountToPrecision(symbol, amount));
2123
+ request['orderQty'] = qty;
2124
+ }
2125
+ if (price !== undefined) {
2126
+ request['price'] = price;
2127
+ }
2128
+ const brokerId = this.safeString(this.options, 'brokerId', 'CCXT');
2129
+ request['text'] = brokerId;
2130
+ const response = await this.privatePutOrder(this.extend(request, params));
2131
+ return this.parseOrder(response);
2132
+ }
2133
+ /**
2134
+ * @method
2135
+ * @name bitmex#cancelOrder
2136
+ * @description cancels an open order
2137
+ * @see https://www.bitmex.com/api/explorer/#!/Order/Order_cancel
2138
+ * @param {string} id order id
2139
+ * @param {string} symbol not used by bitmex cancelOrder ()
2140
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2141
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2142
+ */
2143
+ async cancelOrder(id, symbol = undefined, params = {}) {
2144
+ await this.loadMarkets();
2145
+ // https://github.com/ccxt/ccxt/issues/6507
2146
+ const clientOrderId = this.safeValue2(params, 'clOrdID', 'clientOrderId');
2147
+ const request = {};
2148
+ if (clientOrderId === undefined) {
2149
+ request['orderID'] = id;
2150
+ }
2151
+ else {
2152
+ request['clOrdID'] = clientOrderId;
2153
+ params = this.omit(params, ['clOrdID', 'clientOrderId']);
2154
+ }
2155
+ const response = await this.privateDeleteOrder(this.extend(request, params));
2156
+ const order = this.safeValue(response, 0, {});
2157
+ const error = this.safeString(order, 'error');
2158
+ if (error !== undefined) {
2159
+ if (error.indexOf('Unable to cancel order due to existing state') >= 0) {
2160
+ throw new OrderNotFound(this.id + ' cancelOrder() failed: ' + error);
2161
+ }
2162
+ }
2163
+ return this.parseOrder(order);
2164
+ }
2165
+ /**
2166
+ * @method
2167
+ * @name bitmex#cancelOrders
2168
+ * @description cancel multiple orders
2169
+ * @see https://www.bitmex.com/api/explorer/#!/Order/Order_cancel
2170
+ * @param {string[]} ids order ids
2171
+ * @param {string} symbol not used by bitmex cancelOrders ()
2172
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2173
+ * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2174
+ */
2175
+ async cancelOrders(ids, symbol = undefined, params = {}) {
2176
+ // return await this.cancelOrder (ids, symbol, params);
2177
+ await this.loadMarkets();
2178
+ // https://github.com/ccxt/ccxt/issues/6507
2179
+ const clientOrderId = this.safeValue2(params, 'clOrdID', 'clientOrderId');
2180
+ const request = {};
2181
+ if (clientOrderId === undefined) {
2182
+ request['orderID'] = ids;
2183
+ }
2184
+ else {
2185
+ request['clOrdID'] = clientOrderId;
2186
+ params = this.omit(params, ['clOrdID', 'clientOrderId']);
2187
+ }
2188
+ const response = await this.privateDeleteOrder(this.extend(request, params));
2189
+ return this.parseOrders(response);
2190
+ }
2191
+ /**
2192
+ * @method
2193
+ * @name bitmex#cancelAllOrders
2194
+ * @description cancel all open orders
2195
+ * @see https://www.bitmex.com/api/explorer/#!/Order/Order_cancelAll
2196
+ * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
2197
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2198
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2199
+ */
2200
+ async cancelAllOrders(symbol = undefined, params = {}) {
2201
+ await this.loadMarkets();
2202
+ const request = {};
2203
+ let market = undefined;
2204
+ if (symbol !== undefined) {
2205
+ market = this.market(symbol);
2206
+ request['symbol'] = market['id'];
2207
+ }
2208
+ const response = await this.privateDeleteOrderAll(this.extend(request, params));
2209
+ //
2210
+ // [
2211
+ // {
2212
+ // "orderID": "string",
2213
+ // "clOrdID": "string",
2214
+ // "clOrdLinkID": "string",
2215
+ // "account": 0,
2216
+ // "symbol": "string",
2217
+ // "side": "string",
2218
+ // "simpleOrderQty": 0,
2219
+ // "orderQty": 0,
2220
+ // "price": 0,
2221
+ // "displayQty": 0,
2222
+ // "stopPx": 0,
2223
+ // "pegOffsetValue": 0,
2224
+ // "pegPriceType": "string",
2225
+ // "currency": "string",
2226
+ // "settlCurrency": "string",
2227
+ // "ordType": "string",
2228
+ // "timeInForce": "string",
2229
+ // "execInst": "string",
2230
+ // "contingencyType": "string",
2231
+ // "exDestination": "string",
2232
+ // "ordStatus": "string",
2233
+ // "triggered": "string",
2234
+ // "workingIndicator": true,
2235
+ // "ordRejReason": "string",
2236
+ // "simpleLeavesQty": 0,
2237
+ // "leavesQty": 0,
2238
+ // "simpleCumQty": 0,
2239
+ // "cumQty": 0,
2240
+ // "avgPx": 0,
2241
+ // "multiLegReportingType": "string",
2242
+ // "text": "string",
2243
+ // "transactTime": "2020-06-01T09:36:35.290Z",
2244
+ // "timestamp": "2020-06-01T09:36:35.290Z"
2245
+ // }
2246
+ // ]
2247
+ //
2248
+ return this.parseOrders(response, market);
2249
+ }
2250
+ /**
2251
+ * @method
2252
+ * @name bitmex#cancelAllOrdersAfter
2253
+ * @description dead man's switch, cancel all orders after the given timeout
2254
+ * @see https://www.bitmex.com/api/explorer/#!/Order/Order_cancelAllAfter
2255
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
2256
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2257
+ * @returns {object} the api result
2258
+ */
2259
+ async cancelAllOrdersAfter(timeout, params = {}) {
2260
+ await this.loadMarkets();
2261
+ const request = {
2262
+ 'timeout': (timeout > 0) ? this.parseToInt(timeout / 1000) : 0,
2263
+ };
2264
+ const response = await this.privatePostOrderCancelAllAfter(this.extend(request, params));
2265
+ //
2266
+ // {
2267
+ // now: '2024-04-09T09:01:56.560Z',
2268
+ // cancelTime: '2024-04-09T09:01:56.660Z'
2269
+ // }
2270
+ //
2271
+ return response;
2272
+ }
2273
+ /**
2274
+ * @method
2275
+ * @name bitmex#fetchLeverages
2276
+ * @description fetch the set leverage for all contract markets
2277
+ * @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
2278
+ * @param {string[]} [symbols] a list of unified market symbols
2279
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2280
+ * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
2281
+ */
2282
+ async fetchLeverages(symbols = undefined, params = {}) {
2283
+ await this.loadMarkets();
2284
+ const leverages = await this.fetchPositions(symbols, params);
2285
+ return this.parseLeverages(leverages, symbols, 'symbol');
2286
+ }
2287
+ parseLeverage(leverage, market = undefined) {
2288
+ const marketId = this.safeString(leverage, 'symbol');
2289
+ return {
2290
+ 'info': leverage,
2291
+ 'symbol': this.safeSymbol(marketId, market),
2292
+ 'marginMode': this.safeStringLower(leverage, 'marginMode'),
2293
+ 'longLeverage': this.safeInteger(leverage, 'leverage'),
2294
+ 'shortLeverage': this.safeInteger(leverage, 'leverage'),
2295
+ };
2296
+ }
2297
+ /**
2298
+ * @method
2299
+ * @name bitmex#fetchPositions
2300
+ * @description fetch all open positions
2301
+ * @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
2302
+ * @param {string[]|undefined} symbols list of unified market symbols
2303
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2304
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
2305
+ */
2306
+ async fetchPositions(symbols = undefined, params = {}) {
2307
+ await this.loadMarkets();
2308
+ const response = await this.privateGetPosition(params);
2309
+ //
2310
+ // [
2311
+ // {
2312
+ // "account": 0,
2313
+ // "symbol": "string",
2314
+ // "currency": "string",
2315
+ // "underlying": "string",
2316
+ // "quoteCurrency": "string",
2317
+ // "commission": 0,
2318
+ // "initMarginReq": 0,
2319
+ // "maintMarginReq": 0,
2320
+ // "riskLimit": 0,
2321
+ // "leverage": 0,
2322
+ // "crossMargin": true,
2323
+ // "deleveragePercentile": 0,
2324
+ // "rebalancedPnl": 0,
2325
+ // "prevRealisedPnl": 0,
2326
+ // "prevUnrealisedPnl": 0,
2327
+ // "prevClosePrice": 0,
2328
+ // "openingTimestamp": "2020-11-09T06:53:59.892Z",
2329
+ // "openingQty": 0,
2330
+ // "openingCost": 0,
2331
+ // "openingComm": 0,
2332
+ // "openOrderBuyQty": 0,
2333
+ // "openOrderBuyCost": 0,
2334
+ // "openOrderBuyPremium": 0,
2335
+ // "openOrderSellQty": 0,
2336
+ // "openOrderSellCost": 0,
2337
+ // "openOrderSellPremium": 0,
2338
+ // "execBuyQty": 0,
2339
+ // "execBuyCost": 0,
2340
+ // "execSellQty": 0,
2341
+ // "execSellCost": 0,
2342
+ // "execQty": 0,
2343
+ // "execCost": 0,
2344
+ // "execComm": 0,
2345
+ // "currentTimestamp": "2020-11-09T06:53:59.893Z",
2346
+ // "currentQty": 0,
2347
+ // "currentCost": 0,
2348
+ // "currentComm": 0,
2349
+ // "realisedCost": 0,
2350
+ // "unrealisedCost": 0,
2351
+ // "grossOpenCost": 0,
2352
+ // "grossOpenPremium": 0,
2353
+ // "grossExecCost": 0,
2354
+ // "isOpen": true,
2355
+ // "markPrice": 0,
2356
+ // "markValue": 0,
2357
+ // "riskValue": 0,
2358
+ // "homeNotional": 0,
2359
+ // "foreignNotional": 0,
2360
+ // "posState": "string",
2361
+ // "posCost": 0,
2362
+ // "posCost2": 0,
2363
+ // "posCross": 0,
2364
+ // "posInit": 0,
2365
+ // "posComm": 0,
2366
+ // "posLoss": 0,
2367
+ // "posMargin": 0,
2368
+ // "posMaint": 0,
2369
+ // "posAllowance": 0,
2370
+ // "taxableMargin": 0,
2371
+ // "initMargin": 0,
2372
+ // "maintMargin": 0,
2373
+ // "sessionMargin": 0,
2374
+ // "targetExcessMargin": 0,
2375
+ // "varMargin": 0,
2376
+ // "realisedGrossPnl": 0,
2377
+ // "realisedTax": 0,
2378
+ // "realisedPnl": 0,
2379
+ // "unrealisedGrossPnl": 0,
2380
+ // "longBankrupt": 0,
2381
+ // "shortBankrupt": 0,
2382
+ // "taxBase": 0,
2383
+ // "indicativeTaxRate": 0,
2384
+ // "indicativeTax": 0,
2385
+ // "unrealisedTax": 0,
2386
+ // "unrealisedPnl": 0,
2387
+ // "unrealisedPnlPcnt": 0,
2388
+ // "unrealisedRoePcnt": 0,
2389
+ // "simpleQty": 0,
2390
+ // "simpleCost": 0,
2391
+ // "simpleValue": 0,
2392
+ // "simplePnl": 0,
2393
+ // "simplePnlPcnt": 0,
2394
+ // "avgCostPrice": 0,
2395
+ // "avgEntryPrice": 0,
2396
+ // "breakEvenPrice": 0,
2397
+ // "marginCallPrice": 0,
2398
+ // "liquidationPrice": 0,
2399
+ // "bankruptPrice": 0,
2400
+ // "timestamp": "2020-11-09T06:53:59.894Z",
2401
+ // "lastPrice": 0,
2402
+ // "lastValue": 0
2403
+ // }
2404
+ // ]
2405
+ //
2406
+ const results = this.parsePositions(response, symbols);
2407
+ return this.filterByArrayPositions(results, 'symbol', symbols, false);
2408
+ }
2409
+ parsePosition(position, market = undefined) {
2410
+ //
2411
+ // {
2412
+ // "account": 9371654,
2413
+ // "symbol": "ETHUSDT",
2414
+ // "currency": "USDt",
2415
+ // "underlying": "ETH",
2416
+ // "quoteCurrency": "USDT",
2417
+ // "commission": 0.00075,
2418
+ // "initMarginReq": 0.3333333333333333,
2419
+ // "maintMarginReq": 0.01,
2420
+ // "riskLimit": 1000000000000,
2421
+ // "leverage": 3,
2422
+ // "crossMargin": false,
2423
+ // "deleveragePercentile": 1,
2424
+ // "rebalancedPnl": 0,
2425
+ // "prevRealisedPnl": 0,
2426
+ // "prevUnrealisedPnl": 0,
2427
+ // "prevClosePrice": 2053.738,
2428
+ // "openingTimestamp": "2022-05-21T04:00:00.000Z",
2429
+ // "openingQty": 0,
2430
+ // "openingCost": 0,
2431
+ // "openingComm": 0,
2432
+ // "openOrderBuyQty": 0,
2433
+ // "openOrderBuyCost": 0,
2434
+ // "openOrderBuyPremium": 0,
2435
+ // "openOrderSellQty": 0,
2436
+ // "openOrderSellCost": 0,
2437
+ // "openOrderSellPremium": 0,
2438
+ // "execBuyQty": 2000,
2439
+ // "execBuyCost": 39260000,
2440
+ // "execSellQty": 0,
2441
+ // "execSellCost": 0,
2442
+ // "execQty": 2000,
2443
+ // "execCost": 39260000,
2444
+ // "execComm": 26500,
2445
+ // "currentTimestamp": "2022-05-21T04:35:16.397Z",
2446
+ // "currentQty": 2000,
2447
+ // "currentCost": 39260000,
2448
+ // "currentComm": 26500,
2449
+ // "realisedCost": 0,
2450
+ // "unrealisedCost": 39260000,
2451
+ // "grossOpenCost": 0,
2452
+ // "grossOpenPremium": 0,
2453
+ // "grossExecCost": 39260000,
2454
+ // "isOpen": true,
2455
+ // "markPrice": 1964.195,
2456
+ // "markValue": 39283900,
2457
+ // "riskValue": 39283900,
2458
+ // "homeNotional": 0.02,
2459
+ // "foreignNotional": -39.2839,
2460
+ // "posState": "",
2461
+ // "posCost": 39260000,
2462
+ // "posCost2": 39260000,
2463
+ // "posCross": 0,
2464
+ // "posInit": 13086667,
2465
+ // "posComm": 39261,
2466
+ // "posLoss": 0,
2467
+ // "posMargin": 13125928,
2468
+ // "posMaint": 435787,
2469
+ // "posAllowance": 0,
2470
+ // "taxableMargin": 0,
2471
+ // "initMargin": 0,
2472
+ // "maintMargin": 13149828,
2473
+ // "sessionMargin": 0,
2474
+ // "targetExcessMargin": 0,
2475
+ // "varMargin": 0,
2476
+ // "realisedGrossPnl": 0,
2477
+ // "realisedTax": 0,
2478
+ // "realisedPnl": -26500,
2479
+ // "unrealisedGrossPnl": 23900,
2480
+ // "longBankrupt": 0,
2481
+ // "shortBankrupt": 0,
2482
+ // "taxBase": 0,
2483
+ // "indicativeTaxRate": null,
2484
+ // "indicativeTax": 0,
2485
+ // "unrealisedTax": 0,
2486
+ // "unrealisedPnl": 23900,
2487
+ // "unrealisedPnlPcnt": 0.0006,
2488
+ // "unrealisedRoePcnt": 0.0018,
2489
+ // "simpleQty": null,
2490
+ // "simpleCost": null,
2491
+ // "simpleValue": null,
2492
+ // "simplePnl": null,
2493
+ // "simplePnlPcnt": null,
2494
+ // "avgCostPrice": 1963,
2495
+ // "avgEntryPrice": 1963,
2496
+ // "breakEvenPrice": 1964.35,
2497
+ // "marginCallPrice": 1328.5,
2498
+ // "liquidationPrice": 1328.5,
2499
+ // "bankruptPrice": 1308.7,
2500
+ // "timestamp": "2022-05-21T04:35:16.397Z",
2501
+ // "lastPrice": 1964.195,
2502
+ // "lastValue": 39283900
2503
+ // }
2504
+ //
2505
+ market = this.safeMarket(this.safeString(position, 'symbol'), market);
2506
+ const symbol = market['symbol'];
2507
+ const datetime = this.safeString(position, 'timestamp');
2508
+ const crossMargin = this.safeValue(position, 'crossMargin');
2509
+ const marginMode = (crossMargin === true) ? 'cross' : 'isolated';
2510
+ const notionalString = Precise.stringAbs(this.safeString2(position, 'foreignNotional', 'homeNotional'));
2511
+ const settleCurrencyCode = this.safeString(market, 'settle');
2512
+ const maintenanceMargin = this.convertToRealAmount(settleCurrencyCode, this.safeString(position, 'maintMargin'));
2513
+ const unrealisedPnl = this.convertToRealAmount(settleCurrencyCode, this.safeString(position, 'unrealisedPnl'));
2514
+ const contracts = this.parseNumber(Precise.stringAbs(this.safeString(position, 'currentQty')));
2515
+ const contractSize = this.safeNumber(market, 'contractSize');
2516
+ let side = undefined;
2517
+ const homeNotional = this.safeString(position, 'homeNotional');
2518
+ if (homeNotional !== undefined) {
2519
+ if (homeNotional[0] === '-') {
2520
+ side = 'short';
2521
+ }
2522
+ else {
2523
+ side = 'long';
2524
+ }
2525
+ }
2526
+ return this.safePosition({
2527
+ 'info': position,
2528
+ 'id': this.safeString(position, 'account'),
2529
+ 'symbol': symbol,
2530
+ 'timestamp': this.parse8601(datetime),
2531
+ 'datetime': datetime,
2532
+ 'lastUpdateTimestamp': undefined,
2533
+ 'hedged': undefined,
2534
+ 'side': side,
2535
+ 'contracts': contracts,
2536
+ 'contractSize': contractSize,
2537
+ 'entryPrice': this.safeNumber(position, 'avgEntryPrice'),
2538
+ 'markPrice': this.safeNumber(position, 'markPrice'),
2539
+ 'lastPrice': undefined,
2540
+ 'notional': this.parseNumber(notionalString),
2541
+ 'leverage': this.safeNumber(position, 'leverage'),
2542
+ 'collateral': undefined,
2543
+ 'initialMargin': this.safeNumber(position, 'initMargin'),
2544
+ 'initialMarginPercentage': this.safeNumber(position, 'initMarginReq'),
2545
+ 'maintenanceMargin': maintenanceMargin,
2546
+ 'maintenanceMarginPercentage': this.safeNumber(position, 'maintMarginReq'),
2547
+ 'unrealizedPnl': unrealisedPnl,
2548
+ 'liquidationPrice': this.safeNumber(position, 'liquidationPrice'),
2549
+ 'marginMode': marginMode,
2550
+ 'marginRatio': undefined,
2551
+ 'percentage': this.safeNumber(position, 'unrealisedPnlPcnt'),
2552
+ 'stopLossPrice': undefined,
2553
+ 'takeProfitPrice': undefined,
2554
+ });
2555
+ }
2556
+ /**
2557
+ * @method
2558
+ * @name bitmex#withdraw
2559
+ * @description make a withdrawal
2560
+ * @see https://www.bitmex.com/api/explorer/#!/User/User_requestWithdrawal
2561
+ * @param {string} code unified currency code
2562
+ * @param {float} amount the amount to withdraw
2563
+ * @param {string} address the address to withdraw to
2564
+ * @param {string} tag
2565
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2566
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2567
+ */
2568
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
2569
+ [tag, params] = this.handleWithdrawTagAndParams(tag, params);
2570
+ this.checkAddress(address);
2571
+ await this.loadMarkets();
2572
+ const currency = this.currency(code);
2573
+ const qty = this.convertFromRealAmount(code, amount);
2574
+ let networkCode = undefined;
2575
+ [networkCode, params] = this.handleNetworkCodeAndParams(params);
2576
+ const request = {
2577
+ 'currency': currency['id'],
2578
+ 'amount': qty,
2579
+ 'address': address,
2580
+ 'network': this.networkCodeToId(networkCode, currency['code']),
2581
+ // 'otpToken': '123456', // requires if two-factor auth (OTP) is enabled
2582
+ // 'fee': 0.001, // bitcoin network fee
2583
+ };
2584
+ if (this.twofa !== undefined) {
2585
+ request['otpToken'] = totp(this.twofa);
2586
+ }
2587
+ const response = await this.privatePostUserRequestWithdrawal(this.extend(request, params));
2588
+ //
2589
+ // {
2590
+ // "transactID": "3aece414-bb29-76c8-6c6d-16a477a51a1e",
2591
+ // "account": 1403035,
2592
+ // "currency": "USDt",
2593
+ // "network": "tron",
2594
+ // "transactType": "Withdrawal",
2595
+ // "amount": -11000000,
2596
+ // "fee": 1000000,
2597
+ // "transactStatus": "Pending",
2598
+ // "address": "TAf5JxcAQQsC2Nm2zu21XE2iDtnisxPo1x",
2599
+ // "tx": "",
2600
+ // "text": "",
2601
+ // "transactTime": "2022-12-16T07:37:06.500Z",
2602
+ // "timestamp": "2022-12-16T07:37:06.500Z",
2603
+ // }
2604
+ //
2605
+ return this.parseTransaction(response, currency);
2606
+ }
2607
+ /**
2608
+ * @method
2609
+ * @name bitmex#fetchFundingRates
2610
+ * @description fetch the funding rate for multiple markets
2611
+ * @see https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_getActiveAndIndices
2612
+ * @param {string[]|undefined} symbols list of unified market symbols
2613
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2614
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexed by market symbols
2615
+ */
2616
+ async fetchFundingRates(symbols = undefined, params = {}) {
2617
+ await this.loadMarkets();
2618
+ const response = await this.publicGetInstrumentActiveAndIndices(params);
2619
+ // same response as under "fetchMarkets"
2620
+ const filteredResponse = [];
2621
+ for (let i = 0; i < response.length; i++) {
2622
+ const item = response[i];
2623
+ const marketId = this.safeString(item, 'symbol');
2624
+ const market = this.safeMarket(marketId);
2625
+ const swap = this.safeBool(market, 'swap', false);
2626
+ if (swap) {
2627
+ filteredResponse.push(item);
2628
+ }
2629
+ }
2630
+ symbols = this.marketSymbols(symbols);
2631
+ const result = this.parseFundingRates(filteredResponse);
2632
+ return this.filterByArray(result, 'symbol', symbols);
2633
+ }
2634
+ parseFundingRate(contract, market = undefined) {
2635
+ // see response sample under "fetchMarkets" because same endpoint is being used here
2636
+ const datetime = this.safeString(contract, 'timestamp');
2637
+ const marketId = this.safeString(contract, 'symbol');
2638
+ const fundingDatetime = this.safeString(contract, 'fundingTimestamp');
2639
+ return {
2640
+ 'info': contract,
2641
+ 'symbol': this.safeSymbol(marketId, market),
2642
+ 'markPrice': this.safeNumber(contract, 'markPrice'),
2643
+ 'indexPrice': undefined,
2644
+ 'interestRate': undefined,
2645
+ 'estimatedSettlePrice': this.safeNumber(contract, 'indicativeSettlePrice'),
2646
+ 'timestamp': this.parse8601(datetime),
2647
+ 'datetime': datetime,
2648
+ 'fundingRate': this.safeNumber(contract, 'fundingRate'),
2649
+ 'fundingTimestamp': this.parse8601(fundingDatetime),
2650
+ 'fundingDatetime': fundingDatetime,
2651
+ 'nextFundingRate': this.safeNumber(contract, 'indicativeFundingRate'),
2652
+ 'nextFundingTimestamp': undefined,
2653
+ 'nextFundingDatetime': undefined,
2654
+ 'previousFundingRate': undefined,
2655
+ 'previousFundingTimestamp': undefined,
2656
+ 'previousFundingDatetime': undefined,
2657
+ 'interval': undefined,
2658
+ };
2659
+ }
2660
+ /**
2661
+ * @method
2662
+ * @name bitmex#fetchFundingRateHistory
2663
+ * @description Fetches the history of funding rates
2664
+ * @see https://www.bitmex.com/api/explorer/#!/Funding/Funding_get
2665
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
2666
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
2667
+ * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
2668
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2669
+ * @param {int} [params.until] timestamp in ms for ending date filter
2670
+ * @param {bool} [params.reverse] if true, will sort results newest first
2671
+ * @param {int} [params.start] starting point for results
2672
+ * @param {string} [params.columns] array of column names to fetch in info, if omitted, will return all columns
2673
+ * @param {string} [params.filter] generic table filter, send json key/value pairs, such as {"key": "value"}, you can key on individual fields, and do more advanced querying on timestamps, see the [timestamp docs]{@link https://www.bitmex.com/app/restAPI#Timestamp-Filters} for more details
2674
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
2675
+ */
2676
+ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2677
+ await this.loadMarkets();
2678
+ const request = {};
2679
+ let market = undefined;
2680
+ if (symbol in this.currencies) {
2681
+ const code = this.currency(symbol);
2682
+ request['symbol'] = code['id'];
2683
+ }
2684
+ else if (symbol !== undefined) {
2685
+ const splitSymbol = symbol.split(':');
2686
+ const splitSymbolLength = splitSymbol.length;
2687
+ const timeframes = ['nearest', 'daily', 'weekly', 'monthly', 'quarterly', 'biquarterly', 'perpetual'];
2688
+ if ((splitSymbolLength > 1) && this.inArray(splitSymbol[1], timeframes)) {
2689
+ const code = this.currency(splitSymbol[0]);
2690
+ symbol = code['id'] + ':' + splitSymbol[1];
2691
+ request['symbol'] = symbol;
2692
+ }
2693
+ else {
2694
+ market = this.market(symbol);
2695
+ request['symbol'] = market['id'];
2696
+ }
2697
+ }
2698
+ if (since !== undefined) {
2699
+ request['startTime'] = this.iso8601(since);
2700
+ }
2701
+ if (limit !== undefined) {
2702
+ request['count'] = limit;
2703
+ }
2704
+ const until = this.safeInteger(params, 'until');
2705
+ params = this.omit(params, ['until']);
2706
+ if (until !== undefined) {
2707
+ request['endTime'] = this.iso8601(until);
2708
+ }
2709
+ if ((since === undefined) && (until === undefined)) {
2710
+ request['reverse'] = true;
2711
+ }
2712
+ const response = await this.publicGetFunding(this.extend(request, params));
2713
+ //
2714
+ // [
2715
+ // {
2716
+ // "timestamp": "2016-05-07T12:00:00.000Z",
2717
+ // "symbol": "ETHXBT",
2718
+ // "fundingInterval": "2000-01-02T00:00:00.000Z",
2719
+ // "fundingRate": 0.0010890000000000001,
2720
+ // "fundingRateDaily": 0.0010890000000000001
2721
+ // }
2722
+ // ]
2723
+ //
2724
+ return this.parseFundingRateHistories(response, market, since, limit);
2725
+ }
2726
+ parseFundingRateHistory(info, market = undefined) {
2727
+ //
2728
+ // {
2729
+ // "timestamp": "2016-05-07T12:00:00.000Z",
2730
+ // "symbol": "ETHXBT",
2731
+ // "fundingInterval": "2000-01-02T00:00:00.000Z",
2732
+ // "fundingRate": 0.0010890000000000001,
2733
+ // "fundingRateDaily": 0.0010890000000000001
2734
+ // }
2735
+ //
2736
+ const marketId = this.safeString(info, 'symbol');
2737
+ const datetime = this.safeString(info, 'timestamp');
2738
+ return {
2739
+ 'info': info,
2740
+ 'symbol': this.safeSymbol(marketId, market),
2741
+ 'fundingRate': this.safeNumber(info, 'fundingRate'),
2742
+ 'timestamp': this.parse8601(datetime),
2743
+ 'datetime': datetime,
2744
+ };
2745
+ }
2746
+ /**
2747
+ * @method
2748
+ * @name bitmex#setLeverage
2749
+ * @description set the level of leverage for a market
2750
+ * @see https://www.bitmex.com/api/explorer/#!/Position/Position_updateLeverage
2751
+ * @param {float} leverage the rate of leverage
2752
+ * @param {string} symbol unified market symbol
2753
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2754
+ * @returns {object} response from the exchange
2755
+ */
2756
+ async setLeverage(leverage, symbol = undefined, params = {}) {
2757
+ if (symbol === undefined) {
2758
+ throw new ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
2759
+ }
2760
+ if ((leverage < 0.01) || (leverage > 100)) {
2761
+ throw new BadRequest(this.id + ' leverage should be between 0.01 and 100');
2762
+ }
2763
+ await this.loadMarkets();
2764
+ const market = this.market(symbol);
2765
+ if (market['type'] !== 'swap' && market['type'] !== 'future') {
2766
+ throw new BadSymbol(this.id + ' setLeverage() supports future and swap contracts only');
2767
+ }
2768
+ const request = {
2769
+ 'symbol': market['id'],
2770
+ 'leverage': leverage,
2771
+ };
2772
+ return await this.privatePostPositionLeverage(this.extend(request, params));
2773
+ }
2774
+ /**
2775
+ * @method
2776
+ * @name bitmex#setMarginMode
2777
+ * @description set margin mode to 'cross' or 'isolated'
2778
+ * @see https://www.bitmex.com/api/explorer/#!/Position/Position_isolateMargin
2779
+ * @param {string} marginMode 'cross' or 'isolated'
2780
+ * @param {string} symbol unified market symbol
2781
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2782
+ * @returns {object} response from the exchange
2783
+ */
2784
+ async setMarginMode(marginMode, symbol = undefined, params = {}) {
2785
+ if (symbol === undefined) {
2786
+ throw new ArgumentsRequired(this.id + ' setMarginMode() requires a symbol argument');
2787
+ }
2788
+ marginMode = marginMode.toLowerCase();
2789
+ if (marginMode !== 'isolated' && marginMode !== 'cross') {
2790
+ throw new BadRequest(this.id + ' setMarginMode() marginMode argument should be isolated or cross');
2791
+ }
2792
+ await this.loadMarkets();
2793
+ const market = this.market(symbol);
2794
+ if ((market['type'] !== 'swap') && (market['type'] !== 'future')) {
2795
+ throw new BadSymbol(this.id + ' setMarginMode() supports swap and future contracts only');
2796
+ }
2797
+ const enabled = (marginMode === 'cross') ? false : true;
2798
+ const request = {
2799
+ 'symbol': market['id'],
2800
+ 'enabled': enabled,
2801
+ };
2802
+ return await this.privatePostPositionIsolate(this.extend(request, params));
2803
+ }
2804
+ /**
2805
+ * @method
2806
+ * @name bitmex#fetchDepositAddress
2807
+ * @description fetch the deposit address for a currency associated with this account
2808
+ * @see https://www.bitmex.com/api/explorer/#!/User/User_getDepositAddress
2809
+ * @param {string} code unified currency code
2810
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2811
+ * @param {string} [params.network] deposit chain, can view all chains via this.publicGetWalletAssets, default is eth, unless the currency has a default chain within this.options['networks']
2812
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
2813
+ */
2814
+ async fetchDepositAddress(code, params = {}) {
2815
+ await this.loadMarkets();
2816
+ let networkCode = undefined;
2817
+ [networkCode, params] = this.handleNetworkCodeAndParams(params);
2818
+ if (networkCode === undefined) {
2819
+ throw new ArgumentsRequired(this.id + ' fetchDepositAddress requires params["network"]');
2820
+ }
2821
+ const currency = this.currency(code);
2822
+ params = this.omit(params, 'network');
2823
+ const request = {
2824
+ 'currency': currency['id'],
2825
+ 'network': this.networkCodeToId(networkCode, currency['code']),
2826
+ };
2827
+ const response = await this.privateGetUserDepositAddress(this.extend(request, params));
2828
+ //
2829
+ // '"bc1qmex3puyrzn2gduqcnlu70c2uscpyaa9nm2l2j9le2lt2wkgmw33sy7ndjg"'
2830
+ //
2831
+ return {
2832
+ 'info': response,
2833
+ 'currency': code,
2834
+ 'network': networkCode,
2835
+ 'address': response.replace('"', '').replace('"', ''),
2836
+ 'tag': undefined,
2837
+ };
2838
+ }
2839
+ parseDepositWithdrawFee(fee, currency = undefined) {
2840
+ //
2841
+ // {
2842
+ // "asset": "XBT",
2843
+ // "currency": "XBt",
2844
+ // "majorCurrency": "XBT",
2845
+ // "name": "Bitcoin",
2846
+ // "currencyType": "Crypto",
2847
+ // "scale": "8",
2848
+ // "enabled": true,
2849
+ // "isMarginCurrency": true,
2850
+ // "minDepositAmount": "10000",
2851
+ // "minWithdrawalAmount": "1000",
2852
+ // "maxWithdrawalAmount": "100000000000000",
2853
+ // "networks": [
2854
+ // {
2855
+ // "asset": "btc",
2856
+ // "tokenAddress": '',
2857
+ // "depositEnabled": true,
2858
+ // "withdrawalEnabled": true,
2859
+ // "withdrawalFee": "20000",
2860
+ // "minFee": "20000",
2861
+ // "maxFee": "10000000"
2862
+ // }
2863
+ // ]
2864
+ // }
2865
+ //
2866
+ const networks = this.safeValue(fee, 'networks', []);
2867
+ const networksLength = networks.length;
2868
+ const result = {
2869
+ 'info': fee,
2870
+ 'withdraw': {
2871
+ 'fee': undefined,
2872
+ 'percentage': undefined,
2873
+ },
2874
+ 'deposit': {
2875
+ 'fee': undefined,
2876
+ 'percentage': undefined,
2877
+ },
2878
+ 'networks': {},
2879
+ };
2880
+ if (networksLength !== 0) {
2881
+ const scale = this.safeString(fee, 'scale');
2882
+ const precision = this.parsePrecision(scale);
2883
+ for (let i = 0; i < networksLength; i++) {
2884
+ const network = networks[i];
2885
+ const networkId = this.safeString(network, 'asset');
2886
+ const currencyCode = this.safeString(currency, 'code');
2887
+ const networkCode = this.networkIdToCode(networkId, currencyCode);
2888
+ const withdrawalFeeId = this.safeString(network, 'withdrawalFee');
2889
+ const withdrawalFee = this.parseNumber(Precise.stringMul(withdrawalFeeId, precision));
2890
+ result['networks'][networkCode] = {
2891
+ 'deposit': { 'fee': undefined, 'percentage': undefined },
2892
+ 'withdraw': { 'fee': withdrawalFee, 'percentage': false },
2893
+ };
2894
+ if (networksLength === 1) {
2895
+ result['withdraw']['fee'] = withdrawalFee;
2896
+ result['withdraw']['percentage'] = false;
2897
+ }
2898
+ }
2899
+ }
2900
+ return result;
2901
+ }
2902
+ /**
2903
+ * @method
2904
+ * @name bitmex#fetchDepositWithdrawFees
2905
+ * @description fetch deposit and withdraw fees
2906
+ * @see https://www.bitmex.com/api/explorer/#!/Wallet/Wallet_getAssetsConfig
2907
+ * @param {string[]|undefined} codes list of unified currency codes
2908
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2909
+ * @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
2910
+ */
2911
+ async fetchDepositWithdrawFees(codes = undefined, params = {}) {
2912
+ await this.loadMarkets();
2913
+ const assets = await this.publicGetWalletAssets(params);
2914
+ //
2915
+ // [
2916
+ // {
2917
+ // "asset": "XBT",
2918
+ // "currency": "XBt",
2919
+ // "majorCurrency": "XBT",
2920
+ // "name": "Bitcoin",
2921
+ // "currencyType": "Crypto",
2922
+ // "scale": "8",
2923
+ // "enabled": true,
2924
+ // "isMarginCurrency": true,
2925
+ // "minDepositAmount": "10000",
2926
+ // "minWithdrawalAmount": "1000",
2927
+ // "maxWithdrawalAmount": "100000000000000",
2928
+ // "networks": [
2929
+ // {
2930
+ // "asset": "btc",
2931
+ // "tokenAddress": '',
2932
+ // "depositEnabled": true,
2933
+ // "withdrawalEnabled": true,
2934
+ // "withdrawalFee": "20000",
2935
+ // "minFee": "20000",
2936
+ // "maxFee": "10000000"
2937
+ // }
2938
+ // ]
2939
+ // },
2940
+ // ...
2941
+ // ]
2942
+ //
2943
+ return this.parseDepositWithdrawFees(assets, codes, 'asset');
2944
+ }
2945
+ calculateRateLimiterCost(api, method, path, params, config = {}) {
2946
+ const isAuthenticated = this.checkRequiredCredentials(false);
2947
+ const cost = this.safeValue(config, 'cost', 1);
2948
+ if (cost !== 1) { // trading endpoints
2949
+ if (isAuthenticated) {
2950
+ return cost;
2951
+ }
2952
+ else {
2953
+ return 20;
2954
+ }
2955
+ }
2956
+ return cost;
2957
+ }
2958
+ /**
2959
+ * @method
2960
+ * @name bitmex#fetchLiquidations
2961
+ * @description retrieves the public liquidations of a trading pair
2962
+ * @see https://www.bitmex.com/api/explorer/#!/Liquidation/Liquidation_get
2963
+ * @param {string} symbol unified CCXT market symbol
2964
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
2965
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
2966
+ * @param {object} [params] exchange specific parameters for the bitmex api endpoint
2967
+ * @param {int} [params.until] timestamp in ms of the latest liquidation
2968
+ * @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)
2969
+ * @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
2970
+ */
2971
+ async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
2972
+ await this.loadMarkets();
2973
+ let paginate = false;
2974
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLiquidations', 'paginate');
2975
+ if (paginate) {
2976
+ return await this.fetchPaginatedCallDynamic('fetchLiquidations', symbol, since, limit, params);
2977
+ }
2978
+ const market = this.market(symbol);
2979
+ let request = {
2980
+ 'symbol': market['id'],
2981
+ };
2982
+ if (since !== undefined) {
2983
+ request['startTime'] = since;
2984
+ }
2985
+ if (limit !== undefined) {
2986
+ request['count'] = limit;
2987
+ }
2988
+ [request, params] = this.handleUntilOption('endTime', request, params);
2989
+ const response = await this.publicGetLiquidation(this.extend(request, params));
2990
+ //
2991
+ // [
2992
+ // {
2993
+ // "orderID": "string",
2994
+ // "symbol": "string",
2995
+ // "side": "string",
2996
+ // "price": 0,
2997
+ // "leavesQty": 0
2998
+ // }
2999
+ // ]
3000
+ //
3001
+ return this.parseLiquidations(response, market, since, limit);
3002
+ }
3003
+ parseLiquidation(liquidation, market = undefined) {
3004
+ //
3005
+ // {
3006
+ // "orderID": "string",
3007
+ // "symbol": "string",
3008
+ // "side": "string",
3009
+ // "price": 0,
3010
+ // "leavesQty": 0
3011
+ // }
3012
+ //
3013
+ const marketId = this.safeString(liquidation, 'symbol');
3014
+ return this.safeLiquidation({
3015
+ 'info': liquidation,
3016
+ 'symbol': this.safeSymbol(marketId, market),
3017
+ 'contracts': undefined,
3018
+ 'contractSize': this.safeNumber(market, 'contractSize'),
3019
+ 'price': this.safeNumber(liquidation, 'price'),
3020
+ 'side': this.safeStringLower(liquidation, 'side'),
3021
+ 'baseValue': undefined,
3022
+ 'quoteValue': undefined,
3023
+ 'timestamp': undefined,
3024
+ 'datetime': undefined,
3025
+ });
3026
+ }
3027
+ handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3028
+ if (response === undefined) {
3029
+ return undefined;
3030
+ }
3031
+ if (code === 429) {
3032
+ throw new DDoSProtection(this.id + ' ' + body);
3033
+ }
3034
+ if (code >= 400) {
3035
+ const error = this.safeValue(response, 'error', {});
3036
+ const message = this.safeString(error, 'message');
3037
+ const feedback = this.id + ' ' + body;
3038
+ this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
3039
+ this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
3040
+ if (code === 400) {
3041
+ throw new BadRequest(feedback);
3042
+ }
3043
+ throw new ExchangeError(feedback); // unknown message
3044
+ }
3045
+ return undefined;
3046
+ }
3047
+ nonce() {
3048
+ return this.milliseconds();
3049
+ }
3050
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3051
+ let query = '/api/' + this.version + '/' + path;
3052
+ if (method === 'GET') {
3053
+ if (Object.keys(params).length) {
3054
+ query += '?' + this.urlencode(params);
3055
+ }
3056
+ }
3057
+ else {
3058
+ const format = this.safeString(params, '_format');
3059
+ if (format !== undefined) {
3060
+ query += '?' + this.urlencode({ '_format': format });
3061
+ params = this.omit(params, '_format');
3062
+ }
3063
+ }
3064
+ const url = this.urls['api'][api] + query;
3065
+ const isAuthenticated = this.checkRequiredCredentials(false);
3066
+ if (api === 'private' || (api === 'public' && isAuthenticated)) {
3067
+ this.checkRequiredCredentials();
3068
+ let auth = method + query;
3069
+ let expires = this.safeInteger(this.options, 'api-expires');
3070
+ headers = {
3071
+ 'Content-Type': 'application/json',
3072
+ 'api-key': this.apiKey,
3073
+ };
3074
+ expires = this.sum(this.seconds(), expires);
3075
+ const stringExpires = expires.toString();
3076
+ auth += stringExpires;
3077
+ headers['api-expires'] = stringExpires;
3078
+ if (method === 'POST' || method === 'PUT' || method === 'DELETE') {
3079
+ if (Object.keys(params).length) {
3080
+ body = this.json(params);
3081
+ auth += body;
3082
+ }
3083
+ }
3084
+ headers['api-signature'] = this.hmac(this.encode(auth), this.encode(this.secret), sha256);
3085
+ }
3086
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
3087
+ }
3088
+ }