ccxt 4.2.18 → 4.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (426) hide show
  1. package/README.md +8 -8
  2. package/dist/ccxt.browser.js +34202 -33193
  3. package/dist/ccxt.browser.min.js +2 -2
  4. package/dist/cjs/ccxt.js +12 -1
  5. package/dist/cjs/src/alpaca.js +18 -18
  6. package/dist/cjs/src/ascendex.js +13 -6
  7. package/dist/cjs/src/base/Exchange.js +266 -27
  8. package/dist/cjs/src/bigone.js +434 -168
  9. package/dist/cjs/src/binance.js +163 -34
  10. package/dist/cjs/src/binanceus.js +8 -0
  11. package/dist/cjs/src/bingx.js +183 -41
  12. package/dist/cjs/src/bitfinex.js +2 -3
  13. package/dist/cjs/src/bitget.js +59 -16
  14. package/dist/cjs/src/bitmart.js +5 -5
  15. package/dist/cjs/src/bitmex.js +4 -6
  16. package/dist/cjs/src/bitpanda.js +5 -1991
  17. package/dist/cjs/src/bitstamp.js +8 -0
  18. package/dist/cjs/src/bybit.js +27 -47
  19. package/dist/cjs/src/coinbase.js +176 -26
  20. package/dist/cjs/src/coincheck.js +1 -0
  21. package/dist/cjs/src/coinex.js +3 -0
  22. package/dist/cjs/src/coinlist.js +13 -6
  23. package/dist/cjs/src/coinone.js +2 -2
  24. package/dist/cjs/src/coinsph.js +4 -5
  25. package/dist/cjs/src/delta.js +7 -1
  26. package/dist/cjs/src/deribit.js +17 -4
  27. package/dist/cjs/src/gate.js +151 -169
  28. package/dist/cjs/src/gemini.js +1 -1
  29. package/dist/cjs/src/hitbtc.js +2 -3
  30. package/dist/cjs/src/htx.js +157 -7
  31. package/dist/cjs/src/huobijp.js +2 -3
  32. package/dist/cjs/src/independentreserve.js +7 -5
  33. package/dist/cjs/src/kraken.js +86 -54
  34. package/dist/cjs/src/kucoin.js +5 -0
  35. package/dist/cjs/src/kucoinfutures.js +131 -77
  36. package/dist/cjs/src/lbank.js +60 -33
  37. package/dist/cjs/src/luno.js +84 -2
  38. package/dist/cjs/src/mexc.js +3 -3
  39. package/dist/cjs/src/oceanex.js +1 -1
  40. package/dist/cjs/src/okx.js +23 -11
  41. package/dist/cjs/{js/src/bitpanda.js → src/onetrading.js} +39 -39
  42. package/dist/cjs/src/phemex.js +37 -27
  43. package/dist/cjs/src/poloniexfutures.js +1 -0
  44. package/dist/cjs/src/pro/binance.js +66 -25
  45. package/dist/cjs/src/pro/bitget.js +1 -1
  46. package/dist/cjs/src/pro/bitpanda.js +5 -1330
  47. package/dist/cjs/src/pro/coinbase.js +4 -1
  48. package/dist/cjs/src/pro/hitbtc.js +5 -4
  49. package/dist/cjs/src/pro/htx.js +6 -1
  50. package/dist/cjs/src/pro/kraken.js +1 -1
  51. package/dist/cjs/src/pro/krakenfutures.js +7 -1
  52. package/dist/cjs/src/pro/kucoin.js +46 -36
  53. package/dist/cjs/src/pro/kucoinfutures.js +45 -37
  54. package/dist/cjs/src/pro/lbank.js +881 -0
  55. package/dist/cjs/src/pro/okx.js +52 -2
  56. package/dist/cjs/{js/src/pro/bitpanda.js → src/pro/onetrading.js} +4 -7
  57. package/dist/cjs/src/pro/poloniex.js +2 -2
  58. package/dist/cjs/src/pro/poloniexfutures.js +43 -35
  59. package/dist/cjs/src/pro/woo.js +126 -0
  60. package/dist/cjs/src/probit.js +4 -2
  61. package/dist/cjs/src/upbit.js +12 -12
  62. package/dist/cjs/src/wavesexchange.js +1 -1
  63. package/dist/cjs/src/whitebit.js +1 -0
  64. package/dist/cjs/src/woo.js +56 -0
  65. package/js/ccxt.d.ts +11 -2
  66. package/js/ccxt.js +8 -2
  67. package/js/src/abstract/bitpanda.d.ts +4 -4
  68. package/js/src/abstract/bitstamp.d.ts +8 -0
  69. package/js/src/abstract/gate.d.ts +1 -0
  70. package/js/src/abstract/gateio.d.ts +1 -0
  71. package/js/src/abstract/htx.d.ts +3 -0
  72. package/js/src/abstract/huobi.d.ts +3 -0
  73. package/js/src/abstract/luno.d.ts +1 -0
  74. package/js/src/abstract/onetrading.d.ts +38 -0
  75. package/js/src/ascendex.js +2 -0
  76. package/js/src/bingx.js +1 -1
  77. package/js/src/bitget.js +22 -3
  78. package/js/src/bitpanda.d.ts +2 -72
  79. package/js/src/bitpanda.js +5 -1991
  80. package/js/src/bitstamp.js +8 -0
  81. package/js/src/deribit.js +11 -3
  82. package/js/src/gate.d.ts +1 -0
  83. package/js/src/gate.js +50 -110
  84. package/js/src/htx.js +3 -0
  85. package/js/src/kraken.d.ts +1 -0
  86. package/js/src/kraken.js +39 -38
  87. package/js/src/lbank.js +1 -0
  88. package/js/src/luno.d.ts +3 -1
  89. package/js/src/luno.js +84 -2
  90. package/js/src/mexc.js +1 -2
  91. package/js/src/onetrading.d.ts +74 -0
  92. package/js/src/onetrading.js +2003 -0
  93. package/js/src/poloniexfutures.js +1 -0
  94. package/js/src/pro/binance.js +6 -1
  95. package/js/src/pro/bitpanda.d.ts +2 -34
  96. package/js/src/pro/bitpanda.js +5 -1330
  97. package/js/src/pro/lbank.d.ts +29 -0
  98. package/js/src/pro/lbank.js +882 -0
  99. package/js/src/pro/onetrading.d.ts +36 -0
  100. package/js/src/pro/onetrading.js +1339 -0
  101. package/package.json +2 -2
  102. package/rollup.config.js +2 -0
  103. package/skip-tests.json +2 -1
  104. package/test-commonjs.cjs +25 -1
  105. package/dist/cjs/js/ccxt.js +0 -478
  106. package/dist/cjs/js/src/abstract/alpaca.js +0 -9
  107. package/dist/cjs/js/src/abstract/ascendex.js +0 -9
  108. package/dist/cjs/js/src/abstract/bigone.js +0 -9
  109. package/dist/cjs/js/src/abstract/binance.js +0 -9
  110. package/dist/cjs/js/src/abstract/bingx.js +0 -9
  111. package/dist/cjs/js/src/abstract/bit2c.js +0 -9
  112. package/dist/cjs/js/src/abstract/bitbank.js +0 -9
  113. package/dist/cjs/js/src/abstract/bitbns.js +0 -9
  114. package/dist/cjs/js/src/abstract/bitfinex.js +0 -9
  115. package/dist/cjs/js/src/abstract/bitfinex2.js +0 -9
  116. package/dist/cjs/js/src/abstract/bitflyer.js +0 -9
  117. package/dist/cjs/js/src/abstract/bitforex.js +0 -9
  118. package/dist/cjs/js/src/abstract/bitget.js +0 -9
  119. package/dist/cjs/js/src/abstract/bithumb.js +0 -9
  120. package/dist/cjs/js/src/abstract/bitmart.js +0 -9
  121. package/dist/cjs/js/src/abstract/bitmex.js +0 -9
  122. package/dist/cjs/js/src/abstract/bitopro.js +0 -9
  123. package/dist/cjs/js/src/abstract/bitpanda.js +0 -9
  124. package/dist/cjs/js/src/abstract/bitrue.js +0 -9
  125. package/dist/cjs/js/src/abstract/bitso.js +0 -9
  126. package/dist/cjs/js/src/abstract/bitstamp.js +0 -9
  127. package/dist/cjs/js/src/abstract/bitteam.js +0 -9
  128. package/dist/cjs/js/src/abstract/bitvavo.js +0 -9
  129. package/dist/cjs/js/src/abstract/bl3p.js +0 -9
  130. package/dist/cjs/js/src/abstract/blockchaincom.js +0 -9
  131. package/dist/cjs/js/src/abstract/btcalpha.js +0 -9
  132. package/dist/cjs/js/src/abstract/btcbox.js +0 -9
  133. package/dist/cjs/js/src/abstract/btcmarkets.js +0 -9
  134. package/dist/cjs/js/src/abstract/btcturk.js +0 -9
  135. package/dist/cjs/js/src/abstract/bybit.js +0 -9
  136. package/dist/cjs/js/src/abstract/cex.js +0 -9
  137. package/dist/cjs/js/src/abstract/coinbase.js +0 -9
  138. package/dist/cjs/js/src/abstract/coinbasepro.js +0 -9
  139. package/dist/cjs/js/src/abstract/coincheck.js +0 -9
  140. package/dist/cjs/js/src/abstract/coinex.js +0 -9
  141. package/dist/cjs/js/src/abstract/coinlist.js +0 -9
  142. package/dist/cjs/js/src/abstract/coinmate.js +0 -9
  143. package/dist/cjs/js/src/abstract/coinone.js +0 -9
  144. package/dist/cjs/js/src/abstract/coinsph.js +0 -9
  145. package/dist/cjs/js/src/abstract/coinspot.js +0 -9
  146. package/dist/cjs/js/src/abstract/cryptocom.js +0 -9
  147. package/dist/cjs/js/src/abstract/currencycom.js +0 -9
  148. package/dist/cjs/js/src/abstract/delta.js +0 -9
  149. package/dist/cjs/js/src/abstract/deribit.js +0 -9
  150. package/dist/cjs/js/src/abstract/digifinex.js +0 -9
  151. package/dist/cjs/js/src/abstract/exmo.js +0 -9
  152. package/dist/cjs/js/src/abstract/gate.js +0 -9
  153. package/dist/cjs/js/src/abstract/gemini.js +0 -9
  154. package/dist/cjs/js/src/abstract/hitbtc.js +0 -9
  155. package/dist/cjs/js/src/abstract/hollaex.js +0 -9
  156. package/dist/cjs/js/src/abstract/htx.js +0 -9
  157. package/dist/cjs/js/src/abstract/huobijp.js +0 -9
  158. package/dist/cjs/js/src/abstract/idex.js +0 -9
  159. package/dist/cjs/js/src/abstract/independentreserve.js +0 -9
  160. package/dist/cjs/js/src/abstract/indodax.js +0 -9
  161. package/dist/cjs/js/src/abstract/kraken.js +0 -9
  162. package/dist/cjs/js/src/abstract/krakenfutures.js +0 -9
  163. package/dist/cjs/js/src/abstract/kucoin.js +0 -9
  164. package/dist/cjs/js/src/abstract/kucoinfutures.js +0 -9
  165. package/dist/cjs/js/src/abstract/kuna.js +0 -9
  166. package/dist/cjs/js/src/abstract/latoken.js +0 -9
  167. package/dist/cjs/js/src/abstract/lbank.js +0 -9
  168. package/dist/cjs/js/src/abstract/luno.js +0 -9
  169. package/dist/cjs/js/src/abstract/lykke.js +0 -9
  170. package/dist/cjs/js/src/abstract/mercado.js +0 -9
  171. package/dist/cjs/js/src/abstract/mexc.js +0 -9
  172. package/dist/cjs/js/src/abstract/ndax.js +0 -9
  173. package/dist/cjs/js/src/abstract/novadax.js +0 -9
  174. package/dist/cjs/js/src/abstract/oceanex.js +0 -9
  175. package/dist/cjs/js/src/abstract/okcoin.js +0 -9
  176. package/dist/cjs/js/src/abstract/okx.js +0 -9
  177. package/dist/cjs/js/src/abstract/p2b.js +0 -9
  178. package/dist/cjs/js/src/abstract/paymium.js +0 -9
  179. package/dist/cjs/js/src/abstract/phemex.js +0 -9
  180. package/dist/cjs/js/src/abstract/poloniex.js +0 -9
  181. package/dist/cjs/js/src/abstract/poloniexfutures.js +0 -9
  182. package/dist/cjs/js/src/abstract/probit.js +0 -9
  183. package/dist/cjs/js/src/abstract/timex.js +0 -9
  184. package/dist/cjs/js/src/abstract/tokocrypto.js +0 -9
  185. package/dist/cjs/js/src/abstract/upbit.js +0 -9
  186. package/dist/cjs/js/src/abstract/wavesexchange.js +0 -9
  187. package/dist/cjs/js/src/abstract/wazirx.js +0 -9
  188. package/dist/cjs/js/src/abstract/whitebit.js +0 -9
  189. package/dist/cjs/js/src/abstract/woo.js +0 -9
  190. package/dist/cjs/js/src/abstract/yobit.js +0 -9
  191. package/dist/cjs/js/src/abstract/zaif.js +0 -9
  192. package/dist/cjs/js/src/abstract/zonda.js +0 -9
  193. package/dist/cjs/js/src/ace.js +0 -1058
  194. package/dist/cjs/js/src/alpaca.js +0 -1125
  195. package/dist/cjs/js/src/ascendex.js +0 -3365
  196. package/dist/cjs/js/src/base/Exchange.js +0 -5260
  197. package/dist/cjs/js/src/base/Precise.js +0 -263
  198. package/dist/cjs/js/src/base/errors.js +0 -299
  199. package/dist/cjs/js/src/base/functions/crypto.js +0 -78
  200. package/dist/cjs/js/src/base/functions/encode.js +0 -44
  201. package/dist/cjs/js/src/base/functions/generic.js +0 -193
  202. package/dist/cjs/js/src/base/functions/misc.js +0 -96
  203. package/dist/cjs/js/src/base/functions/number.js +0 -297
  204. package/dist/cjs/js/src/base/functions/platform.js +0 -28
  205. package/dist/cjs/js/src/base/functions/rsa.js +0 -34
  206. package/dist/cjs/js/src/base/functions/string.js +0 -48
  207. package/dist/cjs/js/src/base/functions/throttle.js +0 -66
  208. package/dist/cjs/js/src/base/functions/time.js +0 -187
  209. package/dist/cjs/js/src/base/functions/totp.js +0 -24
  210. package/dist/cjs/js/src/base/functions/type.js +0 -162
  211. package/dist/cjs/js/src/base/functions.js +0 -157
  212. package/dist/cjs/js/src/base/ws/Cache.js +0 -254
  213. package/dist/cjs/js/src/base/ws/Client.js +0 -299
  214. package/dist/cjs/js/src/base/ws/Future.js +0 -34
  215. package/dist/cjs/js/src/base/ws/OrderBook.js +0 -107
  216. package/dist/cjs/js/src/base/ws/OrderBookSide.js +0 -281
  217. package/dist/cjs/js/src/base/ws/WsClient.js +0 -69
  218. package/dist/cjs/js/src/bequant.js +0 -33
  219. package/dist/cjs/js/src/bigone.js +0 -2213
  220. package/dist/cjs/js/src/binance.js +0 -9851
  221. package/dist/cjs/js/src/binancecoinm.js +0 -45
  222. package/dist/cjs/js/src/binanceus.js +0 -92
  223. package/dist/cjs/js/src/binanceusdm.js +0 -58
  224. package/dist/cjs/js/src/bingx.js +0 -3872
  225. package/dist/cjs/js/src/bit2c.js +0 -916
  226. package/dist/cjs/js/src/bitbank.js +0 -1000
  227. package/dist/cjs/js/src/bitbay.js +0 -17
  228. package/dist/cjs/js/src/bitbns.js +0 -1220
  229. package/dist/cjs/js/src/bitcoincom.js +0 -17
  230. package/dist/cjs/js/src/bitfinex.js +0 -1670
  231. package/dist/cjs/js/src/bitfinex2.js +0 -2990
  232. package/dist/cjs/js/src/bitflyer.js +0 -1045
  233. package/dist/cjs/js/src/bitforex.js +0 -852
  234. package/dist/cjs/js/src/bitget.js +0 -8295
  235. package/dist/cjs/js/src/bithumb.js +0 -1090
  236. package/dist/cjs/js/src/bitmart.js +0 -4454
  237. package/dist/cjs/js/src/bitmex.js +0 -2881
  238. package/dist/cjs/js/src/bitopro.js +0 -1724
  239. package/dist/cjs/js/src/bitrue.js +0 -3253
  240. package/dist/cjs/js/src/bitso.js +0 -1753
  241. package/dist/cjs/js/src/bitstamp.js +0 -2188
  242. package/dist/cjs/js/src/bitteam.js +0 -2309
  243. package/dist/cjs/js/src/bitvavo.js +0 -1968
  244. package/dist/cjs/js/src/bl3p.js +0 -447
  245. package/dist/cjs/js/src/blockchaincom.js +0 -1160
  246. package/dist/cjs/js/src/btcalpha.js +0 -929
  247. package/dist/cjs/js/src/btcbox.js +0 -565
  248. package/dist/cjs/js/src/btcmarkets.js +0 -1237
  249. package/dist/cjs/js/src/btcturk.js +0 -929
  250. package/dist/cjs/js/src/bybit.js +0 -7624
  251. package/dist/cjs/js/src/cex.js +0 -1693
  252. package/dist/cjs/js/src/coinbase.js +0 -3424
  253. package/dist/cjs/js/src/coinbasepro.js +0 -1866
  254. package/dist/cjs/js/src/coincheck.js +0 -844
  255. package/dist/cjs/js/src/coinex.js +0 -5417
  256. package/dist/cjs/js/src/coinlist.js +0 -2337
  257. package/dist/cjs/js/src/coinmate.js +0 -989
  258. package/dist/cjs/js/src/coinone.js +0 -1185
  259. package/dist/cjs/js/src/coinsph.js +0 -1933
  260. package/dist/cjs/js/src/coinspot.js +0 -548
  261. package/dist/cjs/js/src/cryptocom.js +0 -3007
  262. package/dist/cjs/js/src/currencycom.js +0 -2015
  263. package/dist/cjs/js/src/delta.js +0 -3262
  264. package/dist/cjs/js/src/deribit.js +0 -3310
  265. package/dist/cjs/js/src/digifinex.js +0 -4307
  266. package/dist/cjs/js/src/exmo.js +0 -2645
  267. package/dist/cjs/js/src/fmfwio.js +0 -34
  268. package/dist/cjs/js/src/gate.js +0 -7077
  269. package/dist/cjs/js/src/gateio.js +0 -16
  270. package/dist/cjs/js/src/gemini.js +0 -1801
  271. package/dist/cjs/js/src/hitbtc.js +0 -3660
  272. package/dist/cjs/js/src/hitbtc3.js +0 -19
  273. package/dist/cjs/js/src/hollaex.js +0 -1882
  274. package/dist/cjs/js/src/htx.js +0 -9174
  275. package/dist/cjs/js/src/huobi.js +0 -16
  276. package/dist/cjs/js/src/huobijp.js +0 -1918
  277. package/dist/cjs/js/src/idex.js +0 -1770
  278. package/dist/cjs/js/src/independentreserve.js +0 -761
  279. package/dist/cjs/js/src/indodax.js +0 -1069
  280. package/dist/cjs/js/src/kraken.js +0 -2891
  281. package/dist/cjs/js/src/krakenfutures.js +0 -2407
  282. package/dist/cjs/js/src/kucoin.js +0 -4494
  283. package/dist/cjs/js/src/kucoinfutures.js +0 -2529
  284. package/dist/cjs/js/src/kuna.js +0 -1949
  285. package/dist/cjs/js/src/latoken.js +0 -1729
  286. package/dist/cjs/js/src/lbank.js +0 -2851
  287. package/dist/cjs/js/src/luno.js +0 -1044
  288. package/dist/cjs/js/src/lykke.js +0 -1303
  289. package/dist/cjs/js/src/mercado.js +0 -897
  290. package/dist/cjs/js/src/mexc.js +0 -5407
  291. package/dist/cjs/js/src/ndax.js +0 -2450
  292. package/dist/cjs/js/src/novadax.js +0 -1556
  293. package/dist/cjs/js/src/oceanex.js +0 -964
  294. package/dist/cjs/js/src/okcoin.js +0 -3115
  295. package/dist/cjs/js/src/okx.js +0 -7331
  296. package/dist/cjs/js/src/p2b.js +0 -1243
  297. package/dist/cjs/js/src/paymium.js +0 -597
  298. package/dist/cjs/js/src/phemex.js +0 -4725
  299. package/dist/cjs/js/src/poloniex.js +0 -2356
  300. package/dist/cjs/js/src/poloniexfutures.js +0 -1794
  301. package/dist/cjs/js/src/pro/alpaca.js +0 -714
  302. package/dist/cjs/js/src/pro/ascendex.js +0 -957
  303. package/dist/cjs/js/src/pro/bequant.js +0 -33
  304. package/dist/cjs/js/src/pro/binance.js +0 -2796
  305. package/dist/cjs/js/src/pro/binancecoinm.js +0 -23
  306. package/dist/cjs/js/src/pro/binanceus.js +0 -51
  307. package/dist/cjs/js/src/pro/binanceusdm.js +0 -32
  308. package/dist/cjs/js/src/pro/bingx.js +0 -944
  309. package/dist/cjs/js/src/pro/bitcoincom.js +0 -29
  310. package/dist/cjs/js/src/pro/bitfinex.js +0 -672
  311. package/dist/cjs/js/src/pro/bitfinex2.js +0 -1159
  312. package/dist/cjs/js/src/pro/bitget.js +0 -1733
  313. package/dist/cjs/js/src/pro/bitmart.js +0 -1486
  314. package/dist/cjs/js/src/pro/bitmex.js +0 -1576
  315. package/dist/cjs/js/src/pro/bitopro.js +0 -327
  316. package/dist/cjs/js/src/pro/bitrue.js +0 -462
  317. package/dist/cjs/js/src/pro/bitstamp.js +0 -547
  318. package/dist/cjs/js/src/pro/bitvavo.js +0 -704
  319. package/dist/cjs/js/src/pro/blockchaincom.js +0 -794
  320. package/dist/cjs/js/src/pro/bybit.js +0 -1843
  321. package/dist/cjs/js/src/pro/cex.js +0 -1510
  322. package/dist/cjs/js/src/pro/coinbase.js +0 -561
  323. package/dist/cjs/js/src/pro/coinbasepro.js +0 -968
  324. package/dist/cjs/js/src/pro/coinex.js +0 -1095
  325. package/dist/cjs/js/src/pro/cryptocom.js +0 -1020
  326. package/dist/cjs/js/src/pro/currencycom.js +0 -563
  327. package/dist/cjs/js/src/pro/deribit.js +0 -825
  328. package/dist/cjs/js/src/pro/exmo.js +0 -658
  329. package/dist/cjs/js/src/pro/gate.js +0 -1316
  330. package/dist/cjs/js/src/pro/gateio.js +0 -16
  331. package/dist/cjs/js/src/pro/gemini.js +0 -649
  332. package/dist/cjs/js/src/pro/hitbtc.js +0 -1294
  333. package/dist/cjs/js/src/pro/hollaex.js +0 -597
  334. package/dist/cjs/js/src/pro/htx.js +0 -2388
  335. package/dist/cjs/js/src/pro/huobi.js +0 -16
  336. package/dist/cjs/js/src/pro/huobijp.js +0 -606
  337. package/dist/cjs/js/src/pro/idex.js +0 -714
  338. package/dist/cjs/js/src/pro/independentreserve.js +0 -280
  339. package/dist/cjs/js/src/pro/kraken.js +0 -1364
  340. package/dist/cjs/js/src/pro/krakenfutures.js +0 -1506
  341. package/dist/cjs/js/src/pro/kucoin.js +0 -1062
  342. package/dist/cjs/js/src/pro/kucoinfutures.js +0 -989
  343. package/dist/cjs/js/src/pro/luno.js +0 -322
  344. package/dist/cjs/js/src/pro/mexc.js +0 -1170
  345. package/dist/cjs/js/src/pro/ndax.js +0 -545
  346. package/dist/cjs/js/src/pro/okcoin.js +0 -760
  347. package/dist/cjs/js/src/pro/okx.js +0 -1608
  348. package/dist/cjs/js/src/pro/phemex.js +0 -1511
  349. package/dist/cjs/js/src/pro/poloniex.js +0 -1253
  350. package/dist/cjs/js/src/pro/poloniexfutures.js +0 -1022
  351. package/dist/cjs/js/src/pro/probit.js +0 -586
  352. package/dist/cjs/js/src/pro/upbit.js +0 -234
  353. package/dist/cjs/js/src/pro/wazirx.js +0 -776
  354. package/dist/cjs/js/src/pro/whitebit.js +0 -927
  355. package/dist/cjs/js/src/pro/woo.js +0 -895
  356. package/dist/cjs/js/src/probit.js +0 -1867
  357. package/dist/cjs/js/src/static_dependencies/fflake/browser.js +0 -401
  358. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +0 -195
  359. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +0 -308
  360. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +0 -554
  361. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +0 -94
  362. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +0 -70
  363. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +0 -91
  364. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +0 -16
  365. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +0 -1760
  366. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +0 -52
  367. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +0 -81
  368. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +0 -376
  369. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +0 -70
  370. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +0 -1580
  371. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +0 -74
  372. package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +0 -24
  373. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +0 -158
  374. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +0 -429
  375. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +0 -176
  376. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +0 -324
  377. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +0 -163
  378. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +0 -245
  379. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +0 -1018
  380. package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +0 -383
  381. package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +0 -258
  382. package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +0 -53
  383. package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +0 -120
  384. package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +0 -69
  385. package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +0 -7
  386. package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +0 -83
  387. package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +0 -240
  388. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +0 -91
  389. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +0 -130
  390. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +0 -214
  391. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +0 -239
  392. package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +0 -93
  393. package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +0 -354
  394. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +0 -16
  395. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +0 -20
  396. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +0 -30
  397. package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +0 -239
  398. package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +0 -372
  399. package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +0 -273
  400. package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +0 -139
  401. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +0 -14
  402. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +0 -16
  403. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +0 -81
  404. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +0 -292
  405. package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +0 -103
  406. package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +0 -140
  407. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +0 -175
  408. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +0 -95
  409. package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +0 -7
  410. package/dist/cjs/js/src/static_dependencies/scure-base/index.js +0 -383
  411. package/dist/cjs/js/src/timex.js +0 -1562
  412. package/dist/cjs/js/src/tokocrypto.js +0 -2542
  413. package/dist/cjs/js/src/upbit.js +0 -1844
  414. package/dist/cjs/js/src/wavesexchange.js +0 -2607
  415. package/dist/cjs/js/src/wazirx.js +0 -953
  416. package/dist/cjs/js/src/whitebit.js +0 -2310
  417. package/dist/cjs/js/src/woo.js +0 -2769
  418. package/dist/cjs/js/src/yobit.js +0 -1314
  419. package/dist/cjs/js/src/zaif.js +0 -736
  420. package/dist/cjs/js/src/zonda.js +0 -1883
  421. package/dist/cjs/src/abstract/bitpanda.js +0 -9
  422. package/test.ts +0 -0
  423. /package/dist/cjs/{js/src/abstract/ace.js → src/abstract/onetrading.js} +0 -0
  424. /package/dist/cjs/{js/src → src}/pro/coincheck.js +0 -0
  425. /package/dist/cjs/{js/src → src}/pro/coinone.js +0 -0
  426. /package/js/src/abstract/{bitpanda.js → onetrading.js} +0 -0
@@ -1,3262 +0,0 @@
1
- 'use strict';
2
-
3
- var delta$1 = require('./abstract/delta.js');
4
- var errors = require('./base/errors.js');
5
- var number = require('./base/functions/number.js');
6
- var Precise = require('./base/Precise.js');
7
- var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
8
-
9
- // ---------------------------------------------------------------------------
10
- // ---------------------------------------------------------------------------
11
- /**
12
- * @class delta
13
- * @augments Exchange
14
- */
15
- class delta extends delta$1 {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'delta',
19
- 'name': 'Delta Exchange',
20
- 'countries': ['VC'],
21
- 'rateLimit': 300,
22
- 'version': 'v2',
23
- // new metainfo interface
24
- 'has': {
25
- 'CORS': undefined,
26
- 'spot': true,
27
- 'margin': false,
28
- 'swap': true,
29
- 'future': false,
30
- 'option': true,
31
- 'addMargin': true,
32
- 'cancelAllOrders': true,
33
- 'cancelOrder': true,
34
- 'closeAllPositions': true,
35
- 'closePosition': false,
36
- 'createOrder': true,
37
- 'createReduceOnlyOrder': true,
38
- 'editOrder': true,
39
- 'fetchBalance': true,
40
- 'fetchClosedOrders': true,
41
- 'fetchCurrencies': true,
42
- 'fetchDeposit': undefined,
43
- 'fetchDepositAddress': true,
44
- 'fetchDeposits': undefined,
45
- 'fetchFundingHistory': false,
46
- 'fetchFundingRate': true,
47
- 'fetchFundingRateHistory': false,
48
- 'fetchFundingRates': true,
49
- 'fetchGreeks': true,
50
- 'fetchIndexOHLCV': true,
51
- 'fetchLedger': true,
52
- 'fetchLeverage': true,
53
- 'fetchLeverageTiers': false,
54
- 'fetchMarginMode': false,
55
- 'fetchMarketLeverageTiers': false,
56
- 'fetchMarkets': true,
57
- 'fetchMarkOHLCV': true,
58
- 'fetchMySettlementHistory': false,
59
- 'fetchMyTrades': true,
60
- 'fetchOHLCV': true,
61
- 'fetchOpenInterest': true,
62
- 'fetchOpenOrders': true,
63
- 'fetchOrderBook': true,
64
- 'fetchPosition': true,
65
- 'fetchPositionMode': false,
66
- 'fetchPositions': true,
67
- 'fetchPremiumIndexOHLCV': false,
68
- 'fetchSettlementHistory': true,
69
- 'fetchStatus': true,
70
- 'fetchTicker': true,
71
- 'fetchTickers': true,
72
- 'fetchTime': true,
73
- 'fetchTrades': true,
74
- 'fetchTransfer': undefined,
75
- 'fetchTransfers': undefined,
76
- 'fetchUnderlyingAssets': false,
77
- 'fetchVolatilityHistory': false,
78
- 'fetchWithdrawal': undefined,
79
- 'fetchWithdrawals': undefined,
80
- 'reduceMargin': true,
81
- 'setLeverage': true,
82
- 'setMargin': false,
83
- 'setMarginMode': false,
84
- 'setPositionMode': false,
85
- 'transfer': false,
86
- 'withdraw': false,
87
- },
88
- 'timeframes': {
89
- '1m': '1m',
90
- '3m': '3m',
91
- '5m': '5m',
92
- '15m': '15m',
93
- '30m': '30m',
94
- '1h': '1h',
95
- '2h': '2h',
96
- '4h': '4h',
97
- '6h': '6h',
98
- '1d': '1d',
99
- '7d': '7d',
100
- '1w': '1w',
101
- '2w': '2w',
102
- '1M': '30d',
103
- },
104
- 'urls': {
105
- 'logo': 'https://user-images.githubusercontent.com/1294454/99450025-3be60a00-2931-11eb-9302-f4fd8d8589aa.jpg',
106
- 'test': {
107
- 'public': 'https://testnet-api.delta.exchange',
108
- 'private': 'https://testnet-api.delta.exchange',
109
- },
110
- 'api': {
111
- 'public': 'https://api.delta.exchange',
112
- 'private': 'https://api.delta.exchange',
113
- },
114
- 'www': 'https://www.delta.exchange',
115
- 'doc': [
116
- 'https://docs.delta.exchange',
117
- ],
118
- 'fees': 'https://www.delta.exchange/fees',
119
- 'referral': 'https://www.delta.exchange/app/signup/?code=IULYNB',
120
- },
121
- 'api': {
122
- 'public': {
123
- 'get': [
124
- 'assets',
125
- 'indices',
126
- 'products',
127
- 'products/{symbol}',
128
- 'tickers',
129
- 'tickers/{symbol}',
130
- 'l2orderbook/{symbol}',
131
- 'trades/{symbol}',
132
- 'stats',
133
- 'history/candles',
134
- 'history/sparklines',
135
- 'settings',
136
- ],
137
- },
138
- 'private': {
139
- 'get': [
140
- 'orders',
141
- 'products/{product_id}/orders/leverage',
142
- 'positions/margined',
143
- 'positions',
144
- 'orders/history',
145
- 'fills',
146
- 'fills/history/download/csv',
147
- 'wallet/balances',
148
- 'wallet/transactions',
149
- 'wallet/transactions/download',
150
- 'wallets/sub_accounts_transfer_history',
151
- 'users/trading_preferences',
152
- 'sub_accounts',
153
- 'profile',
154
- 'deposits/address',
155
- 'orders/leverage',
156
- ],
157
- 'post': [
158
- 'orders',
159
- 'orders/bracket',
160
- 'orders/batch',
161
- 'products/{product_id}/orders/leverage',
162
- 'positions/change_margin',
163
- 'positions/close_all',
164
- 'wallets/sub_account_balance_transfer',
165
- 'orders/cancel_after',
166
- 'orders/leverage',
167
- ],
168
- 'put': [
169
- 'orders',
170
- 'orders/bracket',
171
- 'orders/batch',
172
- 'positions/auto_topup',
173
- 'users/update_mmp',
174
- 'users/reset_mmp',
175
- ],
176
- 'delete': [
177
- 'orders',
178
- 'orders/all',
179
- 'orders/batch',
180
- ],
181
- },
182
- },
183
- 'fees': {
184
- 'trading': {
185
- 'tierBased': true,
186
- 'percentage': true,
187
- 'taker': this.parseNumber('0.0015'),
188
- 'maker': this.parseNumber('0.0010'),
189
- 'tiers': {
190
- 'taker': [
191
- [this.parseNumber('0'), this.parseNumber('0.0015')],
192
- [this.parseNumber('100'), this.parseNumber('0.0013')],
193
- [this.parseNumber('250'), this.parseNumber('0.0013')],
194
- [this.parseNumber('1000'), this.parseNumber('0.001')],
195
- [this.parseNumber('5000'), this.parseNumber('0.0009')],
196
- [this.parseNumber('10000'), this.parseNumber('0.00075')],
197
- [this.parseNumber('20000'), this.parseNumber('0.00065')],
198
- ],
199
- 'maker': [
200
- [this.parseNumber('0'), this.parseNumber('0.001')],
201
- [this.parseNumber('100'), this.parseNumber('0.001')],
202
- [this.parseNumber('250'), this.parseNumber('0.0009')],
203
- [this.parseNumber('1000'), this.parseNumber('0.00075')],
204
- [this.parseNumber('5000'), this.parseNumber('0.0006')],
205
- [this.parseNumber('10000'), this.parseNumber('0.0005')],
206
- [this.parseNumber('20000'), this.parseNumber('0.0005')],
207
- ],
208
- },
209
- },
210
- },
211
- 'options': {
212
- 'networks': {
213
- 'TRC20': 'TRC20(TRON)',
214
- 'BEP20': 'BEP20(BSC)',
215
- },
216
- },
217
- 'precisionMode': number.TICK_SIZE,
218
- 'requiredCredentials': {
219
- 'apiKey': true,
220
- 'secret': true,
221
- },
222
- 'exceptions': {
223
- 'exact': {
224
- // Margin required to place order with selected leverage and quantity is insufficient.
225
- 'insufficient_margin': errors.InsufficientFunds,
226
- 'order_size_exceed_available': errors.InvalidOrder,
227
- 'risk_limits_breached': errors.BadRequest,
228
- 'invalid_contract': errors.BadSymbol,
229
- 'immediate_liquidation': errors.InvalidOrder,
230
- 'out_of_bankruptcy': errors.InvalidOrder,
231
- 'self_matching_disrupted_post_only': errors.InvalidOrder,
232
- 'immediate_execution_post_only': errors.InvalidOrder,
233
- 'bad_schema': errors.BadRequest,
234
- 'invalid_api_key': errors.AuthenticationError,
235
- 'invalid_signature': errors.AuthenticationError,
236
- 'open_order_not_found': errors.OrderNotFound,
237
- 'unavailable': errors.ExchangeNotAvailable, // {"error":{"code":"unavailable"},"success":false}
238
- },
239
- 'broad': {},
240
- },
241
- });
242
- }
243
- convertExpireDate(date) {
244
- // parse YYMMDD to timestamp
245
- const year = date.slice(0, 2);
246
- const month = date.slice(2, 4);
247
- const day = date.slice(4, 6);
248
- const reconstructedDate = '20' + year + '-' + month + '-' + day + 'T00:00:00Z';
249
- return reconstructedDate;
250
- }
251
- createExpiredOptionMarket(symbol) {
252
- // support expired option contracts
253
- const quote = 'USDT';
254
- const optionParts = symbol.split('-');
255
- const symbolBase = symbol.split('/');
256
- let base = undefined;
257
- let expiry = undefined;
258
- let optionType = undefined;
259
- if (symbol.indexOf('/') > -1) {
260
- base = this.safeString(symbolBase, 0);
261
- expiry = this.safeString(optionParts, 1);
262
- optionType = this.safeString(optionParts, 3);
263
- }
264
- else {
265
- base = this.safeString(optionParts, 1);
266
- expiry = this.safeString(optionParts, 3);
267
- optionType = this.safeString(optionParts, 0);
268
- }
269
- const settle = quote;
270
- const strike = this.safeString(optionParts, 2);
271
- const datetime = this.convertExpireDate(expiry);
272
- const timestamp = this.parse8601(datetime);
273
- return {
274
- 'id': optionType + '-' + base + '-' + strike + '-' + expiry,
275
- 'symbol': base + '/' + quote + ':' + settle + '-' + expiry + '-' + strike + '-' + optionType,
276
- 'base': base,
277
- 'quote': quote,
278
- 'settle': settle,
279
- 'baseId': base,
280
- 'quoteId': quote,
281
- 'settleId': settle,
282
- 'active': false,
283
- 'type': 'option',
284
- 'linear': undefined,
285
- 'inverse': undefined,
286
- 'spot': false,
287
- 'swap': false,
288
- 'future': false,
289
- 'option': true,
290
- 'margin': false,
291
- 'contract': true,
292
- 'contractSize': this.parseNumber('1'),
293
- 'expiry': timestamp,
294
- 'expiryDatetime': datetime,
295
- 'optionType': (optionType === 'C') ? 'call' : 'put',
296
- 'strike': this.parseNumber(strike),
297
- 'precision': {
298
- 'amount': undefined,
299
- 'price': undefined,
300
- },
301
- 'limits': {
302
- 'amount': {
303
- 'min': undefined,
304
- 'max': undefined,
305
- },
306
- 'price': {
307
- 'min': undefined,
308
- 'max': undefined,
309
- },
310
- 'cost': {
311
- 'min': undefined,
312
- 'max': undefined,
313
- },
314
- },
315
- 'info': undefined,
316
- };
317
- }
318
- market(symbol) {
319
- if (this.markets === undefined) {
320
- throw new errors.ExchangeError(this.id + ' markets not loaded');
321
- }
322
- if (typeof symbol === 'string') {
323
- if (symbol in this.markets) {
324
- return this.markets[symbol];
325
- }
326
- else if (symbol in this.markets_by_id) {
327
- const markets = this.markets_by_id[symbol];
328
- return markets[0];
329
- }
330
- else if ((symbol.endsWith('-C')) || (symbol.endsWith('-P')) || (symbol.startsWith('C-')) || (symbol.startsWith('P-'))) {
331
- return this.createExpiredOptionMarket(symbol);
332
- }
333
- }
334
- throw new errors.BadSymbol(this.id + ' does not have market symbol ' + symbol);
335
- }
336
- safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
337
- const isOption = (marketId !== undefined) && ((marketId.endsWith('-C')) || (marketId.endsWith('-P')) || (marketId.startsWith('C-')) || (marketId.startsWith('P-')));
338
- if (isOption && !(marketId in this.markets_by_id)) {
339
- // handle expired option contracts
340
- return this.createExpiredOptionMarket(marketId);
341
- }
342
- return super.safeMarket(marketId, market, delimiter, marketType);
343
- }
344
- async fetchTime(params = {}) {
345
- /**
346
- * @method
347
- * @name delta#fetchTime
348
- * @description fetches the current integer timestamp in milliseconds from the exchange server
349
- * @param {object} [params] extra parameters specific to the exchange API endpoint
350
- * @returns {int} the current integer timestamp in milliseconds from the exchange server
351
- */
352
- const response = await this.publicGetSettings(params);
353
- // full response sample under `fetchStatus`
354
- const result = this.safeValue(response, 'result', {});
355
- return this.safeIntegerProduct(result, 'server_time', 0.001);
356
- }
357
- async fetchStatus(params = {}) {
358
- /**
359
- * @method
360
- * @name delta#fetchStatus
361
- * @description the latest known information on the availability of the exchange API
362
- * @param {object} [params] extra parameters specific to the exchange API endpoint
363
- * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
364
- */
365
- const response = await this.publicGetSettings(params);
366
- //
367
- // {
368
- // "result": {
369
- // "deto_liquidity_mining_daily_reward": "40775",
370
- // "deto_msp": "1.0",
371
- // "deto_staking_daily_reward": "23764.08",
372
- // "enabled_wallets": [
373
- // "BTC",
374
- // ...
375
- // ],
376
- // "portfolio_margin_params": {
377
- // "enabled_portfolios": {
378
- // ".DEAVAXUSDT": {
379
- // "asset_id": 5,
380
- // "futures_contingency_margin_percent": "1",
381
- // "interest_rate": "0",
382
- // "maintenance_margin_multiplier": "0.8",
383
- // "max_price_shock": "20",
384
- // "max_short_notional_limit": "2000",
385
- // "options_contingency_margin_percent": "1",
386
- // "options_discount_range": "10",
387
- // "options_liq_band_range_percentage": "25",
388
- // "settling_asset": "USDT",
389
- // "sort_priority": 5,
390
- // "underlying_asset": "AVAX",
391
- // "volatility_down_shock": "30",
392
- // "volatility_up_shock": "45"
393
- // },
394
- // ...
395
- // },
396
- // "portfolio_enabled_contracts": [
397
- // "futures",
398
- // "perpetual_futures",
399
- // "call_options",
400
- // "put_options"
401
- // ]
402
- // },
403
- // "server_time": 1650640673500273,
404
- // "trade_farming_daily_reward": "100000",
405
- // "circulating_supply": "140000000",
406
- // "circulating_supply_update_time": "1636752800",
407
- // "deto_referral_mining_daily_reward": "0",
408
- // "deto_total_reward_pool": "100000000",
409
- // "deto_trade_mining_daily_reward": "0",
410
- // "kyc_deposit_limit": "20",
411
- // "kyc_withdrawal_limit": "10000",
412
- // "maintenance_start_time": "1650387600000000",
413
- // "msp_deto_commission_percent": "25",
414
- // "under_maintenance": "false"
415
- // },
416
- // "success": true
417
- // }
418
- //
419
- const result = this.safeValue(response, 'result', {});
420
- const underMaintenance = this.safeString(result, 'under_maintenance');
421
- const status = (underMaintenance === 'true') ? 'maintenance' : 'ok';
422
- const updated = this.safeIntegerProduct(result, 'server_time', 0.001, this.milliseconds());
423
- return {
424
- 'status': status,
425
- 'updated': updated,
426
- 'eta': undefined,
427
- 'url': undefined,
428
- 'info': response,
429
- };
430
- }
431
- async fetchCurrencies(params = {}) {
432
- /**
433
- * @method
434
- * @name delta#fetchCurrencies
435
- * @description fetches all available currencies on an exchange
436
- * @see https://docs.delta.exchange/#get-list-of-all-assets
437
- * @param {object} [params] extra parameters specific to the exchange API endpoint
438
- * @returns {object} an associative dictionary of currencies
439
- */
440
- const response = await this.publicGetAssets(params);
441
- //
442
- // {
443
- // "result":[
444
- // {
445
- // "base_withdrawal_fee":"0.0005",
446
- // "deposit_status":"enabled",
447
- // "id":2,
448
- // "interest_credit":true,
449
- // "interest_slabs":[
450
- // {"limit":"0.1","rate":"0"},
451
- // {"limit":"1","rate":"0.05"},
452
- // {"limit":"5","rate":"0.075"},
453
- // {"limit":"10","rate":"0.1"},
454
- // {"limit":"9999999999999999","rate":"0"}
455
- // ],
456
- // "kyc_deposit_limit":"10",
457
- // "kyc_withdrawal_limit":"2",
458
- // "min_withdrawal_amount":"0.001",
459
- // "minimum_precision":4,
460
- // "name":"Bitcoin",
461
- // "precision":8,
462
- // "sort_priority":1,
463
- // "symbol":"BTC",
464
- // "variable_withdrawal_fee":"0",
465
- // "withdrawal_status":"enabled"
466
- // },
467
- // ],
468
- // "success":true
469
- // }
470
- //
471
- const currencies = this.safeValue(response, 'result', []);
472
- const result = {};
473
- for (let i = 0; i < currencies.length; i++) {
474
- const currency = currencies[i];
475
- const id = this.safeString(currency, 'symbol');
476
- const numericId = this.safeInteger(currency, 'id');
477
- const code = this.safeCurrencyCode(id);
478
- const depositStatus = this.safeString(currency, 'deposit_status');
479
- const withdrawalStatus = this.safeString(currency, 'withdrawal_status');
480
- const depositsEnabled = (depositStatus === 'enabled');
481
- const withdrawalsEnabled = (withdrawalStatus === 'enabled');
482
- const active = depositsEnabled && withdrawalsEnabled;
483
- result[code] = {
484
- 'id': id,
485
- 'numericId': numericId,
486
- 'code': code,
487
- 'name': this.safeString(currency, 'name'),
488
- 'info': currency,
489
- 'active': active,
490
- 'deposit': depositsEnabled,
491
- 'withdraw': withdrawalsEnabled,
492
- 'fee': this.safeNumber(currency, 'base_withdrawal_fee'),
493
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'precision'))),
494
- 'limits': {
495
- 'amount': { 'min': undefined, 'max': undefined },
496
- 'withdraw': {
497
- 'min': this.safeNumber(currency, 'min_withdrawal_amount'),
498
- 'max': undefined,
499
- },
500
- },
501
- 'networks': {},
502
- };
503
- }
504
- return result;
505
- }
506
- async loadMarkets(reload = false, params = {}) {
507
- const markets = await super.loadMarkets(reload, params);
508
- const currenciesByNumericId = this.safeValue(this.options, 'currenciesByNumericId');
509
- if ((currenciesByNumericId === undefined) || reload) {
510
- this.options['currenciesByNumericId'] = this.indexBy(this.currencies, 'numericId');
511
- }
512
- const marketsByNumericId = this.safeValue(this.options, 'marketsByNumericId');
513
- if ((marketsByNumericId === undefined) || reload) {
514
- this.options['marketsByNumericId'] = this.indexBy(this.markets, 'numericId');
515
- }
516
- return markets;
517
- }
518
- async fetchMarkets(params = {}) {
519
- /**
520
- * @method
521
- * @name delta#fetchMarkets
522
- * @description retrieves data on all markets for delta
523
- * @see https://docs.delta.exchange/#get-list-of-products
524
- * @param {object} [params] extra parameters specific to the exchange API endpoint
525
- * @returns {object[]} an array of objects representing market data
526
- */
527
- const response = await this.publicGetProducts(params);
528
- //
529
- // {
530
- // "meta":{ "after":null, "before":null, "limit":100, "total_count":81 },
531
- // "result":[
532
- // // the below response represents item from perpetual market
533
- // {
534
- // "annualized_funding":"5.475000000000000000",
535
- // "is_quanto":false,
536
- // "ui_config":{
537
- // "default_trading_view_candle":"15",
538
- // "leverage_slider_values":[1,3,5,10,25,50],
539
- // "price_clubbing_values":[0.001,0.005,0.05,0.1,0.5,1,5],
540
- // "show_bracket_orders":false,
541
- // "sort_priority":29,
542
- // "tags":[]
543
- // },
544
- // "basis_factor_max_limit":"0.15",
545
- // "symbol":"P-LINK-D-151120",
546
- // "id":1584,
547
- // "default_leverage":"5.000000000000000000",
548
- // "maker_commission_rate":"0.0005",
549
- // "contract_unit_currency":"LINK",
550
- // "strike_price":"12.507948",
551
- // "settling_asset":{
552
- // // asset structure
553
- // },
554
- // "auction_start_time":null,
555
- // "auction_finish_time":null,
556
- // "settlement_time":"2020-11-15T12:00:00Z",
557
- // "launch_time":"2020-11-14T11:55:05Z",
558
- // "spot_index":{
559
- // // index structure
560
- // },
561
- // "trading_status":"operational",
562
- // "tick_size":"0.001",
563
- // "position_size_limit":100000,
564
- // "notional_type":"vanilla", // vanilla, inverse
565
- // "price_band":"0.4",
566
- // "barrier_price":null,
567
- // "description":"Daily LINK PUT options quoted in USDT and settled in USDT",
568
- // "insurance_fund_margin_contribution":"1",
569
- // "quoting_asset":{
570
- // // asset structure
571
- // },
572
- // "liquidation_penalty_factor":"0.2",
573
- // "product_specs":{"max_volatility":3,"min_volatility":0.3,"spot_price_band":"0.40"},
574
- // "initial_margin_scaling_factor":"0.0001",
575
- // "underlying_asset":{
576
- // // asset structure
577
- // },
578
- // "state":"live",
579
- // "contract_value":"1",
580
- // "initial_margin":"2",
581
- // "impact_size":5000,
582
- // "settlement_price":null,
583
- // "contract_type":"put_options", // put_options, call_options, move_options, perpetual_futures, interest_rate_swaps, futures, spreads
584
- // "taker_commission_rate":"0.0005",
585
- // "maintenance_margin":"1",
586
- // "short_description":"LINK Daily PUT Options",
587
- // "maintenance_margin_scaling_factor":"0.00005",
588
- // "funding_method":"mark_price",
589
- // "max_leverage_notional":"20000"
590
- // },
591
- // // the below response represents item from spot market
592
- // {
593
- // "position_size_limit": 10000000,
594
- // "settlement_price": null,
595
- // "funding_method": "mark_price",
596
- // "settling_asset": null,
597
- // "impact_size": 10,
598
- // "id": 32258,
599
- // "auction_finish_time": null,
600
- // "description": "Solana tether spot market",
601
- // "trading_status": "operational",
602
- // "tick_size": "0.01",
603
- // "liquidation_penalty_factor": "1",
604
- // "spot_index": {
605
- // "config": { "quoting_asset": "USDT", "service_id": 8, "underlying_asset": "SOL" },
606
- // "constituent_exchanges": [
607
- // { "exchange": "binance", "health_interval": 60, "health_priority": 1, "weight": 1 },
608
- // { "exchange": "huobi", "health_interval": 60, "health_priority": 2, "weight": 1 }
609
- // ],
610
- // "constituent_indices": null,
611
- // "description": "Solana index from binance and huobi",
612
- // "health_interval": 300,
613
- // "id": 105,
614
- // "impact_size": "40.000000000000000000",
615
- // "index_type": "spot_pair",
616
- // "is_composite": false,
617
- // "price_method": "ltp",
618
- // "quoting_asset_id": 5,
619
- // "symbol": ".DESOLUSDT",
620
- // "tick_size": "0.000100000000000000",
621
- // "underlying_asset_id": 66
622
- // },
623
- // "contract_type": "spot",
624
- // "launch_time": "2022-02-03T10:18:11Z",
625
- // "symbol": "SOL_USDT",
626
- // "disruption_reason": null,
627
- // "settlement_time": null,
628
- // "insurance_fund_margin_contribution": "1",
629
- // "is_quanto": false,
630
- // "maintenance_margin": "5",
631
- // "taker_commission_rate": "0.0005",
632
- // "auction_start_time": null,
633
- // "max_leverage_notional": "10000000",
634
- // "state": "live",
635
- // "annualized_funding": "0",
636
- // "notional_type": "vanilla",
637
- // "price_band": "100",
638
- // "product_specs": { "kyc_required": false, "max_order_size": 2000, "min_order_size": 0.01, "quoting_precision": 4, "underlying_precision": 2 },
639
- // "default_leverage": "1.000000000000000000",
640
- // "initial_margin": "10",
641
- // "maintenance_margin_scaling_factor": "1",
642
- // "ui_config": {
643
- // "default_trading_view_candle": "1d",
644
- // "leverage_slider_values": [],
645
- // "price_clubbing_values": [ 0.01, 0.05, 0.1, 0.5, 1, 2.5, 5 ],
646
- // "show_bracket_orders": false,
647
- // "sort_priority": 2,
648
- // "tags": []
649
- // },
650
- // "basis_factor_max_limit": "10000",
651
- // "contract_unit_currency": "SOL",
652
- // "strike_price": null,
653
- // "quoting_asset": {
654
- // "base_withdrawal_fee": "10.000000000000000000",
655
- // "deposit_status": "enabled",
656
- // "id": 5,
657
- // "interest_credit": false,
658
- // "interest_slabs": null,
659
- // "kyc_deposit_limit": "100000.000000000000000000",
660
- // "kyc_withdrawal_limit": "10000.000000000000000000",
661
- // "min_withdrawal_amount": "30.000000000000000000",
662
- // "minimum_precision": 2,
663
- // "name": "Tether",
664
- // "networks": [
665
- // { "base_withdrawal_fee": "25", "deposit_status": "enabled", "memo_required": false, "network": "ERC20", "variable_withdrawal_fee": "0", "withdrawal_status": "enabled" },
666
- // { "base_withdrawal_fee": "1", "deposit_status": "enabled", "memo_required": false, "network": "BEP20(BSC)", "variable_withdrawal_fee": "0", "withdrawal_status": "enabled" },
667
- // { "base_withdrawal_fee": "1", "deposit_status": "disabled", "memo_required": false, "network": "TRC20(TRON)", "variable_withdrawal_fee": "0", "withdrawal_status": "disabled" }
668
- // ],
669
- // "precision": 8,
670
- // "sort_priority": 1,
671
- // "symbol": "USDT",
672
- // "variable_withdrawal_fee": "0.000000000000000000",
673
- // "withdrawal_status": "enabled"
674
- // },
675
- // "maker_commission_rate": "0.0005",
676
- // "initial_margin_scaling_factor": "2",
677
- // "underlying_asset": {
678
- // "base_withdrawal_fee": "0.000000000000000000",
679
- // "deposit_status": "enabled",
680
- // "id": 66,
681
- // "interest_credit": false,
682
- // "interest_slabs": null,
683
- // "kyc_deposit_limit": "0.000000000000000000",
684
- // "kyc_withdrawal_limit": "0.000000000000000000",
685
- // "min_withdrawal_amount": "0.020000000000000000",
686
- // "minimum_precision": 4,
687
- // "name": "Solana",
688
- // "networks": [
689
- // { "base_withdrawal_fee": "0.01", "deposit_status": "enabled", "memo_required": false, "network": "SOLANA", "variable_withdrawal_fee": "0", "withdrawal_status": "enabled" },
690
- // { "base_withdrawal_fee": "0.01", "deposit_status": "enabled", "memo_required": false, "network": "BEP20(BSC)", "variable_withdrawal_fee": "0", "withdrawal_status": "enabled" }
691
- // ],
692
- // "precision": 8,
693
- // "sort_priority": 7,
694
- // "symbol": "SOL",
695
- // "variable_withdrawal_fee": "0.000000000000000000",
696
- // "withdrawal_status": "enabled"
697
- // },
698
- // "barrier_price": null,
699
- // "contract_value": "1",
700
- // "short_description": "SOL-USDT spot market"
701
- // },
702
- // ],
703
- // "success":true
704
- // }
705
- //
706
- const markets = this.safeValue(response, 'result', []);
707
- const result = [];
708
- for (let i = 0; i < markets.length; i++) {
709
- const market = markets[i];
710
- let type = this.safeString(market, 'contract_type');
711
- if (type === 'options_combos') {
712
- continue;
713
- }
714
- // const settlingAsset = this.safeValue (market, 'settling_asset', {});
715
- const quotingAsset = this.safeValue(market, 'quoting_asset', {});
716
- const underlyingAsset = this.safeValue(market, 'underlying_asset', {});
717
- const settlingAsset = this.safeValue(market, 'settling_asset');
718
- const productSpecs = this.safeValue(market, 'product_specs', {});
719
- const baseId = this.safeString(underlyingAsset, 'symbol');
720
- const quoteId = this.safeString(quotingAsset, 'symbol');
721
- const settleId = this.safeString(settlingAsset, 'symbol');
722
- const id = this.safeString(market, 'symbol');
723
- const numericId = this.safeInteger(market, 'id');
724
- const base = this.safeCurrencyCode(baseId);
725
- const quote = this.safeCurrencyCode(quoteId);
726
- const settle = this.safeCurrencyCode(settleId);
727
- const callOptions = (type === 'call_options');
728
- const putOptions = (type === 'put_options');
729
- const moveOptions = (type === 'move_options');
730
- const spot = (type === 'spot');
731
- const swap = (type === 'perpetual_futures');
732
- const future = (type === 'futures');
733
- const option = (callOptions || putOptions || moveOptions);
734
- const strike = this.safeString(market, 'strike_price');
735
- const expiryDatetime = this.safeString(market, 'settlement_time');
736
- const expiry = this.parse8601(expiryDatetime);
737
- const contractSize = this.safeNumber(market, 'contract_value');
738
- let amountPrecision = undefined;
739
- if (spot) {
740
- amountPrecision = this.parseNumber(this.parsePrecision(this.safeString(productSpecs, 'underlying_precision'))); // seems inverse of 'impact_size'
741
- }
742
- else {
743
- // other markets (swap, futures, move, spread, irs) seem to use the step of '1' contract
744
- amountPrecision = this.parseNumber('1');
745
- }
746
- const linear = (settle === base);
747
- let optionType = undefined;
748
- let symbol = base + '/' + quote;
749
- if (swap || future || option) {
750
- symbol = symbol + ':' + settle;
751
- if (future || option) {
752
- symbol = symbol + '-' + this.yymmdd(expiry);
753
- if (option) {
754
- type = 'option';
755
- let letter = 'C';
756
- optionType = 'call';
757
- if (putOptions) {
758
- letter = 'P';
759
- optionType = 'put';
760
- }
761
- else if (moveOptions) {
762
- letter = 'M';
763
- optionType = 'move';
764
- }
765
- symbol = symbol + '-' + strike + '-' + letter;
766
- }
767
- else {
768
- type = 'future';
769
- }
770
- }
771
- else {
772
- type = 'swap';
773
- }
774
- }
775
- const state = this.safeString(market, 'state');
776
- result.push({
777
- 'id': id,
778
- 'numericId': numericId,
779
- 'symbol': symbol,
780
- 'base': base,
781
- 'quote': quote,
782
- 'settle': settle,
783
- 'baseId': baseId,
784
- 'quoteId': quoteId,
785
- 'settleId': settleId,
786
- 'type': type,
787
- 'spot': spot,
788
- 'margin': spot ? undefined : false,
789
- 'swap': swap,
790
- 'future': future,
791
- 'option': option,
792
- 'active': (state === 'live'),
793
- 'contract': !spot,
794
- 'linear': spot ? undefined : linear,
795
- 'inverse': spot ? undefined : !linear,
796
- 'taker': this.safeNumber(market, 'taker_commission_rate'),
797
- 'maker': this.safeNumber(market, 'maker_commission_rate'),
798
- 'contractSize': contractSize,
799
- 'expiry': expiry,
800
- 'expiryDatetime': expiryDatetime,
801
- 'strike': this.parseNumber(strike),
802
- 'optionType': optionType,
803
- 'precision': {
804
- 'amount': amountPrecision,
805
- 'price': this.safeNumber(market, 'tick_size'),
806
- },
807
- 'limits': {
808
- 'leverage': {
809
- 'min': undefined,
810
- 'max': undefined,
811
- },
812
- 'amount': {
813
- 'min': this.parseNumber('1'),
814
- 'max': this.safeNumber(market, 'position_size_limit'),
815
- },
816
- 'price': {
817
- 'min': undefined,
818
- 'max': undefined,
819
- },
820
- 'cost': {
821
- 'min': this.safeNumber(market, 'min_size'),
822
- 'max': undefined,
823
- },
824
- },
825
- 'created': this.parse8601(this.safeString(market, 'launch_time')),
826
- 'info': market,
827
- });
828
- }
829
- return result;
830
- }
831
- parseTicker(ticker, market = undefined) {
832
- //
833
- // spot: fetchTicker, fetchTickers
834
- //
835
- // {
836
- // "close": 30634.0,
837
- // "contract_type": "spot",
838
- // "greeks": null,
839
- // "high": 30780.0,
840
- // "low": 30340.5,
841
- // "mark_price": "48000",
842
- // "oi": "0.0000",
843
- // "oi_change_usd_6h": "0.0000",
844
- // "oi_contracts": "0",
845
- // "oi_value": "0.0000",
846
- // "oi_value_symbol": "BTC",
847
- // "oi_value_usd": "0.0000",
848
- // "open": 30464.0,
849
- // "price_band": null,
850
- // "product_id": 8320,
851
- // "quotes": {},
852
- // "size": 2.6816639999999996,
853
- // "spot_price": "30637.91465121",
854
- // "symbol": "BTC_USDT",
855
- // "timestamp": 1689139767621299,
856
- // "turnover": 2.6816639999999996,
857
- // "turnover_symbol": "BTC",
858
- // "turnover_usd": 81896.45613400004,
859
- // "volume": 2.6816639999999996
860
- // }
861
- //
862
- // swap: fetchTicker, fetchTickers
863
- //
864
- // {
865
- // "close": 30600.5,
866
- // "contract_type": "perpetual_futures",
867
- // "funding_rate": "0.00602961",
868
- // "greeks": null,
869
- // "high": 30803.0,
870
- // "low": 30265.5,
871
- // "mark_basis": "-0.45601594",
872
- // "mark_price": "30600.10481568",
873
- // "oi": "469.9190",
874
- // "oi_change_usd_6h": "2226314.9900",
875
- // "oi_contracts": "469919",
876
- // "oi_value": "469.9190",
877
- // "oi_value_symbol": "BTC",
878
- // "oi_value_usd": "14385640.6802",
879
- // "open": 30458.5,
880
- // "price_band": {
881
- // "lower_limit": "29067.08312627",
882
- // "upper_limit": "32126.77608693"
883
- // },
884
- // "product_id": 139,
885
- // "quotes": {
886
- // "ask_iv": null,
887
- // "ask_size": "965",
888
- // "best_ask": "30600.5",
889
- // "best_bid": "30599.5",
890
- // "bid_iv": null,
891
- // "bid_size": "196",
892
- // "impact_mid_price": null,
893
- // "mark_iv": "-0.44931641"
894
- // },
895
- // "size": 1226303,
896
- // "spot_price": "30612.85362773",
897
- // "symbol": "BTCUSDT",
898
- // "timestamp": 1689136597460456,
899
- // "turnover": 37392218.45999999,
900
- // "turnover_symbol": "USDT",
901
- // "turnover_usd": 37392218.45999999,
902
- // "volume": 1226.3029999999485
903
- // }
904
- //
905
- // option: fetchTicker, fetchTickers
906
- //
907
- // {
908
- // "contract_type": "call_options",
909
- // "greeks": {
910
- // "delta": "0.60873994",
911
- // "gamma": "0.00014854",
912
- // "rho": "7.71808010",
913
- // "spot": "30598.49040622",
914
- // "theta": "-30.44743017",
915
- // "vega": "24.83508248"
916
- // },
917
- // "mark_price": "1347.74819696",
918
- // "mark_vol": "0.39966303",
919
- // "oi": "2.7810",
920
- // "oi_change_usd_6h": "0.0000",
921
- // "oi_contracts": "2781",
922
- // "oi_value": "2.7810",
923
- // "oi_value_symbol": "BTC",
924
- // "oi_value_usd": "85127.4337",
925
- // "price_band": {
926
- // "lower_limit": "91.27423497",
927
- // "upper_limit": "7846.19454697"
928
- // },
929
- // "product_id": 107150,
930
- // "quotes": {
931
- // "ask_iv": "0.41023239",
932
- // "ask_size": "2397",
933
- // "best_ask": "1374",
934
- // "best_bid": "1322",
935
- // "bid_iv": "0.38929375",
936
- // "bid_size": "3995",
937
- // "impact_mid_price": null,
938
- // "mark_iv": "0.39965618"
939
- // },
940
- // "spot_price": "30598.43379314",
941
- // "strike_price": "30000",
942
- // "symbol": "C-BTC-30000-280723",
943
- // "timestamp": 1689136932893181,
944
- // "turnover_symbol": "USDT"
945
- // }
946
- //
947
- const timestamp = this.safeIntegerProduct(ticker, 'timestamp', 0.001);
948
- const marketId = this.safeString(ticker, 'symbol');
949
- const symbol = this.safeSymbol(marketId, market);
950
- const last = this.safeString(ticker, 'close');
951
- const quotes = this.safeValue(ticker, 'quotes', {});
952
- return this.safeTicker({
953
- 'symbol': symbol,
954
- 'timestamp': timestamp,
955
- 'datetime': this.iso8601(timestamp),
956
- 'high': this.safeNumber(ticker, 'high'),
957
- 'low': this.safeNumber(ticker, 'low'),
958
- 'bid': this.safeNumber(quotes, 'best_bid'),
959
- 'bidVolume': this.safeNumber(quotes, 'bid_size'),
960
- 'ask': this.safeNumber(quotes, 'best_ask'),
961
- 'askVolume': this.safeNumber(quotes, 'ask_size'),
962
- 'vwap': undefined,
963
- 'open': this.safeString(ticker, 'open'),
964
- 'close': last,
965
- 'last': last,
966
- 'previousClose': undefined,
967
- 'change': undefined,
968
- 'percentage': undefined,
969
- 'average': undefined,
970
- 'baseVolume': this.safeNumber(ticker, 'volume'),
971
- 'quoteVolume': this.safeNumber(ticker, 'turnover'),
972
- 'info': ticker,
973
- }, market);
974
- }
975
- async fetchTicker(symbol, params = {}) {
976
- /**
977
- * @method
978
- * @name delta#fetchTicker
979
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
980
- * @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
981
- * @param {string} symbol unified symbol of the market to fetch the ticker for
982
- * @param {object} [params] extra parameters specific to the exchange API endpoint
983
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
984
- */
985
- await this.loadMarkets();
986
- const market = this.market(symbol);
987
- const request = {
988
- 'symbol': market['id'],
989
- };
990
- const response = await this.publicGetTickersSymbol(this.extend(request, params));
991
- //
992
- // spot
993
- //
994
- // {
995
- // "result": {
996
- // "close": 30634.0,
997
- // "contract_type": "spot",
998
- // "greeks": null,
999
- // "high": 30780.0,
1000
- // "low": 30340.5,
1001
- // "mark_price": "48000",
1002
- // "oi": "0.0000",
1003
- // "oi_change_usd_6h": "0.0000",
1004
- // "oi_contracts": "0",
1005
- // "oi_value": "0.0000",
1006
- // "oi_value_symbol": "BTC",
1007
- // "oi_value_usd": "0.0000",
1008
- // "open": 30464.0,
1009
- // "price_band": null,
1010
- // "product_id": 8320,
1011
- // "quotes": {},
1012
- // "size": 2.6816639999999996,
1013
- // "spot_price": "30637.91465121",
1014
- // "symbol": "BTC_USDT",
1015
- // "timestamp": 1689139767621299,
1016
- // "turnover": 2.6816639999999996,
1017
- // "turnover_symbol": "BTC",
1018
- // "turnover_usd": 81896.45613400004,
1019
- // "volume": 2.6816639999999996
1020
- // },
1021
- // "success": true
1022
- // }
1023
- //
1024
- // swap
1025
- //
1026
- // {
1027
- // "result": {
1028
- // "close": 30600.5,
1029
- // "contract_type": "perpetual_futures",
1030
- // "funding_rate": "0.00602961",
1031
- // "greeks": null,
1032
- // "high": 30803.0,
1033
- // "low": 30265.5,
1034
- // "mark_basis": "-0.45601594",
1035
- // "mark_price": "30600.10481568",
1036
- // "oi": "469.9190",
1037
- // "oi_change_usd_6h": "2226314.9900",
1038
- // "oi_contracts": "469919",
1039
- // "oi_value": "469.9190",
1040
- // "oi_value_symbol": "BTC",
1041
- // "oi_value_usd": "14385640.6802",
1042
- // "open": 30458.5,
1043
- // "price_band": {
1044
- // "lower_limit": "29067.08312627",
1045
- // "upper_limit": "32126.77608693"
1046
- // },
1047
- // "product_id": 139,
1048
- // "quotes": {
1049
- // "ask_iv": null,
1050
- // "ask_size": "965",
1051
- // "best_ask": "30600.5",
1052
- // "best_bid": "30599.5",
1053
- // "bid_iv": null,
1054
- // "bid_size": "196",
1055
- // "impact_mid_price": null,
1056
- // "mark_iv": "-0.44931641"
1057
- // },
1058
- // "size": 1226303,
1059
- // "spot_price": "30612.85362773",
1060
- // "symbol": "BTCUSDT",
1061
- // "timestamp": 1689136597460456,
1062
- // "turnover": 37392218.45999999,
1063
- // "turnover_symbol": "USDT",
1064
- // "turnover_usd": 37392218.45999999,
1065
- // "volume": 1226.3029999999485
1066
- // },
1067
- // "success": true
1068
- // }
1069
- //
1070
- // option
1071
- //
1072
- // {
1073
- // "result": {
1074
- // "contract_type": "call_options",
1075
- // "greeks": {
1076
- // "delta": "0.60873994",
1077
- // "gamma": "0.00014854",
1078
- // "rho": "7.71808010",
1079
- // "spot": "30598.49040622",
1080
- // "theta": "-30.44743017",
1081
- // "vega": "24.83508248"
1082
- // },
1083
- // "mark_price": "1347.74819696",
1084
- // "mark_vol": "0.39966303",
1085
- // "oi": "2.7810",
1086
- // "oi_change_usd_6h": "0.0000",
1087
- // "oi_contracts": "2781",
1088
- // "oi_value": "2.7810",
1089
- // "oi_value_symbol": "BTC",
1090
- // "oi_value_usd": "85127.4337",
1091
- // "price_band": {
1092
- // "lower_limit": "91.27423497",
1093
- // "upper_limit": "7846.19454697"
1094
- // },
1095
- // "product_id": 107150,
1096
- // "quotes": {
1097
- // "ask_iv": "0.41023239",
1098
- // "ask_size": "2397",
1099
- // "best_ask": "1374",
1100
- // "best_bid": "1322",
1101
- // "bid_iv": "0.38929375",
1102
- // "bid_size": "3995",
1103
- // "impact_mid_price": null,
1104
- // "mark_iv": "0.39965618"
1105
- // },
1106
- // "spot_price": "30598.43379314",
1107
- // "strike_price": "30000",
1108
- // "symbol": "C-BTC-30000-280723",
1109
- // "timestamp": 1689136932893181,
1110
- // "turnover_symbol": "USDT"
1111
- // },
1112
- // "success": true
1113
- // }
1114
- //
1115
- const result = this.safeValue(response, 'result', {});
1116
- return this.parseTicker(result, market);
1117
- }
1118
- async fetchTickers(symbols = undefined, params = {}) {
1119
- /**
1120
- * @method
1121
- * @name delta#fetchTickers
1122
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1123
- * @see https://docs.delta.exchange/#get-tickers-for-products
1124
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1125
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1126
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1127
- */
1128
- await this.loadMarkets();
1129
- symbols = this.marketSymbols(symbols);
1130
- const response = await this.publicGetTickers(params);
1131
- //
1132
- // spot
1133
- //
1134
- // {
1135
- // "result": [
1136
- // {
1137
- // "close": 30634.0,
1138
- // "contract_type": "spot",
1139
- // "greeks": null,
1140
- // "high": 30780.0,
1141
- // "low": 30340.5,
1142
- // "mark_price": "48000",
1143
- // "oi": "0.0000",
1144
- // "oi_change_usd_6h": "0.0000",
1145
- // "oi_contracts": "0",
1146
- // "oi_value": "0.0000",
1147
- // "oi_value_symbol": "BTC",
1148
- // "oi_value_usd": "0.0000",
1149
- // "open": 30464.0,
1150
- // "price_band": null,
1151
- // "product_id": 8320,
1152
- // "quotes": {},
1153
- // "size": 2.6816639999999996,
1154
- // "spot_price": "30637.91465121",
1155
- // "symbol": "BTC_USDT",
1156
- // "timestamp": 1689139767621299,
1157
- // "turnover": 2.6816639999999996,
1158
- // "turnover_symbol": "BTC",
1159
- // "turnover_usd": 81896.45613400004,
1160
- // "volume": 2.6816639999999996
1161
- // },
1162
- // ],
1163
- // "success":true
1164
- // }
1165
- //
1166
- // swap
1167
- //
1168
- // {
1169
- // "result": [
1170
- // {
1171
- // "close": 30600.5,
1172
- // "contract_type": "perpetual_futures",
1173
- // "funding_rate": "0.00602961",
1174
- // "greeks": null,
1175
- // "high": 30803.0,
1176
- // "low": 30265.5,
1177
- // "mark_basis": "-0.45601594",
1178
- // "mark_price": "30600.10481568",
1179
- // "oi": "469.9190",
1180
- // "oi_change_usd_6h": "2226314.9900",
1181
- // "oi_contracts": "469919",
1182
- // "oi_value": "469.9190",
1183
- // "oi_value_symbol": "BTC",
1184
- // "oi_value_usd": "14385640.6802",
1185
- // "open": 30458.5,
1186
- // "price_band": {
1187
- // "lower_limit": "29067.08312627",
1188
- // "upper_limit": "32126.77608693"
1189
- // },
1190
- // "product_id": 139,
1191
- // "quotes": {
1192
- // "ask_iv": null,
1193
- // "ask_size": "965",
1194
- // "best_ask": "30600.5",
1195
- // "best_bid": "30599.5",
1196
- // "bid_iv": null,
1197
- // "bid_size": "196",
1198
- // "impact_mid_price": null,
1199
- // "mark_iv": "-0.44931641"
1200
- // },
1201
- // "size": 1226303,
1202
- // "spot_price": "30612.85362773",
1203
- // "symbol": "BTCUSDT",
1204
- // "timestamp": 1689136597460456,
1205
- // "turnover": 37392218.45999999,
1206
- // "turnover_symbol": "USDT",
1207
- // "turnover_usd": 37392218.45999999,
1208
- // "volume": 1226.3029999999485
1209
- // },
1210
- // ],
1211
- // "success":true
1212
- // }
1213
- //
1214
- // option
1215
- //
1216
- // {
1217
- // "result": [
1218
- // {
1219
- // "contract_type": "call_options",
1220
- // "greeks": {
1221
- // "delta": "0.60873994",
1222
- // "gamma": "0.00014854",
1223
- // "rho": "7.71808010",
1224
- // "spot": "30598.49040622",
1225
- // "theta": "-30.44743017",
1226
- // "vega": "24.83508248"
1227
- // },
1228
- // "mark_price": "1347.74819696",
1229
- // "mark_vol": "0.39966303",
1230
- // "oi": "2.7810",
1231
- // "oi_change_usd_6h": "0.0000",
1232
- // "oi_contracts": "2781",
1233
- // "oi_value": "2.7810",
1234
- // "oi_value_symbol": "BTC",
1235
- // "oi_value_usd": "85127.4337",
1236
- // "price_band": {
1237
- // "lower_limit": "91.27423497",
1238
- // "upper_limit": "7846.19454697"
1239
- // },
1240
- // "product_id": 107150,
1241
- // "quotes": {
1242
- // "ask_iv": "0.41023239",
1243
- // "ask_size": "2397",
1244
- // "best_ask": "1374",
1245
- // "best_bid": "1322",
1246
- // "bid_iv": "0.38929375",
1247
- // "bid_size": "3995",
1248
- // "impact_mid_price": null,
1249
- // "mark_iv": "0.39965618"
1250
- // },
1251
- // "spot_price": "30598.43379314",
1252
- // "strike_price": "30000",
1253
- // "symbol": "C-BTC-30000-280723",
1254
- // "timestamp": 1689136932893181,
1255
- // "turnover_symbol": "USDT"
1256
- // },
1257
- // ],
1258
- // "success":true
1259
- // }
1260
- //
1261
- const tickers = this.safeValue(response, 'result', []);
1262
- const result = {};
1263
- for (let i = 0; i < tickers.length; i++) {
1264
- const ticker = this.parseTicker(tickers[i]);
1265
- const symbol = ticker['symbol'];
1266
- result[symbol] = ticker;
1267
- }
1268
- return this.filterByArrayTickers(result, 'symbol', symbols);
1269
- }
1270
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
1271
- /**
1272
- * @method
1273
- * @name delta#fetchOrderBook
1274
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1275
- * @see https://docs.delta.exchange/#get-l2-orderbook
1276
- * @param {string} symbol unified symbol of the market to fetch the order book for
1277
- * @param {int} [limit] the maximum amount of order book entries to return
1278
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1279
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
1280
- */
1281
- await this.loadMarkets();
1282
- const market = this.market(symbol);
1283
- const request = {
1284
- 'symbol': market['id'],
1285
- };
1286
- if (limit !== undefined) {
1287
- request['depth'] = limit;
1288
- }
1289
- const response = await this.publicGetL2orderbookSymbol(this.extend(request, params));
1290
- //
1291
- // {
1292
- // "result":{
1293
- // "buy":[
1294
- // {"price":"15814.0","size":912},
1295
- // {"price":"15813.5","size":1279},
1296
- // {"price":"15813.0","size":1634},
1297
- // ],
1298
- // "sell":[
1299
- // {"price":"15814.5","size":625},
1300
- // {"price":"15815.0","size":982},
1301
- // {"price":"15815.5","size":1328},
1302
- // ],
1303
- // "symbol":"BTCUSDT"
1304
- // },
1305
- // "success":true
1306
- // }
1307
- //
1308
- const result = this.safeValue(response, 'result', {});
1309
- return this.parseOrderBook(result, market['symbol'], undefined, 'buy', 'sell', 'price', 'size');
1310
- }
1311
- parseTrade(trade, market = undefined) {
1312
- //
1313
- // public fetchTrades
1314
- //
1315
- // {
1316
- // "buyer_role":"maker",
1317
- // "price":"15896.5",
1318
- // "seller_role":"taker",
1319
- // "size":241,
1320
- // "symbol":"BTCUSDT",
1321
- // "timestamp":1605376684714595
1322
- // }
1323
- //
1324
- // private fetchMyTrades
1325
- //
1326
- // {
1327
- // "commission":"0.008335000000000000",
1328
- // "created_at":"2020-11-16T19:07:19Z",
1329
- // "fill_type":"normal",
1330
- // "id":"e7ff05c233a74245b72381f8dd91d1ce",
1331
- // "meta_data":{
1332
- // "effective_commission_rate":"0.0005",
1333
- // "order_price":"16249",
1334
- // "order_size":1,
1335
- // "order_type":"market_order",
1336
- // "order_unfilled_size":0,
1337
- // "trading_fee_credits_used":"0"
1338
- // },
1339
- // "order_id":"152999629",
1340
- // "price":"16669",
1341
- // "product":{
1342
- // "contract_type":"perpetual_futures",
1343
- // "contract_unit_currency":"BTC",
1344
- // "contract_value":"0.001",
1345
- // "id":139,
1346
- // "notional_type":"vanilla",
1347
- // "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"},
1348
- // "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"},
1349
- // "symbol":"BTCUSDT",
1350
- // "tick_size":"0.5",
1351
- // "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"}
1352
- // },
1353
- // "product_id":139,
1354
- // "role":"taker",
1355
- // "side":"sell",
1356
- // "size":1
1357
- // }
1358
- //
1359
- const id = this.safeString(trade, 'id');
1360
- const orderId = this.safeString(trade, 'order_id');
1361
- let timestamp = this.parse8601(this.safeString(trade, 'created_at'));
1362
- timestamp = this.safeIntegerProduct(trade, 'timestamp', 0.001, timestamp);
1363
- const priceString = this.safeString(trade, 'price');
1364
- const amountString = this.safeString(trade, 'size');
1365
- const product = this.safeValue(trade, 'product', {});
1366
- const marketId = this.safeString(product, 'symbol');
1367
- const symbol = this.safeSymbol(marketId, market);
1368
- const sellerRole = this.safeString(trade, 'seller_role');
1369
- let side = this.safeString(trade, 'side');
1370
- if (side === undefined) {
1371
- if (sellerRole === 'taker') {
1372
- side = 'sell';
1373
- }
1374
- else if (sellerRole === 'maker') {
1375
- side = 'buy';
1376
- }
1377
- }
1378
- const takerOrMaker = this.safeString(trade, 'role');
1379
- const metaData = this.safeValue(trade, 'meta_data', {});
1380
- let type = this.safeString(metaData, 'order_type');
1381
- if (type !== undefined) {
1382
- type = type.replace('_order', '');
1383
- }
1384
- const feeCostString = this.safeString(trade, 'commission');
1385
- let fee = undefined;
1386
- if (feeCostString !== undefined) {
1387
- const settlingAsset = this.safeValue(product, 'settling_asset', {});
1388
- const feeCurrencyId = this.safeString(settlingAsset, 'symbol');
1389
- const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
1390
- fee = {
1391
- 'cost': feeCostString,
1392
- 'currency': feeCurrencyCode,
1393
- };
1394
- }
1395
- return this.safeTrade({
1396
- 'id': id,
1397
- 'order': orderId,
1398
- 'timestamp': timestamp,
1399
- 'datetime': this.iso8601(timestamp),
1400
- 'symbol': symbol,
1401
- 'type': type,
1402
- 'side': side,
1403
- 'price': priceString,
1404
- 'amount': amountString,
1405
- 'cost': undefined,
1406
- 'takerOrMaker': takerOrMaker,
1407
- 'fee': fee,
1408
- 'info': trade,
1409
- }, market);
1410
- }
1411
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1412
- /**
1413
- * @method
1414
- * @name delta#fetchTrades
1415
- * @description get the list of most recent trades for a particular symbol
1416
- * @see https://docs.delta.exchange/#get-public-trades
1417
- * @param {string} symbol unified symbol of the market to fetch trades for
1418
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
1419
- * @param {int} [limit] the maximum amount of trades to fetch
1420
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1421
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1422
- */
1423
- await this.loadMarkets();
1424
- const market = this.market(symbol);
1425
- const request = {
1426
- 'symbol': market['id'],
1427
- };
1428
- const response = await this.publicGetTradesSymbol(this.extend(request, params));
1429
- //
1430
- // {
1431
- // "result":[
1432
- // {
1433
- // "buyer_role":"maker",
1434
- // "price":"15896.5",
1435
- // "seller_role":"taker",
1436
- // "size":241,
1437
- // "symbol":"BTCUSDT",
1438
- // "timestamp":1605376684714595
1439
- // }
1440
- // ],
1441
- // "success":true
1442
- // }
1443
- //
1444
- const result = this.safeValue(response, 'result', []);
1445
- return this.parseTrades(result, market, since, limit);
1446
- }
1447
- parseOHLCV(ohlcv, market = undefined) {
1448
- //
1449
- // {
1450
- // "time":1605393120,
1451
- // "open":15989,
1452
- // "high":15989,
1453
- // "low":15987.5,
1454
- // "close":15987.5,
1455
- // "volume":565
1456
- // }
1457
- //
1458
- return [
1459
- this.safeTimestamp(ohlcv, 'time'),
1460
- this.safeNumber(ohlcv, 'open'),
1461
- this.safeNumber(ohlcv, 'high'),
1462
- this.safeNumber(ohlcv, 'low'),
1463
- this.safeNumber(ohlcv, 'close'),
1464
- this.safeNumber(ohlcv, 'volume'),
1465
- ];
1466
- }
1467
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1468
- /**
1469
- * @method
1470
- * @name delta#fetchOHLCV
1471
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1472
- * @see https://docs.delta.exchange/#get-ohlc-candles
1473
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1474
- * @param {string} timeframe the length of time each candle represents
1475
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
1476
- * @param {int} [limit] the maximum amount of candles to fetch
1477
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1478
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1479
- */
1480
- await this.loadMarkets();
1481
- const market = this.market(symbol);
1482
- const request = {
1483
- 'resolution': this.safeString(this.timeframes, timeframe, timeframe),
1484
- };
1485
- const duration = this.parseTimeframe(timeframe);
1486
- limit = limit ? limit : 2000; // max 2000
1487
- if (since === undefined) {
1488
- const end = this.seconds();
1489
- request['end'] = end;
1490
- request['start'] = end - limit * duration;
1491
- }
1492
- else {
1493
- const start = this.parseToInt(since / 1000);
1494
- request['start'] = start;
1495
- request['end'] = this.sum(start, limit * duration);
1496
- }
1497
- const price = this.safeString(params, 'price');
1498
- if (price === 'mark') {
1499
- request['symbol'] = 'MARK:' + market['id'];
1500
- }
1501
- else if (price === 'index') {
1502
- request['symbol'] = market['info']['spot_index']['symbol'];
1503
- }
1504
- else {
1505
- request['symbol'] = market['id'];
1506
- }
1507
- params = this.omit(params, 'price');
1508
- const response = await this.publicGetHistoryCandles(this.extend(request, params));
1509
- //
1510
- // {
1511
- // "success":true,
1512
- // "result":[
1513
- // {"time":1605393120,"open":15989,"high":15989,"low":15987.5,"close":15987.5,"volume":565},
1514
- // {"time":1605393180,"open":15966,"high":15966,"low":15959,"close":15959,"volume":24},
1515
- // {"time":1605393300,"open":15973,"high":15973,"low":15973,"close":15973,"volume":1288},
1516
- // ]
1517
- // }
1518
- //
1519
- const result = this.safeValue(response, 'result', []);
1520
- return this.parseOHLCVs(result, market, timeframe, since, limit);
1521
- }
1522
- parseBalance(response) {
1523
- const balances = this.safeValue(response, 'result', []);
1524
- const result = { 'info': response };
1525
- const currenciesByNumericId = this.safeValue(this.options, 'currenciesByNumericId', {});
1526
- for (let i = 0; i < balances.length; i++) {
1527
- const balance = balances[i];
1528
- const currencyId = this.safeString(balance, 'asset_id');
1529
- const currency = this.safeValue(currenciesByNumericId, currencyId);
1530
- const code = (currency === undefined) ? currencyId : currency['code'];
1531
- const account = this.account();
1532
- account['total'] = this.safeString(balance, 'balance');
1533
- account['free'] = this.safeString(balance, 'available_balance');
1534
- result[code] = account;
1535
- }
1536
- return this.safeBalance(result);
1537
- }
1538
- async fetchBalance(params = {}) {
1539
- /**
1540
- * @method
1541
- * @name delta#fetchBalance
1542
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
1543
- * @see https://docs.delta.exchange/#get-wallet-balances
1544
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1545
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1546
- */
1547
- await this.loadMarkets();
1548
- const response = await this.privateGetWalletBalances(params);
1549
- //
1550
- // {
1551
- // "result":[
1552
- // {
1553
- // "asset_id":1,
1554
- // "available_balance":"0",
1555
- // "balance":"0",
1556
- // "commission":"0",
1557
- // "id":154883,
1558
- // "interest_credit":"0",
1559
- // "order_margin":"0",
1560
- // "pending_referral_bonus":"0",
1561
- // "pending_trading_fee_credit":"0",
1562
- // "position_margin":"0",
1563
- // "trading_fee_credit":"0",
1564
- // "user_id":22142
1565
- // },
1566
- // ],
1567
- // "success":true
1568
- // }
1569
- //
1570
- return this.parseBalance(response);
1571
- }
1572
- async fetchPosition(symbol, params = {}) {
1573
- /**
1574
- * @method
1575
- * @name delta#fetchPosition
1576
- * @description fetch data on a single open contract trade position
1577
- * @see https://docs.delta.exchange/#get-position
1578
- * @param {string} symbol unified market symbol of the market the position is held in, default is undefined
1579
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1580
- * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
1581
- */
1582
- await this.loadMarkets();
1583
- const market = this.market(symbol);
1584
- const request = {
1585
- 'product_id': market['numericId'],
1586
- };
1587
- const response = await this.privateGetPositions(this.extend(request, params));
1588
- //
1589
- // {
1590
- // "result":{
1591
- // "entry_price":null,
1592
- // "size":0,
1593
- // "timestamp":1605454074268079
1594
- // },
1595
- // "success":true
1596
- // }
1597
- //
1598
- const result = this.safeValue(response, 'result', {});
1599
- return this.parsePosition(result, market);
1600
- }
1601
- async fetchPositions(symbols = undefined, params = {}) {
1602
- /**
1603
- * @method
1604
- * @name delta#fetchPositions
1605
- * @description fetch all open positions
1606
- * @see https://docs.delta.exchange/#get-margined-positions
1607
- * @param {string[]|undefined} symbols list of unified market symbols
1608
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1609
- * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
1610
- */
1611
- await this.loadMarkets();
1612
- const response = await this.privateGetPositionsMargined(params);
1613
- //
1614
- // {
1615
- // "success": true,
1616
- // "result": [
1617
- // {
1618
- // "user_id": 0,
1619
- // "size": 0,
1620
- // "entry_price": "string",
1621
- // "margin": "string",
1622
- // "liquidation_price": "string",
1623
- // "bankruptcy_price": "string",
1624
- // "adl_level": 0,
1625
- // "product_id": 0,
1626
- // "product_symbol": "string",
1627
- // "commission": "string",
1628
- // "realized_pnl": "string",
1629
- // "realized_funding": "string"
1630
- // }
1631
- // ]
1632
- // }
1633
- //
1634
- const result = this.safeValue(response, 'result', []);
1635
- return this.parsePositions(result, symbols);
1636
- }
1637
- parsePosition(position, market = undefined) {
1638
- //
1639
- // fetchPosition
1640
- //
1641
- // {
1642
- // "entry_price":null,
1643
- // "size":0,
1644
- // "timestamp":1605454074268079
1645
- // }
1646
- //
1647
- //
1648
- // fetchPositions
1649
- //
1650
- // {
1651
- // "user_id": 0,
1652
- // "size": 0,
1653
- // "entry_price": "string",
1654
- // "margin": "string",
1655
- // "liquidation_price": "string",
1656
- // "bankruptcy_price": "string",
1657
- // "adl_level": 0,
1658
- // "product_id": 0,
1659
- // "product_symbol": "string",
1660
- // "commission": "string",
1661
- // "realized_pnl": "string",
1662
- // "realized_funding": "string"
1663
- // }
1664
- //
1665
- const marketId = this.safeString(position, 'product_symbol');
1666
- market = this.safeMarket(marketId, market);
1667
- const symbol = market['symbol'];
1668
- const timestamp = this.safeIntegerProduct(position, 'timestamp', 0.001);
1669
- const sizeString = this.safeString(position, 'size');
1670
- let side = undefined;
1671
- if (sizeString !== undefined) {
1672
- if (Precise["default"].stringGt(sizeString, '0')) {
1673
- side = 'buy';
1674
- }
1675
- else if (Precise["default"].stringLt(sizeString, '0')) {
1676
- side = 'sell';
1677
- }
1678
- }
1679
- return this.safePosition({
1680
- 'info': position,
1681
- 'id': undefined,
1682
- 'symbol': symbol,
1683
- 'notional': undefined,
1684
- 'marginMode': undefined,
1685
- 'liquidationPrice': this.safeNumber(position, 'liquidation_price'),
1686
- 'entryPrice': this.safeNumber(position, 'entry_price'),
1687
- 'unrealizedPnl': undefined,
1688
- 'percentage': undefined,
1689
- 'contracts': this.parseNumber(sizeString),
1690
- 'contractSize': this.safeNumber(market, 'contractSize'),
1691
- 'markPrice': undefined,
1692
- 'side': side,
1693
- 'hedged': undefined,
1694
- 'timestamp': timestamp,
1695
- 'datetime': this.iso8601(timestamp),
1696
- 'maintenanceMargin': undefined,
1697
- 'maintenanceMarginPercentage': undefined,
1698
- 'collateral': undefined,
1699
- 'initialMargin': undefined,
1700
- 'initialMarginPercentage': undefined,
1701
- 'leverage': undefined,
1702
- 'marginRatio': undefined,
1703
- 'stopLossPrice': undefined,
1704
- 'takeProfitPrice': undefined,
1705
- });
1706
- }
1707
- parseOrderStatus(status) {
1708
- const statuses = {
1709
- 'open': 'open',
1710
- 'pending': 'open',
1711
- 'closed': 'closed',
1712
- 'cancelled': 'canceled',
1713
- };
1714
- return this.safeString(statuses, status, status);
1715
- }
1716
- parseOrder(order, market = undefined) {
1717
- //
1718
- // createOrder, cancelOrder, editOrder, fetchOpenOrders, fetchClosedOrders
1719
- //
1720
- // {
1721
- // "average_fill_price":null,
1722
- // "bracket_order":null,
1723
- // "bracket_stop_loss_limit_price":null,
1724
- // "bracket_stop_loss_price":null,
1725
- // "bracket_take_profit_limit_price":null,
1726
- // "bracket_take_profit_price":null,
1727
- // "bracket_trail_amount":null,
1728
- // "cancellation_reason":null,
1729
- // "client_order_id":null,
1730
- // "close_on_trigger":"false",
1731
- // "commission":"0",
1732
- // "created_at":"2020-11-16T02:38:26Z",
1733
- // "id":152870626,
1734
- // "limit_price":"10000",
1735
- // "meta_data":{"source":"api"},
1736
- // "order_type":"limit_order",
1737
- // "paid_commission":"0",
1738
- // "product_id":139,
1739
- // "reduce_only":false,
1740
- // "side":"buy",
1741
- // "size":0,
1742
- // "state":"open",
1743
- // "stop_order_type":null,
1744
- // "stop_price":null,
1745
- // "stop_trigger_method":"mark_price",
1746
- // "time_in_force":"gtc",
1747
- // "trail_amount":null,
1748
- // "unfilled_size":0,
1749
- // "user_id":22142
1750
- // }
1751
- //
1752
- const id = this.safeString(order, 'id');
1753
- const clientOrderId = this.safeString(order, 'client_order_id');
1754
- const timestamp = this.parse8601(this.safeString(order, 'created_at'));
1755
- const marketId = this.safeString(order, 'product_id');
1756
- const marketsByNumericId = this.safeValue(this.options, 'marketsByNumericId', {});
1757
- market = this.safeValue(marketsByNumericId, marketId, market);
1758
- const symbol = (market === undefined) ? marketId : market['symbol'];
1759
- const status = this.parseOrderStatus(this.safeString(order, 'state'));
1760
- const side = this.safeString(order, 'side');
1761
- let type = this.safeString(order, 'order_type');
1762
- type = type.replace('_order', '');
1763
- const price = this.safeString(order, 'limit_price');
1764
- const amount = this.safeString(order, 'size');
1765
- const remaining = this.safeString(order, 'unfilled_size');
1766
- const average = this.safeString(order, 'average_fill_price');
1767
- let fee = undefined;
1768
- const feeCostString = this.safeString(order, 'paid_commission');
1769
- if (feeCostString !== undefined) {
1770
- let feeCurrencyCode = undefined;
1771
- if (market !== undefined) {
1772
- const settlingAsset = this.safeValue(market['info'], 'settling_asset', {});
1773
- const feeCurrencyId = this.safeString(settlingAsset, 'symbol');
1774
- feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
1775
- }
1776
- fee = {
1777
- 'cost': feeCostString,
1778
- 'currency': feeCurrencyCode,
1779
- };
1780
- }
1781
- return this.safeOrder({
1782
- 'info': order,
1783
- 'id': id,
1784
- 'clientOrderId': clientOrderId,
1785
- 'timestamp': timestamp,
1786
- 'datetime': this.iso8601(timestamp),
1787
- 'lastTradeTimestamp': undefined,
1788
- 'symbol': symbol,
1789
- 'type': type,
1790
- 'side': side,
1791
- 'price': price,
1792
- 'amount': amount,
1793
- 'cost': undefined,
1794
- 'average': average,
1795
- 'filled': undefined,
1796
- 'remaining': remaining,
1797
- 'status': status,
1798
- 'fee': fee,
1799
- 'trades': undefined,
1800
- }, market);
1801
- }
1802
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1803
- /**
1804
- * @method
1805
- * @name delta#createOrder
1806
- * @description create a trade order
1807
- * @see https://docs.delta.exchange/#place-order
1808
- * @param {string} symbol unified symbol of the market to create an order in
1809
- * @param {string} type 'market' or 'limit'
1810
- * @param {string} side 'buy' or 'sell'
1811
- * @param {float} amount how much of currency you want to trade in units of base currency
1812
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1813
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1814
- * @param {bool} [params.reduceOnly] *contract only* indicates if this order is to reduce the size of a position
1815
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1816
- */
1817
- await this.loadMarkets();
1818
- const orderType = type + '_order';
1819
- const market = this.market(symbol);
1820
- const request = {
1821
- 'product_id': market['numericId'],
1822
- // 'limit_price': this.priceToPrecision (market['symbol'], price),
1823
- 'size': this.amountToPrecision(market['symbol'], amount),
1824
- 'side': side,
1825
- 'order_type': orderType,
1826
- // 'client_order_id': 'string',
1827
- // 'time_in_force': 'gtc', // gtc, ioc, fok
1828
- // 'post_only': 'false', // 'true',
1829
- // 'reduce_only': 'false', // 'true',
1830
- };
1831
- if (type === 'limit') {
1832
- request['limit_price'] = this.priceToPrecision(market['symbol'], price);
1833
- }
1834
- const clientOrderId = this.safeString2(params, 'clientOrderId', 'client_order_id');
1835
- params = this.omit(params, ['clientOrderId', 'client_order_id']);
1836
- if (clientOrderId !== undefined) {
1837
- request['client_order_id'] = clientOrderId;
1838
- }
1839
- const reduceOnly = this.safeValue(params, 'reduceOnly');
1840
- if (reduceOnly) {
1841
- request['reduce_only'] = reduceOnly;
1842
- params = this.omit(params, 'reduceOnly');
1843
- }
1844
- const response = await this.privatePostOrders(this.extend(request, params));
1845
- //
1846
- // {
1847
- // "result":{
1848
- // "average_fill_price":null,
1849
- // "bracket_order":null,
1850
- // "bracket_stop_loss_limit_price":null,
1851
- // "bracket_stop_loss_price":null,
1852
- // "bracket_take_profit_limit_price":null,
1853
- // "bracket_take_profit_price":null,
1854
- // "bracket_trail_amount":null,
1855
- // "cancellation_reason":null,
1856
- // "client_order_id":null,
1857
- // "close_on_trigger":"false",
1858
- // "commission":"0",
1859
- // "created_at":"2020-11-16T02:38:26Z",
1860
- // "id":152870626,
1861
- // "limit_price":"10000",
1862
- // "meta_data":{"source":"api"},
1863
- // "order_type":"limit_order",
1864
- // "paid_commission":"0",
1865
- // "product_id":139,
1866
- // "reduce_only":false,
1867
- // "side":"buy",
1868
- // "size":0,
1869
- // "state":"open",
1870
- // "stop_order_type":null,
1871
- // "stop_price":null,
1872
- // "stop_trigger_method":"mark_price",
1873
- // "time_in_force":"gtc",
1874
- // "trail_amount":null,
1875
- // "unfilled_size":0,
1876
- // "user_id":22142
1877
- // },
1878
- // "success":true
1879
- // }
1880
- //
1881
- const result = this.safeValue(response, 'result', {});
1882
- return this.parseOrder(result, market);
1883
- }
1884
- async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1885
- /**
1886
- * @method
1887
- * @name delta#editOrder
1888
- * @description edit a trade order
1889
- * @see https://docs.delta.exchange/#edit-order
1890
- * @param {string} id order id
1891
- * @param {string} symbol unified symbol of the market to create an order in
1892
- * @param {string} type 'market' or 'limit'
1893
- * @param {string} side 'buy' or 'sell'
1894
- * @param {float} amount how much of the currency you want to trade in units of the base currency
1895
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency
1896
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1897
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1898
- */
1899
- await this.loadMarkets();
1900
- const market = this.market(symbol);
1901
- const request = {
1902
- 'id': parseInt(id),
1903
- 'product_id': market['numericId'],
1904
- // "limit_price": this.priceToPrecision (symbol, price),
1905
- // "size": this.amountToPrecision (symbol, amount),
1906
- };
1907
- if (amount !== undefined) {
1908
- request['size'] = parseInt(this.amountToPrecision(symbol, amount));
1909
- }
1910
- if (price !== undefined) {
1911
- request['limit_price'] = this.priceToPrecision(symbol, price);
1912
- }
1913
- const response = await this.privatePutOrders(this.extend(request, params));
1914
- //
1915
- // {
1916
- // "success": true,
1917
- // "result": {
1918
- // "id": "ashb1212",
1919
- // "product_id": 27,
1920
- // "limit_price": "9200",
1921
- // "side": "buy",
1922
- // "size": 100,
1923
- // "unfilled_size": 50,
1924
- // "user_id": 1,
1925
- // "order_type": "limit_order",
1926
- // "state": "open",
1927
- // "created_at": "..."
1928
- // }
1929
- // }
1930
- //
1931
- const result = this.safeValue(response, 'result');
1932
- return this.parseOrder(result, market);
1933
- }
1934
- async cancelOrder(id, symbol = undefined, params = {}) {
1935
- /**
1936
- * @method
1937
- * @name delta#cancelOrder
1938
- * @description cancels an open order
1939
- * @see https://docs.delta.exchange/#cancel-order
1940
- * @param {string} id order id
1941
- * @param {string} symbol unified symbol of the market the order was made in
1942
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1943
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1944
- */
1945
- if (symbol === undefined) {
1946
- throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
1947
- }
1948
- await this.loadMarkets();
1949
- const market = this.market(symbol);
1950
- const request = {
1951
- 'id': parseInt(id),
1952
- 'product_id': market['numericId'],
1953
- };
1954
- const response = await this.privateDeleteOrders(this.extend(request, params));
1955
- //
1956
- // {
1957
- // "result":{
1958
- // "average_fill_price":null,
1959
- // "bracket_order":null,
1960
- // "bracket_stop_loss_limit_price":null,
1961
- // "bracket_stop_loss_price":null,
1962
- // "bracket_take_profit_limit_price":null,
1963
- // "bracket_take_profit_price":null,
1964
- // "bracket_trail_amount":null,
1965
- // "cancellation_reason":"cancelled_by_user",
1966
- // "client_order_id":null,
1967
- // "close_on_trigger":"false",
1968
- // "commission":"0",
1969
- // "created_at":"2020-11-16T02:38:26Z",
1970
- // "id":152870626,
1971
- // "limit_price":"10000",
1972
- // "meta_data":{"source":"api"},
1973
- // "order_type":"limit_order",
1974
- // "paid_commission":"0",
1975
- // "product_id":139,
1976
- // "reduce_only":false,
1977
- // "side":"buy",
1978
- // "size":0,
1979
- // "state":"cancelled",
1980
- // "stop_order_type":null,
1981
- // "stop_price":null,
1982
- // "stop_trigger_method":"mark_price",
1983
- // "time_in_force":"gtc",
1984
- // "trail_amount":null,
1985
- // "unfilled_size":0,
1986
- // "user_id":22142
1987
- // },
1988
- // "success":true
1989
- // }
1990
- //
1991
- const result = this.safeValue(response, 'result');
1992
- return this.parseOrder(result, market);
1993
- }
1994
- async cancelAllOrders(symbol = undefined, params = {}) {
1995
- /**
1996
- * @method
1997
- * @name delta#cancelAllOrders
1998
- * @description cancel all open orders in a market
1999
- * @see https://docs.delta.exchange/#cancel-all-open-orders
2000
- * @param {string} symbol unified market symbol of the market to cancel orders in
2001
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2002
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2003
- */
2004
- if (symbol === undefined) {
2005
- throw new errors.ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument');
2006
- }
2007
- await this.loadMarkets();
2008
- const market = this.market(symbol);
2009
- const request = {
2010
- 'product_id': market['numericId'],
2011
- // 'cancel_limit_orders': 'true',
2012
- // 'cancel_stop_orders': 'true',
2013
- };
2014
- const response = this.privateDeleteOrdersAll(this.extend(request, params));
2015
- //
2016
- // {
2017
- // "result":{},
2018
- // "success":true
2019
- // }
2020
- //
2021
- return response;
2022
- }
2023
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2024
- /**
2025
- * @method
2026
- * @name delta#fetchOpenOrders
2027
- * @description fetch all unfilled currently open orders
2028
- * @see https://docs.delta.exchange/#get-active-orders
2029
- * @param {string} symbol unified market symbol
2030
- * @param {int} [since] the earliest time in ms to fetch open orders for
2031
- * @param {int} [limit] the maximum number of open order structures to retrieve
2032
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2033
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2034
- */
2035
- return await this.fetchOrdersWithMethod('privateGetOrders', symbol, since, limit, params);
2036
- }
2037
- async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2038
- /**
2039
- * @method
2040
- * @name delta#fetchClosedOrders
2041
- * @description fetches information on multiple closed orders made by the user
2042
- * @see https://docs.delta.exchange/#get-order-history-cancelled-and-closed
2043
- * @param {string} symbol unified market symbol of the market orders were made in
2044
- * @param {int} [since] the earliest time in ms to fetch orders for
2045
- * @param {int} [limit] the maximum number of order structures to retrieve
2046
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2047
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2048
- */
2049
- return await this.fetchOrdersWithMethod('privateGetOrdersHistory', symbol, since, limit, params);
2050
- }
2051
- async fetchOrdersWithMethod(method, symbol = undefined, since = undefined, limit = undefined, params = {}) {
2052
- await this.loadMarkets();
2053
- const request = {
2054
- // 'product_ids': market['id'], // comma-separated
2055
- // 'contract_types': types, // comma-separated, futures, perpetual_futures, call_options, put_options, interest_rate_swaps, move_options, spreads
2056
- // 'order_types': types, // comma-separated, market, limit, stop_market, stop_limit, all_stop
2057
- // 'start_time': since * 1000,
2058
- // 'end_time': this.microseconds (),
2059
- // 'after', // after cursor for pagination
2060
- // 'before', // before cursor for pagination
2061
- // 'page_size': limit, // number of records per page
2062
- };
2063
- let market = undefined;
2064
- if (symbol !== undefined) {
2065
- market = this.market(symbol);
2066
- request['product_ids'] = market['numericId']; // accepts a comma-separated list of ids
2067
- }
2068
- if (since !== undefined) {
2069
- request['start_time'] = since.toString() + '000';
2070
- }
2071
- if (limit !== undefined) {
2072
- request['page_size'] = limit;
2073
- }
2074
- let response = undefined;
2075
- if (method === 'privateGetOrders') {
2076
- response = await this.privateGetOrders(this.extend(request, params));
2077
- }
2078
- else if (method === 'privateGetOrdersHistory') {
2079
- response = await this.privateGetOrdersHistory(this.extend(request, params));
2080
- }
2081
- //
2082
- // {
2083
- // "success": true,
2084
- // "result": [
2085
- // {
2086
- // "id": "ashb1212",
2087
- // "product_id": 27,
2088
- // "limit_price": "9200",
2089
- // "side": "buy",
2090
- // "size": 100,
2091
- // "unfilled_size": 50,
2092
- // "user_id": 1,
2093
- // "order_type": "limit_order",
2094
- // "state": "open",
2095
- // "created_at": "..."
2096
- // }
2097
- // ],
2098
- // "meta": {
2099
- // "after": "string",
2100
- // "before": "string"
2101
- // }
2102
- // }
2103
- //
2104
- const result = this.safeValue(response, 'result', []);
2105
- return this.parseOrders(result, market, since, limit);
2106
- }
2107
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2108
- /**
2109
- * @method
2110
- * @name delta#fetchMyTrades
2111
- * @description fetch all trades made by the user
2112
- * @see https://docs.delta.exchange/#get-user-fills-by-filters
2113
- * @param {string} symbol unified market symbol
2114
- * @param {int} [since] the earliest time in ms to fetch trades for
2115
- * @param {int} [limit] the maximum number of trades structures to retrieve
2116
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2117
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
2118
- */
2119
- await this.loadMarkets();
2120
- const request = {
2121
- // 'product_ids': market['id'], // comma-separated
2122
- // 'contract_types': types, // comma-separated, futures, perpetual_futures, call_options, put_options, interest_rate_swaps, move_options, spreads
2123
- // 'start_time': since * 1000,
2124
- // 'end_time': this.microseconds (),
2125
- // 'after', // after cursor for pagination
2126
- // 'before', // before cursor for pagination
2127
- // 'page_size': limit, // number of records per page
2128
- };
2129
- let market = undefined;
2130
- if (symbol !== undefined) {
2131
- market = this.market(symbol);
2132
- request['product_ids'] = market['numericId']; // accepts a comma-separated list of ids
2133
- }
2134
- if (since !== undefined) {
2135
- request['start_time'] = since.toString() + '000';
2136
- }
2137
- if (limit !== undefined) {
2138
- request['page_size'] = limit;
2139
- }
2140
- const response = await this.privateGetFills(this.extend(request, params));
2141
- //
2142
- // {
2143
- // "meta":{
2144
- // "after":null,
2145
- // "before":null,
2146
- // "limit":10,
2147
- // "total_count":2
2148
- // },
2149
- // "result":[
2150
- // {
2151
- // "commission":"0.008335000000000000",
2152
- // "created_at":"2020-11-16T19:07:19Z",
2153
- // "fill_type":"normal",
2154
- // "id":"e7ff05c233a74245b72381f8dd91d1ce",
2155
- // "meta_data":{
2156
- // "effective_commission_rate":"0.0005",
2157
- // "order_price":"16249",
2158
- // "order_size":1,
2159
- // "order_type":"market_order",
2160
- // "order_unfilled_size":0,
2161
- // "trading_fee_credits_used":"0"
2162
- // },
2163
- // "order_id":"152999629",
2164
- // "price":"16669",
2165
- // "product":{
2166
- // "contract_type":"perpetual_futures",
2167
- // "contract_unit_currency":"BTC",
2168
- // "contract_value":"0.001",
2169
- // "id":139,
2170
- // "notional_type":"vanilla",
2171
- // "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"},
2172
- // "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"},
2173
- // "symbol":"BTCUSDT",
2174
- // "tick_size":"0.5",
2175
- // "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"}
2176
- // },
2177
- // "product_id":139,
2178
- // "role":"taker",
2179
- // "side":"sell",
2180
- // "size":1
2181
- // }
2182
- // ],
2183
- // "success":true
2184
- // }
2185
- //
2186
- const result = this.safeValue(response, 'result', []);
2187
- return this.parseTrades(result, market, since, limit);
2188
- }
2189
- async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
2190
- /**
2191
- * @method
2192
- * @name delta#fetchLedger
2193
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2194
- * @see https://docs.delta.exchange/#get-wallet-transactions
2195
- * @param {string} code unified currency code, default is undefined
2196
- * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2197
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
2198
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2199
- * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2200
- */
2201
- await this.loadMarkets();
2202
- const request = {
2203
- // 'asset_id': currency['numericId'],
2204
- // 'end_time': this.seconds (),
2205
- // 'after': 'string', // after cursor for pagination
2206
- // 'before': 'string', // before cursor for pagination
2207
- // 'page_size': limit,
2208
- };
2209
- let currency = undefined;
2210
- if (code !== undefined) {
2211
- currency = this.currency(code);
2212
- request['asset_id'] = currency['numericId'];
2213
- }
2214
- if (limit !== undefined) {
2215
- request['page_size'] = limit;
2216
- }
2217
- const response = await this.privateGetWalletTransactions(this.extend(request, params));
2218
- //
2219
- // {
2220
- // "meta":{"after":null,"before":null,"limit":10,"total_count":1},
2221
- // "result":[
2222
- // {
2223
- // "amount":"29.889184",
2224
- // "asset_id":5,
2225
- // "balance":"29.889184",
2226
- // "created_at":"2020-11-15T21:25:01Z",
2227
- // "meta_data":{
2228
- // "deposit_id":3884,
2229
- // "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d"
2230
- // },
2231
- // "transaction_type":"deposit",
2232
- // "user_id":22142,
2233
- // "uuid":"70bb5679da3c4637884e2dc63efaa846"
2234
- // }
2235
- // ],
2236
- // "success":true
2237
- // }
2238
- //
2239
- const result = this.safeValue(response, 'result', []);
2240
- return this.parseLedger(result, currency, since, limit);
2241
- }
2242
- parseLedgerEntryType(type) {
2243
- const types = {
2244
- 'pnl': 'pnl',
2245
- 'deposit': 'transaction',
2246
- 'withdrawal': 'transaction',
2247
- 'commission': 'fee',
2248
- 'conversion': 'trade',
2249
- // 'perpetual_futures_funding': 'perpetual_futures_funding',
2250
- // 'withdrawal_cancellation': 'withdrawal_cancellation',
2251
- 'referral_bonus': 'referral',
2252
- 'commission_rebate': 'rebate',
2253
- // 'promo_credit': 'promo_credit',
2254
- };
2255
- return this.safeString(types, type, type);
2256
- }
2257
- parseLedgerEntry(item, currency = undefined) {
2258
- //
2259
- // {
2260
- // "amount":"29.889184",
2261
- // "asset_id":5,
2262
- // "balance":"29.889184",
2263
- // "created_at":"2020-11-15T21:25:01Z",
2264
- // "meta_data":{
2265
- // "deposit_id":3884,
2266
- // "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d"
2267
- // },
2268
- // "transaction_type":"deposit",
2269
- // "user_id":22142,
2270
- // "uuid":"70bb5679da3c4637884e2dc63efaa846"
2271
- // }
2272
- //
2273
- const id = this.safeString(item, 'uuid');
2274
- let direction = undefined;
2275
- const account = undefined;
2276
- const metaData = this.safeValue(item, 'meta_data', {});
2277
- const referenceId = this.safeString(metaData, 'transaction_id');
2278
- const referenceAccount = undefined;
2279
- let type = this.safeString(item, 'transaction_type');
2280
- if ((type === 'deposit') || (type === 'commission_rebate') || (type === 'referral_bonus') || (type === 'pnl') || (type === 'withdrawal_cancellation') || (type === 'promo_credit')) {
2281
- direction = 'in';
2282
- }
2283
- else if ((type === 'withdrawal') || (type === 'commission') || (type === 'conversion') || (type === 'perpetual_futures_funding')) {
2284
- direction = 'out';
2285
- }
2286
- type = this.parseLedgerEntryType(type);
2287
- const currencyId = this.safeInteger(item, 'asset_id');
2288
- const currenciesByNumericId = this.safeValue(this.options, 'currenciesByNumericId');
2289
- currency = this.safeValue(currenciesByNumericId, currencyId, currency);
2290
- const code = (currency === undefined) ? undefined : currency['code'];
2291
- const amount = this.safeString(item, 'amount');
2292
- const timestamp = this.parse8601(this.safeString(item, 'created_at'));
2293
- const after = this.safeString(item, 'balance');
2294
- const before = Precise["default"].stringMax('0', Precise["default"].stringSub(after, amount));
2295
- const status = 'ok';
2296
- return {
2297
- 'info': item,
2298
- 'id': id,
2299
- 'direction': direction,
2300
- 'account': account,
2301
- 'referenceId': referenceId,
2302
- 'referenceAccount': referenceAccount,
2303
- 'type': type,
2304
- 'currency': code,
2305
- 'amount': this.parseNumber(amount),
2306
- 'before': this.parseNumber(before),
2307
- 'after': this.parseNumber(after),
2308
- 'status': status,
2309
- 'timestamp': timestamp,
2310
- 'datetime': this.iso8601(timestamp),
2311
- 'fee': undefined,
2312
- };
2313
- }
2314
- async fetchDepositAddress(code, params = {}) {
2315
- /**
2316
- * @method
2317
- * @name delta#fetchDepositAddress
2318
- * @description fetch the deposit address for a currency associated with this account
2319
- * @param {string} code unified currency code
2320
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2321
- * @param {string} [params.network] unified network code
2322
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
2323
- */
2324
- await this.loadMarkets();
2325
- const currency = this.currency(code);
2326
- const request = {
2327
- 'asset_symbol': currency['id'],
2328
- };
2329
- const networkCode = this.safeStringUpper(params, 'network');
2330
- if (networkCode !== undefined) {
2331
- request['network'] = this.networkCodeToId(networkCode, code);
2332
- params = this.omit(params, 'network');
2333
- }
2334
- const response = await this.privateGetDepositsAddress(this.extend(request, params));
2335
- //
2336
- // {
2337
- // "success": true,
2338
- // "result": {
2339
- // "id": 1915615,
2340
- // "user_id": 27854758,
2341
- // "address": "TXYB4GdKsXKEWbeSNPsmGZu4ZVCkhVh1Zz",
2342
- // "memo": "",
2343
- // "status": "active",
2344
- // "updated_at": "2023-01-12T06:03:46.000Z",
2345
- // "created_at": "2023-01-12T06:03:46.000Z",
2346
- // "asset_symbol": "USDT",
2347
- // "network": "TRC20(TRON)",
2348
- // "custodian": "fireblocks"
2349
- // }
2350
- // }
2351
- //
2352
- const result = this.safeValue(response, 'result', {});
2353
- return this.parseDepositAddress(result, currency);
2354
- }
2355
- parseDepositAddress(depositAddress, currency = undefined) {
2356
- //
2357
- // {
2358
- // "id": 1915615,
2359
- // "user_id": 27854758,
2360
- // "address": "TXYB4GdKsXKEWbeSNPsmGZu4ZVCkhVh1Zz",
2361
- // "memo": "",
2362
- // "status": "active",
2363
- // "updated_at": "2023-01-12T06:03:46.000Z",
2364
- // "created_at": "2023-01-12T06:03:46.000Z",
2365
- // "asset_symbol": "USDT",
2366
- // "network": "TRC20(TRON)",
2367
- // "custodian": "fireblocks"
2368
- // }
2369
- //
2370
- const address = this.safeString(depositAddress, 'address');
2371
- const marketId = this.safeString(depositAddress, 'asset_symbol');
2372
- const networkId = this.safeString(depositAddress, 'network');
2373
- this.checkAddress(address);
2374
- return {
2375
- 'currency': this.safeCurrencyCode(marketId, currency),
2376
- 'address': address,
2377
- 'tag': this.safeString(depositAddress, 'memo'),
2378
- 'network': this.networkIdToCode(networkId),
2379
- 'info': depositAddress,
2380
- };
2381
- }
2382
- async fetchFundingRate(symbol, params = {}) {
2383
- /**
2384
- * @method
2385
- * @name delta#fetchFundingRate
2386
- * @description fetch the current funding rate
2387
- * @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
2388
- * @param {string} symbol unified market symbol
2389
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2390
- * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
2391
- */
2392
- await this.loadMarkets();
2393
- const market = this.market(symbol);
2394
- if (!market['swap']) {
2395
- throw new errors.BadSymbol(this.id + ' fetchFundingRate() supports swap contracts only');
2396
- }
2397
- const request = {
2398
- 'symbol': market['id'],
2399
- };
2400
- const response = await this.publicGetTickersSymbol(this.extend(request, params));
2401
- //
2402
- // {
2403
- // "result": {
2404
- // "close": 30600.5,
2405
- // "contract_type": "perpetual_futures",
2406
- // "funding_rate": "0.00602961",
2407
- // "greeks": null,
2408
- // "high": 30803.0,
2409
- // "low": 30265.5,
2410
- // "mark_basis": "-0.45601594",
2411
- // "mark_price": "30600.10481568",
2412
- // "oi": "469.9190",
2413
- // "oi_change_usd_6h": "2226314.9900",
2414
- // "oi_contracts": "469919",
2415
- // "oi_value": "469.9190",
2416
- // "oi_value_symbol": "BTC",
2417
- // "oi_value_usd": "14385640.6802",
2418
- // "open": 30458.5,
2419
- // "price_band": {
2420
- // "lower_limit": "29067.08312627",
2421
- // "upper_limit": "32126.77608693"
2422
- // },
2423
- // "product_id": 139,
2424
- // "quotes": {
2425
- // "ask_iv": null,
2426
- // "ask_size": "965",
2427
- // "best_ask": "30600.5",
2428
- // "best_bid": "30599.5",
2429
- // "bid_iv": null,
2430
- // "bid_size": "196",
2431
- // "impact_mid_price": null,
2432
- // "mark_iv": "-0.44931641"
2433
- // },
2434
- // "size": 1226303,
2435
- // "spot_price": "30612.85362773",
2436
- // "symbol": "BTCUSDT",
2437
- // "timestamp": 1689136597460456,
2438
- // "turnover": 37392218.45999999,
2439
- // "turnover_symbol": "USDT",
2440
- // "turnover_usd": 37392218.45999999,
2441
- // "volume": 1226.3029999999485
2442
- // },
2443
- // "success": true
2444
- // }
2445
- //
2446
- const result = this.safeValue(response, 'result', {});
2447
- return this.parseFundingRate(result, market);
2448
- }
2449
- async fetchFundingRates(symbols = undefined, params = {}) {
2450
- /**
2451
- * @method
2452
- * @name delta#fetchFundingRates
2453
- * @description fetch the funding rate for multiple markets
2454
- * @see https://docs.delta.exchange/#get-tickers-for-products
2455
- * @param {string[]|undefined} symbols list of unified market symbols
2456
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2457
- * @returns {object} a dictionary of [funding rates structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexe by market symbols
2458
- */
2459
- await this.loadMarkets();
2460
- symbols = this.marketSymbols(symbols);
2461
- const request = {
2462
- 'contract_types': 'perpetual_futures',
2463
- };
2464
- const response = await this.publicGetTickers(this.extend(request, params));
2465
- //
2466
- // {
2467
- // "result": [
2468
- // {
2469
- // "close": 30600.5,
2470
- // "contract_type": "perpetual_futures",
2471
- // "funding_rate": "0.00602961",
2472
- // "greeks": null,
2473
- // "high": 30803.0,
2474
- // "low": 30265.5,
2475
- // "mark_basis": "-0.45601594",
2476
- // "mark_price": "30600.10481568",
2477
- // "oi": "469.9190",
2478
- // "oi_change_usd_6h": "2226314.9900",
2479
- // "oi_contracts": "469919",
2480
- // "oi_value": "469.9190",
2481
- // "oi_value_symbol": "BTC",
2482
- // "oi_value_usd": "14385640.6802",
2483
- // "open": 30458.5,
2484
- // "price_band": {
2485
- // "lower_limit": "29067.08312627",
2486
- // "upper_limit": "32126.77608693"
2487
- // },
2488
- // "product_id": 139,
2489
- // "quotes": {
2490
- // "ask_iv": null,
2491
- // "ask_size": "965",
2492
- // "best_ask": "30600.5",
2493
- // "best_bid": "30599.5",
2494
- // "bid_iv": null,
2495
- // "bid_size": "196",
2496
- // "impact_mid_price": null,
2497
- // "mark_iv": "-0.44931641"
2498
- // },
2499
- // "size": 1226303,
2500
- // "spot_price": "30612.85362773",
2501
- // "symbol": "BTCUSDT",
2502
- // "timestamp": 1689136597460456,
2503
- // "turnover": 37392218.45999999,
2504
- // "turnover_symbol": "USDT",
2505
- // "turnover_usd": 37392218.45999999,
2506
- // "volume": 1226.3029999999485
2507
- // },
2508
- // ],
2509
- // "success":true
2510
- // }
2511
- //
2512
- const rates = this.safeValue(response, 'result', []);
2513
- const result = this.parseFundingRates(rates);
2514
- return this.filterByArray(result, 'symbol', symbols);
2515
- }
2516
- parseFundingRate(contract, market = undefined) {
2517
- //
2518
- // {
2519
- // "close": 30600.5,
2520
- // "contract_type": "perpetual_futures",
2521
- // "funding_rate": "0.00602961",
2522
- // "greeks": null,
2523
- // "high": 30803.0,
2524
- // "low": 30265.5,
2525
- // "mark_basis": "-0.45601594",
2526
- // "mark_price": "30600.10481568",
2527
- // "oi": "469.9190",
2528
- // "oi_change_usd_6h": "2226314.9900",
2529
- // "oi_contracts": "469919",
2530
- // "oi_value": "469.9190",
2531
- // "oi_value_symbol": "BTC",
2532
- // "oi_value_usd": "14385640.6802",
2533
- // "open": 30458.5,
2534
- // "price_band": {
2535
- // "lower_limit": "29067.08312627",
2536
- // "upper_limit": "32126.77608693"
2537
- // },
2538
- // "product_id": 139,
2539
- // "quotes": {
2540
- // "ask_iv": null,
2541
- // "ask_size": "965",
2542
- // "best_ask": "30600.5",
2543
- // "best_bid": "30599.5",
2544
- // "bid_iv": null,
2545
- // "bid_size": "196",
2546
- // "impact_mid_price": null,
2547
- // "mark_iv": "-0.44931641"
2548
- // },
2549
- // "size": 1226303,
2550
- // "spot_price": "30612.85362773",
2551
- // "symbol": "BTCUSDT",
2552
- // "timestamp": 1689136597460456,
2553
- // "turnover": 37392218.45999999,
2554
- // "turnover_symbol": "USDT",
2555
- // "turnover_usd": 37392218.45999999,
2556
- // "volume": 1226.3029999999485
2557
- // }
2558
- //
2559
- const timestamp = this.safeIntegerProduct(contract, 'timestamp', 0.001);
2560
- const marketId = this.safeString(contract, 'symbol');
2561
- const fundingRateString = this.safeString(contract, 'funding_rate');
2562
- const fundingRate = Precise["default"].stringDiv(fundingRateString, '100');
2563
- return {
2564
- 'info': contract,
2565
- 'symbol': this.safeSymbol(marketId, market),
2566
- 'markPrice': this.safeNumber(contract, 'mark_price'),
2567
- 'indexPrice': this.safeNumber(contract, 'spot_price'),
2568
- 'interestRate': undefined,
2569
- 'estimatedSettlePrice': undefined,
2570
- 'timestamp': timestamp,
2571
- 'datetime': this.iso8601(timestamp),
2572
- 'fundingRate': this.parseNumber(fundingRate),
2573
- 'fundingTimestamp': undefined,
2574
- 'fundingDatetime': undefined,
2575
- 'nextFundingRate': undefined,
2576
- 'nextFundingTimestamp': undefined,
2577
- 'nextFundingDatetime': undefined,
2578
- 'previousFundingRate': undefined,
2579
- 'previousFundingTimestamp': undefined,
2580
- 'previousFundingDatetime': undefined,
2581
- };
2582
- }
2583
- async addMargin(symbol, amount, params = {}) {
2584
- /**
2585
- * @method
2586
- * @name delta#addMargin
2587
- * @description add margin
2588
- * @see https://docs.delta.exchange/#add-remove-position-margin
2589
- * @param {string} symbol unified market symbol
2590
- * @param {float} amount amount of margin to add
2591
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2592
- * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
2593
- */
2594
- return await this.modifyMarginHelper(symbol, amount, 'add', params);
2595
- }
2596
- async reduceMargin(symbol, amount, params = {}) {
2597
- /**
2598
- * @method
2599
- * @name delta#reduceMargin
2600
- * @description remove margin from a position
2601
- * @see https://docs.delta.exchange/#add-remove-position-margin
2602
- * @param {string} symbol unified market symbol
2603
- * @param {float} amount the amount of margin to remove
2604
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2605
- * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure}
2606
- */
2607
- return await this.modifyMarginHelper(symbol, amount, 'reduce', params);
2608
- }
2609
- async modifyMarginHelper(symbol, amount, type, params = {}) {
2610
- await this.loadMarkets();
2611
- const market = this.market(symbol);
2612
- amount = amount.toString();
2613
- if (type === 'reduce') {
2614
- amount = Precise["default"].stringMul(amount, '-1');
2615
- }
2616
- const request = {
2617
- 'product_id': market['numericId'],
2618
- 'delta_margin': amount,
2619
- };
2620
- const response = await this.privatePostPositionsChangeMargin(this.extend(request, params));
2621
- //
2622
- // {
2623
- // "result": {
2624
- // "auto_topup": false,
2625
- // "bankruptcy_price": "24934.12",
2626
- // "commission": "0.01197072",
2627
- // "created_at": "2023-07-20T03:49:09.159401Z",
2628
- // "entry_price": "29926.8",
2629
- // "liquidation_price": "25083.754",
2630
- // "margin": "4.99268",
2631
- // "margin_mode": "isolated",
2632
- // "product_id": 84,
2633
- // "product_symbol": "BTCUSDT",
2634
- // "realized_cashflow": "0",
2635
- // "realized_funding": "0",
2636
- // "realized_pnl": "0",
2637
- // "size": 1,
2638
- // "updated_at": "2023-07-20T03:49:09.159401Z",
2639
- // "user_id": 30084879
2640
- // },
2641
- // "success": true
2642
- // }
2643
- //
2644
- const result = this.safeValue(response, 'result', {});
2645
- return this.parseMarginModification(result, market);
2646
- }
2647
- parseMarginModification(data, market = undefined) {
2648
- //
2649
- // {
2650
- // "auto_topup": false,
2651
- // "bankruptcy_price": "24934.12",
2652
- // "commission": "0.01197072",
2653
- // "created_at": "2023-07-20T03:49:09.159401Z",
2654
- // "entry_price": "29926.8",
2655
- // "liquidation_price": "25083.754",
2656
- // "margin": "4.99268",
2657
- // "margin_mode": "isolated",
2658
- // "product_id": 84,
2659
- // "product_symbol": "BTCUSDT",
2660
- // "realized_cashflow": "0",
2661
- // "realized_funding": "0",
2662
- // "realized_pnl": "0",
2663
- // "size": 1,
2664
- // "updated_at": "2023-07-20T03:49:09.159401Z",
2665
- // "user_id": 30084879
2666
- // }
2667
- //
2668
- const marketId = this.safeString(data, 'product_symbol');
2669
- market = this.safeMarket(marketId, market);
2670
- return {
2671
- 'info': data,
2672
- 'type': undefined,
2673
- 'amount': undefined,
2674
- 'total': this.safeNumber(data, 'margin'),
2675
- 'code': undefined,
2676
- 'symbol': market['symbol'],
2677
- 'status': undefined,
2678
- };
2679
- }
2680
- async fetchOpenInterest(symbol, params = {}) {
2681
- /**
2682
- * @method
2683
- * @name delta#fetchOpenInterest
2684
- * @description retrieves the open interest of a derivative market
2685
- * @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
2686
- * @param {string} symbol unified market symbol
2687
- * @param {object} [params] exchange specific parameters
2688
- * @returns {object} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure}
2689
- */
2690
- await this.loadMarkets();
2691
- const market = this.market(symbol);
2692
- if (!market['contract']) {
2693
- throw new errors.BadRequest(this.id + ' fetchOpenInterest() supports contract markets only');
2694
- }
2695
- const request = {
2696
- 'symbol': market['id'],
2697
- };
2698
- const response = await this.publicGetTickersSymbol(this.extend(request, params));
2699
- //
2700
- // {
2701
- // "result": {
2702
- // "close": 894.0,
2703
- // "contract_type": "call_options",
2704
- // "greeks": {
2705
- // "delta": "0.67324861",
2706
- // "gamma": "0.00022178",
2707
- // "rho": "4.34638266",
2708
- // "spot": "30178.53195697",
2709
- // "theta": "-35.64972577",
2710
- // "vega": "16.34381277"
2711
- // },
2712
- // "high": 946.0,
2713
- // "low": 893.0,
2714
- // "mark_price": "1037.07582681",
2715
- // "mark_vol": "0.35899491",
2716
- // "oi": "0.0910",
2717
- // "oi_change_usd_6h": "-90.5500",
2718
- // "oi_contracts": "91",
2719
- // "oi_value": "0.0910",
2720
- // "oi_value_symbol": "BTC",
2721
- // "oi_value_usd": "2746.3549",
2722
- // "open": 946.0,
2723
- // "price_band": {
2724
- // "lower_limit": "133.37794509",
2725
- // "upper_limit": "5663.66930164"
2726
- // },
2727
- // "product_id": 116171,
2728
- // "quotes": {
2729
- // "ask_iv": "0.36932389",
2730
- // "ask_size": "1321",
2731
- // "best_ask": "1054",
2732
- // "best_bid": "1020",
2733
- // "bid_iv": "0.34851914",
2734
- // "bid_size": "2202",
2735
- // "impact_mid_price": null,
2736
- // "mark_iv": "0.35896335"
2737
- // },
2738
- // "size": 152,
2739
- // "spot_price": "30178.53195697",
2740
- // "strike_price": "29500",
2741
- // "symbol": "C-BTC-29500-280723",
2742
- // "timestamp": 1689834695286094,
2743
- // "turnover": 4546.601744940001,
2744
- // "turnover_symbol": "USDT",
2745
- // "turnover_usd": 4546.601744940001,
2746
- // "volume": 0.15200000000000002
2747
- // },
2748
- // "success": true
2749
- // }
2750
- //
2751
- const result = this.safeValue(response, 'result', {});
2752
- return this.parseOpenInterest(result, market);
2753
- }
2754
- parseOpenInterest(interest, market = undefined) {
2755
- //
2756
- // {
2757
- // "close": 894.0,
2758
- // "contract_type": "call_options",
2759
- // "greeks": {
2760
- // "delta": "0.67324861",
2761
- // "gamma": "0.00022178",
2762
- // "rho": "4.34638266",
2763
- // "spot": "30178.53195697",
2764
- // "theta": "-35.64972577",
2765
- // "vega": "16.34381277"
2766
- // },
2767
- // "high": 946.0,
2768
- // "low": 893.0,
2769
- // "mark_price": "1037.07582681",
2770
- // "mark_vol": "0.35899491",
2771
- // "oi": "0.0910",
2772
- // "oi_change_usd_6h": "-90.5500",
2773
- // "oi_contracts": "91",
2774
- // "oi_value": "0.0910",
2775
- // "oi_value_symbol": "BTC",
2776
- // "oi_value_usd": "2746.3549",
2777
- // "open": 946.0,
2778
- // "price_band": {
2779
- // "lower_limit": "133.37794509",
2780
- // "upper_limit": "5663.66930164"
2781
- // },
2782
- // "product_id": 116171,
2783
- // "quotes": {
2784
- // "ask_iv": "0.36932389",
2785
- // "ask_size": "1321",
2786
- // "best_ask": "1054",
2787
- // "best_bid": "1020",
2788
- // "bid_iv": "0.34851914",
2789
- // "bid_size": "2202",
2790
- // "impact_mid_price": null,
2791
- // "mark_iv": "0.35896335"
2792
- // },
2793
- // "size": 152,
2794
- // "spot_price": "30178.53195697",
2795
- // "strike_price": "29500",
2796
- // "symbol": "C-BTC-29500-280723",
2797
- // "timestamp": 1689834695286094,
2798
- // "turnover": 4546.601744940001,
2799
- // "turnover_symbol": "USDT",
2800
- // "turnover_usd": 4546.601744940001,
2801
- // "volume": 0.15200000000000002
2802
- // }
2803
- //
2804
- const timestamp = this.safeIntegerProduct(interest, 'timestamp', 0.001);
2805
- const marketId = this.safeString(interest, 'symbol');
2806
- return this.safeOpenInterest({
2807
- 'symbol': this.safeSymbol(marketId, market),
2808
- 'baseVolume': this.safeNumber(interest, 'oi_value'),
2809
- 'quoteVolume': this.safeNumber(interest, 'oi_value_usd'),
2810
- 'openInterestAmount': this.safeNumber(interest, 'oi_contracts'),
2811
- 'openInterestValue': this.safeNumber(interest, 'oi'),
2812
- 'timestamp': timestamp,
2813
- 'datetime': this.iso8601(timestamp),
2814
- 'info': interest,
2815
- }, market);
2816
- }
2817
- async fetchLeverage(symbol, params = {}) {
2818
- /**
2819
- * @method
2820
- * @name delta#fetchLeverage
2821
- * @description fetch the set leverage for a market
2822
- * @see https://docs.delta.exchange/#get-order-leverage
2823
- * @param {string} symbol unified market symbol
2824
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2825
- * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
2826
- */
2827
- await this.loadMarkets();
2828
- const market = this.market(symbol);
2829
- const request = {
2830
- 'product_id': market['numericId'],
2831
- };
2832
- //
2833
- // {
2834
- // "result": {
2835
- // "index_symbol": null,
2836
- // "leverage": "10",
2837
- // "margin_mode": "isolated",
2838
- // "order_margin": "0",
2839
- // "product_id": 84,
2840
- // "user_id": 30084879
2841
- // },
2842
- // "success": true
2843
- // }
2844
- //
2845
- return await this.privateGetProductsProductIdOrdersLeverage(this.extend(request, params));
2846
- }
2847
- async setLeverage(leverage, symbol = undefined, params = {}) {
2848
- /**
2849
- * @method
2850
- * @name delta#setLeverage
2851
- * @description set the level of leverage for a market
2852
- * @see https://docs.delta.exchange/#change-order-leverage
2853
- * @param {float} leverage the rate of leverage
2854
- * @param {string} symbol unified market symbol
2855
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2856
- * @returns {object} response from the exchange
2857
- */
2858
- if (symbol === undefined) {
2859
- throw new errors.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
2860
- }
2861
- await this.loadMarkets();
2862
- const market = this.market(symbol);
2863
- const request = {
2864
- 'product_id': market['numericId'],
2865
- 'leverage': leverage,
2866
- };
2867
- //
2868
- // {
2869
- // "result": {
2870
- // "leverage": "20",
2871
- // "margin_mode": "isolated",
2872
- // "order_margin": "0",
2873
- // "product_id": 84
2874
- // },
2875
- // "success": true
2876
- // }
2877
- //
2878
- return await this.privatePostProductsProductIdOrdersLeverage(this.extend(request, params));
2879
- }
2880
- async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2881
- /**
2882
- * @method
2883
- * @name delta#fetchSettlementHistory
2884
- * @description fetches historical settlement records
2885
- * @see https://docs.delta.exchange/#get-product-settlement-prices
2886
- * @param {string} symbol unified market symbol of the settlement history
2887
- * @param {int} [since] timestamp in ms
2888
- * @param {int} [limit] number of records
2889
- * @param {object} [params] exchange specific params
2890
- * @returns {object[]} a list of [settlement history objects]{@link https://docs.ccxt.com/#/?id=settlement-history-structure}
2891
- */
2892
- await this.loadMarkets();
2893
- let market = undefined;
2894
- if (symbol !== undefined) {
2895
- market = this.market(symbol);
2896
- }
2897
- const request = {
2898
- 'states': 'expired',
2899
- };
2900
- if (limit !== undefined) {
2901
- request['page_size'] = limit;
2902
- }
2903
- const response = await this.publicGetProducts(this.extend(request, params));
2904
- //
2905
- // {
2906
- // "result": [
2907
- // {
2908
- // "contract_value": "0.001",
2909
- // "basis_factor_max_limit": "10.95",
2910
- // "maker_commission_rate": "0.0003",
2911
- // "launch_time": "2023-07-19T04:30:03Z",
2912
- // "trading_status": "operational",
2913
- // "product_specs": {
2914
- // "backup_vol_expiry_time": 31536000,
2915
- // "max_deviation_from_external_vol": 0.75,
2916
- // "max_lower_deviation_from_external_vol": 0.75,
2917
- // "max_upper_deviation_from_external_vol": 0.5,
2918
- // "max_volatility": 3,
2919
- // "min_volatility": 0.1,
2920
- // "premium_commission_rate": 0.1,
2921
- // "settlement_index_price": "29993.536675710806",
2922
- // "vol_calculation_method": "orderbook",
2923
- // "vol_expiry_time": 31536000
2924
- // },
2925
- // "description": "BTC call option expiring on 19-7-2023",
2926
- // "settlement_price": "0",
2927
- // "disruption_reason": null,
2928
- // "settling_asset": {},
2929
- // "initial_margin": "1",
2930
- // "tick_size": "0.1",
2931
- // "maintenance_margin": "0.5",
2932
- // "id": 117542,
2933
- // "notional_type": "vanilla",
2934
- // "ui_config": {},
2935
- // "contract_unit_currency": "BTC",
2936
- // "symbol": "C-BTC-30900-190723",
2937
- // "insurance_fund_margin_contribution": "1",
2938
- // "price_band": "2",
2939
- // "annualized_funding": "10.95",
2940
- // "impact_size": 200,
2941
- // "contract_type": "call_options",
2942
- // "position_size_limit": 255633,
2943
- // "max_leverage_notional": "200000",
2944
- // "initial_margin_scaling_factor": "0.000002",
2945
- // "strike_price": "30900",
2946
- // "is_quanto": false,
2947
- // "settlement_time": "2023-07-19T12:00:00Z",
2948
- // "liquidation_penalty_factor": "0.5",
2949
- // "funding_method": "mark_price",
2950
- // "taker_commission_rate": "0.0003",
2951
- // "default_leverage": "100.000000000000000000",
2952
- // "state": "expired",
2953
- // "auction_start_time": null,
2954
- // "short_description": "BTC Call",
2955
- // "quoting_asset": {},
2956
- // "maintenance_margin_scaling_factor":"0.000002"
2957
- // }
2958
- // ],
2959
- // "success": true
2960
- // }
2961
- //
2962
- const result = this.safeValue(response, 'result', []);
2963
- const settlements = this.parseSettlements(result, market);
2964
- const sorted = this.sortBy(settlements, 'timestamp');
2965
- return this.filterBySymbolSinceLimit(sorted, market['symbol'], since, limit);
2966
- }
2967
- parseSettlement(settlement, market) {
2968
- //
2969
- // {
2970
- // "contract_value": "0.001",
2971
- // "basis_factor_max_limit": "10.95",
2972
- // "maker_commission_rate": "0.0003",
2973
- // "launch_time": "2023-07-19T04:30:03Z",
2974
- // "trading_status": "operational",
2975
- // "product_specs": {
2976
- // "backup_vol_expiry_time": 31536000,
2977
- // "max_deviation_from_external_vol": 0.75,
2978
- // "max_lower_deviation_from_external_vol": 0.75,
2979
- // "max_upper_deviation_from_external_vol": 0.5,
2980
- // "max_volatility": 3,
2981
- // "min_volatility": 0.1,
2982
- // "premium_commission_rate": 0.1,
2983
- // "settlement_index_price": "29993.536675710806",
2984
- // "vol_calculation_method": "orderbook",
2985
- // "vol_expiry_time": 31536000
2986
- // },
2987
- // "description": "BTC call option expiring on 19-7-2023",
2988
- // "settlement_price": "0",
2989
- // "disruption_reason": null,
2990
- // "settling_asset": {},
2991
- // "initial_margin": "1",
2992
- // "tick_size": "0.1",
2993
- // "maintenance_margin": "0.5",
2994
- // "id": 117542,
2995
- // "notional_type": "vanilla",
2996
- // "ui_config": {},
2997
- // "contract_unit_currency": "BTC",
2998
- // "symbol": "C-BTC-30900-190723",
2999
- // "insurance_fund_margin_contribution": "1",
3000
- // "price_band": "2",
3001
- // "annualized_funding": "10.95",
3002
- // "impact_size": 200,
3003
- // "contract_type": "call_options",
3004
- // "position_size_limit": 255633,
3005
- // "max_leverage_notional": "200000",
3006
- // "initial_margin_scaling_factor": "0.000002",
3007
- // "strike_price": "30900",
3008
- // "is_quanto": false,
3009
- // "settlement_time": "2023-07-19T12:00:00Z",
3010
- // "liquidation_penalty_factor": "0.5",
3011
- // "funding_method": "mark_price",
3012
- // "taker_commission_rate": "0.0003",
3013
- // "default_leverage": "100.000000000000000000",
3014
- // "state": "expired",
3015
- // "auction_start_time": null,
3016
- // "short_description": "BTC Call",
3017
- // "quoting_asset": {},
3018
- // "maintenance_margin_scaling_factor":"0.000002"
3019
- // }
3020
- //
3021
- const datetime = this.safeString(settlement, 'settlement_time');
3022
- const marketId = this.safeString(settlement, 'symbol');
3023
- return {
3024
- 'info': settlement,
3025
- 'symbol': this.safeSymbol(marketId, market),
3026
- 'price': this.safeNumber(settlement, 'settlement_price'),
3027
- 'timestamp': this.parse8601(datetime),
3028
- 'datetime': datetime,
3029
- };
3030
- }
3031
- parseSettlements(settlements, market) {
3032
- const result = [];
3033
- for (let i = 0; i < settlements.length; i++) {
3034
- result.push(this.parseSettlement(settlements[i], market));
3035
- }
3036
- return result;
3037
- }
3038
- async fetchGreeks(symbol, params = {}) {
3039
- /**
3040
- * @method
3041
- * @name delta#fetchGreeks
3042
- * @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
3043
- * @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
3044
- * @param {string} symbol unified symbol of the market to fetch greeks for
3045
- * @param {object} [params] extra parameters specific to the exchange API endpoint
3046
- * @returns {object} a [greeks structure]{@link https://docs.ccxt.com/#/?id=greeks-structure}
3047
- */
3048
- await this.loadMarkets();
3049
- const market = this.market(symbol);
3050
- const request = {
3051
- 'symbol': market['id'],
3052
- };
3053
- const response = await this.publicGetTickersSymbol(this.extend(request, params));
3054
- //
3055
- // {
3056
- // "result": {
3057
- // "close": 6793.0,
3058
- // "contract_type": "call_options",
3059
- // "greeks": {
3060
- // "delta": "0.94739174",
3061
- // "gamma": "0.00002206",
3062
- // "rho": "11.00890725",
3063
- // "spot": "36839.58124652",
3064
- // "theta": "-18.18365310",
3065
- // "vega": "7.85209698"
3066
- // },
3067
- // "high": 7556.0,
3068
- // "low": 6793.0,
3069
- // "mark_price": "6955.70698909",
3070
- // "mark_vol": "0.66916863",
3071
- // "oi": "1.8980",
3072
- // "oi_change_usd_6h": "110.4600",
3073
- // "oi_contracts": "1898",
3074
- // "oi_value": "1.8980",
3075
- // "oi_value_symbol": "BTC",
3076
- // "oi_value_usd": "69940.7319",
3077
- // "open": 7.2e3,
3078
- // "price_band": {
3079
- // "lower_limit": "5533.89814767",
3080
- // "upper_limit": "11691.37688371"
3081
- // },
3082
- // "product_id": 129508,
3083
- // "quotes": {
3084
- // "ask_iv": "0.90180438",
3085
- // "ask_size": "1898",
3086
- // "best_ask": "7210",
3087
- // "best_bid": "6913",
3088
- // "bid_iv": "0.60881706",
3089
- // "bid_size": "3163",
3090
- // "impact_mid_price": null,
3091
- // "mark_iv": "0.66973549"
3092
- // },
3093
- // "size": 5,
3094
- // "spot_price": "36839.58153868",
3095
- // "strike_price": "30000",
3096
- // "symbol": "C-BTC-30000-241123",
3097
- // "timestamp": 1699584998504530,
3098
- // "turnover": 184.41206804,
3099
- // "turnover_symbol": "USDT",
3100
- // "turnover_usd": 184.41206804,
3101
- // "volume": 0.005
3102
- // },
3103
- // "success": true
3104
- // }
3105
- //
3106
- const result = this.safeValue(response, 'result', {});
3107
- return this.parseGreeks(result, market);
3108
- }
3109
- parseGreeks(greeks, market = undefined) {
3110
- //
3111
- // {
3112
- // "close": 6793.0,
3113
- // "contract_type": "call_options",
3114
- // "greeks": {
3115
- // "delta": "0.94739174",
3116
- // "gamma": "0.00002206",
3117
- // "rho": "11.00890725",
3118
- // "spot": "36839.58124652",
3119
- // "theta": "-18.18365310",
3120
- // "vega": "7.85209698"
3121
- // },
3122
- // "high": 7556.0,
3123
- // "low": 6793.0,
3124
- // "mark_price": "6955.70698909",
3125
- // "mark_vol": "0.66916863",
3126
- // "oi": "1.8980",
3127
- // "oi_change_usd_6h": "110.4600",
3128
- // "oi_contracts": "1898",
3129
- // "oi_value": "1.8980",
3130
- // "oi_value_symbol": "BTC",
3131
- // "oi_value_usd": "69940.7319",
3132
- // "open": 7.2e3,
3133
- // "price_band": {
3134
- // "lower_limit": "5533.89814767",
3135
- // "upper_limit": "11691.37688371"
3136
- // },
3137
- // "product_id": 129508,
3138
- // "quotes": {
3139
- // "ask_iv": "0.90180438",
3140
- // "ask_size": "1898",
3141
- // "best_ask": "7210",
3142
- // "best_bid": "6913",
3143
- // "bid_iv": "0.60881706",
3144
- // "bid_size": "3163",
3145
- // "impact_mid_price": null,
3146
- // "mark_iv": "0.66973549"
3147
- // },
3148
- // "size": 5,
3149
- // "spot_price": "36839.58153868",
3150
- // "strike_price": "30000",
3151
- // "symbol": "C-BTC-30000-241123",
3152
- // "timestamp": 1699584998504530,
3153
- // "turnover": 184.41206804,
3154
- // "turnover_symbol": "USDT",
3155
- // "turnover_usd": 184.41206804,
3156
- // "volume": 0.005
3157
- // }
3158
- //
3159
- const timestamp = this.safeIntegerProduct(greeks, 'timestamp', 0.001);
3160
- const marketId = this.safeString(greeks, 'symbol');
3161
- const symbol = this.safeSymbol(marketId, market);
3162
- const stats = this.safeValue(greeks, 'greeks', {});
3163
- const quotes = this.safeValue(greeks, 'quotes', {});
3164
- return {
3165
- 'symbol': symbol,
3166
- 'timestamp': timestamp,
3167
- 'datetime': this.iso8601(timestamp),
3168
- 'delta': this.safeNumber(stats, 'delta'),
3169
- 'gamma': this.safeNumber(stats, 'gamma'),
3170
- 'theta': this.safeNumber(stats, 'theta'),
3171
- 'vega': this.safeNumber(stats, 'vega'),
3172
- 'rho': this.safeNumber(stats, 'rho'),
3173
- 'bidSize': this.safeNumber(quotes, 'bid_size'),
3174
- 'askSize': this.safeNumber(quotes, 'ask_size'),
3175
- 'bidImpliedVolatility': this.safeNumber(quotes, 'bid_iv'),
3176
- 'askImpliedVolatility': this.safeNumber(quotes, 'ask_iv'),
3177
- 'markImpliedVolatility': this.safeNumber(quotes, 'mark_iv'),
3178
- 'bidPrice': this.safeNumber(quotes, 'best_bid'),
3179
- 'askPrice': this.safeNumber(quotes, 'best_ask'),
3180
- 'markPrice': this.safeNumber(greeks, 'mark_price'),
3181
- 'lastPrice': undefined,
3182
- 'underlyingPrice': this.safeNumber(greeks, 'spot_price'),
3183
- 'info': greeks,
3184
- };
3185
- }
3186
- async closeAllPositions(params = {}) {
3187
- /**
3188
- * @method
3189
- * @name delta#closeAllPositions
3190
- * @description closes all open positions for a market type
3191
- * @see https://docs.delta.exchange/#close-all-positions
3192
- * @param {object} [params] extra parameters specific to the exchange API endpoint
3193
- * @param {int} [params.user_id] the users id
3194
- * @returns {object[]} A list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
3195
- */
3196
- await this.loadMarkets();
3197
- const request = {
3198
- 'close_all_portfolio': true,
3199
- 'close_all_isolated': true,
3200
- // 'user_id': 12345,
3201
- };
3202
- const response = await this.privatePostPositionsCloseAll(this.extend(request, params));
3203
- //
3204
- // {"result":{},"success":true}
3205
- //
3206
- const position = this.parsePosition(this.safeValue(response, 'result', {}));
3207
- return [position];
3208
- }
3209
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3210
- const requestPath = '/' + this.version + '/' + this.implodeParams(path, params);
3211
- let url = this.urls['api'][api] + requestPath;
3212
- const query = this.omit(params, this.extractParams(path));
3213
- if (api === 'public') {
3214
- if (Object.keys(query).length) {
3215
- url += '?' + this.urlencode(query);
3216
- }
3217
- }
3218
- else if (api === 'private') {
3219
- this.checkRequiredCredentials();
3220
- const timestamp = this.seconds().toString();
3221
- headers = {
3222
- 'api-key': this.apiKey,
3223
- 'timestamp': timestamp,
3224
- };
3225
- let auth = method + timestamp + requestPath;
3226
- if ((method === 'GET') || (method === 'DELETE')) {
3227
- if (Object.keys(query).length) {
3228
- const queryString = '?' + this.urlencode(query);
3229
- auth += queryString;
3230
- url += queryString;
3231
- }
3232
- }
3233
- else {
3234
- body = this.json(query);
3235
- auth += body;
3236
- headers['Content-Type'] = 'application/json';
3237
- }
3238
- const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
3239
- headers['signature'] = signature;
3240
- }
3241
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
3242
- }
3243
- handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3244
- if (response === undefined) {
3245
- return undefined;
3246
- }
3247
- //
3248
- // {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false}
3249
- //
3250
- const error = this.safeValue(response, 'error', {});
3251
- const errorCode = this.safeString(error, 'code');
3252
- if (errorCode !== undefined) {
3253
- const feedback = this.id + ' ' + body;
3254
- this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
3255
- this.throwBroadlyMatchedException(this.exceptions['broad'], errorCode, feedback);
3256
- throw new errors.ExchangeError(feedback); // unknown message
3257
- }
3258
- return undefined;
3259
- }
3260
- }
3261
-
3262
- module.exports = delta;