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
@@ -5,8 +5,9 @@
5
5
 
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.ascendex import ImplicitAPI
8
+ import asyncio
8
9
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currencies, Currency, Int, Leverage, Leverages, LeverageTier, LeverageTiers, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
10
+ from ccxt.base.types import Account, Any, Balances, Currencies, Currency, DepositAddress, Int, Leverage, Leverages, LeverageTier, LeverageTiers, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFees, Transaction, TransferEntry
10
11
  from typing import List
11
12
  from ccxt.base.errors import ExchangeError
12
13
  from ccxt.base.errors import AuthenticationError
@@ -24,7 +25,7 @@ from ccxt.base.precise import Precise
24
25
 
25
26
  class ascendex(Exchange, ImplicitAPI):
26
27
 
27
- def describe(self):
28
+ def describe(self) -> Any:
28
29
  return self.deep_extend(super(ascendex, self).describe(), {
29
30
  'id': 'ascendex',
30
31
  'name': 'AscendEX',
@@ -67,6 +68,7 @@ class ascendex(Exchange, ImplicitAPI):
67
68
  'fetchFundingRate': 'emulated',
68
69
  'fetchFundingRateHistory': False,
69
70
  'fetchFundingRates': True,
71
+ 'fetchGreeks': False,
70
72
  'fetchIndexOHLCV': False,
71
73
  'fetchLeverage': 'emulated',
72
74
  'fetchLeverages': True,
@@ -76,10 +78,13 @@ class ascendex(Exchange, ImplicitAPI):
76
78
  'fetchMarketLeverageTiers': 'emulated',
77
79
  'fetchMarkets': True,
78
80
  'fetchMarkOHLCV': False,
81
+ 'fetchMySettlementHistory': False,
79
82
  'fetchOHLCV': True,
80
83
  'fetchOpenInterest': False,
81
84
  'fetchOpenInterestHistory': False,
82
85
  'fetchOpenOrders': True,
86
+ 'fetchOption': False,
87
+ 'fetchOptionChain': False,
83
88
  'fetchOrder': True,
84
89
  'fetchOrderBook': True,
85
90
  'fetchOrders': False,
@@ -88,6 +93,7 @@ class ascendex(Exchange, ImplicitAPI):
88
93
  'fetchPositions': True,
89
94
  'fetchPositionsRisk': False,
90
95
  'fetchPremiumIndexOHLCV': False,
96
+ 'fetchSettlementHistory': False,
91
97
  'fetchTicker': True,
92
98
  'fetchTickers': True,
93
99
  'fetchTime': True,
@@ -99,6 +105,7 @@ class ascendex(Exchange, ImplicitAPI):
99
105
  'fetchTransactions': 'emulated',
100
106
  'fetchTransfer': False,
101
107
  'fetchTransfers': False,
108
+ 'fetchVolatilityHistory': False,
102
109
  'fetchWithdrawal': False,
103
110
  'fetchWithdrawals': True,
104
111
  'reduceMargin': True,
@@ -124,7 +131,7 @@ class ascendex(Exchange, ImplicitAPI):
124
131
  },
125
132
  'version': 'v2',
126
133
  'urls': {
127
- 'logo': 'https://user-images.githubusercontent.com/1294454/112027508-47984600-8b48-11eb-9e17-d26459cc36c6.jpg',
134
+ 'logo': 'https://github.com/user-attachments/assets/55bab6b9-d4ca-42a8-a0e6-fac81ae557f1',
128
135
  'api': {
129
136
  'rest': 'https://ascendex.com',
130
137
  },
@@ -293,26 +300,114 @@ class ascendex(Exchange, ImplicitAPI):
293
300
  'SOL': 'Solana',
294
301
  'AVAX': 'avalanche C chain',
295
302
  'OMNI': 'Omni',
296
- 'TRC': 'TRC20',
297
- 'TRX': 'TRC20',
298
- 'ERC': 'ERC20',
299
- },
300
- 'networksById': {
301
- 'BEP20(BSC)': 'BSC',
302
- 'arbitrum': 'ARB',
303
- 'Solana': 'SOL',
304
- 'avalanche C chain': 'AVAX',
305
- 'Omni': 'OMNI',
303
+ # 'TRC': 'TRC20',
306
304
  'TRC20': 'TRC20',
307
305
  'ERC20': 'ERC20',
308
306
  'GO20': 'GO20',
309
307
  'BEP2': 'BEP2',
310
- 'Bitcoin': 'BTC',
311
- 'Bitcoin ABC': 'BCH',
312
- 'Litecoin': 'LTC',
313
- 'Matic Network': 'MATIC',
314
- 'xDai': 'STAKE',
315
- 'Akash': 'AKT',
308
+ 'BTC': 'Bitcoin',
309
+ 'BCH': 'Bitcoin ABC',
310
+ 'LTC': 'Litecoin',
311
+ 'MATIC': 'Matic Network',
312
+ 'AKT': 'Akash',
313
+ },
314
+ },
315
+ 'features': {
316
+ 'default': {
317
+ 'sandbox': True,
318
+ 'createOrder': {
319
+ 'marginMode': True,
320
+ 'triggerPrice': True,
321
+ 'triggerPriceType': None,
322
+ 'triggerDirection': False,
323
+ 'stopLossPrice': False, # todo with triggerprice
324
+ 'takeProfitPrice': False, # todo with triggerprice
325
+ 'attachedStopLossTakeProfit': None,
326
+ 'timeInForce': {
327
+ 'IOC': True,
328
+ 'FOK': True,
329
+ 'PO': True,
330
+ 'GTD': False,
331
+ },
332
+ 'hedged': False,
333
+ 'trailing': False,
334
+ 'leverage': False,
335
+ 'marketBuyRequiresPrice': False,
336
+ 'marketBuyByCost': False,
337
+ 'selfTradePrevention': False,
338
+ 'iceberg': False,
339
+ },
340
+ 'createOrders': {
341
+ 'max': 10,
342
+ },
343
+ 'fetchMyTrades': None,
344
+ 'fetchOrder': {
345
+ 'marginMode': False,
346
+ 'trigger': False,
347
+ 'trailing': False,
348
+ 'marketType': True,
349
+ 'symbolRequired': False,
350
+ },
351
+ 'fetchOpenOrders': {
352
+ 'marginMode': False,
353
+ 'limit': None,
354
+ 'trigger': False,
355
+ 'trailing': False,
356
+ 'marketType': True,
357
+ 'symbolRequired': False,
358
+ },
359
+ 'fetchOrders': None,
360
+ 'fetchClosedOrders': None,
361
+ 'fetchOHLCV': {
362
+ 'limit': 500,
363
+ },
364
+ },
365
+ 'spot': {
366
+ 'extends': 'default',
367
+ 'fetchClosedOrders': {
368
+ 'marginMode': False,
369
+ 'limit': 1000,
370
+ 'daysBack': 100000,
371
+ 'daysBackCanceled': 1,
372
+ 'untilDays': 100000,
373
+ 'trigger': False,
374
+ 'trailing': False,
375
+ 'symbolRequired': False,
376
+ },
377
+ },
378
+ 'forDerivatives': {
379
+ 'extends': 'default',
380
+ 'createOrder': {
381
+ # todo: implementation
382
+ 'attachedStopLossTakeProfit': {
383
+ 'triggerPriceType': {
384
+ 'last': True,
385
+ 'mark': False,
386
+ 'index': False,
387
+ },
388
+ 'price': False,
389
+ },
390
+ },
391
+ 'fetchClosedOrders': {
392
+ 'marginMode': False,
393
+ 'limit': 1000,
394
+ 'daysBack': None,
395
+ 'daysBackCanceled': None,
396
+ 'untilDays': None,
397
+ 'trigger': False,
398
+ 'trailing': False,
399
+ 'symbolRequired': False,
400
+ },
401
+ },
402
+ 'swap': {
403
+ 'linear': {
404
+ 'extends': 'forDerivatives',
405
+ },
406
+ 'inverse': None,
407
+ },
408
+ 'future': {
409
+ 'linear': None,
410
+ 'inverse': None,
316
411
  },
317
412
  },
318
413
  'exceptions': {
@@ -383,6 +478,7 @@ class ascendex(Exchange, ImplicitAPI):
383
478
  'broad': {},
384
479
  },
385
480
  'commonCurrencies': {
481
+ 'XBT': 'XBT', # self is not BTC ! just another token
386
482
  'BOND': 'BONDED',
387
483
  'BTCBEAR': 'BEAR',
388
484
  'BTCBULL': 'BULL',
@@ -403,94 +499,82 @@ class ascendex(Exchange, ImplicitAPI):
403
499
  :param dict [params]: extra parameters specific to the exchange API endpoint
404
500
  :returns dict: an associative dictionary of currencies
405
501
  """
406
- assets = await self.v1PublicGetAssets(params)
407
- #
408
- # {
409
- # "code":0,
410
- # "data":[
411
- # {
412
- # "assetCode" : "LTCBULL",
413
- # "assetName" : "3X Long LTC Token",
414
- # "precisionScale" : 9,
415
- # "nativeScale" : 4,
416
- # "withdrawalFee" : "0.2",
417
- # "minWithdrawalAmt" : "1.0",
418
- # "status" : "Normal"
419
- # },
420
- # ]
421
- # }
422
- #
423
- margin = await self.v1PublicGetMarginAssets(params)
424
- #
425
- # {
426
- # "code":0,
427
- # "data":[
428
- # {
429
- # "assetCode":"BTT",
430
- # "borrowAssetCode":"BTT-B",
431
- # "interestAssetCode":"BTT-I",
432
- # "nativeScale":0,
433
- # "numConfirmations":1,
434
- # "withdrawFee":"100.0",
435
- # "minWithdrawalAmt":"1000.0",
436
- # "statusCode":"Normal",
437
- # "statusMessage":"",
438
- # "interestRate":"0.001"
439
- # }
440
- # ]
441
- # }
442
- #
443
- cash = await self.v1PublicGetCashAssets(params)
502
+ response = await self.v2PublicGetAssets(params)
444
503
  #
445
- # {
446
- # "code":0,
447
- # "data":[
448
- # {
449
- # "assetCode":"LTCBULL",
450
- # "nativeScale":4,
451
- # "numConfirmations":20,
452
- # "withdrawFee":"0.2",
453
- # "minWithdrawalAmt":"1.0",
454
- # "statusCode":"Normal",
455
- # "statusMessage":""
456
- # }
504
+ # {
505
+ # "code": "0",
506
+ # "data": [
507
+ # {
508
+ # "assetCode": "USDT",
509
+ # "assetName": "Tether",
510
+ # "precisionScale": 9,
511
+ # "nativeScale": 4,
512
+ # "blockChain": [
513
+ # {
514
+ # "chainName": "Solana",
515
+ # "withdrawFee": "2.0",
516
+ # "allowDeposit": True,
517
+ # "allowWithdraw": True,
518
+ # "minDepositAmt": "0.01",
519
+ # "minWithdrawal": "4.0",
520
+ # "numConfirmations": 1
521
+ # },
522
+ # ...
523
+ # ]
524
+ # },
457
525
  # ]
458
- # }
526
+ # }
459
527
  #
460
- assetsData = self.safe_value(assets, 'data', [])
461
- marginData = self.safe_value(margin, 'data', [])
462
- cashData = self.safe_value(cash, 'data', [])
463
- assetsById = self.index_by(assetsData, 'assetCode')
464
- marginById = self.index_by(marginData, 'assetCode')
465
- cashById = self.index_by(cashData, 'assetCode')
466
- dataById = self.deep_extend(assetsById, marginById, cashById)
467
- ids = list(dataById.keys())
528
+ data = self.safe_list(response, 'data', [])
468
529
  result: dict = {}
469
- for i in range(0, len(ids)):
470
- id = ids[i]
471
- currency = dataById[id]
530
+ for i in range(0, len(data)):
531
+ currency = data[i]
532
+ id = self.safe_string(currency, 'assetCode')
472
533
  code = self.safe_currency_code(id)
473
- scale = self.safe_string_2(currency, 'precisionScale', 'nativeScale')
474
- precision = self.parse_number(self.parse_precision(scale))
475
- fee = self.safe_number_2(currency, 'withdrawFee', 'withdrawalFee')
476
- status = self.safe_string_2(currency, 'status', 'statusCode')
477
- active = (status == 'Normal')
478
- marginInside = ('borrowAssetCode' in currency)
479
- result[code] = {
534
+ chains = self.safe_list(currency, 'blockChain', [])
535
+ precision = self.parse_number(self.parse_precision(self.safe_string(currency, 'nativeScale')))
536
+ networks = {}
537
+ for j in range(0, len(chains)):
538
+ networkEtnry = chains[j]
539
+ networkId = self.safe_string(networkEtnry, 'chainName')
540
+ networkCode = self.network_code_to_id(networkId)
541
+ networks[networkCode] = {
542
+ 'fee': self.safe_number(networkEtnry, 'withdrawFee'),
543
+ 'active': None,
544
+ 'withdraw': self.safe_bool(networkEtnry, 'allowWithdraw'),
545
+ 'deposit': self.safe_bool(networkEtnry, 'allowDeposit'),
546
+ 'precision': precision,
547
+ 'limits': {
548
+ 'amount': {
549
+ 'min': None,
550
+ 'max': None,
551
+ },
552
+ 'withdraw': {
553
+ 'min': self.safe_number(networkEtnry, 'minWithdrawal'),
554
+ 'max': None,
555
+ },
556
+ 'deposit': {
557
+ 'min': self.safe_number(networkEtnry, 'minDepositAmt'),
558
+ 'max': None,
559
+ },
560
+ },
561
+ }
562
+ # todo type: if chainsLength == 0 and (assetName.endswith(' Staking') or assetName.find(' Reward ') >= 0 or assetName.find('Slot Auction') >= 0 or assetName.find(' Freeze Asset') >= 0):
563
+ result[code] = self.safe_currency_structure({
480
564
  'id': id,
481
565
  'code': code,
482
566
  'info': currency,
483
567
  'type': None,
484
- 'margin': marginInside,
568
+ 'margin': None,
485
569
  'name': self.safe_string(currency, 'assetName'),
486
- 'active': active,
570
+ 'active': None,
487
571
  'deposit': None,
488
572
  'withdraw': None,
489
- 'fee': fee,
573
+ 'fee': None,
490
574
  'precision': precision,
491
575
  'limits': {
492
576
  'amount': {
493
- 'min': precision,
577
+ 'min': None,
494
578
  'max': None,
495
579
  },
496
580
  'withdraw': {
@@ -498,8 +582,8 @@ class ascendex(Exchange, ImplicitAPI):
498
582
  'max': None,
499
583
  },
500
584
  },
501
- 'networks': {},
502
- }
585
+ 'networks': networks,
586
+ })
503
587
  return result
504
588
 
505
589
  async def fetch_markets(self, params={}) -> List[Market]:
@@ -508,7 +592,13 @@ class ascendex(Exchange, ImplicitAPI):
508
592
  :param dict [params]: extra parameters specific to the exchange API endpoint
509
593
  :returns dict[]: an array of objects representing market data
510
594
  """
511
- products = await self.v1PublicGetProducts(params)
595
+ spotPromise = self.fetch_spot_markets(params)
596
+ contractPromise = self.fetch_contract_markets(params)
597
+ spotMarkets, contractMarkets = await asyncio.gather(*[spotPromise, contractPromise])
598
+ return self.array_concat(spotMarkets, contractMarkets)
599
+
600
+ async def fetch_spot_markets(self, params={}) -> List[Market]:
601
+ productsPromise = self.v1PublicGetProducts(params)
512
602
  #
513
603
  # {
514
604
  # "code": 0,
@@ -529,7 +619,7 @@ class ascendex(Exchange, ImplicitAPI):
529
619
  # ]
530
620
  # }
531
621
  #
532
- cash = await self.v1PublicGetCashProducts(params)
622
+ cashPromise = self.v1PublicGetCashProducts(params)
533
623
  #
534
624
  # {
535
625
  # "code": 0,
@@ -559,7 +649,91 @@ class ascendex(Exchange, ImplicitAPI):
559
649
  # ]
560
650
  # }
561
651
  #
562
- perpetuals = await self.v2PublicGetFuturesContract(params)
652
+ products, cash = await asyncio.gather(*[productsPromise, cashPromise])
653
+ productsData = self.safe_list(products, 'data', [])
654
+ productsById = self.index_by(productsData, 'symbol')
655
+ cashData = self.safe_list(cash, 'data', [])
656
+ cashAndPerpetualsById = self.index_by(cashData, 'symbol')
657
+ dataById = self.deep_extend(productsById, cashAndPerpetualsById)
658
+ ids = list(dataById.keys())
659
+ result = []
660
+ for i in range(0, len(ids)):
661
+ id = ids[i]
662
+ if id.find('-PERP') >= 0:
663
+ continue # skip perpetuals, endpoint returns them
664
+ market = dataById[id]
665
+ status = self.safe_string(market, 'status')
666
+ domain = self.safe_string(market, 'domain')
667
+ active = False
668
+ if ((status == 'Normal') or (status == 'InternalTrading')) and (domain != 'LeveragedETF'):
669
+ active = True
670
+ minQty = self.safe_number(market, 'minQty')
671
+ maxQty = self.safe_number(market, 'maxQty')
672
+ minPrice = self.safe_number(market, 'tickSize')
673
+ maxPrice: Num = None
674
+ underlying = self.safe_string_2(market, 'underlying', 'symbol')
675
+ parts = underlying.split('/')
676
+ baseId = self.safe_string(parts, 0)
677
+ quoteId = self.safe_string(parts, 1)
678
+ base = self.safe_currency_code(baseId)
679
+ quote = self.safe_currency_code(quoteId)
680
+ fee = self.safe_number(market, 'commissionReserveRate')
681
+ marginTradable = self.safe_bool(market, 'marginTradable', False)
682
+ result.append({
683
+ 'id': id,
684
+ 'symbol': base + '/' + quote,
685
+ 'base': base,
686
+ 'baseId': baseId,
687
+ 'quote': quote,
688
+ 'quoteId': quoteId,
689
+ 'settle': None,
690
+ 'settleId': None,
691
+ 'type': 'spot',
692
+ 'spot': True,
693
+ 'margin': marginTradable,
694
+ 'swap': False,
695
+ 'future': False,
696
+ 'option': False,
697
+ 'active': active,
698
+ 'contract': False,
699
+ 'linear': None,
700
+ 'inverse': None,
701
+ 'taker': fee,
702
+ 'maker': fee,
703
+ 'contractSize': None,
704
+ 'expiry': None,
705
+ 'expiryDatetime': None,
706
+ 'strike': None,
707
+ 'optionType': None,
708
+ 'precision': {
709
+ 'amount': self.safe_number(market, 'lotSize'),
710
+ 'price': self.safe_number(market, 'tickSize'),
711
+ },
712
+ 'limits': {
713
+ 'leverage': {
714
+ 'min': None,
715
+ 'max': None,
716
+ },
717
+ 'amount': {
718
+ 'min': minQty,
719
+ 'max': maxQty,
720
+ },
721
+ 'price': {
722
+ 'min': minPrice,
723
+ 'max': maxPrice,
724
+ },
725
+ 'cost': {
726
+ 'min': self.safe_number(market, 'minNotional'),
727
+ 'max': self.safe_number(market, 'maxNotional'),
728
+ },
729
+ },
730
+ 'created': self.safe_integer(market, 'tradingStartTime'),
731
+ 'info': market,
732
+ })
733
+ return result
734
+
735
+ async def fetch_contract_markets(self, params={}) -> List[Market]:
736
+ contracts = await self.v2PublicGetFuturesContract(params)
563
737
  #
564
738
  # {
565
739
  # "code": 0,
@@ -572,9 +746,9 @@ class ascendex(Exchange, ImplicitAPI):
572
746
  # "underlying": "BTC/USDT",
573
747
  # "tradingStartTime": 1579701600000,
574
748
  # "priceFilter": {
575
- # "minPrice": "1",
749
+ # "minPrice": "0.1",
576
750
  # "maxPrice": "1000000",
577
- # "tickSize": "1"
751
+ # "tickSize": "0.1"
578
752
  # },
579
753
  # "lotSizeFilter": {
580
754
  # "minQty": "0.0001",
@@ -597,49 +771,25 @@ class ascendex(Exchange, ImplicitAPI):
597
771
  # ]
598
772
  # }
599
773
  #
600
- productsData = self.safe_value(products, 'data', [])
601
- productsById = self.index_by(productsData, 'symbol')
602
- cashData = self.safe_value(cash, 'data', [])
603
- perpetualsData = self.safe_value(perpetuals, 'data', [])
604
- cashAndPerpetualsData = self.array_concat(cashData, perpetualsData)
605
- cashAndPerpetualsById = self.index_by(cashAndPerpetualsData, 'symbol')
606
- dataById = self.deep_extend(productsById, cashAndPerpetualsById)
607
- ids = list(dataById.keys())
774
+ data = self.safe_list(contracts, 'data', [])
608
775
  result = []
609
- for i in range(0, len(ids)):
610
- id = ids[i]
611
- market = dataById[id]
612
- settleId = self.safe_value(market, 'settlementAsset')
613
- settle = self.safe_currency_code(settleId)
614
- status = self.safe_string(market, 'status')
615
- domain = self.safe_string(market, 'domain')
616
- active = False
617
- if ((status == 'Normal') or (status == 'InternalTrading')) and (domain != 'LeveragedETF'):
618
- active = True
619
- spot = settle is None
620
- swap = not spot
621
- linear = True if swap else None
622
- minQty = self.safe_number(market, 'minQty')
623
- maxQty = self.safe_number(market, 'maxQty')
624
- minPrice = self.safe_number(market, 'tickSize')
625
- maxPrice: Num = None
626
- underlying = self.safe_string_2(market, 'underlying', 'symbol')
776
+ for i in range(0, len(data)):
777
+ market = data[i]
778
+ id = self.safe_string(market, 'symbol')
779
+ underlying = self.safe_string(market, 'underlying')
627
780
  parts = underlying.split('/')
628
781
  baseId = self.safe_string(parts, 0)
629
- quoteId = self.safe_string(parts, 1)
630
782
  base = self.safe_currency_code(baseId)
783
+ quoteId = self.safe_string(parts, 1)
631
784
  quote = self.safe_currency_code(quoteId)
632
- symbol = base + '/' + quote
633
- if swap:
634
- lotSizeFilter = self.safe_value(market, 'lotSizeFilter')
635
- minQty = self.safe_number(lotSizeFilter, 'minQty')
636
- maxQty = self.safe_number(lotSizeFilter, 'maxQty')
637
- priceFilter = self.safe_value(market, 'priceFilter')
638
- minPrice = self.safe_number(priceFilter, 'minPrice')
639
- maxPrice = self.safe_number(priceFilter, 'maxPrice')
640
- symbol = base + '/' + quote + ':' + settle
785
+ settleId = self.safe_string(market, 'settlementAsset')
786
+ settle = self.safe_currency_code(settleId)
787
+ linear = settle == quote
788
+ inverse = settle == base
789
+ symbol = base + '/' + quote + ':' + settle
790
+ priceFilter = self.safe_dict(market, 'priceFilter')
791
+ lotSizeFilter = self.safe_dict(market, 'lotSizeFilter')
641
792
  fee = self.safe_number(market, 'commissionReserveRate')
642
- marginTradable = self.safe_bool(market, 'marginTradable', False)
643
793
  result.append({
644
794
  'id': id,
645
795
  'symbol': symbol,
@@ -649,26 +799,26 @@ class ascendex(Exchange, ImplicitAPI):
649
799
  'baseId': baseId,
650
800
  'quoteId': quoteId,
651
801
  'settleId': settleId,
652
- 'type': 'swap' if swap else 'spot',
653
- 'spot': spot,
654
- 'margin': marginTradable if spot else None,
655
- 'swap': swap,
802
+ 'type': 'swap',
803
+ 'spot': False,
804
+ 'margin': None,
805
+ 'swap': True,
656
806
  'future': False,
657
807
  'option': False,
658
- 'active': active,
659
- 'contract': swap,
808
+ 'active': self.safe_string(market, 'status') == 'Normal',
809
+ 'contract': True,
660
810
  'linear': linear,
661
- 'inverse': not linear if swap else None,
811
+ 'inverse': inverse,
662
812
  'taker': fee,
663
813
  'maker': fee,
664
- 'contractSize': self.parse_number('1') if swap else None,
814
+ 'contractSize': self.parse_number('1'),
665
815
  'expiry': None,
666
816
  'expiryDatetime': None,
667
817
  'strike': None,
668
818
  'optionType': None,
669
819
  'precision': {
670
- 'amount': self.safe_number(market, 'lotSize'),
671
- 'price': self.safe_number(market, 'tickSize'),
820
+ 'amount': self.safe_number(lotSizeFilter, 'lotSize'),
821
+ 'price': self.safe_number(priceFilter, 'tickSize'),
672
822
  },
673
823
  'limits': {
674
824
  'leverage': {
@@ -676,12 +826,12 @@ class ascendex(Exchange, ImplicitAPI):
676
826
  'max': None,
677
827
  },
678
828
  'amount': {
679
- 'min': minQty,
680
- 'max': maxQty,
829
+ 'min': self.safe_number(lotSizeFilter, 'minQty'),
830
+ 'max': self.safe_number(lotSizeFilter, 'maxQty'),
681
831
  },
682
832
  'price': {
683
- 'min': minPrice,
684
- 'max': maxPrice,
833
+ 'min': self.safe_number(priceFilter, 'minPrice'),
834
+ 'max': self.safe_number(priceFilter, 'maxPrice'),
685
835
  },
686
836
  'cost': {
687
837
  'min': self.safe_number(market, 'minNotional'),
@@ -693,7 +843,7 @@ class ascendex(Exchange, ImplicitAPI):
693
843
  })
694
844
  return result
695
845
 
696
- async def fetch_time(self, params={}):
846
+ async def fetch_time(self, params={}) -> Int:
697
847
  """
698
848
  fetches the current integer timestamp in milliseconds from the ascendex server
699
849
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -713,7 +863,7 @@ class ascendex(Exchange, ImplicitAPI):
713
863
  # }
714
864
  # }
715
865
  #
716
- data = self.safe_value(response, 'data')
866
+ data = self.safe_dict(response, 'data', {})
717
867
  return self.safe_integer(data, 'requestReceiveAt')
718
868
 
719
869
  async def fetch_accounts(self, params={}) -> List[Account]:
@@ -742,7 +892,7 @@ class ascendex(Exchange, ImplicitAPI):
742
892
  # }
743
893
  # }
744
894
  #
745
- data = self.safe_value(response, 'data', {})
895
+ data = self.safe_dict(response, 'data', {})
746
896
  accountGroup = self.safe_string(data, 'accountGroup')
747
897
  self.options['account-group'] = accountGroup
748
898
  return [
@@ -760,7 +910,7 @@ class ascendex(Exchange, ImplicitAPI):
760
910
  'timestamp': None,
761
911
  'datetime': None,
762
912
  }
763
- balances = self.safe_value(response, 'data', [])
913
+ balances = self.safe_list(response, 'data', [])
764
914
  for i in range(0, len(balances)):
765
915
  balance = balances[i]
766
916
  code = self.safe_currency_code(self.safe_string(balance, 'asset'))
@@ -776,7 +926,7 @@ class ascendex(Exchange, ImplicitAPI):
776
926
  'timestamp': None,
777
927
  'datetime': None,
778
928
  }
779
- balances = self.safe_value(response, 'data', [])
929
+ balances = self.safe_list(response, 'data', [])
780
930
  for i in range(0, len(balances)):
781
931
  balance = balances[i]
782
932
  code = self.safe_currency_code(self.safe_string(balance, 'asset'))
@@ -795,8 +945,8 @@ class ascendex(Exchange, ImplicitAPI):
795
945
  'timestamp': None,
796
946
  'datetime': None,
797
947
  }
798
- data = self.safe_value(response, 'data', {})
799
- collaterals = self.safe_value(data, 'collaterals', [])
948
+ data = self.safe_dict(response, 'data', {})
949
+ collaterals = self.safe_list(data, 'collaterals', [])
800
950
  for i in range(0, len(collaterals)):
801
951
  balance = collaterals[i]
802
952
  code = self.safe_currency_code(self.safe_string(balance, 'asset'))
@@ -808,9 +958,11 @@ class ascendex(Exchange, ImplicitAPI):
808
958
  async def fetch_balance(self, params={}) -> Balances:
809
959
  """
810
960
  query for balance and get the amount of funds available for trading or funds locked in orders
811
- :see: https://ascendex.github.io/ascendex-pro-api/#cash-account-balance
812
- :see: https://ascendex.github.io/ascendex-pro-api/#margin-account-balance
813
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
961
+
962
+ https://ascendex.github.io/ascendex-pro-api/#cash-account-balance
963
+ https://ascendex.github.io/ascendex-pro-api/#margin-account-balance
964
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
965
+
814
966
  :param dict [params]: extra parameters specific to the exchange API endpoint
815
967
  :param str [params.type]: wallet type, 'spot', 'margin', or 'swap'
816
968
  :param str [params.marginMode]: 'cross' or None, for spot margin trading, value of 'isolated' is invalid
@@ -826,9 +978,9 @@ class ascendex(Exchange, ImplicitAPI):
826
978
  isCross = marginMode == 'cross'
827
979
  marketType = 'margin' if (isMargin or isCross) else marketType
828
980
  params = self.omit(params, 'margin')
829
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
981
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
830
982
  accountCategory = self.safe_string(accountsByType, marketType, 'cash')
831
- account = self.safe_value(self.accounts, 0, {})
983
+ account = self.safe_dict(self.accounts, 0, {})
832
984
  accountGroup = self.safe_string(account, 'id')
833
985
  request: dict = {
834
986
  'account-group': accountGroup,
@@ -931,8 +1083,8 @@ class ascendex(Exchange, ImplicitAPI):
931
1083
  # }
932
1084
  # }
933
1085
  #
934
- data = self.safe_value(response, 'data', {})
935
- orderbook = self.safe_value(data, 'data', {})
1086
+ data = self.safe_dict(response, 'data', {})
1087
+ orderbook = self.safe_dict(data, 'data', {})
936
1088
  timestamp = self.safe_integer(orderbook, 'ts')
937
1089
  result = self.parse_order_book(orderbook, symbol, timestamp)
938
1090
  result['nonce'] = self.safe_integer(orderbook, 'seqnum')
@@ -958,8 +1110,8 @@ class ascendex(Exchange, ImplicitAPI):
958
1110
  delimiter = '/' if (type == 'spot') else None
959
1111
  symbol = self.safe_symbol(marketId, market, delimiter)
960
1112
  close = self.safe_string(ticker, 'close')
961
- bid = self.safe_value(ticker, 'bid', [])
962
- ask = self.safe_value(ticker, 'ask', [])
1113
+ bid = self.safe_list(ticker, 'bid', [])
1114
+ ask = self.safe_list(ticker, 'ask', [])
963
1115
  open = self.safe_string(ticker, 'open')
964
1116
  return self.safe_ticker({
965
1117
  'symbol': symbol,
@@ -1019,8 +1171,10 @@ class ascendex(Exchange, ImplicitAPI):
1019
1171
  async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
1020
1172
  """
1021
1173
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1022
- :see: https://ascendex.github.io/ascendex-pro-api/#ticker
1023
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#ticker
1174
+
1175
+ https://ascendex.github.io/ascendex-pro-api/#ticker
1176
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#ticker
1177
+
1024
1178
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1025
1179
  :param dict [params]: extra parameters specific to the exchange API endpoint
1026
1180
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1029,7 +1183,7 @@ class ascendex(Exchange, ImplicitAPI):
1029
1183
  request: dict = {}
1030
1184
  market = None
1031
1185
  if symbols is not None:
1032
- symbol = self.safe_value(symbols, 0)
1186
+ symbol = self.safe_string(symbols, 0)
1033
1187
  market = self.market(symbol)
1034
1188
  marketIds = self.market_ids(symbols)
1035
1189
  request['symbol'] = ','.join(marketIds)
@@ -1043,22 +1197,20 @@ class ascendex(Exchange, ImplicitAPI):
1043
1197
  #
1044
1198
  # {
1045
1199
  # "code":0,
1046
- # "data":[
1047
- # {
1048
- # "symbol":"QTUM/BTC",
1049
- # "open":"0.00016537",
1050
- # "close":"0.00019077",
1051
- # "high":"0.000192",
1052
- # "low":"0.00016537",
1053
- # "volume":"846.6",
1054
- # "ask":["0.00018698","26.2"],
1055
- # "bid":["0.00018408","503.7"],
1056
- # "type":"spot"
1057
- # }
1058
- # ]
1200
+ # "data": {
1201
+ # "symbol":"QTUM/BTC",
1202
+ # "open":"0.00016537",
1203
+ # "close":"0.00019077",
1204
+ # "high":"0.000192",
1205
+ # "low":"0.00016537",
1206
+ # "volume":"846.6",
1207
+ # "ask":["0.00018698","26.2"],
1208
+ # "bid":["0.00018408","503.7"],
1209
+ # "type":"spot"
1210
+ # }
1059
1211
  # }
1060
1212
  #
1061
- data = self.safe_value(response, 'data', [])
1213
+ data = self.safe_list(response, 'data', [])
1062
1214
  if not isinstance(data, list):
1063
1215
  return self.parse_tickers([data], symbols)
1064
1216
  return self.parse_tickers(data, symbols)
@@ -1079,7 +1231,7 @@ class ascendex(Exchange, ImplicitAPI):
1079
1231
  # }
1080
1232
  # }
1081
1233
  #
1082
- data = self.safe_value(ohlcv, 'data', {})
1234
+ data = self.safe_dict(ohlcv, 'data', {})
1083
1235
  return [
1084
1236
  self.safe_integer(data, 'ts'),
1085
1237
  self.safe_number(data, 'o'),
@@ -1097,6 +1249,7 @@ class ascendex(Exchange, ImplicitAPI):
1097
1249
  :param int [since]: timestamp in ms of the earliest candle to fetch
1098
1250
  :param int [limit]: the maximum amount of candles to fetch
1099
1251
  :param dict [params]: extra parameters specific to the exchange API endpoint
1252
+ :param int [params.until]: timestamp in ms of the latest candle to fetch
1100
1253
  :returns int[][]: A list of candles ordered, open, high, low, close, volume
1101
1254
  """
1102
1255
  await self.load_markets()
@@ -1108,17 +1261,30 @@ class ascendex(Exchange, ImplicitAPI):
1108
1261
  # if since and limit are not specified
1109
1262
  # the exchange will return just 1 last candle by default
1110
1263
  duration = self.parse_timeframe(timeframe)
1111
- options = self.safe_value(self.options, 'fetchOHLCV', {})
1264
+ options = self.safe_dict(self.options, 'fetchOHLCV', {})
1112
1265
  defaultLimit = self.safe_integer(options, 'limit', 500)
1266
+ until = self.safe_integer(params, 'until')
1113
1267
  if since is not None:
1114
1268
  request['from'] = since
1115
1269
  if limit is None:
1116
1270
  limit = defaultLimit
1117
1271
  else:
1118
1272
  limit = min(limit, defaultLimit)
1119
- request['to'] = self.sum(since, limit * duration * 1000, 1)
1273
+ toWithLimit = self.sum(since, limit * duration * 1000, 1)
1274
+ if until is not None:
1275
+ request['to'] = min(toWithLimit, until + 1)
1276
+ else:
1277
+ request['to'] = toWithLimit
1278
+ elif until is not None:
1279
+ request['to'] = until + 1
1280
+ if limit is None:
1281
+ limit = defaultLimit
1282
+ else:
1283
+ limit = min(limit, defaultLimit)
1284
+ request['from'] = until - (limit * duration * 1000)
1120
1285
  elif limit is not None:
1121
1286
  request['n'] = limit # max 500
1287
+ params = self.omit(params, 'until')
1122
1288
  response = await self.v1PublicGetBarhist(self.extend(request, params))
1123
1289
  #
1124
1290
  # {
@@ -1180,7 +1346,9 @@ class ascendex(Exchange, ImplicitAPI):
1180
1346
  async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1181
1347
  """
1182
1348
  get the list of most recent trades for a particular symbol
1183
- :see: https://ascendex.github.io/ascendex-pro-api/#market-trades
1349
+
1350
+ https://ascendex.github.io/ascendex-pro-api/#market-trades
1351
+
1184
1352
  :param str symbol: unified symbol of the market to fetch trades for
1185
1353
  :param int [since]: timestamp in ms of the earliest trade to fetch
1186
1354
  :param int [limit]: the maximum amount of trades to fetch
@@ -1209,7 +1377,7 @@ class ascendex(Exchange, ImplicitAPI):
1209
1377
  # }
1210
1378
  # }
1211
1379
  #
1212
- records = self.safe_value(response, 'data', [])
1380
+ records = self.safe_dict(response, 'data', {})
1213
1381
  trades = self.safe_list(records, 'data', [])
1214
1382
  return self.parse_trades(trades, market, since, limit)
1215
1383
 
@@ -1236,6 +1404,8 @@ class ascendex(Exchange, ImplicitAPI):
1236
1404
  # "timestamp": 1573576916201
1237
1405
  # }
1238
1406
  #
1407
+ # & linear(fetchClosedOrders)
1408
+ #
1239
1409
  # {
1240
1410
  # "ac": "FUTURES",
1241
1411
  # "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
@@ -1243,7 +1413,7 @@ class ascendex(Exchange, ImplicitAPI):
1243
1413
  # "orderId": "a17e0874ecbdU0711043490bbtcpDU5X",
1244
1414
  # "seqNum": -1,
1245
1415
  # "orderType": "Limit",
1246
- # "execInst": "NULL_VAL",
1416
+ # "execInst": "NULL_VAL", # NULL_VAL, ReduceOnly , ...
1247
1417
  # "side": "Buy",
1248
1418
  # "symbol": "BTC-PERP",
1249
1419
  # "price": "30000",
@@ -1332,13 +1502,13 @@ class ascendex(Exchange, ImplicitAPI):
1332
1502
  status = self.parse_order_status(self.safe_string(order, 'status'))
1333
1503
  marketId = self.safe_string(order, 'symbol')
1334
1504
  symbol = self.safe_symbol(marketId, market, '/')
1335
- timestamp = self.safe_integer_2(order, 'timestamp', 'sendingTime')
1505
+ timestamp = self.safe_integer_n(order, ['timestamp', 'sendingTime', 'time'])
1336
1506
  lastTradeTimestamp = self.safe_integer(order, 'lastExecTime')
1337
1507
  if timestamp is None:
1338
1508
  timestamp = lastTradeTimestamp
1339
1509
  price = self.safe_string(order, 'price')
1340
1510
  amount = self.safe_string(order, 'orderQty')
1341
- average = self.safe_string(order, 'avgPx')
1511
+ average = self.safe_string_2(order, 'avgPx', 'avgFilledPx')
1342
1512
  filled = self.safe_string_n(order, ['cumFilledQty', 'cumQty', 'fillQty'])
1343
1513
  id = self.safe_string(order, 'orderId')
1344
1514
  clientOrderId = self.safe_string(order, 'id')
@@ -1362,13 +1532,13 @@ class ascendex(Exchange, ImplicitAPI):
1362
1532
  'cost': feeCost,
1363
1533
  'currency': feeCurrencyCode,
1364
1534
  }
1365
- stopPrice = self.omit_zero(self.safe_string(order, 'stopPrice'))
1535
+ triggerPrice = self.omit_zero(self.safe_string(order, 'stopPrice'))
1366
1536
  reduceOnly = None
1367
- execInst = self.safe_string(order, 'execInst')
1368
- if execInst == 'reduceOnly':
1537
+ execInst = self.safe_string_lower(order, 'execInst')
1538
+ if execInst == 'reduceonly':
1369
1539
  reduceOnly = True
1370
1540
  postOnly = None
1371
- if execInst == 'Post':
1541
+ if execInst == 'post':
1372
1542
  postOnly = True
1373
1543
  return self.safe_order({
1374
1544
  'info': order,
@@ -1384,8 +1554,7 @@ class ascendex(Exchange, ImplicitAPI):
1384
1554
  'reduceOnly': reduceOnly,
1385
1555
  'side': side,
1386
1556
  'price': price,
1387
- 'stopPrice': stopPrice,
1388
- 'triggerPrice': stopPrice,
1557
+ 'triggerPrice': triggerPrice,
1389
1558
  'amount': amount,
1390
1559
  'cost': None,
1391
1560
  'average': average,
@@ -1404,7 +1573,7 @@ class ascendex(Exchange, ImplicitAPI):
1404
1573
  """
1405
1574
  await self.load_markets()
1406
1575
  await self.load_accounts()
1407
- account = self.safe_value(self.accounts, 0, {})
1576
+ account = self.safe_dict(self.accounts, 0, {})
1408
1577
  accountGroup = self.safe_string(account, 'id')
1409
1578
  request: dict = {
1410
1579
  'account-group': accountGroup,
@@ -1426,14 +1595,14 @@ class ascendex(Exchange, ImplicitAPI):
1426
1595
  # }
1427
1596
  # }
1428
1597
  #
1429
- data = self.safe_value(response, 'data', {})
1430
- fees = self.safe_value(data, 'fees', [])
1598
+ data = self.safe_dict(response, 'data', {})
1599
+ fees = self.safe_list(data, 'fees', [])
1431
1600
  result: dict = {}
1432
1601
  for i in range(0, len(fees)):
1433
1602
  fee = fees[i]
1434
1603
  marketId = self.safe_string(fee, 'symbol')
1435
1604
  symbol = self.safe_symbol(marketId, None, '/')
1436
- takerMaker = self.safe_value(fee, 'fee', {})
1605
+ takerMaker = self.safe_dict(fee, 'fee', {})
1437
1606
  result[symbol] = {
1438
1607
  'info': fee,
1439
1608
  'symbol': symbol,
@@ -1446,17 +1615,17 @@ class ascendex(Exchange, ImplicitAPI):
1446
1615
 
1447
1616
  def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1448
1617
  """
1449
- * @ignore
1618
+ @ignore
1450
1619
  helper function to build request
1451
1620
  :param str symbol: unified symbol of the market to create an order in
1452
1621
  :param str type: 'market' or 'limit'
1453
1622
  :param str side: 'buy' or 'sell'
1454
1623
  :param float amount: how much you want to trade in units of the base currency
1455
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1624
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1456
1625
  :param dict [params]: extra parameters specific to the exchange API endpoint
1457
1626
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1458
1627
  :param bool [params.postOnly]: True or False
1459
- :param float [params.stopPrice]: the price at which a trigger order is triggered at
1628
+ :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1460
1629
  :returns dict: request to be sent to the exchange
1461
1630
  """
1462
1631
  market = self.market(symbol)
@@ -1464,12 +1633,12 @@ class ascendex(Exchange, ImplicitAPI):
1464
1633
  marketType = None
1465
1634
  marginMode, params = self.handle_margin_mode_and_params('createOrderRequest', params)
1466
1635
  marketType, params = self.handle_market_type_and_params('createOrderRequest', market, params)
1467
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
1636
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
1468
1637
  accountCategory = self.safe_string(accountsByType, marketType, 'cash')
1469
1638
  if marginMode is not None:
1470
1639
  accountCategory = 'margin'
1471
- account = self.safe_value(self.accounts, 0, {})
1472
- accountGroup = self.safe_value(account, 'id')
1640
+ account = self.safe_dict(self.accounts, 0, {})
1641
+ accountGroup = self.safe_string(account, 'id')
1473
1642
  clientOrderId = self.safe_string_2(params, 'clientOrderId', 'id')
1474
1643
  request: dict = {
1475
1644
  'account-group': accountGroup,
@@ -1487,7 +1656,7 @@ class ascendex(Exchange, ImplicitAPI):
1487
1656
  timeInForce = self.safe_string(params, 'timeInForce')
1488
1657
  postOnly = self.is_post_only(isMarketOrder, False, params)
1489
1658
  reduceOnly = self.safe_bool(params, 'reduceOnly', False)
1490
- stopPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
1659
+ triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
1491
1660
  if isLimitOrder:
1492
1661
  request['orderPrice'] = self.price_to_precision(symbol, price)
1493
1662
  if timeInForce == 'IOC':
@@ -1496,8 +1665,8 @@ class ascendex(Exchange, ImplicitAPI):
1496
1665
  request['timeInForce'] = 'FOK'
1497
1666
  if postOnly:
1498
1667
  request['postOnly'] = True
1499
- if stopPrice is not None:
1500
- request['stopPrice'] = self.price_to_precision(symbol, stopPrice)
1668
+ if triggerPrice is not None:
1669
+ request['stopPrice'] = self.price_to_precision(symbol, triggerPrice)
1501
1670
  if isLimitOrder:
1502
1671
  request['orderType'] = 'stop_limit'
1503
1672
  elif isMarketOrder:
@@ -1519,17 +1688,19 @@ class ascendex(Exchange, ImplicitAPI):
1519
1688
  async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1520
1689
  """
1521
1690
  create a trade order on the exchange
1522
- :see: https://ascendex.github.io/ascendex-pro-api/#place-order
1523
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#new-order
1691
+
1692
+ https://ascendex.github.io/ascendex-pro-api/#place-order
1693
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#new-order
1694
+
1524
1695
  :param str symbol: unified CCXT market symbol
1525
1696
  :param str type: "limit" or "market"
1526
1697
  :param str side: "buy" or "sell"
1527
1698
  :param float amount: the amount of currency to trade
1528
- :param float [price]: *ignored in "market" orders* the price at which the order is to be fullfilled at in units of the quote currency
1699
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1529
1700
  :param dict [params]: extra parameters specific to the exchange API endpoint
1530
1701
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1531
1702
  :param bool [params.postOnly]: True or False
1532
- :param float [params.stopPrice]: the price at which a trigger order is triggered at
1703
+ :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1533
1704
  :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice that the attached take profit order will be triggered(perpetual swap markets only)
1534
1705
  :param float [params.takeProfit.triggerPrice]: *swap only* take profit trigger price
1535
1706
  :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice that the attached stop loss order will be triggered(perpetual swap markets only)
@@ -1608,20 +1779,22 @@ class ascendex(Exchange, ImplicitAPI):
1608
1779
  # }
1609
1780
  # }
1610
1781
  #
1611
- data = self.safe_value(response, 'data', {})
1612
- order = self.safe_value_2(data, 'order', 'info', {})
1782
+ data = self.safe_dict(response, 'data', {})
1783
+ order = self.safe_dict_2(data, 'order', 'info', {})
1613
1784
  return self.parse_order(order, market)
1614
1785
 
1615
1786
  async def create_orders(self, orders: List[OrderRequest], params={}):
1616
1787
  """
1617
1788
  create a list of trade orders
1618
- :see: https://ascendex.github.io/ascendex-pro-api/#place-batch-orders
1619
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#place-batch-orders
1789
+
1790
+ https://ascendex.github.io/ascendex-pro-api/#place-batch-orders
1791
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#place-batch-orders
1792
+
1620
1793
  :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
1621
1794
  :param dict [params]: extra parameters specific to the exchange API endpoint
1622
1795
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1623
1796
  :param bool [params.postOnly]: True or False
1624
- :param float [params.stopPrice]: the price at which a trigger order is triggered at
1797
+ :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1625
1798
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1626
1799
  """
1627
1800
  await self.load_markets()
@@ -1639,9 +1812,9 @@ class ascendex(Exchange, ImplicitAPI):
1639
1812
  raise BadRequest(self.id + ' createOrders() requires all orders to have the same symbol')
1640
1813
  type = self.safe_string(rawOrder, 'type')
1641
1814
  side = self.safe_string(rawOrder, 'side')
1642
- amount = self.safe_value(rawOrder, 'amount')
1643
- price = self.safe_value(rawOrder, 'price')
1644
- orderParams = self.safe_value(rawOrder, 'params', {})
1815
+ amount = self.safe_number(rawOrder, 'amount')
1816
+ price = self.safe_number(rawOrder, 'price')
1817
+ orderParams = self.safe_dict(rawOrder, 'params', {})
1645
1818
  marginResult = self.handle_margin_mode_and_params('createOrders', orderParams)
1646
1819
  currentMarginMode = marginResult[0]
1647
1820
  if currentMarginMode is not None:
@@ -1653,12 +1826,12 @@ class ascendex(Exchange, ImplicitAPI):
1653
1826
  orderRequest = self.create_order_request(marketId, type, side, amount, price, orderParams)
1654
1827
  ordersRequests.append(orderRequest)
1655
1828
  market = self.market(symbol)
1656
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
1829
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
1657
1830
  accountCategory = self.safe_string(accountsByType, market['type'], 'cash')
1658
1831
  if marginMode is not None:
1659
1832
  accountCategory = 'margin'
1660
- account = self.safe_value(self.accounts, 0, {})
1661
- accountGroup = self.safe_value(account, 'id')
1833
+ account = self.safe_dict(self.accounts, 0, {})
1834
+ accountGroup = self.safe_string(account, 'id')
1662
1835
  request: dict = {}
1663
1836
  response = None
1664
1837
  if market['swap']:
@@ -1694,15 +1867,18 @@ class ascendex(Exchange, ImplicitAPI):
1694
1867
  # }
1695
1868
  # }
1696
1869
  #
1697
- data = self.safe_value(response, 'data', {})
1870
+ data = self.safe_dict(response, 'data', {})
1698
1871
  info = self.safe_list(data, 'info', [])
1699
1872
  return self.parse_orders(info, market)
1700
1873
 
1701
1874
  async def fetch_order(self, id: str, symbol: Str = None, params={}):
1702
1875
  """
1703
1876
  fetches information on an order made by the user
1704
- :see: https://ascendex.github.io/ascendex-pro-api/#query-order
1705
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#query-order-by-id
1877
+
1878
+ https://ascendex.github.io/ascendex-pro-api/#query-order
1879
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#query-order-by-id
1880
+
1881
+ :param str id: the order id
1706
1882
  :param str symbol: unified symbol of the market the order was made in
1707
1883
  :param dict [params]: extra parameters specific to the exchange API endpoint
1708
1884
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -1713,10 +1889,10 @@ class ascendex(Exchange, ImplicitAPI):
1713
1889
  if symbol is not None:
1714
1890
  market = self.market(symbol)
1715
1891
  type, query = self.handle_market_type_and_params('fetchOrder', market, params)
1716
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
1892
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
1717
1893
  accountCategory = self.safe_string(accountsByType, type, 'cash')
1718
- account = self.safe_value(self.accounts, 0, {})
1719
- accountGroup = self.safe_value(account, 'id')
1894
+ account = self.safe_dict(self.accounts, 0, {})
1895
+ accountGroup = self.safe_string(account, 'id')
1720
1896
  request: dict = {
1721
1897
  'account-group': accountGroup,
1722
1898
  'account-category': accountCategory,
@@ -1803,8 +1979,10 @@ class ascendex(Exchange, ImplicitAPI):
1803
1979
  async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1804
1980
  """
1805
1981
  fetch all unfilled currently open orders
1806
- :see: https://ascendex.github.io/ascendex-pro-api/#list-open-orders
1807
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-open-orders
1982
+
1983
+ https://ascendex.github.io/ascendex-pro-api/#list-open-orders
1984
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-open-orders
1985
+
1808
1986
  :param str symbol: unified market symbol
1809
1987
  :param int [since]: the earliest time in ms to fetch open orders for
1810
1988
  :param int [limit]: the maximum number of open orders structures to retrieve
@@ -1817,10 +1995,10 @@ class ascendex(Exchange, ImplicitAPI):
1817
1995
  if symbol is not None:
1818
1996
  market = self.market(symbol)
1819
1997
  symbol = market['symbol']
1820
- account = self.safe_value(self.accounts, 0, {})
1821
- accountGroup = self.safe_value(account, 'id')
1998
+ account = self.safe_dict(self.accounts, 0, {})
1999
+ accountGroup = self.safe_string(account, 'id')
1822
2000
  type, query = self.handle_market_type_and_params('fetchOpenOrders', market, params)
1823
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
2001
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
1824
2002
  accountCategory = self.safe_string(accountsByType, type, 'cash')
1825
2003
  request: dict = {
1826
2004
  'account-group': accountGroup,
@@ -1843,7 +2021,7 @@ class ascendex(Exchange, ImplicitAPI):
1843
2021
  # "code": 0,
1844
2022
  # "data": [
1845
2023
  # {
1846
- # "avgPx": "0", # Average filled price of the order
2024
+ # "avgPx": "0", # Average filled price of the order
1847
2025
  # "cumFee": "0", # cumulative fee paid for self order
1848
2026
  # "cumFilledQty": "0", # cumulative filled quantity
1849
2027
  # "errorCode": "", # error code; could be empty
@@ -1901,7 +2079,7 @@ class ascendex(Exchange, ImplicitAPI):
1901
2079
  # ]
1902
2080
  # }
1903
2081
  #
1904
- data = self.safe_value(response, 'data', [])
2082
+ data = self.safe_list(response, 'data', [])
1905
2083
  if accountCategory == 'futures':
1906
2084
  return self.parse_orders(data, market, since, limit)
1907
2085
  # a workaround for https://github.com/ccxt/ccxt/issues/7187
@@ -1914,8 +2092,10 @@ class ascendex(Exchange, ImplicitAPI):
1914
2092
  async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1915
2093
  """
1916
2094
  fetches information on multiple closed orders made by the user
1917
- :see: https://ascendex.github.io/ascendex-pro-api/#list-history-orders-v2
1918
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-current-history-orders
2095
+
2096
+ https://ascendex.github.io/ascendex-pro-api/#list-history-orders-v2
2097
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-current-history-orders
2098
+
1919
2099
  :param str symbol: unified market symbol of the market orders were made in
1920
2100
  :param int [since]: the earliest time in ms to fetch orders for
1921
2101
  :param int [limit]: the maximum number of order structures to retrieve
@@ -1925,8 +2105,8 @@ class ascendex(Exchange, ImplicitAPI):
1925
2105
  """
1926
2106
  await self.load_markets()
1927
2107
  await self.load_accounts()
1928
- account = self.safe_value(self.accounts, 0, {})
1929
- accountGroup = self.safe_value(account, 'id')
2108
+ account = self.safe_dict(self.accounts, 0, {})
2109
+ accountGroup = self.safe_string(account, 'id')
1930
2110
  request: dict = {
1931
2111
  # 'category': accountCategory,
1932
2112
  # 'symbol': market['id'],
@@ -1943,7 +2123,7 @@ class ascendex(Exchange, ImplicitAPI):
1943
2123
  market = self.market(symbol)
1944
2124
  request['symbol'] = market['id']
1945
2125
  type, query = self.handle_market_type_and_params('fetchClosedOrders', market, params)
1946
- options = self.safe_value(self.options, 'fetchClosedOrders', {})
2126
+ options = self.safe_dict(self.options, 'fetchClosedOrders', {})
1947
2127
  defaultMethod = self.safe_string(options, 'method', 'v2PrivateDataGetOrderHist')
1948
2128
  method = self.get_supported_mapping(type, {
1949
2129
  'spot': defaultMethod,
@@ -1955,7 +2135,7 @@ class ascendex(Exchange, ImplicitAPI):
1955
2135
  until = self.safe_string(params, 'until')
1956
2136
  if until is not None:
1957
2137
  request['endTime'] = until
1958
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
2138
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
1959
2139
  accountCategory = self.safe_string(accountsByType, type, 'cash') # margin, futures
1960
2140
  response = None
1961
2141
  if method == 'v1PrivateAccountCategoryGetOrderHistCurrent':
@@ -2068,17 +2248,18 @@ class ascendex(Exchange, ImplicitAPI):
2068
2248
  # ]
2069
2249
  # }
2070
2250
  #
2071
- data = self.safe_value(response, 'data')
2072
- isArray = isinstance(data, list)
2073
- if not isArray:
2074
- data = self.safe_value(data, 'data', [])
2251
+ data = self.safe_list(response, 'data', [])
2252
+ if not isinstance(data, list):
2253
+ data = self.safe_list(data, 'data', [])
2075
2254
  return self.parse_orders(data, market, since, limit)
2076
2255
 
2077
2256
  async def cancel_order(self, id: str, symbol: Str = None, params={}):
2078
2257
  """
2079
2258
  cancels an open order
2080
- :see: https://ascendex.github.io/ascendex-pro-api/#cancel-order
2081
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-order
2259
+
2260
+ https://ascendex.github.io/ascendex-pro-api/#cancel-order
2261
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-order
2262
+
2082
2263
  :param str id: order id
2083
2264
  :param str symbol: unified symbol of the market the order was made in
2084
2265
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2090,10 +2271,10 @@ class ascendex(Exchange, ImplicitAPI):
2090
2271
  await self.load_accounts()
2091
2272
  market = self.market(symbol)
2092
2273
  type, query = self.handle_market_type_and_params('cancelOrder', market, params)
2093
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
2274
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
2094
2275
  accountCategory = self.safe_string(accountsByType, type, 'cash')
2095
- account = self.safe_value(self.accounts, 0, {})
2096
- accountGroup = self.safe_value(account, 'id')
2276
+ account = self.safe_dict(self.accounts, 0, {})
2277
+ accountGroup = self.safe_string(account, 'id')
2097
2278
  request: dict = {
2098
2279
  'account-group': accountGroup,
2099
2280
  'account-category': accountCategory,
@@ -2178,18 +2359,20 @@ class ascendex(Exchange, ImplicitAPI):
2178
2359
  # }
2179
2360
  # }
2180
2361
  #
2181
- data = self.safe_value(response, 'data', {})
2182
- order = self.safe_value_2(data, 'order', 'info', {})
2362
+ data = self.safe_dict(response, 'data', {})
2363
+ order = self.safe_dict_2(data, 'order', 'info', {})
2183
2364
  return self.parse_order(order, market)
2184
2365
 
2185
2366
  async def cancel_all_orders(self, symbol: Str = None, params={}):
2186
2367
  """
2187
2368
  cancel all open orders
2188
- :see: https://ascendex.github.io/ascendex-pro-api/#cancel-all-orders
2189
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-all-open-orders
2369
+
2370
+ https://ascendex.github.io/ascendex-pro-api/#cancel-all-orders
2371
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-all-open-orders
2372
+
2190
2373
  :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
2191
2374
  :param dict [params]: extra parameters specific to the exchange API endpoint
2192
- :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
2375
+ :returns dict[]: a list with a single `order structure <https://docs.ccxt.com/#/?id=order-structure>` with the response assigned to the info property
2193
2376
  """
2194
2377
  await self.load_markets()
2195
2378
  await self.load_accounts()
@@ -2197,10 +2380,10 @@ class ascendex(Exchange, ImplicitAPI):
2197
2380
  if symbol is not None:
2198
2381
  market = self.market(symbol)
2199
2382
  type, query = self.handle_market_type_and_params('cancelAllOrders', market, params)
2200
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
2383
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
2201
2384
  accountCategory = self.safe_string(accountsByType, type, 'cash')
2202
- account = self.safe_value(self.accounts, 0, {})
2203
- accountGroup = self.safe_value(account, 'id')
2385
+ account = self.safe_dict(self.accounts, 0, {})
2386
+ accountGroup = self.safe_string(account, 'id')
2204
2387
  request: dict = {
2205
2388
  'account-group': accountGroup,
2206
2389
  'account-category': accountCategory,
@@ -2250,9 +2433,11 @@ class ascendex(Exchange, ImplicitAPI):
2250
2433
  # }
2251
2434
  # }
2252
2435
  #
2253
- return response
2436
+ return [self.safe_order({
2437
+ 'info': response,
2438
+ })]
2254
2439
 
2255
- def parse_deposit_address(self, depositAddress, currency: Currency = None):
2440
+ def parse_deposit_address(self, depositAddress, currency: Currency = None) -> DepositAddress:
2256
2441
  #
2257
2442
  # {
2258
2443
  # "address": "0xe7c70b4e73b6b450ee46c3b5c0f5fb127ca55722",
@@ -2274,21 +2459,19 @@ class ascendex(Exchange, ImplicitAPI):
2274
2459
  chainName = self.safe_string(depositAddress, 'blockchain')
2275
2460
  network = self.network_id_to_code(chainName, code)
2276
2461
  return {
2462
+ 'info': depositAddress,
2277
2463
  'currency': code,
2464
+ 'network': network,
2278
2465
  'address': address,
2279
2466
  'tag': tag,
2280
- 'network': network,
2281
- 'info': depositAddress,
2282
2467
  }
2283
2468
 
2284
- def safe_network(self, networkId):
2285
- networksById = self.safe_dict(self.options, 'networksById')
2286
- return self.safe_string(networksById, networkId, networkId)
2287
-
2288
- async def fetch_deposit_address(self, code: str, params={}):
2469
+ async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
2289
2470
  """
2290
2471
  fetch the deposit address for a currency associated with self account
2291
- :see: https://ascendex.github.io/ascendex-pro-api/#query-deposit-addresses
2472
+
2473
+ https://ascendex.github.io/ascendex-pro-api/#query-deposit-addresses
2474
+
2292
2475
  :param str code: unified currency code
2293
2476
  :param dict [params]: extra parameters specific to the exchange API endpoint
2294
2477
  :param str [params.network]: unified network code for deposit chain
@@ -2436,7 +2619,7 @@ class ascendex(Exchange, ImplicitAPI):
2436
2619
  # }
2437
2620
  # }
2438
2621
  #
2439
- data = self.safe_value(response, 'data', {})
2622
+ data = self.safe_dict(response, 'data', {})
2440
2623
  transactions = self.safe_list(data, 'data', [])
2441
2624
  return self.parse_transactions(transactions, currency, since, limit)
2442
2625
 
@@ -2468,7 +2651,7 @@ class ascendex(Exchange, ImplicitAPI):
2468
2651
  # }
2469
2652
  # }
2470
2653
  #
2471
- destAddress = self.safe_value(transaction, 'destAddress', {})
2654
+ destAddress = self.safe_dict(transaction, 'destAddress', {})
2472
2655
  address = self.safe_string(destAddress, 'address')
2473
2656
  tag = self.safe_string(destAddress, 'destTag')
2474
2657
  timestamp = self.safe_integer(transaction, 'time')
@@ -2504,7 +2687,7 @@ class ascendex(Exchange, ImplicitAPI):
2504
2687
  'internal': False,
2505
2688
  }
2506
2689
 
2507
- async def fetch_positions(self, symbols: Strings = None, params={}):
2690
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2508
2691
  """
2509
2692
  fetch all open positions
2510
2693
  :param str[]|None symbols: list of unified market symbols
@@ -2513,7 +2696,7 @@ class ascendex(Exchange, ImplicitAPI):
2513
2696
  """
2514
2697
  await self.load_markets()
2515
2698
  await self.load_accounts()
2516
- account = self.safe_value(self.accounts, 0, {})
2699
+ account = self.safe_dict(self.accounts, 0, {})
2517
2700
  accountGroup = self.safe_string(account, 'id')
2518
2701
  request: dict = {
2519
2702
  'account-group': accountGroup,
@@ -2558,8 +2741,8 @@ class ascendex(Exchange, ImplicitAPI):
2558
2741
  # }
2559
2742
  # }
2560
2743
  #
2561
- data = self.safe_value(response, 'data', {})
2562
- position = self.safe_value(data, 'contracts', [])
2744
+ data = self.safe_dict(response, 'data', {})
2745
+ position = self.safe_list(data, 'contracts', [])
2563
2746
  result = []
2564
2747
  for i in range(0, len(position)):
2565
2748
  result.append(self.parse_position(position[i]))
@@ -2629,7 +2812,7 @@ class ascendex(Exchange, ImplicitAPI):
2629
2812
  'takeProfitPrice': self.safe_number(position, 'takeProfitPrice'),
2630
2813
  })
2631
2814
 
2632
- def parse_funding_rate(self, contract, market: Market = None):
2815
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
2633
2816
  #
2634
2817
  # {
2635
2818
  # "time": 1640061364830,
@@ -2664,14 +2847,15 @@ class ascendex(Exchange, ImplicitAPI):
2664
2847
  'fundingRate': nextFundingRate,
2665
2848
  'fundingTimestamp': nextFundingRateTimestamp,
2666
2849
  'fundingDatetime': self.iso8601(nextFundingRateTimestamp),
2850
+ 'interval': None,
2667
2851
  }
2668
2852
 
2669
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
2853
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
2670
2854
  """
2671
2855
  fetch the funding rate for multiple markets
2672
2856
  :param str[]|None symbols: list of unified market symbols
2673
2857
  :param dict [params]: extra parameters specific to the exchange API endpoint
2674
- :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
2858
+ :returns dict[]: a list of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
2675
2859
  """
2676
2860
  await self.load_markets()
2677
2861
  symbols = self.market_symbols(symbols)
@@ -2700,16 +2884,15 @@ class ascendex(Exchange, ImplicitAPI):
2700
2884
  # }
2701
2885
  # }
2702
2886
  #
2703
- data = self.safe_value(response, 'data', {})
2704
- contracts = self.safe_value(data, 'contracts', [])
2705
- result = self.parse_funding_rates(contracts)
2706
- return self.filter_by_array(result, 'symbol', symbols)
2887
+ data = self.safe_dict(response, 'data', {})
2888
+ contracts = self.safe_list(data, 'contracts', [])
2889
+ return self.parse_funding_rates(contracts, symbols)
2707
2890
 
2708
2891
  async def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
2709
2892
  await self.load_markets()
2710
2893
  await self.load_accounts()
2711
2894
  market = self.market(symbol)
2712
- account = self.safe_value(self.accounts, 0, {})
2895
+ account = self.safe_dict(self.accounts, 0, {})
2713
2896
  accountGroup = self.safe_string(account, 'id')
2714
2897
  amount = self.amount_to_precision(symbol, amount)
2715
2898
  request: dict = {
@@ -2775,10 +2958,12 @@ class ascendex(Exchange, ImplicitAPI):
2775
2958
  """
2776
2959
  return await self.modify_margin_helper(symbol, amount, 'add', params)
2777
2960
 
2778
- async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
2961
+ async def set_leverage(self, leverage: int, symbol: Str = None, params={}):
2779
2962
  """
2780
2963
  set the level of leverage for a market
2781
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-contract-leverage
2964
+
2965
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-contract-leverage
2966
+
2782
2967
  :param float leverage: the rate of leverage
2783
2968
  :param str symbol: unified market symbol
2784
2969
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2793,7 +2978,7 @@ class ascendex(Exchange, ImplicitAPI):
2793
2978
  market = self.market(symbol)
2794
2979
  if not market['swap']:
2795
2980
  raise BadSymbol(self.id + ' setLeverage() supports swap contracts only')
2796
- account = self.safe_value(self.accounts, 0, {})
2981
+ account = self.safe_dict(self.accounts, 0, {})
2797
2982
  accountGroup = self.safe_string(account, 'id')
2798
2983
  request: dict = {
2799
2984
  'account-group': accountGroup,
@@ -2805,7 +2990,9 @@ class ascendex(Exchange, ImplicitAPI):
2805
2990
  async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
2806
2991
  """
2807
2992
  set margin mode to 'cross' or 'isolated'
2808
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-margin-type
2993
+
2994
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-margin-type
2995
+
2809
2996
  :param str marginMode: 'cross' or 'isolated'
2810
2997
  :param str symbol: unified market symbol
2811
2998
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2821,7 +3008,7 @@ class ascendex(Exchange, ImplicitAPI):
2821
3008
  await self.load_markets()
2822
3009
  await self.load_accounts()
2823
3010
  market = self.market(symbol)
2824
- account = self.safe_value(self.accounts, 0, {})
3011
+ account = self.safe_dict(self.accounts, 0, {})
2825
3012
  accountGroup = self.safe_string(account, 'id')
2826
3013
  request: dict = {
2827
3014
  'account-group': accountGroup,
@@ -2869,7 +3056,7 @@ class ascendex(Exchange, ImplicitAPI):
2869
3056
  # ]
2870
3057
  # }
2871
3058
  #
2872
- data = self.safe_value(response, 'data')
3059
+ data = self.safe_list(response, 'data', [])
2873
3060
  symbols = self.market_symbols(symbols)
2874
3061
  return self.parse_leverage_tiers(data, symbols, 'symbol')
2875
3062
 
@@ -2901,15 +3088,16 @@ class ascendex(Exchange, ImplicitAPI):
2901
3088
  # ]
2902
3089
  # }
2903
3090
  #
2904
- marginRequirements = self.safe_value(info, 'marginRequirements', [])
2905
- id = self.safe_string(info, 'symbol')
2906
- market = self.safe_market(id, market)
3091
+ marginRequirements = self.safe_list(info, 'marginRequirements', [])
3092
+ marketId = self.safe_string(info, 'symbol')
3093
+ market = self.safe_market(marketId, market)
2907
3094
  tiers = []
2908
3095
  for i in range(0, len(marginRequirements)):
2909
3096
  tier = marginRequirements[i]
2910
3097
  initialMarginRate = self.safe_string(tier, 'initialMarginRate')
2911
3098
  tiers.append({
2912
3099
  'tier': self.sum(i, 1),
3100
+ 'symbol': self.safe_symbol(marketId, market, None, 'contract'),
2913
3101
  'currency': market['quote'],
2914
3102
  'minNotional': self.safe_number(tier, 'positionNotionalLowerBound'),
2915
3103
  'maxNotional': self.safe_number(tier, 'positionNotionalUpperBound'),
@@ -2939,7 +3127,7 @@ class ascendex(Exchange, ImplicitAPI):
2939
3127
  # ]
2940
3128
  # }
2941
3129
  #
2942
- blockChains = self.safe_value(fee, 'blockChain', [])
3130
+ blockChains = self.safe_list(fee, 'blockChain', [])
2943
3131
  blockChainsLength = len(blockChains)
2944
3132
  result: dict = {
2945
3133
  'info': fee,
@@ -2970,7 +3158,9 @@ class ascendex(Exchange, ImplicitAPI):
2970
3158
  async def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
2971
3159
  """
2972
3160
  fetch deposit and withdraw fees
2973
- :see: https://ascendex.github.io/ascendex-pro-api/#list-all-assets
3161
+
3162
+ https://ascendex.github.io/ascendex-pro-api/#list-all-assets
3163
+
2974
3164
  :param str[]|None codes: list of unified currency codes
2975
3165
  :param dict [params]: extra parameters specific to the exchange API endpoint
2976
3166
  :returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -2992,10 +3182,10 @@ class ascendex(Exchange, ImplicitAPI):
2992
3182
  """
2993
3183
  await self.load_markets()
2994
3184
  await self.load_accounts()
2995
- account = self.safe_value(self.accounts, 0, {})
3185
+ account = self.safe_dict(self.accounts, 0, {})
2996
3186
  accountGroup = self.safe_string(account, 'id')
2997
3187
  currency = self.currency(code)
2998
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
3188
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
2999
3189
  fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
3000
3190
  toId = self.safe_string(accountsByType, toAccount, toAccount)
3001
3191
  if fromId != 'cash' and toId != 'cash':
@@ -3011,7 +3201,7 @@ class ascendex(Exchange, ImplicitAPI):
3011
3201
  #
3012
3202
  # {"code": "0"}
3013
3203
  #
3014
- transferOptions = self.safe_value(self.options, 'transfer', {})
3204
+ transferOptions = self.safe_dict(self.options, 'transfer', {})
3015
3205
  fillResponseFromRequest = self.safe_bool(transferOptions, 'fillResponseFromRequest', True)
3016
3206
  transfer = self.parse_transfer(response, currency)
3017
3207
  if fillResponseFromRequest:
@@ -3047,7 +3237,9 @@ class ascendex(Exchange, ImplicitAPI):
3047
3237
  async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3048
3238
  """
3049
3239
  fetch the history of funding payments paid and received on self account
3050
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#funding-payment-history
3240
+
3241
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#funding-payment-history
3242
+
3051
3243
  :param str [symbol]: unified market symbol
3052
3244
  :param int [since]: the earliest time in ms to fetch funding history for
3053
3245
  :param int [limit]: the maximum number of funding history structures to retrieve
@@ -3061,7 +3253,7 @@ class ascendex(Exchange, ImplicitAPI):
3061
3253
  paginate, params = self.handle_option_and_params(params, 'fetchFundingHistory', 'paginate')
3062
3254
  if paginate:
3063
3255
  return await self.fetch_paginated_call_incremental('fetchFundingHistory', symbol, since, limit, params, 'page', 25)
3064
- account = self.safe_value(self.accounts, 0, {})
3256
+ account = self.safe_dict(self.accounts, 0, {})
3065
3257
  accountGroup = self.safe_string(account, 'id')
3066
3258
  request: dict = {
3067
3259
  'account-group': accountGroup,
@@ -3091,7 +3283,7 @@ class ascendex(Exchange, ImplicitAPI):
3091
3283
  # }
3092
3284
  # }
3093
3285
  #
3094
- data = self.safe_value(response, 'data', {})
3286
+ data = self.safe_dict(response, 'data', {})
3095
3287
  rows = self.safe_list(data, 'data', [])
3096
3288
  return self.parse_incomes(rows, market, since, limit)
3097
3289
 
@@ -3119,14 +3311,16 @@ class ascendex(Exchange, ImplicitAPI):
3119
3311
  async def fetch_margin_modes(self, symbols: Strings = None, params={}) -> MarginModes:
3120
3312
  """
3121
3313
  fetches the set margin mode of the user
3122
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
3314
+
3315
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
3316
+
3123
3317
  :param str[] [symbols]: a list of unified market symbols
3124
3318
  :param dict [params]: extra parameters specific to the exchange API endpoint
3125
3319
  :returns dict: a list of `margin mode structures <https://docs.ccxt.com/#/?id=margin-mode-structure>`
3126
3320
  """
3127
3321
  await self.load_markets()
3128
3322
  await self.load_accounts()
3129
- account = self.safe_value(self.accounts, 0, {})
3323
+ account = self.safe_dict(self.accounts, 0, {})
3130
3324
  accountGroup = self.safe_string(account, 'id')
3131
3325
  request: dict = {
3132
3326
  'account-group': accountGroup,
@@ -3188,14 +3382,16 @@ class ascendex(Exchange, ImplicitAPI):
3188
3382
  async def fetch_leverages(self, symbols: Strings = None, params={}) -> Leverages:
3189
3383
  """
3190
3384
  fetch the set leverage for all contract markets
3191
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
3385
+
3386
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
3387
+
3192
3388
  :param str[] [symbols]: a list of unified market symbols
3193
3389
  :param dict [params]: extra parameters specific to the exchange API endpoint
3194
3390
  :returns dict: a list of `leverage structures <https://docs.ccxt.com/#/?id=leverage-structure>`
3195
3391
  """
3196
3392
  await self.load_markets()
3197
3393
  await self.load_accounts()
3198
- account = self.safe_value(self.accounts, 0, {})
3394
+ account = self.safe_dict(self.accounts, 0, {})
3199
3395
  accountGroup = self.safe_string(account, 'id')
3200
3396
  request: dict = {
3201
3397
  'account-group': accountGroup,