ccxt-ir 4.3.46.0.3__py2.py3-none-any.whl → 4.5.0__py2.py3-none-any.whl

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 (529) hide show
  1. ccxt/__init__.py +39 -35
  2. ccxt/abantether.py +8 -8
  3. ccxt/abstract/alpaca.py +4 -0
  4. ccxt/abstract/apex.py +31 -0
  5. ccxt/abstract/bigone.py +1 -1
  6. ccxt/abstract/binance.py +106 -48
  7. ccxt/abstract/binancecoinm.py +106 -48
  8. ccxt/abstract/binanceus.py +141 -83
  9. ccxt/abstract/binanceusdm.py +106 -48
  10. ccxt/abstract/bingx.py +50 -1
  11. ccxt/abstract/bitbank.py +5 -0
  12. ccxt/abstract/bitfinex.py +136 -65
  13. ccxt/abstract/bitflyer.py +1 -0
  14. ccxt/abstract/bitget.py +67 -0
  15. ccxt/abstract/bitmart.py +19 -1
  16. ccxt/abstract/bitopro.py +1 -0
  17. ccxt/abstract/bitrue.py +68 -68
  18. ccxt/abstract/bitstamp.py +1 -0
  19. ccxt/abstract/blofin.py +30 -0
  20. ccxt/abstract/btcbox.py +2 -0
  21. ccxt/abstract/bybit.py +28 -13
  22. ccxt/abstract/cex.py +28 -29
  23. ccxt/abstract/coinbaseexchange.py +1 -0
  24. ccxt/abstract/coinbaseinternational.py +1 -1
  25. ccxt/abstract/cryptocom.py +16 -0
  26. ccxt/abstract/cryptomus.py +20 -0
  27. ccxt/abstract/defx.py +69 -0
  28. ccxt/abstract/deribit.py +1 -0
  29. ccxt/abstract/derive.py +117 -0
  30. ccxt/abstract/digifinex.py +1 -0
  31. ccxt/abstract/ellipx.py +25 -0
  32. ccxt/abstract/foxbit.py +26 -0
  33. ccxt/abstract/gate.py +19 -0
  34. ccxt/abstract/gateio.py +19 -0
  35. ccxt/abstract/gemini.py +1 -0
  36. ccxt/abstract/hibachi.py +26 -0
  37. ccxt/abstract/hyperliquid.py +1 -1
  38. ccxt/abstract/independentreserve.py +6 -0
  39. ccxt/abstract/kraken.py +1 -0
  40. ccxt/abstract/krakenfutures.py +4 -0
  41. ccxt/abstract/kucoin.py +10 -0
  42. ccxt/abstract/kucoinfutures.py +18 -0
  43. ccxt/abstract/lbank.py +2 -1
  44. ccxt/abstract/luno.py +1 -0
  45. ccxt/abstract/mexc.py +2 -0
  46. ccxt/abstract/modetrade.py +119 -0
  47. ccxt/abstract/myokx.py +349 -0
  48. ccxt/abstract/oceanex.py +5 -0
  49. ccxt/abstract/okx.py +25 -0
  50. ccxt/abstract/okxus.py +349 -0
  51. ccxt/abstract/onetrading.py +0 -12
  52. ccxt/abstract/paradex.py +23 -0
  53. ccxt/abstract/phemex.py +2 -0
  54. ccxt/abstract/poloniex.py +36 -0
  55. ccxt/abstract/tradeogre.py +3 -1
  56. ccxt/abstract/upbit.py +51 -34
  57. ccxt/abstract/whitebit.py +16 -0
  58. ccxt/abstract/woo.py +64 -6
  59. ccxt/abstract/xt.py +10 -5
  60. ccxt/afratether.py +7 -7
  61. ccxt/alpaca.py +828 -51
  62. ccxt/apex.py +1875 -0
  63. ccxt/arzinja.py +7 -7
  64. ccxt/arzplus.py +9 -9
  65. ccxt/ascendex.py +501 -306
  66. ccxt/async_support/__init__.py +39 -35
  67. ccxt/async_support/abantether.py +8 -8
  68. ccxt/async_support/afratether.py +9 -9
  69. ccxt/async_support/alpaca.py +828 -51
  70. ccxt/async_support/apex.py +1875 -0
  71. ccxt/async_support/arzinja.py +10 -10
  72. ccxt/async_support/arzplus.py +12 -12
  73. ccxt/async_support/ascendex.py +502 -306
  74. ccxt/async_support/base/exchange.py +303 -89
  75. ccxt/async_support/base/ws/cache.py +9 -3
  76. ccxt/async_support/base/ws/client.py +173 -38
  77. ccxt/async_support/base/ws/future.py +25 -37
  78. ccxt/async_support/bequant.py +5 -3
  79. ccxt/async_support/bigone.py +279 -144
  80. ccxt/async_support/binance.py +2347 -1158
  81. ccxt/async_support/binancecoinm.py +9 -3
  82. ccxt/async_support/binanceus.py +17 -3
  83. ccxt/async_support/binanceusdm.py +9 -4
  84. ccxt/async_support/bingx.py +2962 -920
  85. ccxt/async_support/bit2c.py +147 -27
  86. ccxt/async_support/bitbank.py +151 -23
  87. ccxt/async_support/bitbns.py +104 -30
  88. ccxt/async_support/bitfinex.py +3291 -1113
  89. ccxt/async_support/bitflyer.py +202 -27
  90. ccxt/async_support/bitget.py +3683 -1538
  91. ccxt/async_support/bithumb.py +195 -38
  92. ccxt/async_support/bitimen.py +12 -12
  93. ccxt/async_support/bitir.py +38 -38
  94. ccxt/async_support/bitmart.py +1288 -350
  95. ccxt/async_support/bitmex.py +260 -75
  96. ccxt/async_support/bitopro.py +262 -62
  97. ccxt/async_support/bitpin.py +17 -16
  98. ccxt/async_support/bitrue.py +459 -290
  99. ccxt/async_support/bitso.py +199 -54
  100. ccxt/async_support/bitstamp.py +230 -96
  101. ccxt/async_support/bitteam.py +167 -25
  102. ccxt/async_support/{huobijp.py → bittrade.py} +158 -30
  103. ccxt/async_support/bitvavo.py +213 -49
  104. ccxt/async_support/blockchaincom.py +160 -46
  105. ccxt/async_support/blofin.py +502 -120
  106. ccxt/async_support/btcalpha.py +169 -31
  107. ccxt/async_support/btcbox.py +292 -23
  108. ccxt/async_support/btcmarkets.py +211 -58
  109. ccxt/async_support/btcturk.py +161 -38
  110. ccxt/async_support/bybit.py +1775 -1030
  111. ccxt/async_support/cex.py +1440 -1303
  112. ccxt/async_support/coinbase.py +724 -212
  113. ccxt/async_support/coinbaseadvanced.py +2 -1
  114. ccxt/async_support/coinbaseexchange.py +388 -89
  115. ccxt/async_support/coinbaseinternational.py +412 -57
  116. ccxt/async_support/coincatch.py +177 -78
  117. ccxt/async_support/coincheck.py +135 -19
  118. ccxt/async_support/coinex.py +606 -232
  119. ccxt/async_support/coinmate.py +189 -63
  120. ccxt/async_support/coinmetro.py +195 -54
  121. ccxt/async_support/coinone.py +158 -51
  122. ccxt/async_support/coinsph.py +336 -61
  123. ccxt/async_support/coinspot.py +151 -52
  124. ccxt/async_support/cryptocom.py +661 -111
  125. ccxt/async_support/cryptomus.py +1137 -0
  126. ccxt/async_support/defx.py +2071 -0
  127. ccxt/async_support/delta.py +299 -99
  128. ccxt/async_support/deribit.py +348 -126
  129. ccxt/async_support/derive.py +2572 -0
  130. ccxt/async_support/digifinex.py +430 -214
  131. ccxt/async_support/ellipx.py +2029 -0
  132. ccxt/async_support/eterex.py +10 -10
  133. ccxt/async_support/excoino.py +31 -31
  134. ccxt/async_support/exir.py +14 -14
  135. ccxt/async_support/exmo.py +344 -131
  136. ccxt/async_support/exnovin.py +10 -10
  137. ccxt/async_support/farhadexchange.py +12 -12
  138. ccxt/async_support/fmfwio.py +2 -1
  139. ccxt/async_support/foxbit.py +1935 -0
  140. ccxt/async_support/gate.py +1351 -529
  141. ccxt/async_support/gateio.py +2 -1
  142. ccxt/async_support/gemini.py +144 -39
  143. ccxt/async_support/hashkey.py +152 -109
  144. ccxt/async_support/hibachi.py +2080 -0
  145. ccxt/async_support/hitbtc.py +395 -167
  146. ccxt/async_support/hitobit.py +12 -12
  147. ccxt/async_support/hollaex.py +307 -119
  148. ccxt/async_support/htx.py +851 -383
  149. ccxt/async_support/huobi.py +2 -1
  150. ccxt/async_support/hyperliquid.py +1848 -536
  151. ccxt/async_support/independentreserve.py +288 -15
  152. ccxt/async_support/indodax.py +190 -33
  153. ccxt/async_support/jibitex.py +12 -12
  154. ccxt/async_support/kraken.py +795 -351
  155. ccxt/async_support/krakenfutures.py +214 -62
  156. ccxt/async_support/kucoin.py +715 -396
  157. ccxt/async_support/kucoinfutures.py +652 -89
  158. ccxt/async_support/latoken.py +217 -113
  159. ccxt/async_support/lbank.py +425 -97
  160. ccxt/async_support/luno.py +382 -35
  161. ccxt/async_support/mercado.py +113 -6
  162. ccxt/async_support/mexc.py +874 -437
  163. ccxt/async_support/modetrade.py +2818 -0
  164. ccxt/async_support/myokx.py +54 -0
  165. ccxt/async_support/ndax.py +221 -64
  166. ccxt/async_support/nobitex.py +31 -37
  167. ccxt/async_support/novadax.py +190 -34
  168. ccxt/async_support/oceanex.py +217 -28
  169. ccxt/async_support/okcoin.py +253 -145
  170. ccxt/async_support/okexchange.py +11 -11
  171. ccxt/async_support/okx.py +1088 -351
  172. ccxt/async_support/okxus.py +54 -0
  173. ccxt/async_support/ompfinex.py +25 -24
  174. ccxt/async_support/onetrading.py +213 -392
  175. ccxt/async_support/oxfun.py +245 -166
  176. ccxt/async_support/p2b.py +151 -29
  177. ccxt/async_support/paradex.py +562 -49
  178. ccxt/async_support/paymium.py +82 -19
  179. ccxt/async_support/phemex.py +713 -172
  180. ccxt/async_support/poloniex.py +1602 -283
  181. ccxt/async_support/probit.py +224 -95
  182. ccxt/async_support/ramzinex.py +30 -27
  183. ccxt/async_support/sarmayex.py +9 -9
  184. ccxt/async_support/sarrafex.py +13 -13
  185. ccxt/async_support/tabdeal.py +14 -13
  186. ccxt/async_support/tetherland.py +9 -9
  187. ccxt/async_support/timex.py +210 -51
  188. ccxt/async_support/tokocrypto.py +167 -47
  189. ccxt/async_support/tradeogre.py +266 -31
  190. ccxt/async_support/twox.py +9 -9
  191. ccxt/async_support/ubitex.py +12 -12
  192. ccxt/async_support/upbit.py +568 -165
  193. ccxt/async_support/vertex.py +160 -32
  194. ccxt/async_support/wallex.py +12 -12
  195. ccxt/async_support/wavesexchange.py +165 -30
  196. ccxt/async_support/whitebit.py +975 -127
  197. ccxt/async_support/woo.py +1918 -1016
  198. ccxt/async_support/woofipro.py +433 -141
  199. ccxt/async_support/xt.py +649 -193
  200. ccxt/async_support/yobit.py +195 -70
  201. ccxt/async_support/zaif.py +91 -15
  202. ccxt/async_support/zonda.py +151 -36
  203. ccxt/base/decimal_to_precision.py +14 -10
  204. ccxt/base/errors.py +49 -18
  205. ccxt/base/exchange.py +1556 -450
  206. ccxt/base/precise.py +10 -0
  207. ccxt/base/types.py +114 -6
  208. ccxt/bequant.py +5 -3
  209. ccxt/bigone.py +279 -144
  210. ccxt/binance.py +2347 -1158
  211. ccxt/binancecoinm.py +9 -3
  212. ccxt/binanceus.py +17 -3
  213. ccxt/binanceusdm.py +9 -4
  214. ccxt/bingx.py +2962 -920
  215. ccxt/bit2c.py +147 -27
  216. ccxt/bitbank.py +151 -23
  217. ccxt/bitbns.py +104 -30
  218. ccxt/bitfinex.py +3290 -1113
  219. ccxt/bitflyer.py +202 -27
  220. ccxt/bitget.py +3683 -1538
  221. ccxt/bithumb.py +194 -38
  222. ccxt/bitimen.py +9 -9
  223. ccxt/bitir.py +35 -35
  224. ccxt/bitmart.py +1288 -350
  225. ccxt/bitmex.py +260 -75
  226. ccxt/bitopro.py +262 -62
  227. ccxt/bitpin.py +15 -14
  228. ccxt/bitrue.py +459 -290
  229. ccxt/bitso.py +199 -54
  230. ccxt/bitstamp.py +230 -96
  231. ccxt/bitteam.py +167 -25
  232. ccxt/{huobijp.py → bittrade.py} +158 -30
  233. ccxt/bitvavo.py +213 -49
  234. ccxt/blockchaincom.py +160 -46
  235. ccxt/blofin.py +502 -120
  236. ccxt/btcalpha.py +169 -31
  237. ccxt/btcbox.py +291 -23
  238. ccxt/btcmarkets.py +211 -58
  239. ccxt/btcturk.py +161 -38
  240. ccxt/bybit.py +1775 -1030
  241. ccxt/cex.py +1439 -1303
  242. ccxt/coinbase.py +724 -212
  243. ccxt/coinbaseadvanced.py +2 -1
  244. ccxt/coinbaseexchange.py +388 -89
  245. ccxt/coinbaseinternational.py +412 -57
  246. ccxt/coincatch.py +177 -78
  247. ccxt/coincheck.py +135 -19
  248. ccxt/coinex.py +606 -232
  249. ccxt/coinmate.py +189 -63
  250. ccxt/coinmetro.py +194 -54
  251. ccxt/coinone.py +158 -51
  252. ccxt/coinsph.py +336 -61
  253. ccxt/coinspot.py +151 -52
  254. ccxt/cryptocom.py +661 -111
  255. ccxt/cryptomus.py +1137 -0
  256. ccxt/defx.py +2070 -0
  257. ccxt/delta.py +299 -99
  258. ccxt/deribit.py +348 -126
  259. ccxt/derive.py +2571 -0
  260. ccxt/digifinex.py +430 -214
  261. ccxt/ellipx.py +2029 -0
  262. ccxt/eterex.py +7 -7
  263. ccxt/excoino.py +29 -29
  264. ccxt/exir.py +11 -11
  265. ccxt/exmo.py +343 -131
  266. ccxt/exnovin.py +8 -8
  267. ccxt/farhadexchange.py +10 -10
  268. ccxt/fmfwio.py +2 -1
  269. ccxt/foxbit.py +1935 -0
  270. ccxt/gate.py +1351 -529
  271. ccxt/gateio.py +2 -1
  272. ccxt/gemini.py +144 -39
  273. ccxt/hashkey.py +152 -109
  274. ccxt/hibachi.py +2079 -0
  275. ccxt/hitbtc.py +395 -167
  276. ccxt/hitobit.py +9 -9
  277. ccxt/hollaex.py +307 -119
  278. ccxt/htx.py +851 -383
  279. ccxt/huobi.py +2 -1
  280. ccxt/hyperliquid.py +1848 -536
  281. ccxt/independentreserve.py +287 -15
  282. ccxt/indodax.py +190 -33
  283. ccxt/jibitex.py +9 -9
  284. ccxt/kraken.py +794 -351
  285. ccxt/krakenfutures.py +214 -62
  286. ccxt/kucoin.py +715 -396
  287. ccxt/kucoinfutures.py +652 -89
  288. ccxt/latoken.py +217 -113
  289. ccxt/lbank.py +425 -97
  290. ccxt/luno.py +382 -35
  291. ccxt/mercado.py +113 -6
  292. ccxt/mexc.py +873 -437
  293. ccxt/modetrade.py +2818 -0
  294. ccxt/myokx.py +54 -0
  295. ccxt/ndax.py +221 -64
  296. ccxt/nobitex.py +29 -35
  297. ccxt/novadax.py +190 -34
  298. ccxt/oceanex.py +217 -28
  299. ccxt/okcoin.py +253 -145
  300. ccxt/okexchange.py +9 -9
  301. ccxt/okx.py +1088 -351
  302. ccxt/okxus.py +54 -0
  303. ccxt/ompfinex.py +22 -21
  304. ccxt/onetrading.py +213 -392
  305. ccxt/oxfun.py +245 -166
  306. ccxt/p2b.py +151 -29
  307. ccxt/paradex.py +562 -49
  308. ccxt/paymium.py +82 -19
  309. ccxt/phemex.py +712 -172
  310. ccxt/poloniex.py +1601 -283
  311. ccxt/pro/__init__.py +76 -17
  312. ccxt/pro/alpaca.py +21 -6
  313. ccxt/pro/apex.py +984 -0
  314. ccxt/pro/ascendex.py +58 -10
  315. ccxt/pro/bequant.py +6 -1
  316. ccxt/pro/binance.py +728 -156
  317. ccxt/pro/binancecoinm.py +6 -2
  318. ccxt/pro/binanceus.py +8 -4
  319. ccxt/pro/binanceusdm.py +7 -2
  320. ccxt/pro/bingx.py +333 -142
  321. ccxt/pro/bitfinex.py +727 -262
  322. ccxt/pro/bitget.py +570 -79
  323. ccxt/pro/bithumb.py +20 -6
  324. ccxt/pro/bitmart.py +216 -87
  325. ccxt/pro/bitmex.py +47 -9
  326. ccxt/pro/bitopro.py +26 -14
  327. ccxt/pro/bitrue.py +22 -22
  328. ccxt/pro/bitstamp.py +54 -21
  329. ccxt/pro/{huobijp.py → bittrade.py} +7 -6
  330. ccxt/pro/bitvavo.py +191 -67
  331. ccxt/pro/blockchaincom.py +21 -8
  332. ccxt/pro/blofin.py +9 -1
  333. ccxt/pro/bybit.py +632 -245
  334. ccxt/pro/cex.py +59 -24
  335. ccxt/pro/coinbase.py +102 -73
  336. ccxt/pro/coinbaseadvanced.py +2 -1
  337. ccxt/pro/coinbaseexchange.py +8 -8
  338. ccxt/pro/coinbaseinternational.py +181 -25
  339. ccxt/pro/coincatch.py +6 -7
  340. ccxt/pro/coincheck.py +11 -6
  341. ccxt/pro/coinex.py +967 -665
  342. ccxt/pro/coinone.py +16 -9
  343. ccxt/pro/cryptocom.py +448 -45
  344. ccxt/pro/defx.py +831 -0
  345. ccxt/pro/deribit.py +150 -14
  346. ccxt/pro/derive.py +704 -0
  347. ccxt/pro/exmo.py +239 -6
  348. ccxt/pro/gate.py +623 -65
  349. ccxt/pro/gateio.py +2 -1
  350. ccxt/pro/gemini.py +27 -11
  351. ccxt/pro/hashkey.py +2 -2
  352. ccxt/pro/hitbtc.py +196 -91
  353. ccxt/pro/hollaex.py +23 -7
  354. ccxt/pro/htx.py +51 -14
  355. ccxt/pro/huobi.py +2 -1
  356. ccxt/pro/hyperliquid.py +591 -27
  357. ccxt/pro/independentreserve.py +9 -6
  358. ccxt/pro/kraken.py +640 -320
  359. ccxt/pro/krakenfutures.py +62 -35
  360. ccxt/pro/kucoin.py +267 -46
  361. ccxt/pro/kucoinfutures.py +165 -21
  362. ccxt/pro/lbank.py +102 -21
  363. ccxt/pro/luno.py +12 -8
  364. ccxt/pro/mexc.py +877 -111
  365. ccxt/pro/modetrade.py +1271 -0
  366. ccxt/pro/myokx.py +38 -0
  367. ccxt/pro/ndax.py +15 -2
  368. ccxt/pro/okcoin.py +23 -4
  369. ccxt/pro/okx.py +573 -98
  370. ccxt/pro/okxus.py +38 -0
  371. ccxt/pro/onetrading.py +30 -13
  372. ccxt/pro/oxfun.py +131 -27
  373. ccxt/pro/p2b.py +88 -22
  374. ccxt/pro/paradex.py +3 -3
  375. ccxt/pro/phemex.py +75 -21
  376. ccxt/pro/poloniex.py +124 -41
  377. ccxt/pro/probit.py +87 -80
  378. ccxt/pro/tradeogre.py +272 -0
  379. ccxt/pro/upbit.py +152 -12
  380. ccxt/pro/vertex.py +8 -3
  381. ccxt/pro/whitebit.py +58 -5
  382. ccxt/pro/woo.py +228 -37
  383. ccxt/pro/woofipro.py +106 -18
  384. ccxt/pro/xt.py +111 -5
  385. ccxt/probit.py +224 -95
  386. ccxt/protobuf/__init__.py +0 -0
  387. ccxt/protobuf/mexc/PrivateAccountV3Api_pb2.py +37 -0
  388. ccxt/protobuf/mexc/PrivateDealsV3Api_pb2.py +37 -0
  389. ccxt/protobuf/mexc/PrivateOrdersV3Api_pb2.py +37 -0
  390. ccxt/protobuf/mexc/PublicAggreBookTickerV3Api_pb2.py +37 -0
  391. ccxt/protobuf/mexc/PublicAggreDealsV3Api_pb2.py +39 -0
  392. ccxt/protobuf/mexc/PublicAggreDepthsV3Api_pb2.py +39 -0
  393. ccxt/protobuf/mexc/PublicBookTickerBatchV3Api_pb2.py +38 -0
  394. ccxt/protobuf/mexc/PublicBookTickerV3Api_pb2.py +37 -0
  395. ccxt/protobuf/mexc/PublicDealsV3Api_pb2.py +39 -0
  396. ccxt/protobuf/mexc/PublicIncreaseDepthsBatchV3Api_pb2.py +38 -0
  397. ccxt/protobuf/mexc/PublicIncreaseDepthsV3Api_pb2.py +39 -0
  398. ccxt/protobuf/mexc/PublicLimitDepthsV3Api_pb2.py +39 -0
  399. ccxt/protobuf/mexc/PublicMiniTickerV3Api_pb2.py +37 -0
  400. ccxt/protobuf/mexc/PublicMiniTickersV3Api_pb2.py +38 -0
  401. ccxt/protobuf/mexc/PublicSpotKlineV3Api_pb2.py +37 -0
  402. ccxt/protobuf/mexc/PushDataV3ApiWrapper_pb2.py +52 -0
  403. ccxt/protobuf/mexc/__init__.py +0 -0
  404. ccxt/ramzinex.py +28 -25
  405. ccxt/sarmayex.py +7 -7
  406. ccxt/sarrafex.py +10 -10
  407. ccxt/static_dependencies/__init__.py +1 -1
  408. ccxt/static_dependencies/lark/py.typed +0 -0
  409. ccxt/static_dependencies/marshmallow/py.typed +0 -0
  410. ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
  411. ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
  412. ccxt/tabdeal.py +12 -11
  413. ccxt/test/tests_async.py +261 -57
  414. ccxt/test/tests_helpers.py +1 -3
  415. ccxt/test/tests_init.py +4 -3
  416. ccxt/test/tests_sync.py +261 -57
  417. ccxt/tetherland.py +7 -7
  418. ccxt/timex.py +210 -51
  419. ccxt/tokocrypto.py +167 -47
  420. ccxt/tradeogre.py +266 -31
  421. ccxt/twox.py +7 -7
  422. ccxt/ubitex.py +9 -9
  423. ccxt/upbit.py +568 -165
  424. ccxt/vertex.py +160 -32
  425. ccxt/wallex.py +9 -9
  426. ccxt/wavesexchange.py +165 -30
  427. ccxt/whitebit.py +975 -127
  428. ccxt/woo.py +1917 -1016
  429. ccxt/woofipro.py +432 -141
  430. ccxt/xt.py +649 -193
  431. ccxt/yobit.py +194 -70
  432. ccxt/zaif.py +91 -15
  433. ccxt/zonda.py +151 -36
  434. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info}/METADATA +225 -73
  435. ccxt_ir-4.5.0.dist-info/RECORD +743 -0
  436. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info}/WHEEL +1 -1
  437. ccxt/__test__.py +0 -7
  438. ccxt/abstract/ace.py +0 -15
  439. ccxt/abstract/bitbay.py +0 -53
  440. ccxt/abstract/bitcoincom.py +0 -115
  441. ccxt/abstract/bitfinex2.py +0 -139
  442. ccxt/abstract/bitpanda.py +0 -35
  443. ccxt/abstract/bl3p.py +0 -19
  444. ccxt/abstract/coinlist.py +0 -54
  445. ccxt/abstract/currencycom.py +0 -68
  446. ccxt/abstract/hitbtc3.py +0 -115
  447. ccxt/abstract/idex.py +0 -26
  448. ccxt/abstract/kuna.py +0 -182
  449. ccxt/abstract/lykke.py +0 -29
  450. ccxt/abstract/poloniexfutures.py +0 -48
  451. ccxt/abstract/wazirx.py +0 -30
  452. ccxt/ace.py +0 -1012
  453. ccxt/async_support/ace.py +0 -1012
  454. ccxt/async_support/base/ws/aiohttp_client.py +0 -125
  455. ccxt/async_support/base/ws/fast_client.py +0 -96
  456. ccxt/async_support/bitbay.py +0 -17
  457. ccxt/async_support/bitcoincom.py +0 -17
  458. ccxt/async_support/bitfinex2.py +0 -3552
  459. ccxt/async_support/bitpanda.py +0 -16
  460. ccxt/async_support/bl3p.py +0 -485
  461. ccxt/async_support/coinlist.py +0 -2243
  462. ccxt/async_support/currencycom.py +0 -1950
  463. ccxt/async_support/hitbtc3.py +0 -16
  464. ccxt/async_support/idex.py +0 -1766
  465. ccxt/async_support/kuna.py +0 -1841
  466. ccxt/async_support/lykke.py +0 -1270
  467. ccxt/async_support/poloniexfutures.py +0 -1717
  468. ccxt/async_support/wazirx.py +0 -1224
  469. ccxt/bitbay.py +0 -17
  470. ccxt/bitcoincom.py +0 -17
  471. ccxt/bitfinex2.py +0 -3552
  472. ccxt/bitpanda.py +0 -16
  473. ccxt/bl3p.py +0 -485
  474. ccxt/coinlist.py +0 -2243
  475. ccxt/currencycom.py +0 -1950
  476. ccxt/hitbtc3.py +0 -16
  477. ccxt/idex.py +0 -1766
  478. ccxt/kuna.py +0 -1841
  479. ccxt/lykke.py +0 -1270
  480. ccxt/poloniexfutures.py +0 -1717
  481. ccxt/pro/bitcoincom.py +0 -34
  482. ccxt/pro/bitfinex2.py +0 -1083
  483. ccxt/pro/bitpanda.py +0 -15
  484. ccxt/pro/currencycom.py +0 -536
  485. ccxt/pro/idex.py +0 -672
  486. ccxt/pro/poloniexfutures.py +0 -990
  487. ccxt/pro/wazirx.py +0 -749
  488. ccxt/test/base/__init__.py +0 -29
  489. ccxt/test/base/test_account.py +0 -26
  490. ccxt/test/base/test_balance.py +0 -56
  491. ccxt/test/base/test_borrow_interest.py +0 -35
  492. ccxt/test/base/test_borrow_rate.py +0 -32
  493. ccxt/test/base/test_calculate_fee.py +0 -51
  494. ccxt/test/base/test_crypto.py +0 -127
  495. ccxt/test/base/test_currency.py +0 -76
  496. ccxt/test/base/test_datetime.py +0 -109
  497. ccxt/test/base/test_decimal_to_precision.py +0 -392
  498. ccxt/test/base/test_deep_extend.py +0 -68
  499. ccxt/test/base/test_deposit_withdrawal.py +0 -50
  500. ccxt/test/base/test_exchange_datetime_functions.py +0 -76
  501. ccxt/test/base/test_funding_rate_history.py +0 -29
  502. ccxt/test/base/test_last_price.py +0 -31
  503. ccxt/test/base/test_ledger_entry.py +0 -45
  504. ccxt/test/base/test_ledger_item.py +0 -48
  505. ccxt/test/base/test_leverage_tier.py +0 -33
  506. ccxt/test/base/test_liquidation.py +0 -50
  507. ccxt/test/base/test_margin_mode.py +0 -24
  508. ccxt/test/base/test_margin_modification.py +0 -35
  509. ccxt/test/base/test_market.py +0 -193
  510. ccxt/test/base/test_number.py +0 -411
  511. ccxt/test/base/test_ohlcv.py +0 -33
  512. ccxt/test/base/test_open_interest.py +0 -32
  513. ccxt/test/base/test_order.py +0 -64
  514. ccxt/test/base/test_order_book.py +0 -69
  515. ccxt/test/base/test_position.py +0 -60
  516. ccxt/test/base/test_shared_methods.py +0 -353
  517. ccxt/test/base/test_status.py +0 -24
  518. ccxt/test/base/test_throttle.py +0 -126
  519. ccxt/test/base/test_ticker.py +0 -92
  520. ccxt/test/base/test_trade.py +0 -47
  521. ccxt/test/base/test_trading_fee.py +0 -26
  522. ccxt/test/base/test_transaction.py +0 -39
  523. ccxt/test/test_async.py +0 -1649
  524. ccxt/test/test_sync.py +0 -1648
  525. ccxt/wazirx.py +0 -1224
  526. ccxt_ir-4.3.46.0.3.dist-info/RECORD +0 -773
  527. /ccxt/abstract/{huobijp.py → bittrade.py} +0 -0
  528. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info/licenses}/LICENSE.txt +0 -0
  529. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info}/top_level.txt +0 -0
@@ -8,7 +8,7 @@ from ccxt.abstract.digifinex import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
10
  import json
11
- from ccxt.base.types import Balances, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, Int, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry, TransferEntries
11
+ from ccxt.base.types import Any, Balances, BorrowInterest, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, DepositAddress, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import AuthenticationError
@@ -17,7 +17,6 @@ from ccxt.base.errors import AccountSuspended
17
17
  from ccxt.base.errors import ArgumentsRequired
18
18
  from ccxt.base.errors import BadRequest
19
19
  from ccxt.base.errors import BadSymbol
20
- from ccxt.base.errors import BadResponse
21
20
  from ccxt.base.errors import InsufficientFunds
22
21
  from ccxt.base.errors import InvalidAddress
23
22
  from ccxt.base.errors import InvalidOrder
@@ -27,13 +26,14 @@ from ccxt.base.errors import NetworkError
27
26
  from ccxt.base.errors import DDoSProtection
28
27
  from ccxt.base.errors import RateLimitExceeded
29
28
  from ccxt.base.errors import InvalidNonce
29
+ from ccxt.base.errors import BadResponse
30
30
  from ccxt.base.decimal_to_precision import TICK_SIZE
31
31
  from ccxt.base.precise import Precise
32
32
 
33
33
 
34
34
  class digifinex(Exchange, ImplicitAPI):
35
35
 
36
- def describe(self):
36
+ def describe(self) -> Any:
37
37
  return self.deep_extend(super(digifinex, self).describe(), {
38
38
  'id': 'digifinex',
39
39
  'name': 'DigiFinex',
@@ -68,10 +68,14 @@ class digifinex(Exchange, ImplicitAPI):
68
68
  'fetchCrossBorrowRates': True,
69
69
  'fetchCurrencies': True,
70
70
  'fetchDepositAddress': True,
71
+ 'fetchDepositAddresses': False,
72
+ 'fetchDepositAddressesByNetwork': False,
71
73
  'fetchDeposits': True,
72
74
  'fetchDepositWithdrawFee': 'emulated',
73
75
  'fetchDepositWithdrawFees': True,
74
76
  'fetchFundingHistory': True,
77
+ 'fetchFundingInterval': True,
78
+ 'fetchFundingIntervals': False,
75
79
  'fetchFundingRate': True,
76
80
  'fetchFundingRateHistory': True,
77
81
  'fetchFundingRates': False,
@@ -227,6 +231,7 @@ class digifinex(Exchange, ImplicitAPI):
227
231
  'trade/order_info',
228
232
  ],
229
233
  'post': [
234
+ 'account/transfer',
230
235
  'account/leverage',
231
236
  'account/position_mode',
232
237
  'account/position_margin',
@@ -249,6 +254,112 @@ class digifinex(Exchange, ImplicitAPI):
249
254
  },
250
255
  },
251
256
  },
257
+ 'features': {
258
+ 'default': {
259
+ 'sandbox': False,
260
+ 'createOrder': {
261
+ 'marginMode': True,
262
+ 'triggerPrice': False,
263
+ 'triggerPriceType': None,
264
+ 'triggerDirection': False,
265
+ 'stopLossPrice': False,
266
+ 'takeProfitPrice': False,
267
+ 'attachedStopLossTakeProfit': None,
268
+ 'timeInForce': {
269
+ 'IOC': False,
270
+ 'FOK': False,
271
+ 'PO': True,
272
+ 'GTD': False,
273
+ },
274
+ 'hedged': False,
275
+ 'selfTradePrevention': False,
276
+ 'trailing': False,
277
+ 'leverage': False,
278
+ 'marketBuyByCost': False,
279
+ 'marketBuyRequiresPrice': False,
280
+ 'iceberg': False,
281
+ },
282
+ 'createOrders': {
283
+ 'max': 10,
284
+ },
285
+ 'fetchMyTrades': {
286
+ 'marginMode': True,
287
+ 'limit': 500,
288
+ 'daysBack': 100000, # todo
289
+ 'untilDays': 30,
290
+ 'symbolRequired': False,
291
+ },
292
+ 'fetchOrder': {
293
+ 'marginMode': True,
294
+ 'trigger': False,
295
+ 'trailing': False,
296
+ 'marketType': True,
297
+ 'symbolRequired': True,
298
+ },
299
+ 'fetchOpenOrders': {
300
+ 'marginMode': True,
301
+ 'limit': None,
302
+ 'trigger': False,
303
+ 'trailing': False,
304
+ 'symbolRequired': False,
305
+ },
306
+ 'fetchOrders': {
307
+ 'marginMode': True,
308
+ 'limit': 100,
309
+ 'daysBack': 100000, # todo
310
+ 'untilDays': 30,
311
+ 'trigger': False,
312
+ 'trailing': False,
313
+ 'symbolRequired': False,
314
+ },
315
+ 'fetchClosedOrders': None,
316
+ 'fetchOHLCV': {
317
+ 'limit': 500,
318
+ },
319
+ },
320
+ 'spot': {
321
+ 'extends': 'default',
322
+ },
323
+ 'forDerivatives': {
324
+ 'extends': 'default',
325
+ 'createOrders': {
326
+ 'max': 20,
327
+ 'marginMode': False,
328
+ },
329
+ 'fetchMyTrades': {
330
+ 'marginMode': False,
331
+ 'limit': 100,
332
+ 'daysBack': 100000, # todo
333
+ 'untilDays': 100000, # todo
334
+ },
335
+ 'fetchOrder': {
336
+ 'marginMode': False,
337
+ },
338
+ 'fetchOpenOrders': {
339
+ 'marginMode': False,
340
+ 'limit': 100,
341
+ },
342
+ 'fetchOrders': {
343
+ 'marginMode': False,
344
+ 'daysBack': 100000, # todo
345
+ },
346
+ 'fetchOHLCV': {
347
+ 'limit': 100,
348
+ },
349
+ },
350
+ 'swap': {
351
+ 'linear': {
352
+ 'extends': 'forDerivatives',
353
+ },
354
+ 'inverse': {
355
+ 'extends': 'forDerivatives',
356
+ },
357
+ },
358
+ 'future': {
359
+ 'linear': None,
360
+ 'inverse': None,
361
+ },
362
+ },
252
363
  'fees': {
253
364
  'trading': {
254
365
  'tierBased': True,
@@ -356,6 +467,16 @@ class digifinex(Exchange, ImplicitAPI):
356
467
  'TRX': 'TRC20',
357
468
  'VECHAIN': 'Vechain', # VET
358
469
  },
470
+ 'networksById': {
471
+ 'TRC20': 'TRC20',
472
+ 'TRX': 'TRC20',
473
+ 'BEP20': 'BEP20',
474
+ 'BSC': 'BEP20',
475
+ 'ERC20': 'ERC20',
476
+ 'ETH': 'ERC20',
477
+ 'Polygon': 'POLYGON',
478
+ 'Crypto.com': 'CRONOS',
479
+ },
359
480
  },
360
481
  'commonCurrencies': {
361
482
  'BHT': 'Black House Test',
@@ -383,6 +504,7 @@ class digifinex(Exchange, ImplicitAPI):
383
504
  # "min_withdraw_amount":10,
384
505
  # "min_withdraw_fee":5,
385
506
  # "currency":"USDT",
507
+ # "withdraw_fee_currency":"USDT",
386
508
  # "withdraw_status":0,
387
509
  # "chain":"OMNI"
388
510
  # },
@@ -393,6 +515,7 @@ class digifinex(Exchange, ImplicitAPI):
393
515
  # "min_withdraw_amount":10,
394
516
  # "min_withdraw_fee":3,
395
517
  # "currency":"USDT",
518
+ # "withdraw_fee_currency":"USDT",
396
519
  # "withdraw_status":1,
397
520
  # "chain":"ERC20"
398
521
  # },
@@ -403,6 +526,7 @@ class digifinex(Exchange, ImplicitAPI):
403
526
  # "min_withdraw_amount":0,
404
527
  # "min_withdraw_fee":0,
405
528
  # "currency":"DGF13",
529
+ # "withdraw_fee_currency":"DGF13",
406
530
  # "withdraw_status":0,
407
531
  # "chain":""
408
532
  # },
@@ -410,117 +534,45 @@ class digifinex(Exchange, ImplicitAPI):
410
534
  # "code":200
411
535
  # }
412
536
  #
413
- data = self.safe_value(response, 'data', [])
537
+ data = self.safe_list(response, 'data', [])
538
+ groupedById = self.group_by(data, 'currency')
539
+ keys = list(groupedById.keys())
414
540
  result: dict = {}
415
- for i in range(0, len(data)):
416
- currency = data[i]
417
- id = self.safe_string(currency, 'currency')
541
+ for i in range(0, len(keys)):
542
+ id = keys[i]
543
+ networkEntries = groupedById[id]
418
544
  code = self.safe_currency_code(id)
419
- depositStatus = self.safe_integer(currency, 'deposit_status', 1)
420
- withdrawStatus = self.safe_integer(currency, 'withdraw_status', 1)
421
- deposit = depositStatus > 0
422
- withdraw = withdrawStatus > 0
423
- active = deposit and withdraw
424
- feeString = self.safe_string(currency, 'min_withdraw_fee') # withdraw_fee_rate was zero for all currencies, so self was the worst case scenario
425
- minWithdrawString = self.safe_string(currency, 'min_withdraw_amount')
426
- minDepositString = self.safe_string(currency, 'min_deposit_amount')
427
- minDeposit = self.parse_number(minDepositString)
428
- minWithdraw = self.parse_number(minWithdrawString)
429
- fee = self.parse_number(feeString)
430
- # define precision with temporary way
431
- minFoundPrecision = Precise.string_min(feeString, Precise.string_min(minDepositString, minWithdrawString))
432
- precision = self.parse_number(minFoundPrecision)
433
- networkId = self.safe_string(currency, 'chain')
434
- networkCode = None
435
- if networkId is not None:
545
+ networks = {}
546
+ for j in range(0, len(networkEntries)):
547
+ networkEntry = networkEntries[j]
548
+ networkId = self.safe_string(networkEntry, 'chain')
436
549
  networkCode = self.network_id_to_code(networkId)
437
- network: dict = {
438
- 'info': currency,
439
- 'id': networkId,
440
- 'network': networkCode,
441
- 'active': active,
442
- 'fee': fee,
443
- 'precision': precision,
444
- 'deposit': deposit,
445
- 'withdraw': withdraw,
446
- 'limits': {
447
- 'amount': {
448
- 'min': None,
449
- 'max': None,
450
- },
451
- 'withdraw': {
452
- 'min': minWithdraw,
453
- 'max': None,
454
- },
455
- 'deposit': {
456
- 'min': minDeposit,
457
- 'max': None,
458
- },
459
- },
460
- }
461
- if code in result:
462
- if isinstance(result[code]['info'], list):
463
- result[code]['info'].append(currency)
464
- else:
465
- result[code]['info'] = [result[code]['info'], currency]
466
- if withdraw:
467
- result[code]['withdraw'] = True
468
- result[code]['limits']['withdraw']['min'] = min(result[code]['limits']['withdraw']['min'], minWithdraw)
469
- if deposit:
470
- result[code]['deposit'] = True
471
- result[code]['limits']['deposit']['min'] = min(result[code]['limits']['deposit']['min'], minDeposit)
472
- if active:
473
- result[code]['active'] = True
474
- else:
475
- result[code] = {
476
- 'id': id,
477
- 'code': code,
478
- 'info': currency,
479
- 'type': None,
480
- 'name': None,
481
- 'active': active,
482
- 'deposit': deposit,
483
- 'withdraw': withdraw,
484
- 'fee': self.parse_number(feeString),
550
+ networks[networkCode] = {
551
+ 'id': networkId,
552
+ 'network': networkCode,
553
+ 'active': None,
554
+ 'deposit': self.safe_integer(networkEntry, 'deposit_status') == 1,
555
+ 'withdraw': self.safe_integer(networkEntry, 'withdraw_status') == 1,
556
+ 'fee': self.safe_number(networkEntry, 'min_withdraw_fee'),
485
557
  'precision': None,
486
558
  'limits': {
487
- 'amount': {
488
- 'min': None,
489
- 'max': None,
490
- },
491
559
  'withdraw': {
492
- 'min': minWithdraw,
560
+ 'min': self.safe_number(networkEntry, 'min_withdraw_amount'),
493
561
  'max': None,
494
562
  },
495
563
  'deposit': {
496
- 'min': minDeposit,
564
+ 'min': self.safe_number(networkEntry, 'min_deposit_amount'),
497
565
  'max': None,
498
566
  },
499
567
  },
500
- 'networks': {},
568
+ 'info': networkEntry,
501
569
  }
502
- if networkId is not None:
503
- result[code]['networks'][networkId] = network
504
- else:
505
- result[code]['active'] = active
506
- result[code]['fee'] = self.parse_number(feeString)
507
- result[code]['deposit'] = deposit
508
- result[code]['withdraw'] = withdraw
509
- result[code]['limits'] = {
510
- 'amount': {
511
- 'min': None,
512
- 'max': None,
513
- },
514
- 'withdraw': {
515
- 'min': minWithdraw,
516
- 'max': None,
517
- },
518
- 'deposit': {
519
- 'min': minDeposit,
520
- 'max': None,
521
- },
522
- }
523
- result[code]['precision'] = precision if (result[code]['precision'] is None) else max(result[code]['precision'], precision)
570
+ result[code] = self.safe_currency_structure({
571
+ 'id': id,
572
+ 'code': code,
573
+ 'info': networkEntries,
574
+ 'networks': networks,
575
+ })
524
576
  return result
525
577
 
526
578
  async def fetch_markets(self, params={}) -> List[Market]:
@@ -806,9 +858,11 @@ class digifinex(Exchange, ImplicitAPI):
806
858
  async def fetch_balance(self, params={}) -> Balances:
807
859
  """
808
860
  query for balance and get the amount of funds available for trading or funds locked in orders
809
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-account-assets
810
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
811
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#accountbalance
861
+
862
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-account-assets
863
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
864
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#accountbalance
865
+
812
866
  :param dict [params]: extra parameters specific to the exchange API endpoint
813
867
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
814
868
  """
@@ -869,8 +923,10 @@ class digifinex(Exchange, ImplicitAPI):
869
923
  async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
870
924
  """
871
925
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
872
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-orderbook
873
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderbook
926
+
927
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-orderbook
928
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderbook
929
+
874
930
  :param str symbol: unified symbol of the market to fetch the order book for
875
931
  :param int [limit]: the maximum amount of order book entries to return
876
932
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -940,8 +996,10 @@ class digifinex(Exchange, ImplicitAPI):
940
996
  async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
941
997
  """
942
998
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
943
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
944
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#tickers
999
+
1000
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
1001
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#tickers
1002
+
945
1003
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
946
1004
  :param dict [params]: extra parameters specific to the exchange API endpoint
947
1005
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1023,8 +1081,10 @@ class digifinex(Exchange, ImplicitAPI):
1023
1081
  async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
1024
1082
  """
1025
1083
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1026
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
1027
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#ticker
1084
+
1085
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
1086
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#ticker
1087
+
1028
1088
  :param str symbol: unified symbol of the market to fetch the ticker for
1029
1089
  :param dict [params]: extra parameters specific to the exchange API endpoint
1030
1090
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1164,6 +1224,8 @@ class digifinex(Exchange, ImplicitAPI):
1164
1224
  'average': None,
1165
1225
  'baseVolume': self.safe_string_2(ticker, 'vol', 'volume_24h'),
1166
1226
  'quoteVolume': self.safe_string(ticker, 'base_vol'),
1227
+ 'markPrice': self.safe_string(ticker, 'mark_price'),
1228
+ 'indexPrice': indexPrice,
1167
1229
  'info': ticker,
1168
1230
  }, market)
1169
1231
 
@@ -1295,7 +1357,7 @@ class digifinex(Exchange, ImplicitAPI):
1295
1357
  'fee': fee,
1296
1358
  }, market)
1297
1359
 
1298
- async def fetch_time(self, params={}):
1360
+ async def fetch_time(self, params={}) -> Int:
1299
1361
  """
1300
1362
  fetches the current integer timestamp in milliseconds from the exchange server
1301
1363
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1336,8 +1398,10 @@ class digifinex(Exchange, ImplicitAPI):
1336
1398
  async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1337
1399
  """
1338
1400
  get the list of most recent trades for a particular symbol
1339
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-recent-trades
1340
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#recenttrades
1401
+
1402
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-recent-trades
1403
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#recenttrades
1404
+
1341
1405
  :param str symbol: unified symbol of the market to fetch trades for
1342
1406
  :param int [since]: timestamp in ms of the earliest trade to fetch
1343
1407
  :param int [limit]: the maximum amount of trades to fetch
@@ -1433,13 +1497,16 @@ class digifinex(Exchange, ImplicitAPI):
1433
1497
  async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1434
1498
  """
1435
1499
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1436
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-candles-data
1437
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#recentcandle
1500
+
1501
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-candles-data
1502
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#recentcandle
1503
+
1438
1504
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1439
1505
  :param str timeframe: the length of time each candle represents
1440
1506
  :param int [since]: timestamp in ms of the earliest candle to fetch
1441
1507
  :param int [limit]: the maximum amount of candles to fetch
1442
1508
  :param dict [params]: extra parameters specific to the exchange API endpoint
1509
+ :param int [params.until]: timestamp in ms of the latest candle to fetch
1443
1510
  :returns int[][]: A list of candles ordered, open, high, low, close, volume
1444
1511
  """
1445
1512
  await self.load_markets()
@@ -1453,19 +1520,30 @@ class digifinex(Exchange, ImplicitAPI):
1453
1520
  request['limit'] = min(limit, 100)
1454
1521
  response = await self.publicSwapGetPublicCandles(self.extend(request, params))
1455
1522
  else:
1523
+ until = self.safe_integer(params, 'until')
1456
1524
  request['symbol'] = market['id']
1457
1525
  request['period'] = self.safe_string(self.timeframes, timeframe, timeframe)
1458
- if since is not None:
1459
- startTime = self.parse_to_int(since / 1000)
1526
+ startTime = since
1527
+ duration = self.parse_timeframe(timeframe)
1528
+ if startTime is None:
1529
+ if (limit is not None) or (until is not None):
1530
+ endTime = until if (until is not None) else self.milliseconds()
1531
+ startLimit = limit if (limit is not None) else 200
1532
+ startTime = endTime - (startLimit * duration * 1000)
1533
+ if startTime is not None:
1534
+ startTime = self.parse_to_int(startTime / 1000)
1460
1535
  request['start_time'] = startTime
1461
- if limit is not None:
1462
- duration = self.parse_timeframe(timeframe)
1463
- request['end_time'] = self.sum(startTime, limit * duration)
1464
- elif limit is not None:
1465
- endTime = self.seconds()
1466
- duration = self.parse_timeframe(timeframe)
1467
- auxLimit = limit # in c# -limit is mutating the arg
1468
- request['start_time'] = self.sum(endTime, -auxLimit * duration)
1536
+ if (limit is not None) or (until is not None):
1537
+ if until is not None:
1538
+ endByUntil = self.parse_to_int(until / 1000)
1539
+ if limit is not None:
1540
+ endByLimit = self.sum(startTime, limit * duration)
1541
+ request['end_time'] = min(endByLimit, endByUntil)
1542
+ else:
1543
+ request['end_time'] = endByUntil
1544
+ else:
1545
+ request['end_time'] = self.sum(startTime, limit * duration)
1546
+ params = self.omit(params, 'until')
1469
1547
  response = await self.publicSpotGetKline(self.extend(request, params))
1470
1548
  #
1471
1549
  # spot
@@ -1505,13 +1583,15 @@ class digifinex(Exchange, ImplicitAPI):
1505
1583
  async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1506
1584
  """
1507
1585
  create a trade order
1508
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-new-order
1509
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderplace
1586
+
1587
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-new-order
1588
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderplace
1589
+
1510
1590
  :param str symbol: unified symbol of the market to create an order in
1511
1591
  :param str type: 'market' or 'limit'
1512
1592
  :param str side: 'buy' or 'sell'
1513
1593
  :param float amount: how much you want to trade in units of the base currency, spot market orders use the quote currency, swap requires the number of contracts
1514
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1594
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1515
1595
  :param dict [params]: extra parameters specific to the exchange API endpoint
1516
1596
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1517
1597
  :param bool [params.postOnly]: True or False
@@ -1559,8 +1639,10 @@ class digifinex(Exchange, ImplicitAPI):
1559
1639
  async def create_orders(self, orders: List[OrderRequest], params={}):
1560
1640
  """
1561
1641
  create a list of trade orders(all orders should be of the same symbol)
1562
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-multiple-order
1563
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#batchorder
1642
+
1643
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-multiple-order
1644
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#batchorder
1645
+
1564
1646
  :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
1565
1647
  :param dict [params]: extra parameters specific to the exchange API endpoint
1566
1648
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -1641,13 +1723,13 @@ class digifinex(Exchange, ImplicitAPI):
1641
1723
 
1642
1724
  def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1643
1725
  """
1644
- * @ignore
1726
+ @ignore
1645
1727
  helper function to build request
1646
1728
  :param str symbol: unified symbol of the market to create an order in
1647
1729
  :param str type: 'market' or 'limit'
1648
1730
  :param str side: 'buy' or 'sell'
1649
1731
  :param float amount: how much you want to trade in units of the base currency, spot market orders use the quote currency, swap requires the number of contracts
1650
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1732
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1651
1733
  :param dict [params]: extra parameters specific to the exchange API endpoint
1652
1734
  :returns dict: request to be sent to the exchange
1653
1735
  """
@@ -1733,7 +1815,9 @@ class digifinex(Exchange, ImplicitAPI):
1733
1815
  async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1734
1816
  """
1735
1817
  create a market buy order by providing the symbol and cost
1736
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-new-order
1818
+
1819
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-new-order
1820
+
1737
1821
  :param str symbol: unified symbol of the market to create an order in
1738
1822
  :param float cost: how much you want to trade in units of the quote currency
1739
1823
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1749,8 +1833,10 @@ class digifinex(Exchange, ImplicitAPI):
1749
1833
  async def cancel_order(self, id: str, symbol: Str = None, params={}):
1750
1834
  """
1751
1835
  cancels an open order
1752
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#cancel-order
1753
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#cancelorder
1836
+
1837
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#cancel-order
1838
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#cancelorder
1839
+
1754
1840
  :param str id: order id
1755
1841
  :param str symbol: not used by digifinex cancelOrder()
1756
1842
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1809,7 +1895,34 @@ class digifinex(Exchange, ImplicitAPI):
1809
1895
  numCanceledOrders = len(canceledOrders)
1810
1896
  if numCanceledOrders != 1:
1811
1897
  raise OrderNotFound(self.id + ' cancelOrder() ' + id + ' not found')
1812
- return response
1898
+ orders = self.parse_cancel_orders(response)
1899
+ return self.safe_dict(orders, 0)
1900
+ else:
1901
+ return self.safe_order({
1902
+ 'info': response,
1903
+ 'orderId': self.safe_string(response, 'data'),
1904
+ })
1905
+
1906
+ def parse_cancel_orders(self, response):
1907
+ success = self.safe_list(response, 'success')
1908
+ error = self.safe_list(response, 'error')
1909
+ result = []
1910
+ for i in range(0, len(success)):
1911
+ order = success[i]
1912
+ result.append(self.safe_order({
1913
+ 'info': order,
1914
+ 'id': order,
1915
+ 'status': 'canceled',
1916
+ }))
1917
+ for i in range(0, len(error)):
1918
+ order = error[i]
1919
+ result.append(self.safe_order({
1920
+ 'info': order,
1921
+ 'id': self.safe_string_2(order, 'order-id', 'order_id'),
1922
+ 'status': 'failed',
1923
+ 'clientOrderId': self.safe_string(order, 'client-order-id'),
1924
+ }))
1925
+ return result
1813
1926
 
1814
1927
  async def cancel_orders(self, ids, symbol: Str = None, params={}):
1815
1928
  """
@@ -1840,11 +1953,7 @@ class digifinex(Exchange, ImplicitAPI):
1840
1953
  # ]
1841
1954
  # }
1842
1955
  #
1843
- canceledOrders = self.safe_value(response, 'success', [])
1844
- numCanceledOrders = len(canceledOrders)
1845
- if numCanceledOrders < 1:
1846
- raise OrderNotFound(self.id + ' cancelOrders() error')
1847
- return response
1956
+ return self.parse_cancel_orders(response)
1848
1957
 
1849
1958
  def parse_order_status(self, status: Str):
1850
1959
  statuses: dict = {
@@ -1975,7 +2084,6 @@ class digifinex(Exchange, ImplicitAPI):
1975
2084
  'postOnly': None,
1976
2085
  'side': side,
1977
2086
  'price': self.safe_number(order, 'price'),
1978
- 'stopPrice': None,
1979
2087
  'triggerPrice': None,
1980
2088
  'amount': self.safe_number_2(order, 'amount', 'size'),
1981
2089
  'filled': self.safe_number_2(order, 'executed_amount', 'filled_qty'),
@@ -1992,8 +2100,10 @@ class digifinex(Exchange, ImplicitAPI):
1992
2100
  async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1993
2101
  """
1994
2102
  fetch all unfilled currently open orders
1995
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#current-active-orders
1996
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#openorder
2103
+
2104
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#current-active-orders
2105
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#openorder
2106
+
1997
2107
  :param str symbol: unified market symbol
1998
2108
  :param int [since]: the earliest time in ms to fetch open orders for
1999
2109
  :param int [limit]: the maximum number of open orders structures to retrieve
@@ -2086,8 +2196,10 @@ class digifinex(Exchange, ImplicitAPI):
2086
2196
  async def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2087
2197
  """
2088
2198
  fetches information on multiple orders made by the user
2089
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-all-orders-including-history-orders
2090
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#historyorder
2199
+
2200
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-all-orders-including-history-orders
2201
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#historyorder
2202
+
2091
2203
  :param str symbol: unified market symbol of the market orders were made in
2092
2204
  :param int [since]: the earliest time in ms to fetch orders for
2093
2205
  :param int [limit]: the maximum number of order structures to retrieve
@@ -2181,8 +2293,10 @@ class digifinex(Exchange, ImplicitAPI):
2181
2293
  async def fetch_order(self, id: str, symbol: Str = None, params={}):
2182
2294
  """
2183
2295
  fetches information on an order made by the user
2184
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-order-status
2185
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderinfo
2296
+
2297
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-order-status
2298
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderinfo
2299
+
2186
2300
  :param str id: order id
2187
2301
  :param str symbol: unified symbol of the market the order was made in
2188
2302
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2270,8 +2384,10 @@ class digifinex(Exchange, ImplicitAPI):
2270
2384
  async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2271
2385
  """
2272
2386
  fetch all trades made by the user
2273
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#customer-39-s-trades
2274
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#historytrade
2387
+
2388
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#customer-39-s-trades
2389
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#historytrade
2390
+
2275
2391
  :param str symbol: unified market symbol
2276
2392
  :param int [since]: the earliest time in ms to fetch trades for
2277
2393
  :param int [limit]: the maximum number of trades structures to retrieve
@@ -2361,7 +2477,7 @@ class digifinex(Exchange, ImplicitAPI):
2361
2477
  types: dict = {}
2362
2478
  return self.safe_string(types, type, type)
2363
2479
 
2364
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
2480
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
2365
2481
  #
2366
2482
  # spot and margin
2367
2483
  #
@@ -2383,13 +2499,15 @@ class digifinex(Exchange, ImplicitAPI):
2383
2499
  # }
2384
2500
  #
2385
2501
  type = self.parse_ledger_entry_type(self.safe_string_2(item, 'type', 'finance_type'))
2386
- code = self.safe_currency_code(self.safe_string_2(item, 'currency_mark', 'currency'), currency)
2502
+ currencyId = self.safe_string_2(item, 'currency_mark', 'currency')
2503
+ code = self.safe_currency_code(currencyId, currency)
2504
+ currency = self.safe_currency(currencyId, currency)
2387
2505
  amount = self.safe_number_2(item, 'num', 'change')
2388
2506
  after = self.safe_number(item, 'balance')
2389
2507
  timestamp = self.safe_timestamp(item, 'time')
2390
2508
  if timestamp is None:
2391
2509
  timestamp = self.safe_integer(item, 'timestamp')
2392
- return {
2510
+ return self.safe_ledger_entry({
2393
2511
  'info': item,
2394
2512
  'id': None,
2395
2513
  'direction': None,
@@ -2405,18 +2523,20 @@ class digifinex(Exchange, ImplicitAPI):
2405
2523
  'timestamp': timestamp,
2406
2524
  'datetime': self.iso8601(timestamp),
2407
2525
  'fee': None,
2408
- }
2526
+ }, currency)
2409
2527
 
2410
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
2528
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
2411
2529
  """
2412
- fetch the history of changes, actions done by the user or operations that altered balance of the user
2413
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-margin-otc-financial-logs
2414
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#bills
2415
- :param str code: unified currency code, default is None
2530
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
2531
+
2532
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-margin-otc-financial-logs
2533
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#bills
2534
+
2535
+ :param str [code]: unified currency code, default is None
2416
2536
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
2417
- :param int [limit]: max number of ledger entrys to return, default is None
2537
+ :param int [limit]: max number of ledger entries to return, default is None
2418
2538
  :param dict [params]: extra parameters specific to the exchange API endpoint
2419
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
2539
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
2420
2540
  """
2421
2541
  await self.load_markets()
2422
2542
  request: dict = {}
@@ -2488,7 +2608,7 @@ class digifinex(Exchange, ImplicitAPI):
2488
2608
  ledger = self.safe_value(data, 'finance', [])
2489
2609
  return self.parse_ledger(ledger, currency, since, limit)
2490
2610
 
2491
- def parse_deposit_address(self, depositAddress, currency: Currency = None):
2611
+ def parse_deposit_address(self, depositAddress, currency: Currency = None) -> DepositAddress:
2492
2612
  #
2493
2613
  # {
2494
2614
  # "addressTag":"",
@@ -2504,12 +2624,12 @@ class digifinex(Exchange, ImplicitAPI):
2504
2624
  return {
2505
2625
  'info': depositAddress,
2506
2626
  'currency': code,
2627
+ 'network': None,
2507
2628
  'address': address,
2508
2629
  'tag': tag,
2509
- 'network': None,
2510
2630
  }
2511
2631
 
2512
- async def fetch_deposit_address(self, code: str, params={}):
2632
+ async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
2513
2633
  """
2514
2634
  fetch the deposit address for a currency associated with self account
2515
2635
  :param str code: unified currency code
@@ -2688,12 +2808,23 @@ class digifinex(Exchange, ImplicitAPI):
2688
2808
 
2689
2809
  def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:
2690
2810
  #
2691
- # transfer
2811
+ # transfer between spot, margin and OTC
2692
2812
  #
2693
2813
  # {
2694
2814
  # "code": 0
2695
2815
  # }
2696
2816
  #
2817
+ # transfer between spot and swap
2818
+ #
2819
+ # {
2820
+ # "code": 0,
2821
+ # "data": {
2822
+ # "type": 2,
2823
+ # "currency": "USDT",
2824
+ # "transfer_amount": "5"
2825
+ # }
2826
+ # }
2827
+ #
2697
2828
  # fetchTransfers
2698
2829
  #
2699
2830
  # {
@@ -2706,7 +2837,8 @@ class digifinex(Exchange, ImplicitAPI):
2706
2837
  #
2707
2838
  fromAccount = None
2708
2839
  toAccount = None
2709
- type = self.safe_integer(transfer, 'type')
2840
+ data = self.safe_dict(transfer, 'data', transfer)
2841
+ type = self.safe_integer(data, 'type')
2710
2842
  if type == 1:
2711
2843
  fromAccount = 'spot'
2712
2844
  toAccount = 'swap'
@@ -2719,8 +2851,8 @@ class digifinex(Exchange, ImplicitAPI):
2719
2851
  'id': self.safe_string(transfer, 'transfer_id'),
2720
2852
  'timestamp': timestamp,
2721
2853
  'datetime': self.iso8601(timestamp),
2722
- 'currency': self.safe_currency_code(self.safe_string(transfer, 'currency'), currency),
2723
- 'amount': self.safe_number(transfer, 'amount'),
2854
+ 'currency': self.safe_currency_code(self.safe_string(data, 'currency'), currency),
2855
+ 'amount': self.safe_number_2(data, 'amount', 'transfer_amount'),
2724
2856
  'fromAccount': fromAccount,
2725
2857
  'toAccount': toAccount,
2726
2858
  'status': self.parse_transfer_status(self.safe_string(transfer, 'code')),
@@ -2729,33 +2861,59 @@ class digifinex(Exchange, ImplicitAPI):
2729
2861
  async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
2730
2862
  """
2731
2863
  transfer currency internally between wallets on the same account
2864
+
2865
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#transfer-assets-among-accounts
2866
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#accounttransfer
2867
+
2732
2868
  :param str code: unified currency code
2733
2869
  :param float amount: amount to transfer
2734
- :param str fromAccount: account to transfer from
2735
- :param str toAccount: account to transfer to
2870
+ :param str fromAccount: 'spot', 'swap', 'margin', 'OTC' - account to transfer from
2871
+ :param str toAccount: 'spot', 'swap', 'margin', 'OTC' - account to transfer to
2736
2872
  :param dict [params]: extra parameters specific to the exchange API endpoint
2737
2873
  :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
2738
2874
  """
2739
2875
  await self.load_markets()
2740
2876
  currency = self.currency(code)
2877
+ currencyId = currency['id']
2741
2878
  accountsByType = self.safe_value(self.options, 'accountsByType', {})
2742
2879
  fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
2743
2880
  toId = self.safe_string(accountsByType, toAccount, toAccount)
2744
- request: dict = {
2745
- 'currency_mark': currency['id'],
2746
- 'num': self.currency_to_precision(code, amount),
2747
- 'from': fromId, # 1 = SPOT, 2 = MARGIN, 3 = OTC
2748
- 'to': toId, # 1 = SPOT, 2 = MARGIN, 3 = OTC
2749
- }
2750
- response = await self.privateSpotPostTransfer(self.extend(request, params))
2751
- #
2752
- # {
2753
- # "code": 0
2754
- # }
2755
- #
2881
+ request = {}
2882
+ fromSwap = (fromAccount == 'swap')
2883
+ toSwap = (toAccount == 'swap')
2884
+ response = None
2885
+ amountString = self.currency_to_precision(code, amount)
2886
+ if fromSwap or toSwap:
2887
+ if (fromId != '1') and (toId != '1'):
2888
+ raise ExchangeError(self.id + ' transfer() supports transferring between spot and swap, spot and margin, spot and OTC only')
2889
+ request['type'] = 1 if toSwap else 2 # 1 = spot to swap, 2 = swap to spot
2890
+ request['currency'] = currencyId
2891
+ request['transfer_amount'] = amountString
2892
+ #
2893
+ # {
2894
+ # "code": 0,
2895
+ # "data": {
2896
+ # "type": 2,
2897
+ # "currency": "USDT",
2898
+ # "transfer_amount": "5"
2899
+ # }
2900
+ # }
2901
+ #
2902
+ response = await self.privateSwapPostAccountTransfer(self.extend(request, params))
2903
+ else:
2904
+ request['currency_mark'] = currencyId
2905
+ request['num'] = amountString
2906
+ request['from'] = fromId # 1 = SPOT, 2 = MARGIN, 3 = OTC
2907
+ request['to'] = toId # 1 = SPOT, 2 = MARGIN, 3 = OTC
2908
+ #
2909
+ # {
2910
+ # "code": 0
2911
+ # }
2912
+ #
2913
+ response = await self.privateSpotPostTransfer(self.extend(request, params))
2756
2914
  return self.parse_transfer(response, currency)
2757
2915
 
2758
- async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
2916
+ async def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
2759
2917
  """
2760
2918
  make a withdrawal
2761
2919
  :param str code: unified currency code
@@ -2786,7 +2944,7 @@ class digifinex(Exchange, ImplicitAPI):
2786
2944
  #
2787
2945
  return self.parse_transaction(response, currency)
2788
2946
 
2789
- async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2947
+ async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
2790
2948
  await self.load_markets()
2791
2949
  request: dict = {}
2792
2950
  market = None
@@ -2819,7 +2977,7 @@ class digifinex(Exchange, ImplicitAPI):
2819
2977
  interest = self.parse_borrow_interests(rows, market)
2820
2978
  return self.filter_by_currency_since_limit(interest, code, since, limit)
2821
2979
 
2822
- def parse_borrow_interest(self, info: dict, market: Market = None):
2980
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
2823
2981
  #
2824
2982
  # {
2825
2983
  # "amount": 0.0006103,
@@ -2841,21 +2999,23 @@ class digifinex(Exchange, ImplicitAPI):
2841
2999
  currency = None if (market is None) else market['base']
2842
3000
  symbol = self.safe_symbol(marketId, market)
2843
3001
  return {
2844
- 'account': symbol,
3002
+ 'info': info,
2845
3003
  'symbol': symbol,
2846
3004
  'currency': currency,
2847
3005
  'interest': None,
2848
3006
  'interestRate': 0.001, # all interest rates on digifinex are 0.1%
2849
3007
  'amountBorrowed': self.parse_number(amountBorrowed),
3008
+ 'marginMode': None,
2850
3009
  'timestamp': None,
2851
3010
  'datetime': None,
2852
- 'info': info,
2853
3011
  }
2854
3012
 
2855
3013
  async def fetch_cross_borrow_rate(self, code: str, params={}) -> CrossBorrowRate:
2856
3014
  """
2857
3015
  fetch the rate of interest to borrow a currency for margin trading
2858
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
3016
+
3017
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
3018
+
2859
3019
  :param str code: unified currency code
2860
3020
  :param dict [params]: extra parameters specific to the exchange API endpoint
2861
3021
  :returns dict: a `borrow rate structure <https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure>`
@@ -2892,7 +3052,9 @@ class digifinex(Exchange, ImplicitAPI):
2892
3052
  async def fetch_cross_borrow_rates(self, params={}) -> CrossBorrowRates:
2893
3053
  """
2894
3054
  fetch the borrow interest rates of all currencies
2895
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
3055
+
3056
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
3057
+
2896
3058
  :param dict [params]: extra parameters specific to the exchange API endpoint
2897
3059
  :returns dict: a list of `borrow rate structures <https://docs.ccxt.com/#/?id=borrow-rate-structure>`
2898
3060
  """
@@ -2956,10 +3118,12 @@ class digifinex(Exchange, ImplicitAPI):
2956
3118
  result[code] = borrowRate
2957
3119
  return result
2958
3120
 
2959
- async def fetch_funding_rate(self, symbol: str, params={}):
3121
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
2960
3122
  """
2961
3123
  fetch the current funding rate
2962
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
3124
+
3125
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
3126
+
2963
3127
  :param str symbol: unified market symbol
2964
3128
  :param dict [params]: extra parameters specific to the exchange API endpoint
2965
3129
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -2984,10 +3148,22 @@ class digifinex(Exchange, ImplicitAPI):
2984
3148
  # }
2985
3149
  # }
2986
3150
  #
2987
- data = self.safe_value(response, 'data', {})
3151
+ data = self.safe_dict(response, 'data', {})
2988
3152
  return self.parse_funding_rate(data, market)
2989
3153
 
2990
- def parse_funding_rate(self, contract, market: Market = None):
3154
+ async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
3155
+ """
3156
+ fetch the current funding rate interval
3157
+
3158
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
3159
+
3160
+ :param str symbol: unified market symbol
3161
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3162
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
3163
+ """
3164
+ return await self.fetch_funding_rate(symbol, params)
3165
+
3166
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
2991
3167
  #
2992
3168
  # {
2993
3169
  # "instrument_id": "BTCUSDTPERP",
@@ -3000,6 +3176,9 @@ class digifinex(Exchange, ImplicitAPI):
3000
3176
  marketId = self.safe_string(contract, 'instrument_id')
3001
3177
  timestamp = self.safe_integer(contract, 'funding_time')
3002
3178
  nextTimestamp = self.safe_integer(contract, 'next_funding_time')
3179
+ fundingTimeString = self.safe_string(contract, 'funding_time')
3180
+ nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
3181
+ millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
3003
3182
  return {
3004
3183
  'info': contract,
3005
3184
  'symbol': self.safe_symbol(marketId, market),
@@ -3012,13 +3191,24 @@ class digifinex(Exchange, ImplicitAPI):
3012
3191
  'fundingRate': self.safe_number(contract, 'funding_rate'),
3013
3192
  'fundingTimestamp': timestamp,
3014
3193
  'fundingDatetime': self.iso8601(timestamp),
3015
- 'nextFundingRate': self.safe_string(contract, 'next_funding_rate'),
3194
+ 'nextFundingRate': self.safe_number(contract, 'next_funding_rate'),
3016
3195
  'nextFundingTimestamp': nextTimestamp,
3017
3196
  'nextFundingDatetime': self.iso8601(nextTimestamp),
3018
3197
  'previousFundingRate': None,
3019
3198
  'previousFundingTimestamp': None,
3020
3199
  'previousFundingDatetime': None,
3200
+ 'interval': self.parse_funding_interval(millisecondsInterval),
3201
+ }
3202
+
3203
+ def parse_funding_interval(self, interval):
3204
+ intervals: dict = {
3205
+ '3600000': '1h',
3206
+ '14400000': '4h',
3207
+ '28800000': '8h',
3208
+ '57600000': '16h',
3209
+ '86400000': '24h',
3021
3210
  }
3211
+ return self.safe_string(intervals, interval, interval)
3022
3212
 
3023
3213
  async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3024
3214
  """
@@ -3079,7 +3269,9 @@ class digifinex(Exchange, ImplicitAPI):
3079
3269
  async def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
3080
3270
  """
3081
3271
  fetch the trading fees for a market
3082
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#tradingfee
3272
+
3273
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#tradingfee
3274
+
3083
3275
  :param str symbol: unified market symbol
3084
3276
  :param dict [params]: extra parameters specific to the exchange API endpoint
3085
3277
  :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -3124,11 +3316,13 @@ class digifinex(Exchange, ImplicitAPI):
3124
3316
  'tierBased': None,
3125
3317
  }
3126
3318
 
3127
- async def fetch_positions(self, symbols: Strings = None, params={}):
3319
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
3128
3320
  """
3129
3321
  fetch all open positions
3130
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
3131
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positions
3322
+
3323
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
3324
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#positions
3325
+
3132
3326
  :param str[]|None symbols: list of unified market symbols
3133
3327
  :param dict [params]: extra parameters specific to the exchange API endpoint
3134
3328
  :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
@@ -3224,8 +3418,10 @@ class digifinex(Exchange, ImplicitAPI):
3224
3418
 
3225
3419
  async def fetch_position(self, symbol: str, params={}):
3226
3420
  """
3227
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
3228
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positions
3421
+
3422
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
3423
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#positions
3424
+
3229
3425
  fetch data on a single open contract trade position
3230
3426
  :param str symbol: unified market symbol of the market the position is held in
3231
3427
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3390,10 +3586,12 @@ class digifinex(Exchange, ImplicitAPI):
3390
3586
  'takeProfitPrice': None,
3391
3587
  })
3392
3588
 
3393
- async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
3589
+ async def set_leverage(self, leverage: int, symbol: Str = None, params={}):
3394
3590
  """
3395
3591
  set the level of leverage for a market
3396
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#setleverage
3592
+
3593
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#setleverage
3594
+
3397
3595
  :param float leverage: the rate of leverage
3398
3596
  :param str symbol: unified market symbol
3399
3597
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3439,10 +3637,12 @@ class digifinex(Exchange, ImplicitAPI):
3439
3637
  # }
3440
3638
  #
3441
3639
 
3442
- async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> TransferEntries:
3640
+ async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
3443
3641
  """
3444
3642
  fetch the transfer history, only transfers between spot and swap accounts are supported
3445
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#transferrecord
3643
+
3644
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#transferrecord
3645
+
3446
3646
  :param str code: unified currency code of the currency transferred
3447
3647
  :param int [since]: the earliest time in ms to fetch transfers for
3448
3648
  :param int [limit]: the maximum number of transfers to retrieve
@@ -3480,7 +3680,9 @@ class digifinex(Exchange, ImplicitAPI):
3480
3680
 
3481
3681
  async def fetch_leverage_tiers(self, symbols: Strings = None, params={}) -> LeverageTiers:
3482
3682
  """
3483
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#instruments
3683
+
3684
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#instruments
3685
+
3484
3686
  retrieve information on the maximum leverage, for different trade sizes
3485
3687
  :param str[]|None symbols: a list of unified market symbols
3486
3688
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3523,8 +3725,10 @@ class digifinex(Exchange, ImplicitAPI):
3523
3725
 
3524
3726
  async def fetch_market_leverage_tiers(self, symbol: str, params={}) -> List[LeverageTier]:
3525
3727
  """
3526
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#instrument
3527
3728
  retrieve information on the maximum leverage, for different trade sizes for a single market
3729
+
3730
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#instrument
3731
+
3528
3732
  :param str symbol: unified market symbol
3529
3733
  :param dict [params]: extra parameters specific to the exchange API endpoint
3530
3734
  :returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
@@ -3597,9 +3801,10 @@ class digifinex(Exchange, ImplicitAPI):
3597
3801
  for i in range(0, len(brackets)):
3598
3802
  tier = brackets[i]
3599
3803
  marketId = self.safe_string(info, 'instrument_id')
3600
- market = self.safe_market(marketId)
3804
+ market = self.safe_market(marketId, market)
3601
3805
  tiers.append({
3602
3806
  'tier': self.sum(i, 1),
3807
+ 'symbol': self.safe_symbol(marketId, market, None, 'swap'),
3603
3808
  'currency': market['settle'],
3604
3809
  'minNotional': None,
3605
3810
  'maxNotional': self.safe_number(tier, 'max_limit'),
@@ -3611,7 +3816,7 @@ class digifinex(Exchange, ImplicitAPI):
3611
3816
 
3612
3817
  def handle_margin_mode_and_params(self, methodName, params={}, defaultValue=None):
3613
3818
  """
3614
- * @ignore
3819
+ @ignore
3615
3820
  marginMode specified by params["marginMode"], self.options["marginMode"], self.options["defaultMarginMode"], params["margin"] = True or self.options["defaultType"] = 'margin'
3616
3821
  :param dict [params]: extra parameters specific to the exchange API endpoint
3617
3822
  :returns Array: the marginMode in lowercase
@@ -3631,7 +3836,9 @@ class digifinex(Exchange, ImplicitAPI):
3631
3836
  async def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
3632
3837
  """
3633
3838
  fetch deposit and withdraw fees
3634
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-currency-deposit-and-withdrawal-information
3839
+
3840
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-currency-deposit-and-withdrawal-information
3841
+
3635
3842
  :param str[]|None codes: not used by fetchDepositWithdrawFees()
3636
3843
  :param dict [params]: extra parameters specific to the exchange API endpoint
3637
3844
  :returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -3708,7 +3915,8 @@ class digifinex(Exchange, ImplicitAPI):
3708
3915
  if depositWithdrawFee is None:
3709
3916
  depositWithdrawFees[code] = self.deposit_withdraw_fee({})
3710
3917
  depositWithdrawFees[code]['info'] = []
3711
- depositWithdrawFees[code]['info'].append(entry)
3918
+ depositWithdrawInfo = depositWithdrawFees[code]['info']
3919
+ depositWithdrawInfo.append(entry)
3712
3920
  networkId = self.safe_string(entry, 'chain')
3713
3921
  withdrawFee = self.safe_value(entry, 'min_withdraw_fee')
3714
3922
  withdrawResult: dict = {
@@ -3738,7 +3946,9 @@ class digifinex(Exchange, ImplicitAPI):
3738
3946
  async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3739
3947
  """
3740
3948
  add margin to a position
3741
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
3949
+
3950
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
3951
+
3742
3952
  :param str symbol: unified market symbol
3743
3953
  :param float amount: amount of margin to add
3744
3954
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3752,7 +3962,9 @@ class digifinex(Exchange, ImplicitAPI):
3752
3962
  async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3753
3963
  """
3754
3964
  remove margin from a position
3755
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
3965
+
3966
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
3967
+
3756
3968
  :param str symbol: unified market symbol
3757
3969
  :param float amount: the amount of margin to remove
3758
3970
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3819,7 +4031,9 @@ class digifinex(Exchange, ImplicitAPI):
3819
4031
  async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3820
4032
  """
3821
4033
  fetch the history of funding payments paid and received on self account
3822
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#funding-fee
4034
+
4035
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#funding-fee
4036
+
3823
4037
  :param str [symbol]: unified market symbol
3824
4038
  :param int [since]: the earliest time in ms to fetch funding history for
3825
4039
  :param int [limit]: the maximum number of funding history structures to retrieve
@@ -3880,7 +4094,9 @@ class digifinex(Exchange, ImplicitAPI):
3880
4094
  async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
3881
4095
  """
3882
4096
  set margin mode to 'cross' or 'isolated'
3883
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmode
4097
+
4098
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmode
4099
+
3884
4100
  :param str marginMode: 'cross' or 'isolated'
3885
4101
  :param str symbol: unified market symbol
3886
4102
  :param dict [params]: extra parameters specific to the exchange API endpoint