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
ccxt/digifinex.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.digifinex import ImplicitAPI
8
8
  import hashlib
9
9
  import json
10
- 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
10
+ 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
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -16,7 +16,6 @@ from ccxt.base.errors import AccountSuspended
16
16
  from ccxt.base.errors import ArgumentsRequired
17
17
  from ccxt.base.errors import BadRequest
18
18
  from ccxt.base.errors import BadSymbol
19
- from ccxt.base.errors import BadResponse
20
19
  from ccxt.base.errors import InsufficientFunds
21
20
  from ccxt.base.errors import InvalidAddress
22
21
  from ccxt.base.errors import InvalidOrder
@@ -26,13 +25,14 @@ from ccxt.base.errors import NetworkError
26
25
  from ccxt.base.errors import DDoSProtection
27
26
  from ccxt.base.errors import RateLimitExceeded
28
27
  from ccxt.base.errors import InvalidNonce
28
+ from ccxt.base.errors import BadResponse
29
29
  from ccxt.base.decimal_to_precision import TICK_SIZE
30
30
  from ccxt.base.precise import Precise
31
31
 
32
32
 
33
33
  class digifinex(Exchange, ImplicitAPI):
34
34
 
35
- def describe(self):
35
+ def describe(self) -> Any:
36
36
  return self.deep_extend(super(digifinex, self).describe(), {
37
37
  'id': 'digifinex',
38
38
  'name': 'DigiFinex',
@@ -67,10 +67,14 @@ class digifinex(Exchange, ImplicitAPI):
67
67
  'fetchCrossBorrowRates': True,
68
68
  'fetchCurrencies': True,
69
69
  'fetchDepositAddress': True,
70
+ 'fetchDepositAddresses': False,
71
+ 'fetchDepositAddressesByNetwork': False,
70
72
  'fetchDeposits': True,
71
73
  'fetchDepositWithdrawFee': 'emulated',
72
74
  'fetchDepositWithdrawFees': True,
73
75
  'fetchFundingHistory': True,
76
+ 'fetchFundingInterval': True,
77
+ 'fetchFundingIntervals': False,
74
78
  'fetchFundingRate': True,
75
79
  'fetchFundingRateHistory': True,
76
80
  'fetchFundingRates': False,
@@ -226,6 +230,7 @@ class digifinex(Exchange, ImplicitAPI):
226
230
  'trade/order_info',
227
231
  ],
228
232
  'post': [
233
+ 'account/transfer',
229
234
  'account/leverage',
230
235
  'account/position_mode',
231
236
  'account/position_margin',
@@ -248,6 +253,112 @@ class digifinex(Exchange, ImplicitAPI):
248
253
  },
249
254
  },
250
255
  },
256
+ 'features': {
257
+ 'default': {
258
+ 'sandbox': False,
259
+ 'createOrder': {
260
+ 'marginMode': True,
261
+ 'triggerPrice': False,
262
+ 'triggerPriceType': None,
263
+ 'triggerDirection': False,
264
+ 'stopLossPrice': False,
265
+ 'takeProfitPrice': False,
266
+ 'attachedStopLossTakeProfit': None,
267
+ 'timeInForce': {
268
+ 'IOC': False,
269
+ 'FOK': False,
270
+ 'PO': True,
271
+ 'GTD': False,
272
+ },
273
+ 'hedged': False,
274
+ 'selfTradePrevention': False,
275
+ 'trailing': False,
276
+ 'leverage': False,
277
+ 'marketBuyByCost': False,
278
+ 'marketBuyRequiresPrice': False,
279
+ 'iceberg': False,
280
+ },
281
+ 'createOrders': {
282
+ 'max': 10,
283
+ },
284
+ 'fetchMyTrades': {
285
+ 'marginMode': True,
286
+ 'limit': 500,
287
+ 'daysBack': 100000, # todo
288
+ 'untilDays': 30,
289
+ 'symbolRequired': False,
290
+ },
291
+ 'fetchOrder': {
292
+ 'marginMode': True,
293
+ 'trigger': False,
294
+ 'trailing': False,
295
+ 'marketType': True,
296
+ 'symbolRequired': True,
297
+ },
298
+ 'fetchOpenOrders': {
299
+ 'marginMode': True,
300
+ 'limit': None,
301
+ 'trigger': False,
302
+ 'trailing': False,
303
+ 'symbolRequired': False,
304
+ },
305
+ 'fetchOrders': {
306
+ 'marginMode': True,
307
+ 'limit': 100,
308
+ 'daysBack': 100000, # todo
309
+ 'untilDays': 30,
310
+ 'trigger': False,
311
+ 'trailing': False,
312
+ 'symbolRequired': False,
313
+ },
314
+ 'fetchClosedOrders': None,
315
+ 'fetchOHLCV': {
316
+ 'limit': 500,
317
+ },
318
+ },
319
+ 'spot': {
320
+ 'extends': 'default',
321
+ },
322
+ 'forDerivatives': {
323
+ 'extends': 'default',
324
+ 'createOrders': {
325
+ 'max': 20,
326
+ 'marginMode': False,
327
+ },
328
+ 'fetchMyTrades': {
329
+ 'marginMode': False,
330
+ 'limit': 100,
331
+ 'daysBack': 100000, # todo
332
+ 'untilDays': 100000, # todo
333
+ },
334
+ 'fetchOrder': {
335
+ 'marginMode': False,
336
+ },
337
+ 'fetchOpenOrders': {
338
+ 'marginMode': False,
339
+ 'limit': 100,
340
+ },
341
+ 'fetchOrders': {
342
+ 'marginMode': False,
343
+ 'daysBack': 100000, # todo
344
+ },
345
+ 'fetchOHLCV': {
346
+ 'limit': 100,
347
+ },
348
+ },
349
+ 'swap': {
350
+ 'linear': {
351
+ 'extends': 'forDerivatives',
352
+ },
353
+ 'inverse': {
354
+ 'extends': 'forDerivatives',
355
+ },
356
+ },
357
+ 'future': {
358
+ 'linear': None,
359
+ 'inverse': None,
360
+ },
361
+ },
251
362
  'fees': {
252
363
  'trading': {
253
364
  'tierBased': True,
@@ -355,6 +466,16 @@ class digifinex(Exchange, ImplicitAPI):
355
466
  'TRX': 'TRC20',
356
467
  'VECHAIN': 'Vechain', # VET
357
468
  },
469
+ 'networksById': {
470
+ 'TRC20': 'TRC20',
471
+ 'TRX': 'TRC20',
472
+ 'BEP20': 'BEP20',
473
+ 'BSC': 'BEP20',
474
+ 'ERC20': 'ERC20',
475
+ 'ETH': 'ERC20',
476
+ 'Polygon': 'POLYGON',
477
+ 'Crypto.com': 'CRONOS',
478
+ },
358
479
  },
359
480
  'commonCurrencies': {
360
481
  'BHT': 'Black House Test',
@@ -382,6 +503,7 @@ class digifinex(Exchange, ImplicitAPI):
382
503
  # "min_withdraw_amount":10,
383
504
  # "min_withdraw_fee":5,
384
505
  # "currency":"USDT",
506
+ # "withdraw_fee_currency":"USDT",
385
507
  # "withdraw_status":0,
386
508
  # "chain":"OMNI"
387
509
  # },
@@ -392,6 +514,7 @@ class digifinex(Exchange, ImplicitAPI):
392
514
  # "min_withdraw_amount":10,
393
515
  # "min_withdraw_fee":3,
394
516
  # "currency":"USDT",
517
+ # "withdraw_fee_currency":"USDT",
395
518
  # "withdraw_status":1,
396
519
  # "chain":"ERC20"
397
520
  # },
@@ -402,6 +525,7 @@ class digifinex(Exchange, ImplicitAPI):
402
525
  # "min_withdraw_amount":0,
403
526
  # "min_withdraw_fee":0,
404
527
  # "currency":"DGF13",
528
+ # "withdraw_fee_currency":"DGF13",
405
529
  # "withdraw_status":0,
406
530
  # "chain":""
407
531
  # },
@@ -409,117 +533,45 @@ class digifinex(Exchange, ImplicitAPI):
409
533
  # "code":200
410
534
  # }
411
535
  #
412
- data = self.safe_value(response, 'data', [])
536
+ data = self.safe_list(response, 'data', [])
537
+ groupedById = self.group_by(data, 'currency')
538
+ keys = list(groupedById.keys())
413
539
  result: dict = {}
414
- for i in range(0, len(data)):
415
- currency = data[i]
416
- id = self.safe_string(currency, 'currency')
540
+ for i in range(0, len(keys)):
541
+ id = keys[i]
542
+ networkEntries = groupedById[id]
417
543
  code = self.safe_currency_code(id)
418
- depositStatus = self.safe_integer(currency, 'deposit_status', 1)
419
- withdrawStatus = self.safe_integer(currency, 'withdraw_status', 1)
420
- deposit = depositStatus > 0
421
- withdraw = withdrawStatus > 0
422
- active = deposit and withdraw
423
- feeString = self.safe_string(currency, 'min_withdraw_fee') # withdraw_fee_rate was zero for all currencies, so self was the worst case scenario
424
- minWithdrawString = self.safe_string(currency, 'min_withdraw_amount')
425
- minDepositString = self.safe_string(currency, 'min_deposit_amount')
426
- minDeposit = self.parse_number(minDepositString)
427
- minWithdraw = self.parse_number(minWithdrawString)
428
- fee = self.parse_number(feeString)
429
- # define precision with temporary way
430
- minFoundPrecision = Precise.string_min(feeString, Precise.string_min(minDepositString, minWithdrawString))
431
- precision = self.parse_number(minFoundPrecision)
432
- networkId = self.safe_string(currency, 'chain')
433
- networkCode = None
434
- if networkId is not None:
544
+ networks = {}
545
+ for j in range(0, len(networkEntries)):
546
+ networkEntry = networkEntries[j]
547
+ networkId = self.safe_string(networkEntry, 'chain')
435
548
  networkCode = self.network_id_to_code(networkId)
436
- network: dict = {
437
- 'info': currency,
438
- 'id': networkId,
439
- 'network': networkCode,
440
- 'active': active,
441
- 'fee': fee,
442
- 'precision': precision,
443
- 'deposit': deposit,
444
- 'withdraw': withdraw,
445
- 'limits': {
446
- 'amount': {
447
- 'min': None,
448
- 'max': None,
449
- },
450
- 'withdraw': {
451
- 'min': minWithdraw,
452
- 'max': None,
453
- },
454
- 'deposit': {
455
- 'min': minDeposit,
456
- 'max': None,
457
- },
458
- },
459
- }
460
- if code in result:
461
- if isinstance(result[code]['info'], list):
462
- result[code]['info'].append(currency)
463
- else:
464
- result[code]['info'] = [result[code]['info'], currency]
465
- if withdraw:
466
- result[code]['withdraw'] = True
467
- result[code]['limits']['withdraw']['min'] = min(result[code]['limits']['withdraw']['min'], minWithdraw)
468
- if deposit:
469
- result[code]['deposit'] = True
470
- result[code]['limits']['deposit']['min'] = min(result[code]['limits']['deposit']['min'], minDeposit)
471
- if active:
472
- result[code]['active'] = True
473
- else:
474
- result[code] = {
475
- 'id': id,
476
- 'code': code,
477
- 'info': currency,
478
- 'type': None,
479
- 'name': None,
480
- 'active': active,
481
- 'deposit': deposit,
482
- 'withdraw': withdraw,
483
- 'fee': self.parse_number(feeString),
549
+ networks[networkCode] = {
550
+ 'id': networkId,
551
+ 'network': networkCode,
552
+ 'active': None,
553
+ 'deposit': self.safe_integer(networkEntry, 'deposit_status') == 1,
554
+ 'withdraw': self.safe_integer(networkEntry, 'withdraw_status') == 1,
555
+ 'fee': self.safe_number(networkEntry, 'min_withdraw_fee'),
484
556
  'precision': None,
485
557
  'limits': {
486
- 'amount': {
487
- 'min': None,
488
- 'max': None,
489
- },
490
558
  'withdraw': {
491
- 'min': minWithdraw,
559
+ 'min': self.safe_number(networkEntry, 'min_withdraw_amount'),
492
560
  'max': None,
493
561
  },
494
562
  'deposit': {
495
- 'min': minDeposit,
563
+ 'min': self.safe_number(networkEntry, 'min_deposit_amount'),
496
564
  'max': None,
497
565
  },
498
566
  },
499
- 'networks': {},
567
+ 'info': networkEntry,
500
568
  }
501
- if networkId is not None:
502
- result[code]['networks'][networkId] = network
503
- else:
504
- result[code]['active'] = active
505
- result[code]['fee'] = self.parse_number(feeString)
506
- result[code]['deposit'] = deposit
507
- result[code]['withdraw'] = withdraw
508
- result[code]['limits'] = {
509
- 'amount': {
510
- 'min': None,
511
- 'max': None,
512
- },
513
- 'withdraw': {
514
- 'min': minWithdraw,
515
- 'max': None,
516
- },
517
- 'deposit': {
518
- 'min': minDeposit,
519
- 'max': None,
520
- },
521
- }
522
- result[code]['precision'] = precision if (result[code]['precision'] is None) else max(result[code]['precision'], precision)
569
+ result[code] = self.safe_currency_structure({
570
+ 'id': id,
571
+ 'code': code,
572
+ 'info': networkEntries,
573
+ 'networks': networks,
574
+ })
523
575
  return result
524
576
 
525
577
  def fetch_markets(self, params={}) -> List[Market]:
@@ -805,9 +857,11 @@ class digifinex(Exchange, ImplicitAPI):
805
857
  def fetch_balance(self, params={}) -> Balances:
806
858
  """
807
859
  query for balance and get the amount of funds available for trading or funds locked in orders
808
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-account-assets
809
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
810
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#accountbalance
860
+
861
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-account-assets
862
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
863
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#accountbalance
864
+
811
865
  :param dict [params]: extra parameters specific to the exchange API endpoint
812
866
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
813
867
  """
@@ -868,8 +922,10 @@ class digifinex(Exchange, ImplicitAPI):
868
922
  def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
869
923
  """
870
924
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
871
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-orderbook
872
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderbook
925
+
926
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-orderbook
927
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderbook
928
+
873
929
  :param str symbol: unified symbol of the market to fetch the order book for
874
930
  :param int [limit]: the maximum amount of order book entries to return
875
931
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -939,8 +995,10 @@ class digifinex(Exchange, ImplicitAPI):
939
995
  def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
940
996
  """
941
997
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
942
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
943
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#tickers
998
+
999
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
1000
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#tickers
1001
+
944
1002
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
945
1003
  :param dict [params]: extra parameters specific to the exchange API endpoint
946
1004
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1022,8 +1080,10 @@ class digifinex(Exchange, ImplicitAPI):
1022
1080
  def fetch_ticker(self, symbol: str, params={}) -> Ticker:
1023
1081
  """
1024
1082
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1025
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
1026
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#ticker
1083
+
1084
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
1085
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#ticker
1086
+
1027
1087
  :param str symbol: unified symbol of the market to fetch the ticker for
1028
1088
  :param dict [params]: extra parameters specific to the exchange API endpoint
1029
1089
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1163,6 +1223,8 @@ class digifinex(Exchange, ImplicitAPI):
1163
1223
  'average': None,
1164
1224
  'baseVolume': self.safe_string_2(ticker, 'vol', 'volume_24h'),
1165
1225
  'quoteVolume': self.safe_string(ticker, 'base_vol'),
1226
+ 'markPrice': self.safe_string(ticker, 'mark_price'),
1227
+ 'indexPrice': indexPrice,
1166
1228
  'info': ticker,
1167
1229
  }, market)
1168
1230
 
@@ -1294,7 +1356,7 @@ class digifinex(Exchange, ImplicitAPI):
1294
1356
  'fee': fee,
1295
1357
  }, market)
1296
1358
 
1297
- def fetch_time(self, params={}):
1359
+ def fetch_time(self, params={}) -> Int:
1298
1360
  """
1299
1361
  fetches the current integer timestamp in milliseconds from the exchange server
1300
1362
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1335,8 +1397,10 @@ class digifinex(Exchange, ImplicitAPI):
1335
1397
  def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1336
1398
  """
1337
1399
  get the list of most recent trades for a particular symbol
1338
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-recent-trades
1339
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#recenttrades
1400
+
1401
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-recent-trades
1402
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#recenttrades
1403
+
1340
1404
  :param str symbol: unified symbol of the market to fetch trades for
1341
1405
  :param int [since]: timestamp in ms of the earliest trade to fetch
1342
1406
  :param int [limit]: the maximum amount of trades to fetch
@@ -1432,13 +1496,16 @@ class digifinex(Exchange, ImplicitAPI):
1432
1496
  def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1433
1497
  """
1434
1498
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1435
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-candles-data
1436
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#recentcandle
1499
+
1500
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-candles-data
1501
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#recentcandle
1502
+
1437
1503
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1438
1504
  :param str timeframe: the length of time each candle represents
1439
1505
  :param int [since]: timestamp in ms of the earliest candle to fetch
1440
1506
  :param int [limit]: the maximum amount of candles to fetch
1441
1507
  :param dict [params]: extra parameters specific to the exchange API endpoint
1508
+ :param int [params.until]: timestamp in ms of the latest candle to fetch
1442
1509
  :returns int[][]: A list of candles ordered, open, high, low, close, volume
1443
1510
  """
1444
1511
  self.load_markets()
@@ -1452,19 +1519,30 @@ class digifinex(Exchange, ImplicitAPI):
1452
1519
  request['limit'] = min(limit, 100)
1453
1520
  response = self.publicSwapGetPublicCandles(self.extend(request, params))
1454
1521
  else:
1522
+ until = self.safe_integer(params, 'until')
1455
1523
  request['symbol'] = market['id']
1456
1524
  request['period'] = self.safe_string(self.timeframes, timeframe, timeframe)
1457
- if since is not None:
1458
- startTime = self.parse_to_int(since / 1000)
1525
+ startTime = since
1526
+ duration = self.parse_timeframe(timeframe)
1527
+ if startTime is None:
1528
+ if (limit is not None) or (until is not None):
1529
+ endTime = until if (until is not None) else self.milliseconds()
1530
+ startLimit = limit if (limit is not None) else 200
1531
+ startTime = endTime - (startLimit * duration * 1000)
1532
+ if startTime is not None:
1533
+ startTime = self.parse_to_int(startTime / 1000)
1459
1534
  request['start_time'] = startTime
1460
- if limit is not None:
1461
- duration = self.parse_timeframe(timeframe)
1462
- request['end_time'] = self.sum(startTime, limit * duration)
1463
- elif limit is not None:
1464
- endTime = self.seconds()
1465
- duration = self.parse_timeframe(timeframe)
1466
- auxLimit = limit # in c# -limit is mutating the arg
1467
- request['start_time'] = self.sum(endTime, -auxLimit * duration)
1535
+ if (limit is not None) or (until is not None):
1536
+ if until is not None:
1537
+ endByUntil = self.parse_to_int(until / 1000)
1538
+ if limit is not None:
1539
+ endByLimit = self.sum(startTime, limit * duration)
1540
+ request['end_time'] = min(endByLimit, endByUntil)
1541
+ else:
1542
+ request['end_time'] = endByUntil
1543
+ else:
1544
+ request['end_time'] = self.sum(startTime, limit * duration)
1545
+ params = self.omit(params, 'until')
1468
1546
  response = self.publicSpotGetKline(self.extend(request, params))
1469
1547
  #
1470
1548
  # spot
@@ -1504,13 +1582,15 @@ class digifinex(Exchange, ImplicitAPI):
1504
1582
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1505
1583
  """
1506
1584
  create a trade order
1507
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-new-order
1508
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderplace
1585
+
1586
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-new-order
1587
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderplace
1588
+
1509
1589
  :param str symbol: unified symbol of the market to create an order in
1510
1590
  :param str type: 'market' or 'limit'
1511
1591
  :param str side: 'buy' or 'sell'
1512
1592
  :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
1513
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1593
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1514
1594
  :param dict [params]: extra parameters specific to the exchange API endpoint
1515
1595
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1516
1596
  :param bool [params.postOnly]: True or False
@@ -1558,8 +1638,10 @@ class digifinex(Exchange, ImplicitAPI):
1558
1638
  def create_orders(self, orders: List[OrderRequest], params={}):
1559
1639
  """
1560
1640
  create a list of trade orders(all orders should be of the same symbol)
1561
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-multiple-order
1562
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#batchorder
1641
+
1642
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-multiple-order
1643
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#batchorder
1644
+
1563
1645
  :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
1564
1646
  :param dict [params]: extra parameters specific to the exchange API endpoint
1565
1647
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -1640,13 +1722,13 @@ class digifinex(Exchange, ImplicitAPI):
1640
1722
 
1641
1723
  def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1642
1724
  """
1643
- * @ignore
1725
+ @ignore
1644
1726
  helper function to build request
1645
1727
  :param str symbol: unified symbol of the market to create an order in
1646
1728
  :param str type: 'market' or 'limit'
1647
1729
  :param str side: 'buy' or 'sell'
1648
1730
  :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
1649
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1731
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1650
1732
  :param dict [params]: extra parameters specific to the exchange API endpoint
1651
1733
  :returns dict: request to be sent to the exchange
1652
1734
  """
@@ -1732,7 +1814,9 @@ class digifinex(Exchange, ImplicitAPI):
1732
1814
  def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1733
1815
  """
1734
1816
  create a market buy order by providing the symbol and cost
1735
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-new-order
1817
+
1818
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-new-order
1819
+
1736
1820
  :param str symbol: unified symbol of the market to create an order in
1737
1821
  :param float cost: how much you want to trade in units of the quote currency
1738
1822
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1748,8 +1832,10 @@ class digifinex(Exchange, ImplicitAPI):
1748
1832
  def cancel_order(self, id: str, symbol: Str = None, params={}):
1749
1833
  """
1750
1834
  cancels an open order
1751
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#cancel-order
1752
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#cancelorder
1835
+
1836
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#cancel-order
1837
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#cancelorder
1838
+
1753
1839
  :param str id: order id
1754
1840
  :param str symbol: not used by digifinex cancelOrder()
1755
1841
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1808,7 +1894,34 @@ class digifinex(Exchange, ImplicitAPI):
1808
1894
  numCanceledOrders = len(canceledOrders)
1809
1895
  if numCanceledOrders != 1:
1810
1896
  raise OrderNotFound(self.id + ' cancelOrder() ' + id + ' not found')
1811
- return response
1897
+ orders = self.parse_cancel_orders(response)
1898
+ return self.safe_dict(orders, 0)
1899
+ else:
1900
+ return self.safe_order({
1901
+ 'info': response,
1902
+ 'orderId': self.safe_string(response, 'data'),
1903
+ })
1904
+
1905
+ def parse_cancel_orders(self, response):
1906
+ success = self.safe_list(response, 'success')
1907
+ error = self.safe_list(response, 'error')
1908
+ result = []
1909
+ for i in range(0, len(success)):
1910
+ order = success[i]
1911
+ result.append(self.safe_order({
1912
+ 'info': order,
1913
+ 'id': order,
1914
+ 'status': 'canceled',
1915
+ }))
1916
+ for i in range(0, len(error)):
1917
+ order = error[i]
1918
+ result.append(self.safe_order({
1919
+ 'info': order,
1920
+ 'id': self.safe_string_2(order, 'order-id', 'order_id'),
1921
+ 'status': 'failed',
1922
+ 'clientOrderId': self.safe_string(order, 'client-order-id'),
1923
+ }))
1924
+ return result
1812
1925
 
1813
1926
  def cancel_orders(self, ids, symbol: Str = None, params={}):
1814
1927
  """
@@ -1839,11 +1952,7 @@ class digifinex(Exchange, ImplicitAPI):
1839
1952
  # ]
1840
1953
  # }
1841
1954
  #
1842
- canceledOrders = self.safe_value(response, 'success', [])
1843
- numCanceledOrders = len(canceledOrders)
1844
- if numCanceledOrders < 1:
1845
- raise OrderNotFound(self.id + ' cancelOrders() error')
1846
- return response
1955
+ return self.parse_cancel_orders(response)
1847
1956
 
1848
1957
  def parse_order_status(self, status: Str):
1849
1958
  statuses: dict = {
@@ -1974,7 +2083,6 @@ class digifinex(Exchange, ImplicitAPI):
1974
2083
  'postOnly': None,
1975
2084
  'side': side,
1976
2085
  'price': self.safe_number(order, 'price'),
1977
- 'stopPrice': None,
1978
2086
  'triggerPrice': None,
1979
2087
  'amount': self.safe_number_2(order, 'amount', 'size'),
1980
2088
  'filled': self.safe_number_2(order, 'executed_amount', 'filled_qty'),
@@ -1991,8 +2099,10 @@ class digifinex(Exchange, ImplicitAPI):
1991
2099
  def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1992
2100
  """
1993
2101
  fetch all unfilled currently open orders
1994
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#current-active-orders
1995
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#openorder
2102
+
2103
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#current-active-orders
2104
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#openorder
2105
+
1996
2106
  :param str symbol: unified market symbol
1997
2107
  :param int [since]: the earliest time in ms to fetch open orders for
1998
2108
  :param int [limit]: the maximum number of open orders structures to retrieve
@@ -2085,8 +2195,10 @@ class digifinex(Exchange, ImplicitAPI):
2085
2195
  def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2086
2196
  """
2087
2197
  fetches information on multiple orders made by the user
2088
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-all-orders-including-history-orders
2089
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#historyorder
2198
+
2199
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-all-orders-including-history-orders
2200
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#historyorder
2201
+
2090
2202
  :param str symbol: unified market symbol of the market orders were made in
2091
2203
  :param int [since]: the earliest time in ms to fetch orders for
2092
2204
  :param int [limit]: the maximum number of order structures to retrieve
@@ -2180,8 +2292,10 @@ class digifinex(Exchange, ImplicitAPI):
2180
2292
  def fetch_order(self, id: str, symbol: Str = None, params={}):
2181
2293
  """
2182
2294
  fetches information on an order made by the user
2183
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-order-status
2184
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderinfo
2295
+
2296
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-order-status
2297
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderinfo
2298
+
2185
2299
  :param str id: order id
2186
2300
  :param str symbol: unified symbol of the market the order was made in
2187
2301
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2269,8 +2383,10 @@ class digifinex(Exchange, ImplicitAPI):
2269
2383
  def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2270
2384
  """
2271
2385
  fetch all trades made by the user
2272
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#customer-39-s-trades
2273
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#historytrade
2386
+
2387
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#customer-39-s-trades
2388
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#historytrade
2389
+
2274
2390
  :param str symbol: unified market symbol
2275
2391
  :param int [since]: the earliest time in ms to fetch trades for
2276
2392
  :param int [limit]: the maximum number of trades structures to retrieve
@@ -2360,7 +2476,7 @@ class digifinex(Exchange, ImplicitAPI):
2360
2476
  types: dict = {}
2361
2477
  return self.safe_string(types, type, type)
2362
2478
 
2363
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
2479
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
2364
2480
  #
2365
2481
  # spot and margin
2366
2482
  #
@@ -2382,13 +2498,15 @@ class digifinex(Exchange, ImplicitAPI):
2382
2498
  # }
2383
2499
  #
2384
2500
  type = self.parse_ledger_entry_type(self.safe_string_2(item, 'type', 'finance_type'))
2385
- code = self.safe_currency_code(self.safe_string_2(item, 'currency_mark', 'currency'), currency)
2501
+ currencyId = self.safe_string_2(item, 'currency_mark', 'currency')
2502
+ code = self.safe_currency_code(currencyId, currency)
2503
+ currency = self.safe_currency(currencyId, currency)
2386
2504
  amount = self.safe_number_2(item, 'num', 'change')
2387
2505
  after = self.safe_number(item, 'balance')
2388
2506
  timestamp = self.safe_timestamp(item, 'time')
2389
2507
  if timestamp is None:
2390
2508
  timestamp = self.safe_integer(item, 'timestamp')
2391
- return {
2509
+ return self.safe_ledger_entry({
2392
2510
  'info': item,
2393
2511
  'id': None,
2394
2512
  'direction': None,
@@ -2404,18 +2522,20 @@ class digifinex(Exchange, ImplicitAPI):
2404
2522
  'timestamp': timestamp,
2405
2523
  'datetime': self.iso8601(timestamp),
2406
2524
  'fee': None,
2407
- }
2525
+ }, currency)
2408
2526
 
2409
- def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
2527
+ def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
2410
2528
  """
2411
- fetch the history of changes, actions done by the user or operations that altered balance of the user
2412
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-margin-otc-financial-logs
2413
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#bills
2414
- :param str code: unified currency code, default is None
2529
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
2530
+
2531
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-margin-otc-financial-logs
2532
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#bills
2533
+
2534
+ :param str [code]: unified currency code, default is None
2415
2535
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
2416
- :param int [limit]: max number of ledger entrys to return, default is None
2536
+ :param int [limit]: max number of ledger entries to return, default is None
2417
2537
  :param dict [params]: extra parameters specific to the exchange API endpoint
2418
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
2538
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
2419
2539
  """
2420
2540
  self.load_markets()
2421
2541
  request: dict = {}
@@ -2487,7 +2607,7 @@ class digifinex(Exchange, ImplicitAPI):
2487
2607
  ledger = self.safe_value(data, 'finance', [])
2488
2608
  return self.parse_ledger(ledger, currency, since, limit)
2489
2609
 
2490
- def parse_deposit_address(self, depositAddress, currency: Currency = None):
2610
+ def parse_deposit_address(self, depositAddress, currency: Currency = None) -> DepositAddress:
2491
2611
  #
2492
2612
  # {
2493
2613
  # "addressTag":"",
@@ -2503,12 +2623,12 @@ class digifinex(Exchange, ImplicitAPI):
2503
2623
  return {
2504
2624
  'info': depositAddress,
2505
2625
  'currency': code,
2626
+ 'network': None,
2506
2627
  'address': address,
2507
2628
  'tag': tag,
2508
- 'network': None,
2509
2629
  }
2510
2630
 
2511
- def fetch_deposit_address(self, code: str, params={}):
2631
+ def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
2512
2632
  """
2513
2633
  fetch the deposit address for a currency associated with self account
2514
2634
  :param str code: unified currency code
@@ -2687,12 +2807,23 @@ class digifinex(Exchange, ImplicitAPI):
2687
2807
 
2688
2808
  def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:
2689
2809
  #
2690
- # transfer
2810
+ # transfer between spot, margin and OTC
2691
2811
  #
2692
2812
  # {
2693
2813
  # "code": 0
2694
2814
  # }
2695
2815
  #
2816
+ # transfer between spot and swap
2817
+ #
2818
+ # {
2819
+ # "code": 0,
2820
+ # "data": {
2821
+ # "type": 2,
2822
+ # "currency": "USDT",
2823
+ # "transfer_amount": "5"
2824
+ # }
2825
+ # }
2826
+ #
2696
2827
  # fetchTransfers
2697
2828
  #
2698
2829
  # {
@@ -2705,7 +2836,8 @@ class digifinex(Exchange, ImplicitAPI):
2705
2836
  #
2706
2837
  fromAccount = None
2707
2838
  toAccount = None
2708
- type = self.safe_integer(transfer, 'type')
2839
+ data = self.safe_dict(transfer, 'data', transfer)
2840
+ type = self.safe_integer(data, 'type')
2709
2841
  if type == 1:
2710
2842
  fromAccount = 'spot'
2711
2843
  toAccount = 'swap'
@@ -2718,8 +2850,8 @@ class digifinex(Exchange, ImplicitAPI):
2718
2850
  'id': self.safe_string(transfer, 'transfer_id'),
2719
2851
  'timestamp': timestamp,
2720
2852
  'datetime': self.iso8601(timestamp),
2721
- 'currency': self.safe_currency_code(self.safe_string(transfer, 'currency'), currency),
2722
- 'amount': self.safe_number(transfer, 'amount'),
2853
+ 'currency': self.safe_currency_code(self.safe_string(data, 'currency'), currency),
2854
+ 'amount': self.safe_number_2(data, 'amount', 'transfer_amount'),
2723
2855
  'fromAccount': fromAccount,
2724
2856
  'toAccount': toAccount,
2725
2857
  'status': self.parse_transfer_status(self.safe_string(transfer, 'code')),
@@ -2728,33 +2860,59 @@ class digifinex(Exchange, ImplicitAPI):
2728
2860
  def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
2729
2861
  """
2730
2862
  transfer currency internally between wallets on the same account
2863
+
2864
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#transfer-assets-among-accounts
2865
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#accounttransfer
2866
+
2731
2867
  :param str code: unified currency code
2732
2868
  :param float amount: amount to transfer
2733
- :param str fromAccount: account to transfer from
2734
- :param str toAccount: account to transfer to
2869
+ :param str fromAccount: 'spot', 'swap', 'margin', 'OTC' - account to transfer from
2870
+ :param str toAccount: 'spot', 'swap', 'margin', 'OTC' - account to transfer to
2735
2871
  :param dict [params]: extra parameters specific to the exchange API endpoint
2736
2872
  :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
2737
2873
  """
2738
2874
  self.load_markets()
2739
2875
  currency = self.currency(code)
2876
+ currencyId = currency['id']
2740
2877
  accountsByType = self.safe_value(self.options, 'accountsByType', {})
2741
2878
  fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
2742
2879
  toId = self.safe_string(accountsByType, toAccount, toAccount)
2743
- request: dict = {
2744
- 'currency_mark': currency['id'],
2745
- 'num': self.currency_to_precision(code, amount),
2746
- 'from': fromId, # 1 = SPOT, 2 = MARGIN, 3 = OTC
2747
- 'to': toId, # 1 = SPOT, 2 = MARGIN, 3 = OTC
2748
- }
2749
- response = self.privateSpotPostTransfer(self.extend(request, params))
2750
- #
2751
- # {
2752
- # "code": 0
2753
- # }
2754
- #
2880
+ request = {}
2881
+ fromSwap = (fromAccount == 'swap')
2882
+ toSwap = (toAccount == 'swap')
2883
+ response = None
2884
+ amountString = self.currency_to_precision(code, amount)
2885
+ if fromSwap or toSwap:
2886
+ if (fromId != '1') and (toId != '1'):
2887
+ raise ExchangeError(self.id + ' transfer() supports transferring between spot and swap, spot and margin, spot and OTC only')
2888
+ request['type'] = 1 if toSwap else 2 # 1 = spot to swap, 2 = swap to spot
2889
+ request['currency'] = currencyId
2890
+ request['transfer_amount'] = amountString
2891
+ #
2892
+ # {
2893
+ # "code": 0,
2894
+ # "data": {
2895
+ # "type": 2,
2896
+ # "currency": "USDT",
2897
+ # "transfer_amount": "5"
2898
+ # }
2899
+ # }
2900
+ #
2901
+ response = self.privateSwapPostAccountTransfer(self.extend(request, params))
2902
+ else:
2903
+ request['currency_mark'] = currencyId
2904
+ request['num'] = amountString
2905
+ request['from'] = fromId # 1 = SPOT, 2 = MARGIN, 3 = OTC
2906
+ request['to'] = toId # 1 = SPOT, 2 = MARGIN, 3 = OTC
2907
+ #
2908
+ # {
2909
+ # "code": 0
2910
+ # }
2911
+ #
2912
+ response = self.privateSpotPostTransfer(self.extend(request, params))
2755
2913
  return self.parse_transfer(response, currency)
2756
2914
 
2757
- def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
2915
+ def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
2758
2916
  """
2759
2917
  make a withdrawal
2760
2918
  :param str code: unified currency code
@@ -2785,7 +2943,7 @@ class digifinex(Exchange, ImplicitAPI):
2785
2943
  #
2786
2944
  return self.parse_transaction(response, currency)
2787
2945
 
2788
- def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2946
+ def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
2789
2947
  self.load_markets()
2790
2948
  request: dict = {}
2791
2949
  market = None
@@ -2818,7 +2976,7 @@ class digifinex(Exchange, ImplicitAPI):
2818
2976
  interest = self.parse_borrow_interests(rows, market)
2819
2977
  return self.filter_by_currency_since_limit(interest, code, since, limit)
2820
2978
 
2821
- def parse_borrow_interest(self, info: dict, market: Market = None):
2979
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
2822
2980
  #
2823
2981
  # {
2824
2982
  # "amount": 0.0006103,
@@ -2840,21 +2998,23 @@ class digifinex(Exchange, ImplicitAPI):
2840
2998
  currency = None if (market is None) else market['base']
2841
2999
  symbol = self.safe_symbol(marketId, market)
2842
3000
  return {
2843
- 'account': symbol,
3001
+ 'info': info,
2844
3002
  'symbol': symbol,
2845
3003
  'currency': currency,
2846
3004
  'interest': None,
2847
3005
  'interestRate': 0.001, # all interest rates on digifinex are 0.1%
2848
3006
  'amountBorrowed': self.parse_number(amountBorrowed),
3007
+ 'marginMode': None,
2849
3008
  'timestamp': None,
2850
3009
  'datetime': None,
2851
- 'info': info,
2852
3010
  }
2853
3011
 
2854
3012
  def fetch_cross_borrow_rate(self, code: str, params={}) -> CrossBorrowRate:
2855
3013
  """
2856
3014
  fetch the rate of interest to borrow a currency for margin trading
2857
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
3015
+
3016
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
3017
+
2858
3018
  :param str code: unified currency code
2859
3019
  :param dict [params]: extra parameters specific to the exchange API endpoint
2860
3020
  :returns dict: a `borrow rate structure <https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure>`
@@ -2891,7 +3051,9 @@ class digifinex(Exchange, ImplicitAPI):
2891
3051
  def fetch_cross_borrow_rates(self, params={}) -> CrossBorrowRates:
2892
3052
  """
2893
3053
  fetch the borrow interest rates of all currencies
2894
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
3054
+
3055
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
3056
+
2895
3057
  :param dict [params]: extra parameters specific to the exchange API endpoint
2896
3058
  :returns dict: a list of `borrow rate structures <https://docs.ccxt.com/#/?id=borrow-rate-structure>`
2897
3059
  """
@@ -2955,10 +3117,12 @@ class digifinex(Exchange, ImplicitAPI):
2955
3117
  result[code] = borrowRate
2956
3118
  return result
2957
3119
 
2958
- def fetch_funding_rate(self, symbol: str, params={}):
3120
+ def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
2959
3121
  """
2960
3122
  fetch the current funding rate
2961
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
3123
+
3124
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
3125
+
2962
3126
  :param str symbol: unified market symbol
2963
3127
  :param dict [params]: extra parameters specific to the exchange API endpoint
2964
3128
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -2983,10 +3147,22 @@ class digifinex(Exchange, ImplicitAPI):
2983
3147
  # }
2984
3148
  # }
2985
3149
  #
2986
- data = self.safe_value(response, 'data', {})
3150
+ data = self.safe_dict(response, 'data', {})
2987
3151
  return self.parse_funding_rate(data, market)
2988
3152
 
2989
- def parse_funding_rate(self, contract, market: Market = None):
3153
+ def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
3154
+ """
3155
+ fetch the current funding rate interval
3156
+
3157
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
3158
+
3159
+ :param str symbol: unified market symbol
3160
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3161
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
3162
+ """
3163
+ return self.fetch_funding_rate(symbol, params)
3164
+
3165
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
2990
3166
  #
2991
3167
  # {
2992
3168
  # "instrument_id": "BTCUSDTPERP",
@@ -2999,6 +3175,9 @@ class digifinex(Exchange, ImplicitAPI):
2999
3175
  marketId = self.safe_string(contract, 'instrument_id')
3000
3176
  timestamp = self.safe_integer(contract, 'funding_time')
3001
3177
  nextTimestamp = self.safe_integer(contract, 'next_funding_time')
3178
+ fundingTimeString = self.safe_string(contract, 'funding_time')
3179
+ nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
3180
+ millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
3002
3181
  return {
3003
3182
  'info': contract,
3004
3183
  'symbol': self.safe_symbol(marketId, market),
@@ -3011,13 +3190,24 @@ class digifinex(Exchange, ImplicitAPI):
3011
3190
  'fundingRate': self.safe_number(contract, 'funding_rate'),
3012
3191
  'fundingTimestamp': timestamp,
3013
3192
  'fundingDatetime': self.iso8601(timestamp),
3014
- 'nextFundingRate': self.safe_string(contract, 'next_funding_rate'),
3193
+ 'nextFundingRate': self.safe_number(contract, 'next_funding_rate'),
3015
3194
  'nextFundingTimestamp': nextTimestamp,
3016
3195
  'nextFundingDatetime': self.iso8601(nextTimestamp),
3017
3196
  'previousFundingRate': None,
3018
3197
  'previousFundingTimestamp': None,
3019
3198
  'previousFundingDatetime': None,
3199
+ 'interval': self.parse_funding_interval(millisecondsInterval),
3200
+ }
3201
+
3202
+ def parse_funding_interval(self, interval):
3203
+ intervals: dict = {
3204
+ '3600000': '1h',
3205
+ '14400000': '4h',
3206
+ '28800000': '8h',
3207
+ '57600000': '16h',
3208
+ '86400000': '24h',
3020
3209
  }
3210
+ return self.safe_string(intervals, interval, interval)
3021
3211
 
3022
3212
  def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3023
3213
  """
@@ -3078,7 +3268,9 @@ class digifinex(Exchange, ImplicitAPI):
3078
3268
  def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
3079
3269
  """
3080
3270
  fetch the trading fees for a market
3081
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#tradingfee
3271
+
3272
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#tradingfee
3273
+
3082
3274
  :param str symbol: unified market symbol
3083
3275
  :param dict [params]: extra parameters specific to the exchange API endpoint
3084
3276
  :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -3123,11 +3315,13 @@ class digifinex(Exchange, ImplicitAPI):
3123
3315
  'tierBased': None,
3124
3316
  }
3125
3317
 
3126
- def fetch_positions(self, symbols: Strings = None, params={}):
3318
+ def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
3127
3319
  """
3128
3320
  fetch all open positions
3129
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
3130
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positions
3321
+
3322
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
3323
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#positions
3324
+
3131
3325
  :param str[]|None symbols: list of unified market symbols
3132
3326
  :param dict [params]: extra parameters specific to the exchange API endpoint
3133
3327
  :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
@@ -3223,8 +3417,10 @@ class digifinex(Exchange, ImplicitAPI):
3223
3417
 
3224
3418
  def fetch_position(self, symbol: str, params={}):
3225
3419
  """
3226
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
3227
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positions
3420
+
3421
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
3422
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#positions
3423
+
3228
3424
  fetch data on a single open contract trade position
3229
3425
  :param str symbol: unified market symbol of the market the position is held in
3230
3426
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3389,10 +3585,12 @@ class digifinex(Exchange, ImplicitAPI):
3389
3585
  'takeProfitPrice': None,
3390
3586
  })
3391
3587
 
3392
- def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
3588
+ def set_leverage(self, leverage: int, symbol: Str = None, params={}):
3393
3589
  """
3394
3590
  set the level of leverage for a market
3395
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#setleverage
3591
+
3592
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#setleverage
3593
+
3396
3594
  :param float leverage: the rate of leverage
3397
3595
  :param str symbol: unified market symbol
3398
3596
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3438,10 +3636,12 @@ class digifinex(Exchange, ImplicitAPI):
3438
3636
  # }
3439
3637
  #
3440
3638
 
3441
- def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> TransferEntries:
3639
+ def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
3442
3640
  """
3443
3641
  fetch the transfer history, only transfers between spot and swap accounts are supported
3444
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#transferrecord
3642
+
3643
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#transferrecord
3644
+
3445
3645
  :param str code: unified currency code of the currency transferred
3446
3646
  :param int [since]: the earliest time in ms to fetch transfers for
3447
3647
  :param int [limit]: the maximum number of transfers to retrieve
@@ -3479,7 +3679,9 @@ class digifinex(Exchange, ImplicitAPI):
3479
3679
 
3480
3680
  def fetch_leverage_tiers(self, symbols: Strings = None, params={}) -> LeverageTiers:
3481
3681
  """
3482
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#instruments
3682
+
3683
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#instruments
3684
+
3483
3685
  retrieve information on the maximum leverage, for different trade sizes
3484
3686
  :param str[]|None symbols: a list of unified market symbols
3485
3687
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3522,8 +3724,10 @@ class digifinex(Exchange, ImplicitAPI):
3522
3724
 
3523
3725
  def fetch_market_leverage_tiers(self, symbol: str, params={}) -> List[LeverageTier]:
3524
3726
  """
3525
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#instrument
3526
3727
  retrieve information on the maximum leverage, for different trade sizes for a single market
3728
+
3729
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#instrument
3730
+
3527
3731
  :param str symbol: unified market symbol
3528
3732
  :param dict [params]: extra parameters specific to the exchange API endpoint
3529
3733
  :returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
@@ -3596,9 +3800,10 @@ class digifinex(Exchange, ImplicitAPI):
3596
3800
  for i in range(0, len(brackets)):
3597
3801
  tier = brackets[i]
3598
3802
  marketId = self.safe_string(info, 'instrument_id')
3599
- market = self.safe_market(marketId)
3803
+ market = self.safe_market(marketId, market)
3600
3804
  tiers.append({
3601
3805
  'tier': self.sum(i, 1),
3806
+ 'symbol': self.safe_symbol(marketId, market, None, 'swap'),
3602
3807
  'currency': market['settle'],
3603
3808
  'minNotional': None,
3604
3809
  'maxNotional': self.safe_number(tier, 'max_limit'),
@@ -3610,7 +3815,7 @@ class digifinex(Exchange, ImplicitAPI):
3610
3815
 
3611
3816
  def handle_margin_mode_and_params(self, methodName, params={}, defaultValue=None):
3612
3817
  """
3613
- * @ignore
3818
+ @ignore
3614
3819
  marginMode specified by params["marginMode"], self.options["marginMode"], self.options["defaultMarginMode"], params["margin"] = True or self.options["defaultType"] = 'margin'
3615
3820
  :param dict [params]: extra parameters specific to the exchange API endpoint
3616
3821
  :returns Array: the marginMode in lowercase
@@ -3630,7 +3835,9 @@ class digifinex(Exchange, ImplicitAPI):
3630
3835
  def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
3631
3836
  """
3632
3837
  fetch deposit and withdraw fees
3633
- :see: https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-currency-deposit-and-withdrawal-information
3838
+
3839
+ https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-currency-deposit-and-withdrawal-information
3840
+
3634
3841
  :param str[]|None codes: not used by fetchDepositWithdrawFees()
3635
3842
  :param dict [params]: extra parameters specific to the exchange API endpoint
3636
3843
  :returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -3707,7 +3914,8 @@ class digifinex(Exchange, ImplicitAPI):
3707
3914
  if depositWithdrawFee is None:
3708
3915
  depositWithdrawFees[code] = self.deposit_withdraw_fee({})
3709
3916
  depositWithdrawFees[code]['info'] = []
3710
- depositWithdrawFees[code]['info'].append(entry)
3917
+ depositWithdrawInfo = depositWithdrawFees[code]['info']
3918
+ depositWithdrawInfo.append(entry)
3711
3919
  networkId = self.safe_string(entry, 'chain')
3712
3920
  withdrawFee = self.safe_value(entry, 'min_withdraw_fee')
3713
3921
  withdrawResult: dict = {
@@ -3737,7 +3945,9 @@ class digifinex(Exchange, ImplicitAPI):
3737
3945
  def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3738
3946
  """
3739
3947
  add margin to a position
3740
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
3948
+
3949
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
3950
+
3741
3951
  :param str symbol: unified market symbol
3742
3952
  :param float amount: amount of margin to add
3743
3953
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3751,7 +3961,9 @@ class digifinex(Exchange, ImplicitAPI):
3751
3961
  def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3752
3962
  """
3753
3963
  remove margin from a position
3754
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
3964
+
3965
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
3966
+
3755
3967
  :param str symbol: unified market symbol
3756
3968
  :param float amount: the amount of margin to remove
3757
3969
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3818,7 +4030,9 @@ class digifinex(Exchange, ImplicitAPI):
3818
4030
  def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3819
4031
  """
3820
4032
  fetch the history of funding payments paid and received on self account
3821
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#funding-fee
4033
+
4034
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#funding-fee
4035
+
3822
4036
  :param str [symbol]: unified market symbol
3823
4037
  :param int [since]: the earliest time in ms to fetch funding history for
3824
4038
  :param int [limit]: the maximum number of funding history structures to retrieve
@@ -3879,7 +4093,9 @@ class digifinex(Exchange, ImplicitAPI):
3879
4093
  def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
3880
4094
  """
3881
4095
  set margin mode to 'cross' or 'isolated'
3882
- :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmode
4096
+
4097
+ https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmode
4098
+
3883
4099
  :param str marginMode: 'cross' or 'isolated'
3884
4100
  :param str symbol: unified market symbol
3885
4101
  :param dict [params]: extra parameters specific to the exchange API endpoint