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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (529) hide show
  1. ccxt/__init__.py +39 -35
  2. ccxt/abantether.py +8 -8
  3. ccxt/abstract/alpaca.py +4 -0
  4. ccxt/abstract/apex.py +31 -0
  5. ccxt/abstract/bigone.py +1 -1
  6. ccxt/abstract/binance.py +106 -48
  7. ccxt/abstract/binancecoinm.py +106 -48
  8. ccxt/abstract/binanceus.py +141 -83
  9. ccxt/abstract/binanceusdm.py +106 -48
  10. ccxt/abstract/bingx.py +50 -1
  11. ccxt/abstract/bitbank.py +5 -0
  12. ccxt/abstract/bitfinex.py +136 -65
  13. ccxt/abstract/bitflyer.py +1 -0
  14. ccxt/abstract/bitget.py +67 -0
  15. ccxt/abstract/bitmart.py +19 -1
  16. ccxt/abstract/bitopro.py +1 -0
  17. ccxt/abstract/bitrue.py +68 -68
  18. ccxt/abstract/bitstamp.py +1 -0
  19. ccxt/abstract/blofin.py +30 -0
  20. ccxt/abstract/btcbox.py +2 -0
  21. ccxt/abstract/bybit.py +28 -13
  22. ccxt/abstract/cex.py +28 -29
  23. ccxt/abstract/coinbaseexchange.py +1 -0
  24. ccxt/abstract/coinbaseinternational.py +1 -1
  25. ccxt/abstract/cryptocom.py +16 -0
  26. ccxt/abstract/cryptomus.py +20 -0
  27. ccxt/abstract/defx.py +69 -0
  28. ccxt/abstract/deribit.py +1 -0
  29. ccxt/abstract/derive.py +117 -0
  30. ccxt/abstract/digifinex.py +1 -0
  31. ccxt/abstract/ellipx.py +25 -0
  32. ccxt/abstract/foxbit.py +26 -0
  33. ccxt/abstract/gate.py +19 -0
  34. ccxt/abstract/gateio.py +19 -0
  35. ccxt/abstract/gemini.py +1 -0
  36. ccxt/abstract/hibachi.py +26 -0
  37. ccxt/abstract/hyperliquid.py +1 -1
  38. ccxt/abstract/independentreserve.py +6 -0
  39. ccxt/abstract/kraken.py +1 -0
  40. ccxt/abstract/krakenfutures.py +4 -0
  41. ccxt/abstract/kucoin.py +10 -0
  42. ccxt/abstract/kucoinfutures.py +18 -0
  43. ccxt/abstract/lbank.py +2 -1
  44. ccxt/abstract/luno.py +1 -0
  45. ccxt/abstract/mexc.py +2 -0
  46. ccxt/abstract/modetrade.py +119 -0
  47. ccxt/abstract/myokx.py +349 -0
  48. ccxt/abstract/oceanex.py +5 -0
  49. ccxt/abstract/okx.py +25 -0
  50. ccxt/abstract/okxus.py +349 -0
  51. ccxt/abstract/onetrading.py +0 -12
  52. ccxt/abstract/paradex.py +23 -0
  53. ccxt/abstract/phemex.py +2 -0
  54. ccxt/abstract/poloniex.py +36 -0
  55. ccxt/abstract/tradeogre.py +3 -1
  56. ccxt/abstract/upbit.py +51 -34
  57. ccxt/abstract/whitebit.py +16 -0
  58. ccxt/abstract/woo.py +64 -6
  59. ccxt/abstract/xt.py +10 -5
  60. ccxt/afratether.py +7 -7
  61. ccxt/alpaca.py +828 -51
  62. ccxt/apex.py +1875 -0
  63. ccxt/arzinja.py +7 -7
  64. ccxt/arzplus.py +9 -9
  65. ccxt/ascendex.py +501 -306
  66. ccxt/async_support/__init__.py +39 -35
  67. ccxt/async_support/abantether.py +8 -8
  68. ccxt/async_support/afratether.py +9 -9
  69. ccxt/async_support/alpaca.py +828 -51
  70. ccxt/async_support/apex.py +1875 -0
  71. ccxt/async_support/arzinja.py +10 -10
  72. ccxt/async_support/arzplus.py +12 -12
  73. ccxt/async_support/ascendex.py +502 -306
  74. ccxt/async_support/base/exchange.py +303 -89
  75. ccxt/async_support/base/ws/cache.py +9 -3
  76. ccxt/async_support/base/ws/client.py +173 -38
  77. ccxt/async_support/base/ws/future.py +25 -37
  78. ccxt/async_support/bequant.py +5 -3
  79. ccxt/async_support/bigone.py +279 -144
  80. ccxt/async_support/binance.py +2347 -1158
  81. ccxt/async_support/binancecoinm.py +9 -3
  82. ccxt/async_support/binanceus.py +17 -3
  83. ccxt/async_support/binanceusdm.py +9 -4
  84. ccxt/async_support/bingx.py +2962 -920
  85. ccxt/async_support/bit2c.py +147 -27
  86. ccxt/async_support/bitbank.py +151 -23
  87. ccxt/async_support/bitbns.py +104 -30
  88. ccxt/async_support/bitfinex.py +3291 -1113
  89. ccxt/async_support/bitflyer.py +202 -27
  90. ccxt/async_support/bitget.py +3683 -1538
  91. ccxt/async_support/bithumb.py +195 -38
  92. ccxt/async_support/bitimen.py +12 -12
  93. ccxt/async_support/bitir.py +38 -38
  94. ccxt/async_support/bitmart.py +1288 -350
  95. ccxt/async_support/bitmex.py +260 -75
  96. ccxt/async_support/bitopro.py +262 -62
  97. ccxt/async_support/bitpin.py +17 -16
  98. ccxt/async_support/bitrue.py +459 -290
  99. ccxt/async_support/bitso.py +199 -54
  100. ccxt/async_support/bitstamp.py +230 -96
  101. ccxt/async_support/bitteam.py +167 -25
  102. ccxt/async_support/{huobijp.py → bittrade.py} +158 -30
  103. ccxt/async_support/bitvavo.py +213 -49
  104. ccxt/async_support/blockchaincom.py +160 -46
  105. ccxt/async_support/blofin.py +502 -120
  106. ccxt/async_support/btcalpha.py +169 -31
  107. ccxt/async_support/btcbox.py +292 -23
  108. ccxt/async_support/btcmarkets.py +211 -58
  109. ccxt/async_support/btcturk.py +161 -38
  110. ccxt/async_support/bybit.py +1775 -1030
  111. ccxt/async_support/cex.py +1440 -1303
  112. ccxt/async_support/coinbase.py +724 -212
  113. ccxt/async_support/coinbaseadvanced.py +2 -1
  114. ccxt/async_support/coinbaseexchange.py +388 -89
  115. ccxt/async_support/coinbaseinternational.py +412 -57
  116. ccxt/async_support/coincatch.py +177 -78
  117. ccxt/async_support/coincheck.py +135 -19
  118. ccxt/async_support/coinex.py +606 -232
  119. ccxt/async_support/coinmate.py +189 -63
  120. ccxt/async_support/coinmetro.py +195 -54
  121. ccxt/async_support/coinone.py +158 -51
  122. ccxt/async_support/coinsph.py +336 -61
  123. ccxt/async_support/coinspot.py +151 -52
  124. ccxt/async_support/cryptocom.py +661 -111
  125. ccxt/async_support/cryptomus.py +1137 -0
  126. ccxt/async_support/defx.py +2071 -0
  127. ccxt/async_support/delta.py +299 -99
  128. ccxt/async_support/deribit.py +348 -126
  129. ccxt/async_support/derive.py +2572 -0
  130. ccxt/async_support/digifinex.py +430 -214
  131. ccxt/async_support/ellipx.py +2029 -0
  132. ccxt/async_support/eterex.py +10 -10
  133. ccxt/async_support/excoino.py +31 -31
  134. ccxt/async_support/exir.py +14 -14
  135. ccxt/async_support/exmo.py +344 -131
  136. ccxt/async_support/exnovin.py +10 -10
  137. ccxt/async_support/farhadexchange.py +12 -12
  138. ccxt/async_support/fmfwio.py +2 -1
  139. ccxt/async_support/foxbit.py +1935 -0
  140. ccxt/async_support/gate.py +1351 -529
  141. ccxt/async_support/gateio.py +2 -1
  142. ccxt/async_support/gemini.py +144 -39
  143. ccxt/async_support/hashkey.py +152 -109
  144. ccxt/async_support/hibachi.py +2080 -0
  145. ccxt/async_support/hitbtc.py +395 -167
  146. ccxt/async_support/hitobit.py +12 -12
  147. ccxt/async_support/hollaex.py +307 -119
  148. ccxt/async_support/htx.py +851 -383
  149. ccxt/async_support/huobi.py +2 -1
  150. ccxt/async_support/hyperliquid.py +1848 -536
  151. ccxt/async_support/independentreserve.py +288 -15
  152. ccxt/async_support/indodax.py +190 -33
  153. ccxt/async_support/jibitex.py +12 -12
  154. ccxt/async_support/kraken.py +795 -351
  155. ccxt/async_support/krakenfutures.py +214 -62
  156. ccxt/async_support/kucoin.py +715 -396
  157. ccxt/async_support/kucoinfutures.py +652 -89
  158. ccxt/async_support/latoken.py +217 -113
  159. ccxt/async_support/lbank.py +425 -97
  160. ccxt/async_support/luno.py +382 -35
  161. ccxt/async_support/mercado.py +113 -6
  162. ccxt/async_support/mexc.py +874 -437
  163. ccxt/async_support/modetrade.py +2818 -0
  164. ccxt/async_support/myokx.py +54 -0
  165. ccxt/async_support/ndax.py +221 -64
  166. ccxt/async_support/nobitex.py +31 -37
  167. ccxt/async_support/novadax.py +190 -34
  168. ccxt/async_support/oceanex.py +217 -28
  169. ccxt/async_support/okcoin.py +253 -145
  170. ccxt/async_support/okexchange.py +11 -11
  171. ccxt/async_support/okx.py +1088 -351
  172. ccxt/async_support/okxus.py +54 -0
  173. ccxt/async_support/ompfinex.py +25 -24
  174. ccxt/async_support/onetrading.py +213 -392
  175. ccxt/async_support/oxfun.py +245 -166
  176. ccxt/async_support/p2b.py +151 -29
  177. ccxt/async_support/paradex.py +562 -49
  178. ccxt/async_support/paymium.py +82 -19
  179. ccxt/async_support/phemex.py +713 -172
  180. ccxt/async_support/poloniex.py +1602 -283
  181. ccxt/async_support/probit.py +224 -95
  182. ccxt/async_support/ramzinex.py +30 -27
  183. ccxt/async_support/sarmayex.py +9 -9
  184. ccxt/async_support/sarrafex.py +13 -13
  185. ccxt/async_support/tabdeal.py +14 -13
  186. ccxt/async_support/tetherland.py +9 -9
  187. ccxt/async_support/timex.py +210 -51
  188. ccxt/async_support/tokocrypto.py +167 -47
  189. ccxt/async_support/tradeogre.py +266 -31
  190. ccxt/async_support/twox.py +9 -9
  191. ccxt/async_support/ubitex.py +12 -12
  192. ccxt/async_support/upbit.py +568 -165
  193. ccxt/async_support/vertex.py +160 -32
  194. ccxt/async_support/wallex.py +12 -12
  195. ccxt/async_support/wavesexchange.py +165 -30
  196. ccxt/async_support/whitebit.py +975 -127
  197. ccxt/async_support/woo.py +1918 -1016
  198. ccxt/async_support/woofipro.py +433 -141
  199. ccxt/async_support/xt.py +649 -193
  200. ccxt/async_support/yobit.py +195 -70
  201. ccxt/async_support/zaif.py +91 -15
  202. ccxt/async_support/zonda.py +151 -36
  203. ccxt/base/decimal_to_precision.py +14 -10
  204. ccxt/base/errors.py +49 -18
  205. ccxt/base/exchange.py +1556 -450
  206. ccxt/base/precise.py +10 -0
  207. ccxt/base/types.py +114 -6
  208. ccxt/bequant.py +5 -3
  209. ccxt/bigone.py +279 -144
  210. ccxt/binance.py +2347 -1158
  211. ccxt/binancecoinm.py +9 -3
  212. ccxt/binanceus.py +17 -3
  213. ccxt/binanceusdm.py +9 -4
  214. ccxt/bingx.py +2962 -920
  215. ccxt/bit2c.py +147 -27
  216. ccxt/bitbank.py +151 -23
  217. ccxt/bitbns.py +104 -30
  218. ccxt/bitfinex.py +3290 -1113
  219. ccxt/bitflyer.py +202 -27
  220. ccxt/bitget.py +3683 -1538
  221. ccxt/bithumb.py +194 -38
  222. ccxt/bitimen.py +9 -9
  223. ccxt/bitir.py +35 -35
  224. ccxt/bitmart.py +1288 -350
  225. ccxt/bitmex.py +260 -75
  226. ccxt/bitopro.py +262 -62
  227. ccxt/bitpin.py +15 -14
  228. ccxt/bitrue.py +459 -290
  229. ccxt/bitso.py +199 -54
  230. ccxt/bitstamp.py +230 -96
  231. ccxt/bitteam.py +167 -25
  232. ccxt/{huobijp.py → bittrade.py} +158 -30
  233. ccxt/bitvavo.py +213 -49
  234. ccxt/blockchaincom.py +160 -46
  235. ccxt/blofin.py +502 -120
  236. ccxt/btcalpha.py +169 -31
  237. ccxt/btcbox.py +291 -23
  238. ccxt/btcmarkets.py +211 -58
  239. ccxt/btcturk.py +161 -38
  240. ccxt/bybit.py +1775 -1030
  241. ccxt/cex.py +1439 -1303
  242. ccxt/coinbase.py +724 -212
  243. ccxt/coinbaseadvanced.py +2 -1
  244. ccxt/coinbaseexchange.py +388 -89
  245. ccxt/coinbaseinternational.py +412 -57
  246. ccxt/coincatch.py +177 -78
  247. ccxt/coincheck.py +135 -19
  248. ccxt/coinex.py +606 -232
  249. ccxt/coinmate.py +189 -63
  250. ccxt/coinmetro.py +194 -54
  251. ccxt/coinone.py +158 -51
  252. ccxt/coinsph.py +336 -61
  253. ccxt/coinspot.py +151 -52
  254. ccxt/cryptocom.py +661 -111
  255. ccxt/cryptomus.py +1137 -0
  256. ccxt/defx.py +2070 -0
  257. ccxt/delta.py +299 -99
  258. ccxt/deribit.py +348 -126
  259. ccxt/derive.py +2571 -0
  260. ccxt/digifinex.py +430 -214
  261. ccxt/ellipx.py +2029 -0
  262. ccxt/eterex.py +7 -7
  263. ccxt/excoino.py +29 -29
  264. ccxt/exir.py +11 -11
  265. ccxt/exmo.py +343 -131
  266. ccxt/exnovin.py +8 -8
  267. ccxt/farhadexchange.py +10 -10
  268. ccxt/fmfwio.py +2 -1
  269. ccxt/foxbit.py +1935 -0
  270. ccxt/gate.py +1351 -529
  271. ccxt/gateio.py +2 -1
  272. ccxt/gemini.py +144 -39
  273. ccxt/hashkey.py +152 -109
  274. ccxt/hibachi.py +2079 -0
  275. ccxt/hitbtc.py +395 -167
  276. ccxt/hitobit.py +9 -9
  277. ccxt/hollaex.py +307 -119
  278. ccxt/htx.py +851 -383
  279. ccxt/huobi.py +2 -1
  280. ccxt/hyperliquid.py +1848 -536
  281. ccxt/independentreserve.py +287 -15
  282. ccxt/indodax.py +190 -33
  283. ccxt/jibitex.py +9 -9
  284. ccxt/kraken.py +794 -351
  285. ccxt/krakenfutures.py +214 -62
  286. ccxt/kucoin.py +715 -396
  287. ccxt/kucoinfutures.py +652 -89
  288. ccxt/latoken.py +217 -113
  289. ccxt/lbank.py +425 -97
  290. ccxt/luno.py +382 -35
  291. ccxt/mercado.py +113 -6
  292. ccxt/mexc.py +873 -437
  293. ccxt/modetrade.py +2818 -0
  294. ccxt/myokx.py +54 -0
  295. ccxt/ndax.py +221 -64
  296. ccxt/nobitex.py +29 -35
  297. ccxt/novadax.py +190 -34
  298. ccxt/oceanex.py +217 -28
  299. ccxt/okcoin.py +253 -145
  300. ccxt/okexchange.py +9 -9
  301. ccxt/okx.py +1088 -351
  302. ccxt/okxus.py +54 -0
  303. ccxt/ompfinex.py +22 -21
  304. ccxt/onetrading.py +213 -392
  305. ccxt/oxfun.py +245 -166
  306. ccxt/p2b.py +151 -29
  307. ccxt/paradex.py +562 -49
  308. ccxt/paymium.py +82 -19
  309. ccxt/phemex.py +712 -172
  310. ccxt/poloniex.py +1601 -283
  311. ccxt/pro/__init__.py +76 -17
  312. ccxt/pro/alpaca.py +21 -6
  313. ccxt/pro/apex.py +984 -0
  314. ccxt/pro/ascendex.py +58 -10
  315. ccxt/pro/bequant.py +6 -1
  316. ccxt/pro/binance.py +728 -156
  317. ccxt/pro/binancecoinm.py +6 -2
  318. ccxt/pro/binanceus.py +8 -4
  319. ccxt/pro/binanceusdm.py +7 -2
  320. ccxt/pro/bingx.py +333 -142
  321. ccxt/pro/bitfinex.py +727 -262
  322. ccxt/pro/bitget.py +570 -79
  323. ccxt/pro/bithumb.py +20 -6
  324. ccxt/pro/bitmart.py +216 -87
  325. ccxt/pro/bitmex.py +47 -9
  326. ccxt/pro/bitopro.py +26 -14
  327. ccxt/pro/bitrue.py +22 -22
  328. ccxt/pro/bitstamp.py +54 -21
  329. ccxt/pro/{huobijp.py → bittrade.py} +7 -6
  330. ccxt/pro/bitvavo.py +191 -67
  331. ccxt/pro/blockchaincom.py +21 -8
  332. ccxt/pro/blofin.py +9 -1
  333. ccxt/pro/bybit.py +632 -245
  334. ccxt/pro/cex.py +59 -24
  335. ccxt/pro/coinbase.py +102 -73
  336. ccxt/pro/coinbaseadvanced.py +2 -1
  337. ccxt/pro/coinbaseexchange.py +8 -8
  338. ccxt/pro/coinbaseinternational.py +181 -25
  339. ccxt/pro/coincatch.py +6 -7
  340. ccxt/pro/coincheck.py +11 -6
  341. ccxt/pro/coinex.py +967 -665
  342. ccxt/pro/coinone.py +16 -9
  343. ccxt/pro/cryptocom.py +448 -45
  344. ccxt/pro/defx.py +831 -0
  345. ccxt/pro/deribit.py +150 -14
  346. ccxt/pro/derive.py +704 -0
  347. ccxt/pro/exmo.py +239 -6
  348. ccxt/pro/gate.py +623 -65
  349. ccxt/pro/gateio.py +2 -1
  350. ccxt/pro/gemini.py +27 -11
  351. ccxt/pro/hashkey.py +2 -2
  352. ccxt/pro/hitbtc.py +196 -91
  353. ccxt/pro/hollaex.py +23 -7
  354. ccxt/pro/htx.py +51 -14
  355. ccxt/pro/huobi.py +2 -1
  356. ccxt/pro/hyperliquid.py +591 -27
  357. ccxt/pro/independentreserve.py +9 -6
  358. ccxt/pro/kraken.py +640 -320
  359. ccxt/pro/krakenfutures.py +62 -35
  360. ccxt/pro/kucoin.py +267 -46
  361. ccxt/pro/kucoinfutures.py +165 -21
  362. ccxt/pro/lbank.py +102 -21
  363. ccxt/pro/luno.py +12 -8
  364. ccxt/pro/mexc.py +877 -111
  365. ccxt/pro/modetrade.py +1271 -0
  366. ccxt/pro/myokx.py +38 -0
  367. ccxt/pro/ndax.py +15 -2
  368. ccxt/pro/okcoin.py +23 -4
  369. ccxt/pro/okx.py +573 -98
  370. ccxt/pro/okxus.py +38 -0
  371. ccxt/pro/onetrading.py +30 -13
  372. ccxt/pro/oxfun.py +131 -27
  373. ccxt/pro/p2b.py +88 -22
  374. ccxt/pro/paradex.py +3 -3
  375. ccxt/pro/phemex.py +75 -21
  376. ccxt/pro/poloniex.py +124 -41
  377. ccxt/pro/probit.py +87 -80
  378. ccxt/pro/tradeogre.py +272 -0
  379. ccxt/pro/upbit.py +152 -12
  380. ccxt/pro/vertex.py +8 -3
  381. ccxt/pro/whitebit.py +58 -5
  382. ccxt/pro/woo.py +228 -37
  383. ccxt/pro/woofipro.py +106 -18
  384. ccxt/pro/xt.py +111 -5
  385. ccxt/probit.py +224 -95
  386. ccxt/protobuf/__init__.py +0 -0
  387. ccxt/protobuf/mexc/PrivateAccountV3Api_pb2.py +37 -0
  388. ccxt/protobuf/mexc/PrivateDealsV3Api_pb2.py +37 -0
  389. ccxt/protobuf/mexc/PrivateOrdersV3Api_pb2.py +37 -0
  390. ccxt/protobuf/mexc/PublicAggreBookTickerV3Api_pb2.py +37 -0
  391. ccxt/protobuf/mexc/PublicAggreDealsV3Api_pb2.py +39 -0
  392. ccxt/protobuf/mexc/PublicAggreDepthsV3Api_pb2.py +39 -0
  393. ccxt/protobuf/mexc/PublicBookTickerBatchV3Api_pb2.py +38 -0
  394. ccxt/protobuf/mexc/PublicBookTickerV3Api_pb2.py +37 -0
  395. ccxt/protobuf/mexc/PublicDealsV3Api_pb2.py +39 -0
  396. ccxt/protobuf/mexc/PublicIncreaseDepthsBatchV3Api_pb2.py +38 -0
  397. ccxt/protobuf/mexc/PublicIncreaseDepthsV3Api_pb2.py +39 -0
  398. ccxt/protobuf/mexc/PublicLimitDepthsV3Api_pb2.py +39 -0
  399. ccxt/protobuf/mexc/PublicMiniTickerV3Api_pb2.py +37 -0
  400. ccxt/protobuf/mexc/PublicMiniTickersV3Api_pb2.py +38 -0
  401. ccxt/protobuf/mexc/PublicSpotKlineV3Api_pb2.py +37 -0
  402. ccxt/protobuf/mexc/PushDataV3ApiWrapper_pb2.py +52 -0
  403. ccxt/protobuf/mexc/__init__.py +0 -0
  404. ccxt/ramzinex.py +28 -25
  405. ccxt/sarmayex.py +7 -7
  406. ccxt/sarrafex.py +10 -10
  407. ccxt/static_dependencies/__init__.py +1 -1
  408. ccxt/static_dependencies/lark/py.typed +0 -0
  409. ccxt/static_dependencies/marshmallow/py.typed +0 -0
  410. ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
  411. ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
  412. ccxt/tabdeal.py +12 -11
  413. ccxt/test/tests_async.py +261 -57
  414. ccxt/test/tests_helpers.py +1 -3
  415. ccxt/test/tests_init.py +4 -3
  416. ccxt/test/tests_sync.py +261 -57
  417. ccxt/tetherland.py +7 -7
  418. ccxt/timex.py +210 -51
  419. ccxt/tokocrypto.py +167 -47
  420. ccxt/tradeogre.py +266 -31
  421. ccxt/twox.py +7 -7
  422. ccxt/ubitex.py +9 -9
  423. ccxt/upbit.py +568 -165
  424. ccxt/vertex.py +160 -32
  425. ccxt/wallex.py +9 -9
  426. ccxt/wavesexchange.py +165 -30
  427. ccxt/whitebit.py +975 -127
  428. ccxt/woo.py +1917 -1016
  429. ccxt/woofipro.py +432 -141
  430. ccxt/xt.py +649 -193
  431. ccxt/yobit.py +194 -70
  432. ccxt/zaif.py +91 -15
  433. ccxt/zonda.py +151 -36
  434. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info}/METADATA +225 -73
  435. ccxt_ir-4.5.0.dist-info/RECORD +743 -0
  436. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info}/WHEEL +1 -1
  437. ccxt/__test__.py +0 -7
  438. ccxt/abstract/ace.py +0 -15
  439. ccxt/abstract/bitbay.py +0 -53
  440. ccxt/abstract/bitcoincom.py +0 -115
  441. ccxt/abstract/bitfinex2.py +0 -139
  442. ccxt/abstract/bitpanda.py +0 -35
  443. ccxt/abstract/bl3p.py +0 -19
  444. ccxt/abstract/coinlist.py +0 -54
  445. ccxt/abstract/currencycom.py +0 -68
  446. ccxt/abstract/hitbtc3.py +0 -115
  447. ccxt/abstract/idex.py +0 -26
  448. ccxt/abstract/kuna.py +0 -182
  449. ccxt/abstract/lykke.py +0 -29
  450. ccxt/abstract/poloniexfutures.py +0 -48
  451. ccxt/abstract/wazirx.py +0 -30
  452. ccxt/ace.py +0 -1012
  453. ccxt/async_support/ace.py +0 -1012
  454. ccxt/async_support/base/ws/aiohttp_client.py +0 -125
  455. ccxt/async_support/base/ws/fast_client.py +0 -96
  456. ccxt/async_support/bitbay.py +0 -17
  457. ccxt/async_support/bitcoincom.py +0 -17
  458. ccxt/async_support/bitfinex2.py +0 -3552
  459. ccxt/async_support/bitpanda.py +0 -16
  460. ccxt/async_support/bl3p.py +0 -485
  461. ccxt/async_support/coinlist.py +0 -2243
  462. ccxt/async_support/currencycom.py +0 -1950
  463. ccxt/async_support/hitbtc3.py +0 -16
  464. ccxt/async_support/idex.py +0 -1766
  465. ccxt/async_support/kuna.py +0 -1841
  466. ccxt/async_support/lykke.py +0 -1270
  467. ccxt/async_support/poloniexfutures.py +0 -1717
  468. ccxt/async_support/wazirx.py +0 -1224
  469. ccxt/bitbay.py +0 -17
  470. ccxt/bitcoincom.py +0 -17
  471. ccxt/bitfinex2.py +0 -3552
  472. ccxt/bitpanda.py +0 -16
  473. ccxt/bl3p.py +0 -485
  474. ccxt/coinlist.py +0 -2243
  475. ccxt/currencycom.py +0 -1950
  476. ccxt/hitbtc3.py +0 -16
  477. ccxt/idex.py +0 -1766
  478. ccxt/kuna.py +0 -1841
  479. ccxt/lykke.py +0 -1270
  480. ccxt/poloniexfutures.py +0 -1717
  481. ccxt/pro/bitcoincom.py +0 -34
  482. ccxt/pro/bitfinex2.py +0 -1083
  483. ccxt/pro/bitpanda.py +0 -15
  484. ccxt/pro/currencycom.py +0 -536
  485. ccxt/pro/idex.py +0 -672
  486. ccxt/pro/poloniexfutures.py +0 -990
  487. ccxt/pro/wazirx.py +0 -749
  488. ccxt/test/base/__init__.py +0 -29
  489. ccxt/test/base/test_account.py +0 -26
  490. ccxt/test/base/test_balance.py +0 -56
  491. ccxt/test/base/test_borrow_interest.py +0 -35
  492. ccxt/test/base/test_borrow_rate.py +0 -32
  493. ccxt/test/base/test_calculate_fee.py +0 -51
  494. ccxt/test/base/test_crypto.py +0 -127
  495. ccxt/test/base/test_currency.py +0 -76
  496. ccxt/test/base/test_datetime.py +0 -109
  497. ccxt/test/base/test_decimal_to_precision.py +0 -392
  498. ccxt/test/base/test_deep_extend.py +0 -68
  499. ccxt/test/base/test_deposit_withdrawal.py +0 -50
  500. ccxt/test/base/test_exchange_datetime_functions.py +0 -76
  501. ccxt/test/base/test_funding_rate_history.py +0 -29
  502. ccxt/test/base/test_last_price.py +0 -31
  503. ccxt/test/base/test_ledger_entry.py +0 -45
  504. ccxt/test/base/test_ledger_item.py +0 -48
  505. ccxt/test/base/test_leverage_tier.py +0 -33
  506. ccxt/test/base/test_liquidation.py +0 -50
  507. ccxt/test/base/test_margin_mode.py +0 -24
  508. ccxt/test/base/test_margin_modification.py +0 -35
  509. ccxt/test/base/test_market.py +0 -193
  510. ccxt/test/base/test_number.py +0 -411
  511. ccxt/test/base/test_ohlcv.py +0 -33
  512. ccxt/test/base/test_open_interest.py +0 -32
  513. ccxt/test/base/test_order.py +0 -64
  514. ccxt/test/base/test_order_book.py +0 -69
  515. ccxt/test/base/test_position.py +0 -60
  516. ccxt/test/base/test_shared_methods.py +0 -353
  517. ccxt/test/base/test_status.py +0 -24
  518. ccxt/test/base/test_throttle.py +0 -126
  519. ccxt/test/base/test_ticker.py +0 -92
  520. ccxt/test/base/test_trade.py +0 -47
  521. ccxt/test/base/test_trading_fee.py +0 -26
  522. ccxt/test/base/test_transaction.py +0 -39
  523. ccxt/test/test_async.py +0 -1649
  524. ccxt/test/test_sync.py +0 -1648
  525. ccxt/wazirx.py +0 -1224
  526. ccxt_ir-4.3.46.0.3.dist-info/RECORD +0 -773
  527. /ccxt/abstract/{huobijp.py → bittrade.py} +0 -0
  528. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info/licenses}/LICENSE.txt +0 -0
  529. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info}/top_level.txt +0 -0
ccxt/ascendex.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.ascendex import ImplicitAPI
8
8
  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
9
+ 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
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -24,7 +24,7 @@ from ccxt.base.precise import Precise
24
24
 
25
25
  class ascendex(Exchange, ImplicitAPI):
26
26
 
27
- def describe(self):
27
+ def describe(self) -> Any:
28
28
  return self.deep_extend(super(ascendex, self).describe(), {
29
29
  'id': 'ascendex',
30
30
  'name': 'AscendEX',
@@ -67,6 +67,7 @@ class ascendex(Exchange, ImplicitAPI):
67
67
  'fetchFundingRate': 'emulated',
68
68
  'fetchFundingRateHistory': False,
69
69
  'fetchFundingRates': True,
70
+ 'fetchGreeks': False,
70
71
  'fetchIndexOHLCV': False,
71
72
  'fetchLeverage': 'emulated',
72
73
  'fetchLeverages': True,
@@ -76,10 +77,13 @@ class ascendex(Exchange, ImplicitAPI):
76
77
  'fetchMarketLeverageTiers': 'emulated',
77
78
  'fetchMarkets': True,
78
79
  'fetchMarkOHLCV': False,
80
+ 'fetchMySettlementHistory': False,
79
81
  'fetchOHLCV': True,
80
82
  'fetchOpenInterest': False,
81
83
  'fetchOpenInterestHistory': False,
82
84
  'fetchOpenOrders': True,
85
+ 'fetchOption': False,
86
+ 'fetchOptionChain': False,
83
87
  'fetchOrder': True,
84
88
  'fetchOrderBook': True,
85
89
  'fetchOrders': False,
@@ -88,6 +92,7 @@ class ascendex(Exchange, ImplicitAPI):
88
92
  'fetchPositions': True,
89
93
  'fetchPositionsRisk': False,
90
94
  'fetchPremiumIndexOHLCV': False,
95
+ 'fetchSettlementHistory': False,
91
96
  'fetchTicker': True,
92
97
  'fetchTickers': True,
93
98
  'fetchTime': True,
@@ -99,6 +104,7 @@ class ascendex(Exchange, ImplicitAPI):
99
104
  'fetchTransactions': 'emulated',
100
105
  'fetchTransfer': False,
101
106
  'fetchTransfers': False,
107
+ 'fetchVolatilityHistory': False,
102
108
  'fetchWithdrawal': False,
103
109
  'fetchWithdrawals': True,
104
110
  'reduceMargin': True,
@@ -124,7 +130,7 @@ class ascendex(Exchange, ImplicitAPI):
124
130
  },
125
131
  'version': 'v2',
126
132
  'urls': {
127
- 'logo': 'https://user-images.githubusercontent.com/1294454/112027508-47984600-8b48-11eb-9e17-d26459cc36c6.jpg',
133
+ 'logo': 'https://github.com/user-attachments/assets/55bab6b9-d4ca-42a8-a0e6-fac81ae557f1',
128
134
  'api': {
129
135
  'rest': 'https://ascendex.com',
130
136
  },
@@ -293,26 +299,114 @@ class ascendex(Exchange, ImplicitAPI):
293
299
  'SOL': 'Solana',
294
300
  'AVAX': 'avalanche C chain',
295
301
  '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',
302
+ # 'TRC': 'TRC20',
306
303
  'TRC20': 'TRC20',
307
304
  'ERC20': 'ERC20',
308
305
  'GO20': 'GO20',
309
306
  'BEP2': 'BEP2',
310
- 'Bitcoin': 'BTC',
311
- 'Bitcoin ABC': 'BCH',
312
- 'Litecoin': 'LTC',
313
- 'Matic Network': 'MATIC',
314
- 'xDai': 'STAKE',
315
- 'Akash': 'AKT',
307
+ 'BTC': 'Bitcoin',
308
+ 'BCH': 'Bitcoin ABC',
309
+ 'LTC': 'Litecoin',
310
+ 'MATIC': 'Matic Network',
311
+ 'AKT': 'Akash',
312
+ },
313
+ },
314
+ 'features': {
315
+ 'default': {
316
+ 'sandbox': True,
317
+ 'createOrder': {
318
+ 'marginMode': True,
319
+ 'triggerPrice': True,
320
+ 'triggerPriceType': None,
321
+ 'triggerDirection': False,
322
+ 'stopLossPrice': False, # todo with triggerprice
323
+ 'takeProfitPrice': False, # todo with triggerprice
324
+ 'attachedStopLossTakeProfit': None,
325
+ 'timeInForce': {
326
+ 'IOC': True,
327
+ 'FOK': True,
328
+ 'PO': True,
329
+ 'GTD': False,
330
+ },
331
+ 'hedged': False,
332
+ 'trailing': False,
333
+ 'leverage': False,
334
+ 'marketBuyRequiresPrice': False,
335
+ 'marketBuyByCost': False,
336
+ 'selfTradePrevention': False,
337
+ 'iceberg': False,
338
+ },
339
+ 'createOrders': {
340
+ 'max': 10,
341
+ },
342
+ 'fetchMyTrades': None,
343
+ 'fetchOrder': {
344
+ 'marginMode': False,
345
+ 'trigger': False,
346
+ 'trailing': False,
347
+ 'marketType': True,
348
+ 'symbolRequired': False,
349
+ },
350
+ 'fetchOpenOrders': {
351
+ 'marginMode': False,
352
+ 'limit': None,
353
+ 'trigger': False,
354
+ 'trailing': False,
355
+ 'marketType': True,
356
+ 'symbolRequired': False,
357
+ },
358
+ 'fetchOrders': None,
359
+ 'fetchClosedOrders': None,
360
+ 'fetchOHLCV': {
361
+ 'limit': 500,
362
+ },
363
+ },
364
+ 'spot': {
365
+ 'extends': 'default',
366
+ 'fetchClosedOrders': {
367
+ 'marginMode': False,
368
+ 'limit': 1000,
369
+ 'daysBack': 100000,
370
+ 'daysBackCanceled': 1,
371
+ 'untilDays': 100000,
372
+ 'trigger': False,
373
+ 'trailing': False,
374
+ 'symbolRequired': False,
375
+ },
376
+ },
377
+ 'forDerivatives': {
378
+ 'extends': 'default',
379
+ 'createOrder': {
380
+ # todo: implementation
381
+ 'attachedStopLossTakeProfit': {
382
+ 'triggerPriceType': {
383
+ 'last': True,
384
+ 'mark': False,
385
+ 'index': False,
386
+ },
387
+ 'price': False,
388
+ },
389
+ },
390
+ 'fetchClosedOrders': {
391
+ 'marginMode': False,
392
+ 'limit': 1000,
393
+ 'daysBack': None,
394
+ 'daysBackCanceled': None,
395
+ 'untilDays': None,
396
+ 'trigger': False,
397
+ 'trailing': False,
398
+ 'symbolRequired': False,
399
+ },
400
+ },
401
+ 'swap': {
402
+ 'linear': {
403
+ 'extends': 'forDerivatives',
404
+ },
405
+ 'inverse': None,
406
+ },
407
+ 'future': {
408
+ 'linear': None,
409
+ 'inverse': None,
316
410
  },
317
411
  },
318
412
  'exceptions': {
@@ -383,6 +477,7 @@ class ascendex(Exchange, ImplicitAPI):
383
477
  'broad': {},
384
478
  },
385
479
  'commonCurrencies': {
480
+ 'XBT': 'XBT', # self is not BTC ! just another token
386
481
  'BOND': 'BONDED',
387
482
  'BTCBEAR': 'BEAR',
388
483
  'BTCBULL': 'BULL',
@@ -403,94 +498,82 @@ class ascendex(Exchange, ImplicitAPI):
403
498
  :param dict [params]: extra parameters specific to the exchange API endpoint
404
499
  :returns dict: an associative dictionary of currencies
405
500
  """
406
- assets = 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 = 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 = self.v1PublicGetCashAssets(params)
501
+ response = self.v2PublicGetAssets(params)
444
502
  #
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
- # }
503
+ # {
504
+ # "code": "0",
505
+ # "data": [
506
+ # {
507
+ # "assetCode": "USDT",
508
+ # "assetName": "Tether",
509
+ # "precisionScale": 9,
510
+ # "nativeScale": 4,
511
+ # "blockChain": [
512
+ # {
513
+ # "chainName": "Solana",
514
+ # "withdrawFee": "2.0",
515
+ # "allowDeposit": True,
516
+ # "allowWithdraw": True,
517
+ # "minDepositAmt": "0.01",
518
+ # "minWithdrawal": "4.0",
519
+ # "numConfirmations": 1
520
+ # },
521
+ # ...
522
+ # ]
523
+ # },
457
524
  # ]
458
- # }
525
+ # }
459
526
  #
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())
527
+ data = self.safe_list(response, 'data', [])
468
528
  result: dict = {}
469
- for i in range(0, len(ids)):
470
- id = ids[i]
471
- currency = dataById[id]
529
+ for i in range(0, len(data)):
530
+ currency = data[i]
531
+ id = self.safe_string(currency, 'assetCode')
472
532
  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] = {
533
+ chains = self.safe_list(currency, 'blockChain', [])
534
+ precision = self.parse_number(self.parse_precision(self.safe_string(currency, 'nativeScale')))
535
+ networks = {}
536
+ for j in range(0, len(chains)):
537
+ networkEtnry = chains[j]
538
+ networkId = self.safe_string(networkEtnry, 'chainName')
539
+ networkCode = self.network_code_to_id(networkId)
540
+ networks[networkCode] = {
541
+ 'fee': self.safe_number(networkEtnry, 'withdrawFee'),
542
+ 'active': None,
543
+ 'withdraw': self.safe_bool(networkEtnry, 'allowWithdraw'),
544
+ 'deposit': self.safe_bool(networkEtnry, 'allowDeposit'),
545
+ 'precision': precision,
546
+ 'limits': {
547
+ 'amount': {
548
+ 'min': None,
549
+ 'max': None,
550
+ },
551
+ 'withdraw': {
552
+ 'min': self.safe_number(networkEtnry, 'minWithdrawal'),
553
+ 'max': None,
554
+ },
555
+ 'deposit': {
556
+ 'min': self.safe_number(networkEtnry, 'minDepositAmt'),
557
+ 'max': None,
558
+ },
559
+ },
560
+ }
561
+ # 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):
562
+ result[code] = self.safe_currency_structure({
480
563
  'id': id,
481
564
  'code': code,
482
565
  'info': currency,
483
566
  'type': None,
484
- 'margin': marginInside,
567
+ 'margin': None,
485
568
  'name': self.safe_string(currency, 'assetName'),
486
- 'active': active,
569
+ 'active': None,
487
570
  'deposit': None,
488
571
  'withdraw': None,
489
- 'fee': fee,
572
+ 'fee': None,
490
573
  'precision': precision,
491
574
  'limits': {
492
575
  'amount': {
493
- 'min': precision,
576
+ 'min': None,
494
577
  'max': None,
495
578
  },
496
579
  'withdraw': {
@@ -498,8 +581,8 @@ class ascendex(Exchange, ImplicitAPI):
498
581
  'max': None,
499
582
  },
500
583
  },
501
- 'networks': {},
502
- }
584
+ 'networks': networks,
585
+ })
503
586
  return result
504
587
 
505
588
  def fetch_markets(self, params={}) -> List[Market]:
@@ -508,7 +591,13 @@ class ascendex(Exchange, ImplicitAPI):
508
591
  :param dict [params]: extra parameters specific to the exchange API endpoint
509
592
  :returns dict[]: an array of objects representing market data
510
593
  """
511
- products = self.v1PublicGetProducts(params)
594
+ spotPromise = self.fetch_spot_markets(params)
595
+ contractPromise = self.fetch_contract_markets(params)
596
+ spotMarkets, contractMarkets = [spotPromise, contractPromise]
597
+ return self.array_concat(spotMarkets, contractMarkets)
598
+
599
+ def fetch_spot_markets(self, params={}) -> List[Market]:
600
+ productsPromise = self.v1PublicGetProducts(params)
512
601
  #
513
602
  # {
514
603
  # "code": 0,
@@ -529,7 +618,7 @@ class ascendex(Exchange, ImplicitAPI):
529
618
  # ]
530
619
  # }
531
620
  #
532
- cash = self.v1PublicGetCashProducts(params)
621
+ cashPromise = self.v1PublicGetCashProducts(params)
533
622
  #
534
623
  # {
535
624
  # "code": 0,
@@ -559,7 +648,91 @@ class ascendex(Exchange, ImplicitAPI):
559
648
  # ]
560
649
  # }
561
650
  #
562
- perpetuals = self.v2PublicGetFuturesContract(params)
651
+ products, cash = [productsPromise, cashPromise]
652
+ productsData = self.safe_list(products, 'data', [])
653
+ productsById = self.index_by(productsData, 'symbol')
654
+ cashData = self.safe_list(cash, 'data', [])
655
+ cashAndPerpetualsById = self.index_by(cashData, 'symbol')
656
+ dataById = self.deep_extend(productsById, cashAndPerpetualsById)
657
+ ids = list(dataById.keys())
658
+ result = []
659
+ for i in range(0, len(ids)):
660
+ id = ids[i]
661
+ if id.find('-PERP') >= 0:
662
+ continue # skip perpetuals, endpoint returns them
663
+ market = dataById[id]
664
+ status = self.safe_string(market, 'status')
665
+ domain = self.safe_string(market, 'domain')
666
+ active = False
667
+ if ((status == 'Normal') or (status == 'InternalTrading')) and (domain != 'LeveragedETF'):
668
+ active = True
669
+ minQty = self.safe_number(market, 'minQty')
670
+ maxQty = self.safe_number(market, 'maxQty')
671
+ minPrice = self.safe_number(market, 'tickSize')
672
+ maxPrice: Num = None
673
+ underlying = self.safe_string_2(market, 'underlying', 'symbol')
674
+ parts = underlying.split('/')
675
+ baseId = self.safe_string(parts, 0)
676
+ quoteId = self.safe_string(parts, 1)
677
+ base = self.safe_currency_code(baseId)
678
+ quote = self.safe_currency_code(quoteId)
679
+ fee = self.safe_number(market, 'commissionReserveRate')
680
+ marginTradable = self.safe_bool(market, 'marginTradable', False)
681
+ result.append({
682
+ 'id': id,
683
+ 'symbol': base + '/' + quote,
684
+ 'base': base,
685
+ 'baseId': baseId,
686
+ 'quote': quote,
687
+ 'quoteId': quoteId,
688
+ 'settle': None,
689
+ 'settleId': None,
690
+ 'type': 'spot',
691
+ 'spot': True,
692
+ 'margin': marginTradable,
693
+ 'swap': False,
694
+ 'future': False,
695
+ 'option': False,
696
+ 'active': active,
697
+ 'contract': False,
698
+ 'linear': None,
699
+ 'inverse': None,
700
+ 'taker': fee,
701
+ 'maker': fee,
702
+ 'contractSize': None,
703
+ 'expiry': None,
704
+ 'expiryDatetime': None,
705
+ 'strike': None,
706
+ 'optionType': None,
707
+ 'precision': {
708
+ 'amount': self.safe_number(market, 'lotSize'),
709
+ 'price': self.safe_number(market, 'tickSize'),
710
+ },
711
+ 'limits': {
712
+ 'leverage': {
713
+ 'min': None,
714
+ 'max': None,
715
+ },
716
+ 'amount': {
717
+ 'min': minQty,
718
+ 'max': maxQty,
719
+ },
720
+ 'price': {
721
+ 'min': minPrice,
722
+ 'max': maxPrice,
723
+ },
724
+ 'cost': {
725
+ 'min': self.safe_number(market, 'minNotional'),
726
+ 'max': self.safe_number(market, 'maxNotional'),
727
+ },
728
+ },
729
+ 'created': self.safe_integer(market, 'tradingStartTime'),
730
+ 'info': market,
731
+ })
732
+ return result
733
+
734
+ def fetch_contract_markets(self, params={}) -> List[Market]:
735
+ contracts = self.v2PublicGetFuturesContract(params)
563
736
  #
564
737
  # {
565
738
  # "code": 0,
@@ -572,9 +745,9 @@ class ascendex(Exchange, ImplicitAPI):
572
745
  # "underlying": "BTC/USDT",
573
746
  # "tradingStartTime": 1579701600000,
574
747
  # "priceFilter": {
575
- # "minPrice": "1",
748
+ # "minPrice": "0.1",
576
749
  # "maxPrice": "1000000",
577
- # "tickSize": "1"
750
+ # "tickSize": "0.1"
578
751
  # },
579
752
  # "lotSizeFilter": {
580
753
  # "minQty": "0.0001",
@@ -597,49 +770,25 @@ class ascendex(Exchange, ImplicitAPI):
597
770
  # ]
598
771
  # }
599
772
  #
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())
773
+ data = self.safe_list(contracts, 'data', [])
608
774
  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')
775
+ for i in range(0, len(data)):
776
+ market = data[i]
777
+ id = self.safe_string(market, 'symbol')
778
+ underlying = self.safe_string(market, 'underlying')
627
779
  parts = underlying.split('/')
628
780
  baseId = self.safe_string(parts, 0)
629
- quoteId = self.safe_string(parts, 1)
630
781
  base = self.safe_currency_code(baseId)
782
+ quoteId = self.safe_string(parts, 1)
631
783
  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
784
+ settleId = self.safe_string(market, 'settlementAsset')
785
+ settle = self.safe_currency_code(settleId)
786
+ linear = settle == quote
787
+ inverse = settle == base
788
+ symbol = base + '/' + quote + ':' + settle
789
+ priceFilter = self.safe_dict(market, 'priceFilter')
790
+ lotSizeFilter = self.safe_dict(market, 'lotSizeFilter')
641
791
  fee = self.safe_number(market, 'commissionReserveRate')
642
- marginTradable = self.safe_bool(market, 'marginTradable', False)
643
792
  result.append({
644
793
  'id': id,
645
794
  'symbol': symbol,
@@ -649,26 +798,26 @@ class ascendex(Exchange, ImplicitAPI):
649
798
  'baseId': baseId,
650
799
  'quoteId': quoteId,
651
800
  'settleId': settleId,
652
- 'type': 'swap' if swap else 'spot',
653
- 'spot': spot,
654
- 'margin': marginTradable if spot else None,
655
- 'swap': swap,
801
+ 'type': 'swap',
802
+ 'spot': False,
803
+ 'margin': None,
804
+ 'swap': True,
656
805
  'future': False,
657
806
  'option': False,
658
- 'active': active,
659
- 'contract': swap,
807
+ 'active': self.safe_string(market, 'status') == 'Normal',
808
+ 'contract': True,
660
809
  'linear': linear,
661
- 'inverse': not linear if swap else None,
810
+ 'inverse': inverse,
662
811
  'taker': fee,
663
812
  'maker': fee,
664
- 'contractSize': self.parse_number('1') if swap else None,
813
+ 'contractSize': self.parse_number('1'),
665
814
  'expiry': None,
666
815
  'expiryDatetime': None,
667
816
  'strike': None,
668
817
  'optionType': None,
669
818
  'precision': {
670
- 'amount': self.safe_number(market, 'lotSize'),
671
- 'price': self.safe_number(market, 'tickSize'),
819
+ 'amount': self.safe_number(lotSizeFilter, 'lotSize'),
820
+ 'price': self.safe_number(priceFilter, 'tickSize'),
672
821
  },
673
822
  'limits': {
674
823
  'leverage': {
@@ -676,12 +825,12 @@ class ascendex(Exchange, ImplicitAPI):
676
825
  'max': None,
677
826
  },
678
827
  'amount': {
679
- 'min': minQty,
680
- 'max': maxQty,
828
+ 'min': self.safe_number(lotSizeFilter, 'minQty'),
829
+ 'max': self.safe_number(lotSizeFilter, 'maxQty'),
681
830
  },
682
831
  'price': {
683
- 'min': minPrice,
684
- 'max': maxPrice,
832
+ 'min': self.safe_number(priceFilter, 'minPrice'),
833
+ 'max': self.safe_number(priceFilter, 'maxPrice'),
685
834
  },
686
835
  'cost': {
687
836
  'min': self.safe_number(market, 'minNotional'),
@@ -693,7 +842,7 @@ class ascendex(Exchange, ImplicitAPI):
693
842
  })
694
843
  return result
695
844
 
696
- def fetch_time(self, params={}):
845
+ def fetch_time(self, params={}) -> Int:
697
846
  """
698
847
  fetches the current integer timestamp in milliseconds from the ascendex server
699
848
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -713,7 +862,7 @@ class ascendex(Exchange, ImplicitAPI):
713
862
  # }
714
863
  # }
715
864
  #
716
- data = self.safe_value(response, 'data')
865
+ data = self.safe_dict(response, 'data', {})
717
866
  return self.safe_integer(data, 'requestReceiveAt')
718
867
 
719
868
  def fetch_accounts(self, params={}) -> List[Account]:
@@ -742,7 +891,7 @@ class ascendex(Exchange, ImplicitAPI):
742
891
  # }
743
892
  # }
744
893
  #
745
- data = self.safe_value(response, 'data', {})
894
+ data = self.safe_dict(response, 'data', {})
746
895
  accountGroup = self.safe_string(data, 'accountGroup')
747
896
  self.options['account-group'] = accountGroup
748
897
  return [
@@ -760,7 +909,7 @@ class ascendex(Exchange, ImplicitAPI):
760
909
  'timestamp': None,
761
910
  'datetime': None,
762
911
  }
763
- balances = self.safe_value(response, 'data', [])
912
+ balances = self.safe_list(response, 'data', [])
764
913
  for i in range(0, len(balances)):
765
914
  balance = balances[i]
766
915
  code = self.safe_currency_code(self.safe_string(balance, 'asset'))
@@ -776,7 +925,7 @@ class ascendex(Exchange, ImplicitAPI):
776
925
  'timestamp': None,
777
926
  'datetime': None,
778
927
  }
779
- balances = self.safe_value(response, 'data', [])
928
+ balances = self.safe_list(response, 'data', [])
780
929
  for i in range(0, len(balances)):
781
930
  balance = balances[i]
782
931
  code = self.safe_currency_code(self.safe_string(balance, 'asset'))
@@ -795,8 +944,8 @@ class ascendex(Exchange, ImplicitAPI):
795
944
  'timestamp': None,
796
945
  'datetime': None,
797
946
  }
798
- data = self.safe_value(response, 'data', {})
799
- collaterals = self.safe_value(data, 'collaterals', [])
947
+ data = self.safe_dict(response, 'data', {})
948
+ collaterals = self.safe_list(data, 'collaterals', [])
800
949
  for i in range(0, len(collaterals)):
801
950
  balance = collaterals[i]
802
951
  code = self.safe_currency_code(self.safe_string(balance, 'asset'))
@@ -808,9 +957,11 @@ class ascendex(Exchange, ImplicitAPI):
808
957
  def fetch_balance(self, params={}) -> Balances:
809
958
  """
810
959
  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
960
+
961
+ https://ascendex.github.io/ascendex-pro-api/#cash-account-balance
962
+ https://ascendex.github.io/ascendex-pro-api/#margin-account-balance
963
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
964
+
814
965
  :param dict [params]: extra parameters specific to the exchange API endpoint
815
966
  :param str [params.type]: wallet type, 'spot', 'margin', or 'swap'
816
967
  :param str [params.marginMode]: 'cross' or None, for spot margin trading, value of 'isolated' is invalid
@@ -826,9 +977,9 @@ class ascendex(Exchange, ImplicitAPI):
826
977
  isCross = marginMode == 'cross'
827
978
  marketType = 'margin' if (isMargin or isCross) else marketType
828
979
  params = self.omit(params, 'margin')
829
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
980
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
830
981
  accountCategory = self.safe_string(accountsByType, marketType, 'cash')
831
- account = self.safe_value(self.accounts, 0, {})
982
+ account = self.safe_dict(self.accounts, 0, {})
832
983
  accountGroup = self.safe_string(account, 'id')
833
984
  request: dict = {
834
985
  'account-group': accountGroup,
@@ -931,8 +1082,8 @@ class ascendex(Exchange, ImplicitAPI):
931
1082
  # }
932
1083
  # }
933
1084
  #
934
- data = self.safe_value(response, 'data', {})
935
- orderbook = self.safe_value(data, 'data', {})
1085
+ data = self.safe_dict(response, 'data', {})
1086
+ orderbook = self.safe_dict(data, 'data', {})
936
1087
  timestamp = self.safe_integer(orderbook, 'ts')
937
1088
  result = self.parse_order_book(orderbook, symbol, timestamp)
938
1089
  result['nonce'] = self.safe_integer(orderbook, 'seqnum')
@@ -958,8 +1109,8 @@ class ascendex(Exchange, ImplicitAPI):
958
1109
  delimiter = '/' if (type == 'spot') else None
959
1110
  symbol = self.safe_symbol(marketId, market, delimiter)
960
1111
  close = self.safe_string(ticker, 'close')
961
- bid = self.safe_value(ticker, 'bid', [])
962
- ask = self.safe_value(ticker, 'ask', [])
1112
+ bid = self.safe_list(ticker, 'bid', [])
1113
+ ask = self.safe_list(ticker, 'ask', [])
963
1114
  open = self.safe_string(ticker, 'open')
964
1115
  return self.safe_ticker({
965
1116
  'symbol': symbol,
@@ -1019,8 +1170,10 @@ class ascendex(Exchange, ImplicitAPI):
1019
1170
  def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
1020
1171
  """
1021
1172
  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
1173
+
1174
+ https://ascendex.github.io/ascendex-pro-api/#ticker
1175
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#ticker
1176
+
1024
1177
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1025
1178
  :param dict [params]: extra parameters specific to the exchange API endpoint
1026
1179
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1029,7 +1182,7 @@ class ascendex(Exchange, ImplicitAPI):
1029
1182
  request: dict = {}
1030
1183
  market = None
1031
1184
  if symbols is not None:
1032
- symbol = self.safe_value(symbols, 0)
1185
+ symbol = self.safe_string(symbols, 0)
1033
1186
  market = self.market(symbol)
1034
1187
  marketIds = self.market_ids(symbols)
1035
1188
  request['symbol'] = ','.join(marketIds)
@@ -1043,22 +1196,20 @@ class ascendex(Exchange, ImplicitAPI):
1043
1196
  #
1044
1197
  # {
1045
1198
  # "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
- # ]
1199
+ # "data": {
1200
+ # "symbol":"QTUM/BTC",
1201
+ # "open":"0.00016537",
1202
+ # "close":"0.00019077",
1203
+ # "high":"0.000192",
1204
+ # "low":"0.00016537",
1205
+ # "volume":"846.6",
1206
+ # "ask":["0.00018698","26.2"],
1207
+ # "bid":["0.00018408","503.7"],
1208
+ # "type":"spot"
1209
+ # }
1059
1210
  # }
1060
1211
  #
1061
- data = self.safe_value(response, 'data', [])
1212
+ data = self.safe_list(response, 'data', [])
1062
1213
  if not isinstance(data, list):
1063
1214
  return self.parse_tickers([data], symbols)
1064
1215
  return self.parse_tickers(data, symbols)
@@ -1079,7 +1230,7 @@ class ascendex(Exchange, ImplicitAPI):
1079
1230
  # }
1080
1231
  # }
1081
1232
  #
1082
- data = self.safe_value(ohlcv, 'data', {})
1233
+ data = self.safe_dict(ohlcv, 'data', {})
1083
1234
  return [
1084
1235
  self.safe_integer(data, 'ts'),
1085
1236
  self.safe_number(data, 'o'),
@@ -1097,6 +1248,7 @@ class ascendex(Exchange, ImplicitAPI):
1097
1248
  :param int [since]: timestamp in ms of the earliest candle to fetch
1098
1249
  :param int [limit]: the maximum amount of candles to fetch
1099
1250
  :param dict [params]: extra parameters specific to the exchange API endpoint
1251
+ :param int [params.until]: timestamp in ms of the latest candle to fetch
1100
1252
  :returns int[][]: A list of candles ordered, open, high, low, close, volume
1101
1253
  """
1102
1254
  self.load_markets()
@@ -1108,17 +1260,30 @@ class ascendex(Exchange, ImplicitAPI):
1108
1260
  # if since and limit are not specified
1109
1261
  # the exchange will return just 1 last candle by default
1110
1262
  duration = self.parse_timeframe(timeframe)
1111
- options = self.safe_value(self.options, 'fetchOHLCV', {})
1263
+ options = self.safe_dict(self.options, 'fetchOHLCV', {})
1112
1264
  defaultLimit = self.safe_integer(options, 'limit', 500)
1265
+ until = self.safe_integer(params, 'until')
1113
1266
  if since is not None:
1114
1267
  request['from'] = since
1115
1268
  if limit is None:
1116
1269
  limit = defaultLimit
1117
1270
  else:
1118
1271
  limit = min(limit, defaultLimit)
1119
- request['to'] = self.sum(since, limit * duration * 1000, 1)
1272
+ toWithLimit = self.sum(since, limit * duration * 1000, 1)
1273
+ if until is not None:
1274
+ request['to'] = min(toWithLimit, until + 1)
1275
+ else:
1276
+ request['to'] = toWithLimit
1277
+ elif until is not None:
1278
+ request['to'] = until + 1
1279
+ if limit is None:
1280
+ limit = defaultLimit
1281
+ else:
1282
+ limit = min(limit, defaultLimit)
1283
+ request['from'] = until - (limit * duration * 1000)
1120
1284
  elif limit is not None:
1121
1285
  request['n'] = limit # max 500
1286
+ params = self.omit(params, 'until')
1122
1287
  response = self.v1PublicGetBarhist(self.extend(request, params))
1123
1288
  #
1124
1289
  # {
@@ -1180,7 +1345,9 @@ class ascendex(Exchange, ImplicitAPI):
1180
1345
  def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1181
1346
  """
1182
1347
  get the list of most recent trades for a particular symbol
1183
- :see: https://ascendex.github.io/ascendex-pro-api/#market-trades
1348
+
1349
+ https://ascendex.github.io/ascendex-pro-api/#market-trades
1350
+
1184
1351
  :param str symbol: unified symbol of the market to fetch trades for
1185
1352
  :param int [since]: timestamp in ms of the earliest trade to fetch
1186
1353
  :param int [limit]: the maximum amount of trades to fetch
@@ -1209,7 +1376,7 @@ class ascendex(Exchange, ImplicitAPI):
1209
1376
  # }
1210
1377
  # }
1211
1378
  #
1212
- records = self.safe_value(response, 'data', [])
1379
+ records = self.safe_dict(response, 'data', {})
1213
1380
  trades = self.safe_list(records, 'data', [])
1214
1381
  return self.parse_trades(trades, market, since, limit)
1215
1382
 
@@ -1236,6 +1403,8 @@ class ascendex(Exchange, ImplicitAPI):
1236
1403
  # "timestamp": 1573576916201
1237
1404
  # }
1238
1405
  #
1406
+ # & linear(fetchClosedOrders)
1407
+ #
1239
1408
  # {
1240
1409
  # "ac": "FUTURES",
1241
1410
  # "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
@@ -1243,7 +1412,7 @@ class ascendex(Exchange, ImplicitAPI):
1243
1412
  # "orderId": "a17e0874ecbdU0711043490bbtcpDU5X",
1244
1413
  # "seqNum": -1,
1245
1414
  # "orderType": "Limit",
1246
- # "execInst": "NULL_VAL",
1415
+ # "execInst": "NULL_VAL", # NULL_VAL, ReduceOnly , ...
1247
1416
  # "side": "Buy",
1248
1417
  # "symbol": "BTC-PERP",
1249
1418
  # "price": "30000",
@@ -1332,13 +1501,13 @@ class ascendex(Exchange, ImplicitAPI):
1332
1501
  status = self.parse_order_status(self.safe_string(order, 'status'))
1333
1502
  marketId = self.safe_string(order, 'symbol')
1334
1503
  symbol = self.safe_symbol(marketId, market, '/')
1335
- timestamp = self.safe_integer_2(order, 'timestamp', 'sendingTime')
1504
+ timestamp = self.safe_integer_n(order, ['timestamp', 'sendingTime', 'time'])
1336
1505
  lastTradeTimestamp = self.safe_integer(order, 'lastExecTime')
1337
1506
  if timestamp is None:
1338
1507
  timestamp = lastTradeTimestamp
1339
1508
  price = self.safe_string(order, 'price')
1340
1509
  amount = self.safe_string(order, 'orderQty')
1341
- average = self.safe_string(order, 'avgPx')
1510
+ average = self.safe_string_2(order, 'avgPx', 'avgFilledPx')
1342
1511
  filled = self.safe_string_n(order, ['cumFilledQty', 'cumQty', 'fillQty'])
1343
1512
  id = self.safe_string(order, 'orderId')
1344
1513
  clientOrderId = self.safe_string(order, 'id')
@@ -1362,13 +1531,13 @@ class ascendex(Exchange, ImplicitAPI):
1362
1531
  'cost': feeCost,
1363
1532
  'currency': feeCurrencyCode,
1364
1533
  }
1365
- stopPrice = self.omit_zero(self.safe_string(order, 'stopPrice'))
1534
+ triggerPrice = self.omit_zero(self.safe_string(order, 'stopPrice'))
1366
1535
  reduceOnly = None
1367
- execInst = self.safe_string(order, 'execInst')
1368
- if execInst == 'reduceOnly':
1536
+ execInst = self.safe_string_lower(order, 'execInst')
1537
+ if execInst == 'reduceonly':
1369
1538
  reduceOnly = True
1370
1539
  postOnly = None
1371
- if execInst == 'Post':
1540
+ if execInst == 'post':
1372
1541
  postOnly = True
1373
1542
  return self.safe_order({
1374
1543
  'info': order,
@@ -1384,8 +1553,7 @@ class ascendex(Exchange, ImplicitAPI):
1384
1553
  'reduceOnly': reduceOnly,
1385
1554
  'side': side,
1386
1555
  'price': price,
1387
- 'stopPrice': stopPrice,
1388
- 'triggerPrice': stopPrice,
1556
+ 'triggerPrice': triggerPrice,
1389
1557
  'amount': amount,
1390
1558
  'cost': None,
1391
1559
  'average': average,
@@ -1404,7 +1572,7 @@ class ascendex(Exchange, ImplicitAPI):
1404
1572
  """
1405
1573
  self.load_markets()
1406
1574
  self.load_accounts()
1407
- account = self.safe_value(self.accounts, 0, {})
1575
+ account = self.safe_dict(self.accounts, 0, {})
1408
1576
  accountGroup = self.safe_string(account, 'id')
1409
1577
  request: dict = {
1410
1578
  'account-group': accountGroup,
@@ -1426,14 +1594,14 @@ class ascendex(Exchange, ImplicitAPI):
1426
1594
  # }
1427
1595
  # }
1428
1596
  #
1429
- data = self.safe_value(response, 'data', {})
1430
- fees = self.safe_value(data, 'fees', [])
1597
+ data = self.safe_dict(response, 'data', {})
1598
+ fees = self.safe_list(data, 'fees', [])
1431
1599
  result: dict = {}
1432
1600
  for i in range(0, len(fees)):
1433
1601
  fee = fees[i]
1434
1602
  marketId = self.safe_string(fee, 'symbol')
1435
1603
  symbol = self.safe_symbol(marketId, None, '/')
1436
- takerMaker = self.safe_value(fee, 'fee', {})
1604
+ takerMaker = self.safe_dict(fee, 'fee', {})
1437
1605
  result[symbol] = {
1438
1606
  'info': fee,
1439
1607
  'symbol': symbol,
@@ -1446,17 +1614,17 @@ class ascendex(Exchange, ImplicitAPI):
1446
1614
 
1447
1615
  def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1448
1616
  """
1449
- * @ignore
1617
+ @ignore
1450
1618
  helper function to build request
1451
1619
  :param str symbol: unified symbol of the market to create an order in
1452
1620
  :param str type: 'market' or 'limit'
1453
1621
  :param str side: 'buy' or 'sell'
1454
1622
  :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
1623
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1456
1624
  :param dict [params]: extra parameters specific to the exchange API endpoint
1457
1625
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1458
1626
  :param bool [params.postOnly]: True or False
1459
- :param float [params.stopPrice]: the price at which a trigger order is triggered at
1627
+ :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1460
1628
  :returns dict: request to be sent to the exchange
1461
1629
  """
1462
1630
  market = self.market(symbol)
@@ -1464,12 +1632,12 @@ class ascendex(Exchange, ImplicitAPI):
1464
1632
  marketType = None
1465
1633
  marginMode, params = self.handle_margin_mode_and_params('createOrderRequest', params)
1466
1634
  marketType, params = self.handle_market_type_and_params('createOrderRequest', market, params)
1467
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
1635
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
1468
1636
  accountCategory = self.safe_string(accountsByType, marketType, 'cash')
1469
1637
  if marginMode is not None:
1470
1638
  accountCategory = 'margin'
1471
- account = self.safe_value(self.accounts, 0, {})
1472
- accountGroup = self.safe_value(account, 'id')
1639
+ account = self.safe_dict(self.accounts, 0, {})
1640
+ accountGroup = self.safe_string(account, 'id')
1473
1641
  clientOrderId = self.safe_string_2(params, 'clientOrderId', 'id')
1474
1642
  request: dict = {
1475
1643
  'account-group': accountGroup,
@@ -1487,7 +1655,7 @@ class ascendex(Exchange, ImplicitAPI):
1487
1655
  timeInForce = self.safe_string(params, 'timeInForce')
1488
1656
  postOnly = self.is_post_only(isMarketOrder, False, params)
1489
1657
  reduceOnly = self.safe_bool(params, 'reduceOnly', False)
1490
- stopPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
1658
+ triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
1491
1659
  if isLimitOrder:
1492
1660
  request['orderPrice'] = self.price_to_precision(symbol, price)
1493
1661
  if timeInForce == 'IOC':
@@ -1496,8 +1664,8 @@ class ascendex(Exchange, ImplicitAPI):
1496
1664
  request['timeInForce'] = 'FOK'
1497
1665
  if postOnly:
1498
1666
  request['postOnly'] = True
1499
- if stopPrice is not None:
1500
- request['stopPrice'] = self.price_to_precision(symbol, stopPrice)
1667
+ if triggerPrice is not None:
1668
+ request['stopPrice'] = self.price_to_precision(symbol, triggerPrice)
1501
1669
  if isLimitOrder:
1502
1670
  request['orderType'] = 'stop_limit'
1503
1671
  elif isMarketOrder:
@@ -1519,17 +1687,19 @@ class ascendex(Exchange, ImplicitAPI):
1519
1687
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1520
1688
  """
1521
1689
  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
1690
+
1691
+ https://ascendex.github.io/ascendex-pro-api/#place-order
1692
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#new-order
1693
+
1524
1694
  :param str symbol: unified CCXT market symbol
1525
1695
  :param str type: "limit" or "market"
1526
1696
  :param str side: "buy" or "sell"
1527
1697
  :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
1698
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1529
1699
  :param dict [params]: extra parameters specific to the exchange API endpoint
1530
1700
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1531
1701
  :param bool [params.postOnly]: True or False
1532
- :param float [params.stopPrice]: the price at which a trigger order is triggered at
1702
+ :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1533
1703
  :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
1704
  :param float [params.takeProfit.triggerPrice]: *swap only* take profit trigger price
1535
1705
  :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 +1778,22 @@ class ascendex(Exchange, ImplicitAPI):
1608
1778
  # }
1609
1779
  # }
1610
1780
  #
1611
- data = self.safe_value(response, 'data', {})
1612
- order = self.safe_value_2(data, 'order', 'info', {})
1781
+ data = self.safe_dict(response, 'data', {})
1782
+ order = self.safe_dict_2(data, 'order', 'info', {})
1613
1783
  return self.parse_order(order, market)
1614
1784
 
1615
1785
  def create_orders(self, orders: List[OrderRequest], params={}):
1616
1786
  """
1617
1787
  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
1788
+
1789
+ https://ascendex.github.io/ascendex-pro-api/#place-batch-orders
1790
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#place-batch-orders
1791
+
1620
1792
  :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
1793
  :param dict [params]: extra parameters specific to the exchange API endpoint
1622
1794
  :param str [params.timeInForce]: "GTC", "IOC", "FOK", or "PO"
1623
1795
  :param bool [params.postOnly]: True or False
1624
- :param float [params.stopPrice]: the price at which a trigger order is triggered at
1796
+ :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1625
1797
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1626
1798
  """
1627
1799
  self.load_markets()
@@ -1639,9 +1811,9 @@ class ascendex(Exchange, ImplicitAPI):
1639
1811
  raise BadRequest(self.id + ' createOrders() requires all orders to have the same symbol')
1640
1812
  type = self.safe_string(rawOrder, 'type')
1641
1813
  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', {})
1814
+ amount = self.safe_number(rawOrder, 'amount')
1815
+ price = self.safe_number(rawOrder, 'price')
1816
+ orderParams = self.safe_dict(rawOrder, 'params', {})
1645
1817
  marginResult = self.handle_margin_mode_and_params('createOrders', orderParams)
1646
1818
  currentMarginMode = marginResult[0]
1647
1819
  if currentMarginMode is not None:
@@ -1653,12 +1825,12 @@ class ascendex(Exchange, ImplicitAPI):
1653
1825
  orderRequest = self.create_order_request(marketId, type, side, amount, price, orderParams)
1654
1826
  ordersRequests.append(orderRequest)
1655
1827
  market = self.market(symbol)
1656
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
1828
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
1657
1829
  accountCategory = self.safe_string(accountsByType, market['type'], 'cash')
1658
1830
  if marginMode is not None:
1659
1831
  accountCategory = 'margin'
1660
- account = self.safe_value(self.accounts, 0, {})
1661
- accountGroup = self.safe_value(account, 'id')
1832
+ account = self.safe_dict(self.accounts, 0, {})
1833
+ accountGroup = self.safe_string(account, 'id')
1662
1834
  request: dict = {}
1663
1835
  response = None
1664
1836
  if market['swap']:
@@ -1694,15 +1866,18 @@ class ascendex(Exchange, ImplicitAPI):
1694
1866
  # }
1695
1867
  # }
1696
1868
  #
1697
- data = self.safe_value(response, 'data', {})
1869
+ data = self.safe_dict(response, 'data', {})
1698
1870
  info = self.safe_list(data, 'info', [])
1699
1871
  return self.parse_orders(info, market)
1700
1872
 
1701
1873
  def fetch_order(self, id: str, symbol: Str = None, params={}):
1702
1874
  """
1703
1875
  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
1876
+
1877
+ https://ascendex.github.io/ascendex-pro-api/#query-order
1878
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#query-order-by-id
1879
+
1880
+ :param str id: the order id
1706
1881
  :param str symbol: unified symbol of the market the order was made in
1707
1882
  :param dict [params]: extra parameters specific to the exchange API endpoint
1708
1883
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -1713,10 +1888,10 @@ class ascendex(Exchange, ImplicitAPI):
1713
1888
  if symbol is not None:
1714
1889
  market = self.market(symbol)
1715
1890
  type, query = self.handle_market_type_and_params('fetchOrder', market, params)
1716
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
1891
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
1717
1892
  accountCategory = self.safe_string(accountsByType, type, 'cash')
1718
- account = self.safe_value(self.accounts, 0, {})
1719
- accountGroup = self.safe_value(account, 'id')
1893
+ account = self.safe_dict(self.accounts, 0, {})
1894
+ accountGroup = self.safe_string(account, 'id')
1720
1895
  request: dict = {
1721
1896
  'account-group': accountGroup,
1722
1897
  'account-category': accountCategory,
@@ -1803,8 +1978,10 @@ class ascendex(Exchange, ImplicitAPI):
1803
1978
  def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1804
1979
  """
1805
1980
  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
1981
+
1982
+ https://ascendex.github.io/ascendex-pro-api/#list-open-orders
1983
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-open-orders
1984
+
1808
1985
  :param str symbol: unified market symbol
1809
1986
  :param int [since]: the earliest time in ms to fetch open orders for
1810
1987
  :param int [limit]: the maximum number of open orders structures to retrieve
@@ -1817,10 +1994,10 @@ class ascendex(Exchange, ImplicitAPI):
1817
1994
  if symbol is not None:
1818
1995
  market = self.market(symbol)
1819
1996
  symbol = market['symbol']
1820
- account = self.safe_value(self.accounts, 0, {})
1821
- accountGroup = self.safe_value(account, 'id')
1997
+ account = self.safe_dict(self.accounts, 0, {})
1998
+ accountGroup = self.safe_string(account, 'id')
1822
1999
  type, query = self.handle_market_type_and_params('fetchOpenOrders', market, params)
1823
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
2000
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
1824
2001
  accountCategory = self.safe_string(accountsByType, type, 'cash')
1825
2002
  request: dict = {
1826
2003
  'account-group': accountGroup,
@@ -1843,7 +2020,7 @@ class ascendex(Exchange, ImplicitAPI):
1843
2020
  # "code": 0,
1844
2021
  # "data": [
1845
2022
  # {
1846
- # "avgPx": "0", # Average filled price of the order
2023
+ # "avgPx": "0", # Average filled price of the order
1847
2024
  # "cumFee": "0", # cumulative fee paid for self order
1848
2025
  # "cumFilledQty": "0", # cumulative filled quantity
1849
2026
  # "errorCode": "", # error code; could be empty
@@ -1901,7 +2078,7 @@ class ascendex(Exchange, ImplicitAPI):
1901
2078
  # ]
1902
2079
  # }
1903
2080
  #
1904
- data = self.safe_value(response, 'data', [])
2081
+ data = self.safe_list(response, 'data', [])
1905
2082
  if accountCategory == 'futures':
1906
2083
  return self.parse_orders(data, market, since, limit)
1907
2084
  # a workaround for https://github.com/ccxt/ccxt/issues/7187
@@ -1914,8 +2091,10 @@ class ascendex(Exchange, ImplicitAPI):
1914
2091
  def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1915
2092
  """
1916
2093
  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
2094
+
2095
+ https://ascendex.github.io/ascendex-pro-api/#list-history-orders-v2
2096
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-current-history-orders
2097
+
1919
2098
  :param str symbol: unified market symbol of the market orders were made in
1920
2099
  :param int [since]: the earliest time in ms to fetch orders for
1921
2100
  :param int [limit]: the maximum number of order structures to retrieve
@@ -1925,8 +2104,8 @@ class ascendex(Exchange, ImplicitAPI):
1925
2104
  """
1926
2105
  self.load_markets()
1927
2106
  self.load_accounts()
1928
- account = self.safe_value(self.accounts, 0, {})
1929
- accountGroup = self.safe_value(account, 'id')
2107
+ account = self.safe_dict(self.accounts, 0, {})
2108
+ accountGroup = self.safe_string(account, 'id')
1930
2109
  request: dict = {
1931
2110
  # 'category': accountCategory,
1932
2111
  # 'symbol': market['id'],
@@ -1943,7 +2122,7 @@ class ascendex(Exchange, ImplicitAPI):
1943
2122
  market = self.market(symbol)
1944
2123
  request['symbol'] = market['id']
1945
2124
  type, query = self.handle_market_type_and_params('fetchClosedOrders', market, params)
1946
- options = self.safe_value(self.options, 'fetchClosedOrders', {})
2125
+ options = self.safe_dict(self.options, 'fetchClosedOrders', {})
1947
2126
  defaultMethod = self.safe_string(options, 'method', 'v2PrivateDataGetOrderHist')
1948
2127
  method = self.get_supported_mapping(type, {
1949
2128
  'spot': defaultMethod,
@@ -1955,7 +2134,7 @@ class ascendex(Exchange, ImplicitAPI):
1955
2134
  until = self.safe_string(params, 'until')
1956
2135
  if until is not None:
1957
2136
  request['endTime'] = until
1958
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
2137
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
1959
2138
  accountCategory = self.safe_string(accountsByType, type, 'cash') # margin, futures
1960
2139
  response = None
1961
2140
  if method == 'v1PrivateAccountCategoryGetOrderHistCurrent':
@@ -2068,17 +2247,18 @@ class ascendex(Exchange, ImplicitAPI):
2068
2247
  # ]
2069
2248
  # }
2070
2249
  #
2071
- data = self.safe_value(response, 'data')
2072
- isArray = isinstance(data, list)
2073
- if not isArray:
2074
- data = self.safe_value(data, 'data', [])
2250
+ data = self.safe_list(response, 'data', [])
2251
+ if not isinstance(data, list):
2252
+ data = self.safe_list(data, 'data', [])
2075
2253
  return self.parse_orders(data, market, since, limit)
2076
2254
 
2077
2255
  def cancel_order(self, id: str, symbol: Str = None, params={}):
2078
2256
  """
2079
2257
  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
2258
+
2259
+ https://ascendex.github.io/ascendex-pro-api/#cancel-order
2260
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-order
2261
+
2082
2262
  :param str id: order id
2083
2263
  :param str symbol: unified symbol of the market the order was made in
2084
2264
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2090,10 +2270,10 @@ class ascendex(Exchange, ImplicitAPI):
2090
2270
  self.load_accounts()
2091
2271
  market = self.market(symbol)
2092
2272
  type, query = self.handle_market_type_and_params('cancelOrder', market, params)
2093
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
2273
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
2094
2274
  accountCategory = self.safe_string(accountsByType, type, 'cash')
2095
- account = self.safe_value(self.accounts, 0, {})
2096
- accountGroup = self.safe_value(account, 'id')
2275
+ account = self.safe_dict(self.accounts, 0, {})
2276
+ accountGroup = self.safe_string(account, 'id')
2097
2277
  request: dict = {
2098
2278
  'account-group': accountGroup,
2099
2279
  'account-category': accountCategory,
@@ -2178,18 +2358,20 @@ class ascendex(Exchange, ImplicitAPI):
2178
2358
  # }
2179
2359
  # }
2180
2360
  #
2181
- data = self.safe_value(response, 'data', {})
2182
- order = self.safe_value_2(data, 'order', 'info', {})
2361
+ data = self.safe_dict(response, 'data', {})
2362
+ order = self.safe_dict_2(data, 'order', 'info', {})
2183
2363
  return self.parse_order(order, market)
2184
2364
 
2185
2365
  def cancel_all_orders(self, symbol: Str = None, params={}):
2186
2366
  """
2187
2367
  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
2368
+
2369
+ https://ascendex.github.io/ascendex-pro-api/#cancel-all-orders
2370
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-all-open-orders
2371
+
2190
2372
  :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
2191
2373
  :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>`
2374
+ :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
2375
  """
2194
2376
  self.load_markets()
2195
2377
  self.load_accounts()
@@ -2197,10 +2379,10 @@ class ascendex(Exchange, ImplicitAPI):
2197
2379
  if symbol is not None:
2198
2380
  market = self.market(symbol)
2199
2381
  type, query = self.handle_market_type_and_params('cancelAllOrders', market, params)
2200
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
2382
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
2201
2383
  accountCategory = self.safe_string(accountsByType, type, 'cash')
2202
- account = self.safe_value(self.accounts, 0, {})
2203
- accountGroup = self.safe_value(account, 'id')
2384
+ account = self.safe_dict(self.accounts, 0, {})
2385
+ accountGroup = self.safe_string(account, 'id')
2204
2386
  request: dict = {
2205
2387
  'account-group': accountGroup,
2206
2388
  'account-category': accountCategory,
@@ -2250,9 +2432,11 @@ class ascendex(Exchange, ImplicitAPI):
2250
2432
  # }
2251
2433
  # }
2252
2434
  #
2253
- return response
2435
+ return [self.safe_order({
2436
+ 'info': response,
2437
+ })]
2254
2438
 
2255
- def parse_deposit_address(self, depositAddress, currency: Currency = None):
2439
+ def parse_deposit_address(self, depositAddress, currency: Currency = None) -> DepositAddress:
2256
2440
  #
2257
2441
  # {
2258
2442
  # "address": "0xe7c70b4e73b6b450ee46c3b5c0f5fb127ca55722",
@@ -2274,21 +2458,19 @@ class ascendex(Exchange, ImplicitAPI):
2274
2458
  chainName = self.safe_string(depositAddress, 'blockchain')
2275
2459
  network = self.network_id_to_code(chainName, code)
2276
2460
  return {
2461
+ 'info': depositAddress,
2277
2462
  'currency': code,
2463
+ 'network': network,
2278
2464
  'address': address,
2279
2465
  'tag': tag,
2280
- 'network': network,
2281
- 'info': depositAddress,
2282
2466
  }
2283
2467
 
2284
- def safe_network(self, networkId):
2285
- networksById = self.safe_dict(self.options, 'networksById')
2286
- return self.safe_string(networksById, networkId, networkId)
2287
-
2288
- def fetch_deposit_address(self, code: str, params={}):
2468
+ def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
2289
2469
  """
2290
2470
  fetch the deposit address for a currency associated with self account
2291
- :see: https://ascendex.github.io/ascendex-pro-api/#query-deposit-addresses
2471
+
2472
+ https://ascendex.github.io/ascendex-pro-api/#query-deposit-addresses
2473
+
2292
2474
  :param str code: unified currency code
2293
2475
  :param dict [params]: extra parameters specific to the exchange API endpoint
2294
2476
  :param str [params.network]: unified network code for deposit chain
@@ -2436,7 +2618,7 @@ class ascendex(Exchange, ImplicitAPI):
2436
2618
  # }
2437
2619
  # }
2438
2620
  #
2439
- data = self.safe_value(response, 'data', {})
2621
+ data = self.safe_dict(response, 'data', {})
2440
2622
  transactions = self.safe_list(data, 'data', [])
2441
2623
  return self.parse_transactions(transactions, currency, since, limit)
2442
2624
 
@@ -2468,7 +2650,7 @@ class ascendex(Exchange, ImplicitAPI):
2468
2650
  # }
2469
2651
  # }
2470
2652
  #
2471
- destAddress = self.safe_value(transaction, 'destAddress', {})
2653
+ destAddress = self.safe_dict(transaction, 'destAddress', {})
2472
2654
  address = self.safe_string(destAddress, 'address')
2473
2655
  tag = self.safe_string(destAddress, 'destTag')
2474
2656
  timestamp = self.safe_integer(transaction, 'time')
@@ -2504,7 +2686,7 @@ class ascendex(Exchange, ImplicitAPI):
2504
2686
  'internal': False,
2505
2687
  }
2506
2688
 
2507
- def fetch_positions(self, symbols: Strings = None, params={}):
2689
+ def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
2508
2690
  """
2509
2691
  fetch all open positions
2510
2692
  :param str[]|None symbols: list of unified market symbols
@@ -2513,7 +2695,7 @@ class ascendex(Exchange, ImplicitAPI):
2513
2695
  """
2514
2696
  self.load_markets()
2515
2697
  self.load_accounts()
2516
- account = self.safe_value(self.accounts, 0, {})
2698
+ account = self.safe_dict(self.accounts, 0, {})
2517
2699
  accountGroup = self.safe_string(account, 'id')
2518
2700
  request: dict = {
2519
2701
  'account-group': accountGroup,
@@ -2558,8 +2740,8 @@ class ascendex(Exchange, ImplicitAPI):
2558
2740
  # }
2559
2741
  # }
2560
2742
  #
2561
- data = self.safe_value(response, 'data', {})
2562
- position = self.safe_value(data, 'contracts', [])
2743
+ data = self.safe_dict(response, 'data', {})
2744
+ position = self.safe_list(data, 'contracts', [])
2563
2745
  result = []
2564
2746
  for i in range(0, len(position)):
2565
2747
  result.append(self.parse_position(position[i]))
@@ -2629,7 +2811,7 @@ class ascendex(Exchange, ImplicitAPI):
2629
2811
  'takeProfitPrice': self.safe_number(position, 'takeProfitPrice'),
2630
2812
  })
2631
2813
 
2632
- def parse_funding_rate(self, contract, market: Market = None):
2814
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
2633
2815
  #
2634
2816
  # {
2635
2817
  # "time": 1640061364830,
@@ -2664,14 +2846,15 @@ class ascendex(Exchange, ImplicitAPI):
2664
2846
  'fundingRate': nextFundingRate,
2665
2847
  'fundingTimestamp': nextFundingRateTimestamp,
2666
2848
  'fundingDatetime': self.iso8601(nextFundingRateTimestamp),
2849
+ 'interval': None,
2667
2850
  }
2668
2851
 
2669
- def fetch_funding_rates(self, symbols: Strings = None, params={}):
2852
+ def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
2670
2853
  """
2671
2854
  fetch the funding rate for multiple markets
2672
2855
  :param str[]|None symbols: list of unified market symbols
2673
2856
  :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
2857
+ :returns dict[]: a list of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
2675
2858
  """
2676
2859
  self.load_markets()
2677
2860
  symbols = self.market_symbols(symbols)
@@ -2700,16 +2883,15 @@ class ascendex(Exchange, ImplicitAPI):
2700
2883
  # }
2701
2884
  # }
2702
2885
  #
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)
2886
+ data = self.safe_dict(response, 'data', {})
2887
+ contracts = self.safe_list(data, 'contracts', [])
2888
+ return self.parse_funding_rates(contracts, symbols)
2707
2889
 
2708
2890
  def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
2709
2891
  self.load_markets()
2710
2892
  self.load_accounts()
2711
2893
  market = self.market(symbol)
2712
- account = self.safe_value(self.accounts, 0, {})
2894
+ account = self.safe_dict(self.accounts, 0, {})
2713
2895
  accountGroup = self.safe_string(account, 'id')
2714
2896
  amount = self.amount_to_precision(symbol, amount)
2715
2897
  request: dict = {
@@ -2775,10 +2957,12 @@ class ascendex(Exchange, ImplicitAPI):
2775
2957
  """
2776
2958
  return self.modify_margin_helper(symbol, amount, 'add', params)
2777
2959
 
2778
- def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
2960
+ def set_leverage(self, leverage: int, symbol: Str = None, params={}):
2779
2961
  """
2780
2962
  set the level of leverage for a market
2781
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-contract-leverage
2963
+
2964
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-contract-leverage
2965
+
2782
2966
  :param float leverage: the rate of leverage
2783
2967
  :param str symbol: unified market symbol
2784
2968
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2793,7 +2977,7 @@ class ascendex(Exchange, ImplicitAPI):
2793
2977
  market = self.market(symbol)
2794
2978
  if not market['swap']:
2795
2979
  raise BadSymbol(self.id + ' setLeverage() supports swap contracts only')
2796
- account = self.safe_value(self.accounts, 0, {})
2980
+ account = self.safe_dict(self.accounts, 0, {})
2797
2981
  accountGroup = self.safe_string(account, 'id')
2798
2982
  request: dict = {
2799
2983
  'account-group': accountGroup,
@@ -2805,7 +2989,9 @@ class ascendex(Exchange, ImplicitAPI):
2805
2989
  def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
2806
2990
  """
2807
2991
  set margin mode to 'cross' or 'isolated'
2808
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-margin-type
2992
+
2993
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-margin-type
2994
+
2809
2995
  :param str marginMode: 'cross' or 'isolated'
2810
2996
  :param str symbol: unified market symbol
2811
2997
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2821,7 +3007,7 @@ class ascendex(Exchange, ImplicitAPI):
2821
3007
  self.load_markets()
2822
3008
  self.load_accounts()
2823
3009
  market = self.market(symbol)
2824
- account = self.safe_value(self.accounts, 0, {})
3010
+ account = self.safe_dict(self.accounts, 0, {})
2825
3011
  accountGroup = self.safe_string(account, 'id')
2826
3012
  request: dict = {
2827
3013
  'account-group': accountGroup,
@@ -2869,7 +3055,7 @@ class ascendex(Exchange, ImplicitAPI):
2869
3055
  # ]
2870
3056
  # }
2871
3057
  #
2872
- data = self.safe_value(response, 'data')
3058
+ data = self.safe_list(response, 'data', [])
2873
3059
  symbols = self.market_symbols(symbols)
2874
3060
  return self.parse_leverage_tiers(data, symbols, 'symbol')
2875
3061
 
@@ -2901,15 +3087,16 @@ class ascendex(Exchange, ImplicitAPI):
2901
3087
  # ]
2902
3088
  # }
2903
3089
  #
2904
- marginRequirements = self.safe_value(info, 'marginRequirements', [])
2905
- id = self.safe_string(info, 'symbol')
2906
- market = self.safe_market(id, market)
3090
+ marginRequirements = self.safe_list(info, 'marginRequirements', [])
3091
+ marketId = self.safe_string(info, 'symbol')
3092
+ market = self.safe_market(marketId, market)
2907
3093
  tiers = []
2908
3094
  for i in range(0, len(marginRequirements)):
2909
3095
  tier = marginRequirements[i]
2910
3096
  initialMarginRate = self.safe_string(tier, 'initialMarginRate')
2911
3097
  tiers.append({
2912
3098
  'tier': self.sum(i, 1),
3099
+ 'symbol': self.safe_symbol(marketId, market, None, 'contract'),
2913
3100
  'currency': market['quote'],
2914
3101
  'minNotional': self.safe_number(tier, 'positionNotionalLowerBound'),
2915
3102
  'maxNotional': self.safe_number(tier, 'positionNotionalUpperBound'),
@@ -2939,7 +3126,7 @@ class ascendex(Exchange, ImplicitAPI):
2939
3126
  # ]
2940
3127
  # }
2941
3128
  #
2942
- blockChains = self.safe_value(fee, 'blockChain', [])
3129
+ blockChains = self.safe_list(fee, 'blockChain', [])
2943
3130
  blockChainsLength = len(blockChains)
2944
3131
  result: dict = {
2945
3132
  'info': fee,
@@ -2970,7 +3157,9 @@ class ascendex(Exchange, ImplicitAPI):
2970
3157
  def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
2971
3158
  """
2972
3159
  fetch deposit and withdraw fees
2973
- :see: https://ascendex.github.io/ascendex-pro-api/#list-all-assets
3160
+
3161
+ https://ascendex.github.io/ascendex-pro-api/#list-all-assets
3162
+
2974
3163
  :param str[]|None codes: list of unified currency codes
2975
3164
  :param dict [params]: extra parameters specific to the exchange API endpoint
2976
3165
  :returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -2992,10 +3181,10 @@ class ascendex(Exchange, ImplicitAPI):
2992
3181
  """
2993
3182
  self.load_markets()
2994
3183
  self.load_accounts()
2995
- account = self.safe_value(self.accounts, 0, {})
3184
+ account = self.safe_dict(self.accounts, 0, {})
2996
3185
  accountGroup = self.safe_string(account, 'id')
2997
3186
  currency = self.currency(code)
2998
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
3187
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
2999
3188
  fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
3000
3189
  toId = self.safe_string(accountsByType, toAccount, toAccount)
3001
3190
  if fromId != 'cash' and toId != 'cash':
@@ -3011,7 +3200,7 @@ class ascendex(Exchange, ImplicitAPI):
3011
3200
  #
3012
3201
  # {"code": "0"}
3013
3202
  #
3014
- transferOptions = self.safe_value(self.options, 'transfer', {})
3203
+ transferOptions = self.safe_dict(self.options, 'transfer', {})
3015
3204
  fillResponseFromRequest = self.safe_bool(transferOptions, 'fillResponseFromRequest', True)
3016
3205
  transfer = self.parse_transfer(response, currency)
3017
3206
  if fillResponseFromRequest:
@@ -3047,7 +3236,9 @@ class ascendex(Exchange, ImplicitAPI):
3047
3236
  def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3048
3237
  """
3049
3238
  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
3239
+
3240
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#funding-payment-history
3241
+
3051
3242
  :param str [symbol]: unified market symbol
3052
3243
  :param int [since]: the earliest time in ms to fetch funding history for
3053
3244
  :param int [limit]: the maximum number of funding history structures to retrieve
@@ -3061,7 +3252,7 @@ class ascendex(Exchange, ImplicitAPI):
3061
3252
  paginate, params = self.handle_option_and_params(params, 'fetchFundingHistory', 'paginate')
3062
3253
  if paginate:
3063
3254
  return self.fetch_paginated_call_incremental('fetchFundingHistory', symbol, since, limit, params, 'page', 25)
3064
- account = self.safe_value(self.accounts, 0, {})
3255
+ account = self.safe_dict(self.accounts, 0, {})
3065
3256
  accountGroup = self.safe_string(account, 'id')
3066
3257
  request: dict = {
3067
3258
  'account-group': accountGroup,
@@ -3091,7 +3282,7 @@ class ascendex(Exchange, ImplicitAPI):
3091
3282
  # }
3092
3283
  # }
3093
3284
  #
3094
- data = self.safe_value(response, 'data', {})
3285
+ data = self.safe_dict(response, 'data', {})
3095
3286
  rows = self.safe_list(data, 'data', [])
3096
3287
  return self.parse_incomes(rows, market, since, limit)
3097
3288
 
@@ -3119,14 +3310,16 @@ class ascendex(Exchange, ImplicitAPI):
3119
3310
  def fetch_margin_modes(self, symbols: Strings = None, params={}) -> MarginModes:
3120
3311
  """
3121
3312
  fetches the set margin mode of the user
3122
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
3313
+
3314
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
3315
+
3123
3316
  :param str[] [symbols]: a list of unified market symbols
3124
3317
  :param dict [params]: extra parameters specific to the exchange API endpoint
3125
3318
  :returns dict: a list of `margin mode structures <https://docs.ccxt.com/#/?id=margin-mode-structure>`
3126
3319
  """
3127
3320
  self.load_markets()
3128
3321
  self.load_accounts()
3129
- account = self.safe_value(self.accounts, 0, {})
3322
+ account = self.safe_dict(self.accounts, 0, {})
3130
3323
  accountGroup = self.safe_string(account, 'id')
3131
3324
  request: dict = {
3132
3325
  'account-group': accountGroup,
@@ -3188,14 +3381,16 @@ class ascendex(Exchange, ImplicitAPI):
3188
3381
  def fetch_leverages(self, symbols: Strings = None, params={}) -> Leverages:
3189
3382
  """
3190
3383
  fetch the set leverage for all contract markets
3191
- :see: https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
3384
+
3385
+ https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
3386
+
3192
3387
  :param str[] [symbols]: a list of unified market symbols
3193
3388
  :param dict [params]: extra parameters specific to the exchange API endpoint
3194
3389
  :returns dict: a list of `leverage structures <https://docs.ccxt.com/#/?id=leverage-structure>`
3195
3390
  """
3196
3391
  self.load_markets()
3197
3392
  self.load_accounts()
3198
- account = self.safe_value(self.accounts, 0, {})
3393
+ account = self.safe_dict(self.accounts, 0, {})
3199
3394
  accountGroup = self.safe_string(account, 'id')
3200
3395
  request: dict = {
3201
3396
  'account-group': accountGroup,