ccxt-ir 4.3.46.0.1__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 (772) hide show
  1. ccxt/__init__.py +358 -0
  2. ccxt/abantether.py +316 -0
  3. ccxt/abstract/__init__.py +0 -0
  4. ccxt/abstract/abantether.py +5 -0
  5. ccxt/abstract/ace.py +15 -0
  6. ccxt/abstract/afratether.py +6 -0
  7. ccxt/abstract/alpaca.py +70 -0
  8. ccxt/abstract/arzinja.py +5 -0
  9. ccxt/abstract/arzplus.py +7 -0
  10. ccxt/abstract/ascendex.py +77 -0
  11. ccxt/abstract/bequant.py +115 -0
  12. ccxt/abstract/bigone.py +45 -0
  13. ccxt/abstract/binance.py +712 -0
  14. ccxt/abstract/binancecoinm.py +712 -0
  15. ccxt/abstract/binanceus.py +764 -0
  16. ccxt/abstract/binanceusdm.py +712 -0
  17. ccxt/abstract/bingx.py +113 -0
  18. ccxt/abstract/bit2c.py +27 -0
  19. ccxt/abstract/bitbank.py +27 -0
  20. ccxt/abstract/bitbay.py +53 -0
  21. ccxt/abstract/bitbns.py +40 -0
  22. ccxt/abstract/bitcoincom.py +115 -0
  23. ccxt/abstract/bitfinex.py +69 -0
  24. ccxt/abstract/bitfinex2.py +139 -0
  25. ccxt/abstract/bitflyer.py +38 -0
  26. ccxt/abstract/bitget.py +508 -0
  27. ccxt/abstract/bithumb.py +32 -0
  28. ccxt/abstract/bitimen.py +7 -0
  29. ccxt/abstract/bitir.py +7 -0
  30. ccxt/abstract/bitmart.py +99 -0
  31. ccxt/abstract/bitmex.py +97 -0
  32. ccxt/abstract/bitopro.py +29 -0
  33. ccxt/abstract/bitpanda.py +35 -0
  34. ccxt/abstract/bitpin.py +7 -0
  35. ccxt/abstract/bitrue.py +72 -0
  36. ccxt/abstract/bitso.py +43 -0
  37. ccxt/abstract/bitstamp.py +258 -0
  38. ccxt/abstract/bitteam.py +29 -0
  39. ccxt/abstract/bitvavo.py +27 -0
  40. ccxt/abstract/bl3p.py +19 -0
  41. ccxt/abstract/blockchaincom.py +28 -0
  42. ccxt/abstract/blofin.py +37 -0
  43. ccxt/abstract/btcalpha.py +18 -0
  44. ccxt/abstract/btcbox.py +13 -0
  45. ccxt/abstract/btcmarkets.py +39 -0
  46. ccxt/abstract/btcturk.py +20 -0
  47. ccxt/abstract/bybit.py +298 -0
  48. ccxt/abstract/cex.py +33 -0
  49. ccxt/abstract/coinbase.py +94 -0
  50. ccxt/abstract/coinbaseadvanced.py +94 -0
  51. ccxt/abstract/coinbaseexchange.py +67 -0
  52. ccxt/abstract/coinbaseinternational.py +39 -0
  53. ccxt/abstract/coincatch.py +94 -0
  54. ccxt/abstract/coincheck.py +33 -0
  55. ccxt/abstract/coinex.py +237 -0
  56. ccxt/abstract/coinlist.py +54 -0
  57. ccxt/abstract/coinmate.py +62 -0
  58. ccxt/abstract/coinmetro.py +34 -0
  59. ccxt/abstract/coinone.py +67 -0
  60. ccxt/abstract/coinsph.py +54 -0
  61. ccxt/abstract/coinspot.py +28 -0
  62. ccxt/abstract/cryptocom.py +107 -0
  63. ccxt/abstract/currencycom.py +68 -0
  64. ccxt/abstract/delta.py +50 -0
  65. ccxt/abstract/deribit.py +125 -0
  66. ccxt/abstract/digifinex.py +91 -0
  67. ccxt/abstract/eterex.py +5 -0
  68. ccxt/abstract/excoino.py +7 -0
  69. ccxt/abstract/exir.py +8 -0
  70. ccxt/abstract/exmo.py +55 -0
  71. ccxt/abstract/exnovin.py +6 -0
  72. ccxt/abstract/farhadexchange.py +5 -0
  73. ccxt/abstract/fmfwio.py +115 -0
  74. ccxt/abstract/gate.py +265 -0
  75. ccxt/abstract/gateio.py +265 -0
  76. ccxt/abstract/gemini.py +58 -0
  77. ccxt/abstract/hashkey.py +67 -0
  78. ccxt/abstract/hitbtc.py +115 -0
  79. ccxt/abstract/hitbtc3.py +115 -0
  80. ccxt/abstract/hitobit.py +8 -0
  81. ccxt/abstract/hollaex.py +33 -0
  82. ccxt/abstract/htx.py +548 -0
  83. ccxt/abstract/huobi.py +548 -0
  84. ccxt/abstract/huobijp.py +114 -0
  85. ccxt/abstract/hyperliquid.py +6 -0
  86. ccxt/abstract/idex.py +26 -0
  87. ccxt/abstract/independentreserve.py +37 -0
  88. ccxt/abstract/indodax.py +26 -0
  89. ccxt/abstract/jibitex.py +7 -0
  90. ccxt/abstract/kraken.py +57 -0
  91. ccxt/abstract/krakenfutures.py +38 -0
  92. ccxt/abstract/kucoin.py +214 -0
  93. ccxt/abstract/kucoinfutures.py +233 -0
  94. ccxt/abstract/kuna.py +182 -0
  95. ccxt/abstract/latoken.py +56 -0
  96. ccxt/abstract/lbank.py +61 -0
  97. ccxt/abstract/luno.py +37 -0
  98. ccxt/abstract/lykke.py +29 -0
  99. ccxt/abstract/mercado.py +25 -0
  100. ccxt/abstract/mexc.py +178 -0
  101. ccxt/abstract/ndax.py +97 -0
  102. ccxt/abstract/nobitex.py +7 -0
  103. ccxt/abstract/novadax.py +29 -0
  104. ccxt/abstract/oceanex.py +22 -0
  105. ccxt/abstract/okcoin.py +74 -0
  106. ccxt/abstract/okexchange.py +8 -0
  107. ccxt/abstract/okx.py +324 -0
  108. ccxt/abstract/ompfinex.py +7 -0
  109. ccxt/abstract/onetrading.py +35 -0
  110. ccxt/abstract/oxfun.py +34 -0
  111. ccxt/abstract/p2b.py +22 -0
  112. ccxt/abstract/paradex.py +40 -0
  113. ccxt/abstract/paymium.py +28 -0
  114. ccxt/abstract/phemex.py +115 -0
  115. ccxt/abstract/poloniex.py +69 -0
  116. ccxt/abstract/poloniexfutures.py +48 -0
  117. ccxt/abstract/probit.py +23 -0
  118. ccxt/abstract/ramzinex.py +7 -0
  119. ccxt/abstract/sarmayex.py +5 -0
  120. ccxt/abstract/sarrafex.py +7 -0
  121. ccxt/abstract/tabdeal.py +7 -0
  122. ccxt/abstract/tetherland.py +5 -0
  123. ccxt/abstract/timex.py +62 -0
  124. ccxt/abstract/tokocrypto.py +37 -0
  125. ccxt/abstract/tradeogre.py +16 -0
  126. ccxt/abstract/twox.py +5 -0
  127. ccxt/abstract/ubitex.py +7 -0
  128. ccxt/abstract/upbit.py +38 -0
  129. ccxt/abstract/vertex.py +19 -0
  130. ccxt/abstract/wallex.py +8 -0
  131. ccxt/abstract/wavesexchange.py +154 -0
  132. ccxt/abstract/wazirx.py +30 -0
  133. ccxt/abstract/whitebit.py +98 -0
  134. ccxt/abstract/woo.py +83 -0
  135. ccxt/abstract/woofipro.py +119 -0
  136. ccxt/abstract/xt.py +152 -0
  137. ccxt/abstract/yobit.py +16 -0
  138. ccxt/abstract/zaif.py +38 -0
  139. ccxt/abstract/zonda.py +53 -0
  140. ccxt/ace.py +1012 -0
  141. ccxt/afratether.py +293 -0
  142. ccxt/alpaca.py +1083 -0
  143. ccxt/arzinja.py +285 -0
  144. ccxt/arzplus.py +412 -0
  145. ccxt/ascendex.py +3330 -0
  146. ccxt/async_support/__init__.py +337 -0
  147. ccxt/async_support/abantether.py +316 -0
  148. ccxt/async_support/ace.py +1012 -0
  149. ccxt/async_support/afratether.py +293 -0
  150. ccxt/async_support/alpaca.py +1083 -0
  151. ccxt/async_support/arzinja.py +285 -0
  152. ccxt/async_support/arzplus.py +412 -0
  153. ccxt/async_support/ascendex.py +3330 -0
  154. ccxt/async_support/base/__init__.py +1 -0
  155. ccxt/async_support/base/exchange.py +1966 -0
  156. ccxt/async_support/base/throttler.py +50 -0
  157. ccxt/async_support/base/ws/__init__.py +38 -0
  158. ccxt/async_support/base/ws/aiohttp_client.py +125 -0
  159. ccxt/async_support/base/ws/cache.py +212 -0
  160. ccxt/async_support/base/ws/client.py +193 -0
  161. ccxt/async_support/base/ws/fast_client.py +96 -0
  162. ccxt/async_support/base/ws/functions.py +59 -0
  163. ccxt/async_support/base/ws/future.py +58 -0
  164. ccxt/async_support/base/ws/order_book.py +78 -0
  165. ccxt/async_support/base/ws/order_book_side.py +174 -0
  166. ccxt/async_support/bequant.py +33 -0
  167. ccxt/async_support/bigone.py +2113 -0
  168. ccxt/async_support/binance.py +12234 -0
  169. ccxt/async_support/binancecoinm.py +45 -0
  170. ccxt/async_support/binanceus.py +211 -0
  171. ccxt/async_support/binanceusdm.py +58 -0
  172. ccxt/async_support/bingx.py +4325 -0
  173. ccxt/async_support/bit2c.py +866 -0
  174. ccxt/async_support/bitbank.py +1001 -0
  175. ccxt/async_support/bitbay.py +17 -0
  176. ccxt/async_support/bitbns.py +1154 -0
  177. ccxt/async_support/bitcoincom.py +17 -0
  178. ccxt/async_support/bitfinex.py +1617 -0
  179. ccxt/async_support/bitfinex2.py +3552 -0
  180. ccxt/async_support/bitflyer.py +995 -0
  181. ccxt/async_support/bitget.py +8273 -0
  182. ccxt/async_support/bithumb.py +1061 -0
  183. ccxt/async_support/bitimen.py +401 -0
  184. ccxt/async_support/bitir.py +490 -0
  185. ccxt/async_support/bitmart.py +4415 -0
  186. ccxt/async_support/bitmex.py +2756 -0
  187. ccxt/async_support/bitopro.py +1630 -0
  188. ccxt/async_support/bitpanda.py +16 -0
  189. ccxt/async_support/bitpin.py +454 -0
  190. ccxt/async_support/bitrue.py +3027 -0
  191. ccxt/async_support/bitso.py +1670 -0
  192. ccxt/async_support/bitstamp.py +2203 -0
  193. ccxt/async_support/bitteam.py +2239 -0
  194. ccxt/async_support/bitvavo.py +1968 -0
  195. ccxt/async_support/bl3p.py +485 -0
  196. ccxt/async_support/blockchaincom.py +1104 -0
  197. ccxt/async_support/blofin.py +2066 -0
  198. ccxt/async_support/btcalpha.py +891 -0
  199. ccxt/async_support/btcbox.py +544 -0
  200. ccxt/async_support/btcmarkets.py +1221 -0
  201. ccxt/async_support/btcturk.py +911 -0
  202. ccxt/async_support/bybit.py +8159 -0
  203. ccxt/async_support/cex.py +1605 -0
  204. ccxt/async_support/coinbase.py +4475 -0
  205. ccxt/async_support/coinbaseadvanced.py +17 -0
  206. ccxt/async_support/coinbaseexchange.py +1734 -0
  207. ccxt/async_support/coinbaseinternational.py +1899 -0
  208. ccxt/async_support/coincatch.py +5069 -0
  209. ccxt/async_support/coincheck.py +815 -0
  210. ccxt/async_support/coinex.py +5526 -0
  211. ccxt/async_support/coinlist.py +2243 -0
  212. ccxt/async_support/coinmate.py +1067 -0
  213. ccxt/async_support/coinmetro.py +1797 -0
  214. ccxt/async_support/coinone.py +1127 -0
  215. ccxt/async_support/coinsph.py +1850 -0
  216. ccxt/async_support/coinspot.py +534 -0
  217. ccxt/async_support/cryptocom.py +2822 -0
  218. ccxt/async_support/currencycom.py +1950 -0
  219. ccxt/async_support/delta.py +3376 -0
  220. ccxt/async_support/deribit.py +3437 -0
  221. ccxt/async_support/digifinex.py +3960 -0
  222. ccxt/async_support/eterex.py +286 -0
  223. ccxt/async_support/excoino.py +399 -0
  224. ccxt/async_support/exir.py +375 -0
  225. ccxt/async_support/exmo.py +2462 -0
  226. ccxt/async_support/exnovin.py +360 -0
  227. ccxt/async_support/farhadexchange.py +266 -0
  228. ccxt/async_support/fmfwio.py +34 -0
  229. ccxt/async_support/gate.py +6976 -0
  230. ccxt/async_support/gateio.py +16 -0
  231. ccxt/async_support/gemini.py +1825 -0
  232. ccxt/async_support/hashkey.py +4150 -0
  233. ccxt/async_support/hitbtc.py +3423 -0
  234. ccxt/async_support/hitbtc3.py +16 -0
  235. ccxt/async_support/hitobit.py +391 -0
  236. ccxt/async_support/hollaex.py +1813 -0
  237. ccxt/async_support/htx.py +8506 -0
  238. ccxt/async_support/huobi.py +16 -0
  239. ccxt/async_support/huobijp.py +1801 -0
  240. ccxt/async_support/hyperliquid.py +2431 -0
  241. ccxt/async_support/idex.py +1766 -0
  242. ccxt/async_support/independentreserve.py +784 -0
  243. ccxt/async_support/indodax.py +1247 -0
  244. ccxt/async_support/jibitex.py +395 -0
  245. ccxt/async_support/kraken.py +2894 -0
  246. ccxt/async_support/krakenfutures.py +2601 -0
  247. ccxt/async_support/kucoin.py +4602 -0
  248. ccxt/async_support/kucoinfutures.py +2698 -0
  249. ccxt/async_support/kuna.py +1841 -0
  250. ccxt/async_support/latoken.py +1664 -0
  251. ccxt/async_support/lbank.py +2683 -0
  252. ccxt/async_support/luno.py +1067 -0
  253. ccxt/async_support/lykke.py +1270 -0
  254. ccxt/async_support/mercado.py +842 -0
  255. ccxt/async_support/mexc.py +5369 -0
  256. ccxt/async_support/ndax.py +2354 -0
  257. ccxt/async_support/nobitex.py +419 -0
  258. ccxt/async_support/novadax.py +1484 -0
  259. ccxt/async_support/oceanex.py +903 -0
  260. ccxt/async_support/okcoin.py +2936 -0
  261. ccxt/async_support/okexchange.py +349 -0
  262. ccxt/async_support/okx.py +7827 -0
  263. ccxt/async_support/ompfinex.py +472 -0
  264. ccxt/async_support/onetrading.py +1911 -0
  265. ccxt/async_support/oxfun.py +2773 -0
  266. ccxt/async_support/p2b.py +1194 -0
  267. ccxt/async_support/paradex.py +2015 -0
  268. ccxt/async_support/paymium.py +564 -0
  269. ccxt/async_support/phemex.py +4473 -0
  270. ccxt/async_support/poloniex.py +2232 -0
  271. ccxt/async_support/poloniexfutures.py +1717 -0
  272. ccxt/async_support/probit.py +1734 -0
  273. ccxt/async_support/ramzinex.py +476 -0
  274. ccxt/async_support/sarmayex.py +357 -0
  275. ccxt/async_support/sarrafex.py +478 -0
  276. ccxt/async_support/tabdeal.py +364 -0
  277. ccxt/async_support/tetherland.py +349 -0
  278. ccxt/async_support/timex.py +1593 -0
  279. ccxt/async_support/tokocrypto.py +2405 -0
  280. ccxt/async_support/tradeogre.py +608 -0
  281. ccxt/async_support/twox.py +326 -0
  282. ccxt/async_support/ubitex.py +409 -0
  283. ccxt/async_support/upbit.py +1833 -0
  284. ccxt/async_support/vertex.py +2922 -0
  285. ccxt/async_support/wallex.py +445 -0
  286. ccxt/async_support/wavesexchange.py +2473 -0
  287. ccxt/async_support/wazirx.py +1224 -0
  288. ccxt/async_support/whitebit.py +2469 -0
  289. ccxt/async_support/woo.py +3114 -0
  290. ccxt/async_support/woofipro.py +2533 -0
  291. ccxt/async_support/xt.py +4454 -0
  292. ccxt/async_support/yobit.py +1283 -0
  293. ccxt/async_support/zaif.py +725 -0
  294. ccxt/async_support/zonda.py +1828 -0
  295. ccxt/base/__init__.py +27 -0
  296. ccxt/base/decimal_to_precision.py +174 -0
  297. ccxt/base/errors.py +242 -0
  298. ccxt/base/exchange.py +5941 -0
  299. ccxt/base/precise.py +287 -0
  300. ccxt/base/types.py +502 -0
  301. ccxt/bequant.py +33 -0
  302. ccxt/bigone.py +2112 -0
  303. ccxt/binance.py +12233 -0
  304. ccxt/binancecoinm.py +45 -0
  305. ccxt/binanceus.py +211 -0
  306. ccxt/binanceusdm.py +58 -0
  307. ccxt/bingx.py +4324 -0
  308. ccxt/bit2c.py +866 -0
  309. ccxt/bitbank.py +1001 -0
  310. ccxt/bitbay.py +17 -0
  311. ccxt/bitbns.py +1154 -0
  312. ccxt/bitcoincom.py +17 -0
  313. ccxt/bitfinex.py +1617 -0
  314. ccxt/bitfinex2.py +3552 -0
  315. ccxt/bitflyer.py +995 -0
  316. ccxt/bitget.py +8272 -0
  317. ccxt/bithumb.py +1061 -0
  318. ccxt/bitimen.py +401 -0
  319. ccxt/bitir.py +490 -0
  320. ccxt/bitmart.py +4415 -0
  321. ccxt/bitmex.py +2756 -0
  322. ccxt/bitopro.py +1630 -0
  323. ccxt/bitpanda.py +16 -0
  324. ccxt/bitpin.py +454 -0
  325. ccxt/bitrue.py +3026 -0
  326. ccxt/bitso.py +1670 -0
  327. ccxt/bitstamp.py +2203 -0
  328. ccxt/bitteam.py +2239 -0
  329. ccxt/bitvavo.py +1968 -0
  330. ccxt/bl3p.py +485 -0
  331. ccxt/blockchaincom.py +1104 -0
  332. ccxt/blofin.py +2066 -0
  333. ccxt/btcalpha.py +891 -0
  334. ccxt/btcbox.py +544 -0
  335. ccxt/btcmarkets.py +1221 -0
  336. ccxt/btcturk.py +911 -0
  337. ccxt/bybit.py +8158 -0
  338. ccxt/cex.py +1605 -0
  339. ccxt/coinbase.py +4474 -0
  340. ccxt/coinbaseadvanced.py +17 -0
  341. ccxt/coinbaseexchange.py +1734 -0
  342. ccxt/coinbaseinternational.py +1899 -0
  343. ccxt/coincatch.py +5069 -0
  344. ccxt/coincheck.py +815 -0
  345. ccxt/coinex.py +5525 -0
  346. ccxt/coinlist.py +2243 -0
  347. ccxt/coinmate.py +1067 -0
  348. ccxt/coinmetro.py +1797 -0
  349. ccxt/coinone.py +1127 -0
  350. ccxt/coinsph.py +1850 -0
  351. ccxt/coinspot.py +534 -0
  352. ccxt/cryptocom.py +2822 -0
  353. ccxt/currencycom.py +1950 -0
  354. ccxt/delta.py +3376 -0
  355. ccxt/deribit.py +3437 -0
  356. ccxt/digifinex.py +3959 -0
  357. ccxt/eterex.py +286 -0
  358. ccxt/excoino.py +399 -0
  359. ccxt/exir.py +375 -0
  360. ccxt/exmo.py +2462 -0
  361. ccxt/exnovin.py +360 -0
  362. ccxt/farhadexchange.py +266 -0
  363. ccxt/fmfwio.py +34 -0
  364. ccxt/gate.py +6975 -0
  365. ccxt/gateio.py +16 -0
  366. ccxt/gemini.py +1824 -0
  367. ccxt/hashkey.py +4150 -0
  368. ccxt/hitbtc.py +3423 -0
  369. ccxt/hitbtc3.py +16 -0
  370. ccxt/hitobit.py +391 -0
  371. ccxt/hollaex.py +1813 -0
  372. ccxt/htx.py +8505 -0
  373. ccxt/huobi.py +16 -0
  374. ccxt/huobijp.py +1801 -0
  375. ccxt/hyperliquid.py +2430 -0
  376. ccxt/idex.py +1766 -0
  377. ccxt/independentreserve.py +784 -0
  378. ccxt/indodax.py +1247 -0
  379. ccxt/jibitex.py +395 -0
  380. ccxt/kraken.py +2894 -0
  381. ccxt/krakenfutures.py +2601 -0
  382. ccxt/kucoin.py +4601 -0
  383. ccxt/kucoinfutures.py +2698 -0
  384. ccxt/kuna.py +1841 -0
  385. ccxt/latoken.py +1664 -0
  386. ccxt/lbank.py +2682 -0
  387. ccxt/luno.py +1067 -0
  388. ccxt/lykke.py +1270 -0
  389. ccxt/mercado.py +842 -0
  390. ccxt/mexc.py +5369 -0
  391. ccxt/ndax.py +2354 -0
  392. ccxt/nobitex.py +419 -0
  393. ccxt/novadax.py +1484 -0
  394. ccxt/oceanex.py +903 -0
  395. ccxt/okcoin.py +2936 -0
  396. ccxt/okexchange.py +349 -0
  397. ccxt/okx.py +7826 -0
  398. ccxt/ompfinex.py +472 -0
  399. ccxt/onetrading.py +1911 -0
  400. ccxt/oxfun.py +2772 -0
  401. ccxt/p2b.py +1194 -0
  402. ccxt/paradex.py +2015 -0
  403. ccxt/paymium.py +564 -0
  404. ccxt/phemex.py +4473 -0
  405. ccxt/poloniex.py +2232 -0
  406. ccxt/poloniexfutures.py +1717 -0
  407. ccxt/pro/__init__.py +149 -0
  408. ccxt/pro/alpaca.py +685 -0
  409. ccxt/pro/ascendex.py +916 -0
  410. ccxt/pro/bequant.py +38 -0
  411. ccxt/pro/binance.py +3488 -0
  412. ccxt/pro/binancecoinm.py +28 -0
  413. ccxt/pro/binanceus.py +48 -0
  414. ccxt/pro/binanceusdm.py +31 -0
  415. ccxt/pro/bingx.py +1264 -0
  416. ccxt/pro/bitcoincom.py +34 -0
  417. ccxt/pro/bitfinex.py +621 -0
  418. ccxt/pro/bitfinex2.py +1083 -0
  419. ccxt/pro/bitget.py +1692 -0
  420. ccxt/pro/bithumb.py +368 -0
  421. ccxt/pro/bitmart.py +1449 -0
  422. ccxt/pro/bitmex.py +1656 -0
  423. ccxt/pro/bitopro.py +445 -0
  424. ccxt/pro/bitpanda.py +15 -0
  425. ccxt/pro/bitrue.py +447 -0
  426. ccxt/pro/bitstamp.py +522 -0
  427. ccxt/pro/bitvavo.py +1270 -0
  428. ccxt/pro/blockchaincom.py +738 -0
  429. ccxt/pro/blofin.py +692 -0
  430. ccxt/pro/bybit.py +2000 -0
  431. ccxt/pro/cex.py +1440 -0
  432. ccxt/pro/coinbase.py +678 -0
  433. ccxt/pro/coinbaseadvanced.py +16 -0
  434. ccxt/pro/coinbaseexchange.py +895 -0
  435. ccxt/pro/coinbaseinternational.py +620 -0
  436. ccxt/pro/coincatch.py +1464 -0
  437. ccxt/pro/coincheck.py +199 -0
  438. ccxt/pro/coinex.py +1061 -0
  439. ccxt/pro/coinone.py +395 -0
  440. ccxt/pro/cryptocom.py +947 -0
  441. ccxt/pro/currencycom.py +536 -0
  442. ccxt/pro/deribit.py +892 -0
  443. ccxt/pro/exmo.py +629 -0
  444. ccxt/pro/gate.py +1416 -0
  445. ccxt/pro/gateio.py +15 -0
  446. ccxt/pro/gemini.py +865 -0
  447. ccxt/pro/hashkey.py +802 -0
  448. ccxt/pro/hitbtc.py +1216 -0
  449. ccxt/pro/hollaex.py +563 -0
  450. ccxt/pro/htx.py +2215 -0
  451. ccxt/pro/huobi.py +15 -0
  452. ccxt/pro/huobijp.py +570 -0
  453. ccxt/pro/hyperliquid.py +525 -0
  454. ccxt/pro/idex.py +672 -0
  455. ccxt/pro/independentreserve.py +270 -0
  456. ccxt/pro/kraken.py +1356 -0
  457. ccxt/pro/krakenfutures.py +1492 -0
  458. ccxt/pro/kucoin.py +1133 -0
  459. ccxt/pro/kucoinfutures.py +1081 -0
  460. ccxt/pro/lbank.py +843 -0
  461. ccxt/pro/luno.py +303 -0
  462. ccxt/pro/mexc.py +1122 -0
  463. ccxt/pro/ndax.py +506 -0
  464. ccxt/pro/okcoin.py +698 -0
  465. ccxt/pro/okx.py +1851 -0
  466. ccxt/pro/onetrading.py +1275 -0
  467. ccxt/pro/oxfun.py +950 -0
  468. ccxt/pro/p2b.py +419 -0
  469. ccxt/pro/paradex.py +352 -0
  470. ccxt/pro/phemex.py +1441 -0
  471. ccxt/pro/poloniex.py +1166 -0
  472. ccxt/pro/poloniexfutures.py +990 -0
  473. ccxt/pro/probit.py +551 -0
  474. ccxt/pro/upbit.py +520 -0
  475. ccxt/pro/vertex.py +943 -0
  476. ccxt/pro/wazirx.py +749 -0
  477. ccxt/pro/whitebit.py +864 -0
  478. ccxt/pro/woo.py +1078 -0
  479. ccxt/pro/woofipro.py +1183 -0
  480. ccxt/pro/xt.py +1067 -0
  481. ccxt/probit.py +1734 -0
  482. ccxt/ramzinex.py +476 -0
  483. ccxt/sarmayex.py +357 -0
  484. ccxt/sarrafex.py +478 -0
  485. ccxt/static_dependencies/__init__.py +1 -0
  486. ccxt/static_dependencies/ecdsa/__init__.py +14 -0
  487. ccxt/static_dependencies/ecdsa/_version.py +520 -0
  488. ccxt/static_dependencies/ecdsa/curves.py +56 -0
  489. ccxt/static_dependencies/ecdsa/der.py +221 -0
  490. ccxt/static_dependencies/ecdsa/ecdsa.py +310 -0
  491. ccxt/static_dependencies/ecdsa/ellipticcurve.py +197 -0
  492. ccxt/static_dependencies/ecdsa/keys.py +332 -0
  493. ccxt/static_dependencies/ecdsa/numbertheory.py +531 -0
  494. ccxt/static_dependencies/ecdsa/rfc6979.py +100 -0
  495. ccxt/static_dependencies/ecdsa/util.py +266 -0
  496. ccxt/static_dependencies/ethereum/__init__.py +7 -0
  497. ccxt/static_dependencies/ethereum/abi/__init__.py +16 -0
  498. ccxt/static_dependencies/ethereum/abi/abi.py +19 -0
  499. ccxt/static_dependencies/ethereum/abi/base.py +152 -0
  500. ccxt/static_dependencies/ethereum/abi/codec.py +217 -0
  501. ccxt/static_dependencies/ethereum/abi/constants.py +3 -0
  502. ccxt/static_dependencies/ethereum/abi/decoding.py +565 -0
  503. ccxt/static_dependencies/ethereum/abi/encoding.py +720 -0
  504. ccxt/static_dependencies/ethereum/abi/exceptions.py +139 -0
  505. ccxt/static_dependencies/ethereum/abi/grammar.py +443 -0
  506. ccxt/static_dependencies/ethereum/abi/packed.py +13 -0
  507. ccxt/static_dependencies/ethereum/abi/py.typed +0 -0
  508. ccxt/static_dependencies/ethereum/abi/registry.py +643 -0
  509. ccxt/static_dependencies/ethereum/abi/tools/__init__.py +3 -0
  510. ccxt/static_dependencies/ethereum/abi/tools/_strategies.py +230 -0
  511. ccxt/static_dependencies/ethereum/abi/utils/__init__.py +0 -0
  512. ccxt/static_dependencies/ethereum/abi/utils/numeric.py +83 -0
  513. ccxt/static_dependencies/ethereum/abi/utils/padding.py +27 -0
  514. ccxt/static_dependencies/ethereum/abi/utils/string.py +19 -0
  515. ccxt/static_dependencies/ethereum/account/__init__.py +3 -0
  516. ccxt/static_dependencies/ethereum/account/encode_typed_data/__init__.py +4 -0
  517. ccxt/static_dependencies/ethereum/account/encode_typed_data/encoding_and_hashing.py +239 -0
  518. ccxt/static_dependencies/ethereum/account/encode_typed_data/helpers.py +40 -0
  519. ccxt/static_dependencies/ethereum/account/messages.py +263 -0
  520. ccxt/static_dependencies/ethereum/account/py.typed +0 -0
  521. ccxt/static_dependencies/ethereum/hexbytes/__init__.py +5 -0
  522. ccxt/static_dependencies/ethereum/hexbytes/_utils.py +54 -0
  523. ccxt/static_dependencies/ethereum/hexbytes/main.py +65 -0
  524. ccxt/static_dependencies/ethereum/hexbytes/py.typed +0 -0
  525. ccxt/static_dependencies/ethereum/typing/__init__.py +63 -0
  526. ccxt/static_dependencies/ethereum/typing/abi.py +6 -0
  527. ccxt/static_dependencies/ethereum/typing/bls.py +7 -0
  528. ccxt/static_dependencies/ethereum/typing/discovery.py +5 -0
  529. ccxt/static_dependencies/ethereum/typing/encoding.py +7 -0
  530. ccxt/static_dependencies/ethereum/typing/enums.py +17 -0
  531. ccxt/static_dependencies/ethereum/typing/ethpm.py +9 -0
  532. ccxt/static_dependencies/ethereum/typing/evm.py +20 -0
  533. ccxt/static_dependencies/ethereum/typing/networks.py +1122 -0
  534. ccxt/static_dependencies/ethereum/typing/py.typed +0 -0
  535. ccxt/static_dependencies/ethereum/utils/__init__.py +115 -0
  536. ccxt/static_dependencies/ethereum/utils/abi.py +72 -0
  537. ccxt/static_dependencies/ethereum/utils/address.py +171 -0
  538. ccxt/static_dependencies/ethereum/utils/applicators.py +151 -0
  539. ccxt/static_dependencies/ethereum/utils/conversions.py +190 -0
  540. ccxt/static_dependencies/ethereum/utils/currency.py +107 -0
  541. ccxt/static_dependencies/ethereum/utils/curried/__init__.py +269 -0
  542. ccxt/static_dependencies/ethereum/utils/debug.py +20 -0
  543. ccxt/static_dependencies/ethereum/utils/decorators.py +132 -0
  544. ccxt/static_dependencies/ethereum/utils/encoding.py +6 -0
  545. ccxt/static_dependencies/ethereum/utils/exceptions.py +4 -0
  546. ccxt/static_dependencies/ethereum/utils/functional.py +75 -0
  547. ccxt/static_dependencies/ethereum/utils/hexadecimal.py +74 -0
  548. ccxt/static_dependencies/ethereum/utils/humanize.py +188 -0
  549. ccxt/static_dependencies/ethereum/utils/logging.py +159 -0
  550. ccxt/static_dependencies/ethereum/utils/module_loading.py +31 -0
  551. ccxt/static_dependencies/ethereum/utils/numeric.py +43 -0
  552. ccxt/static_dependencies/ethereum/utils/py.typed +0 -0
  553. ccxt/static_dependencies/ethereum/utils/toolz.py +76 -0
  554. ccxt/static_dependencies/ethereum/utils/types.py +54 -0
  555. ccxt/static_dependencies/ethereum/utils/typing/__init__.py +18 -0
  556. ccxt/static_dependencies/ethereum/utils/typing/misc.py +14 -0
  557. ccxt/static_dependencies/ethereum/utils/units.py +31 -0
  558. ccxt/static_dependencies/keccak/__init__.py +3 -0
  559. ccxt/static_dependencies/keccak/keccak.py +197 -0
  560. ccxt/static_dependencies/lark/__init__.py +38 -0
  561. ccxt/static_dependencies/lark/__pyinstaller/__init__.py +6 -0
  562. ccxt/static_dependencies/lark/__pyinstaller/hook-lark.py +14 -0
  563. ccxt/static_dependencies/lark/ast_utils.py +59 -0
  564. ccxt/static_dependencies/lark/common.py +86 -0
  565. ccxt/static_dependencies/lark/exceptions.py +292 -0
  566. ccxt/static_dependencies/lark/grammar.py +130 -0
  567. ccxt/static_dependencies/lark/grammars/__init__.py +0 -0
  568. ccxt/static_dependencies/lark/indenter.py +143 -0
  569. ccxt/static_dependencies/lark/lark.py +658 -0
  570. ccxt/static_dependencies/lark/lexer.py +678 -0
  571. ccxt/static_dependencies/lark/load_grammar.py +1428 -0
  572. ccxt/static_dependencies/lark/parse_tree_builder.py +391 -0
  573. ccxt/static_dependencies/lark/parser_frontends.py +257 -0
  574. ccxt/static_dependencies/lark/parsers/__init__.py +0 -0
  575. ccxt/static_dependencies/lark/parsers/cyk.py +340 -0
  576. ccxt/static_dependencies/lark/parsers/earley.py +314 -0
  577. ccxt/static_dependencies/lark/parsers/earley_common.py +42 -0
  578. ccxt/static_dependencies/lark/parsers/earley_forest.py +801 -0
  579. ccxt/static_dependencies/lark/parsers/grammar_analysis.py +203 -0
  580. ccxt/static_dependencies/lark/parsers/lalr_analysis.py +332 -0
  581. ccxt/static_dependencies/lark/parsers/lalr_interactive_parser.py +158 -0
  582. ccxt/static_dependencies/lark/parsers/lalr_parser.py +122 -0
  583. ccxt/static_dependencies/lark/parsers/lalr_parser_state.py +110 -0
  584. ccxt/static_dependencies/lark/parsers/xearley.py +165 -0
  585. ccxt/static_dependencies/lark/reconstruct.py +107 -0
  586. ccxt/static_dependencies/lark/tools/__init__.py +70 -0
  587. ccxt/static_dependencies/lark/tools/nearley.py +202 -0
  588. ccxt/static_dependencies/lark/tools/serialize.py +32 -0
  589. ccxt/static_dependencies/lark/tools/standalone.py +196 -0
  590. ccxt/static_dependencies/lark/tree.py +267 -0
  591. ccxt/static_dependencies/lark/tree_matcher.py +186 -0
  592. ccxt/static_dependencies/lark/tree_templates.py +180 -0
  593. ccxt/static_dependencies/lark/utils.py +343 -0
  594. ccxt/static_dependencies/lark/visitors.py +596 -0
  595. ccxt/static_dependencies/marshmallow/__init__.py +81 -0
  596. ccxt/static_dependencies/marshmallow/base.py +65 -0
  597. ccxt/static_dependencies/marshmallow/class_registry.py +94 -0
  598. ccxt/static_dependencies/marshmallow/decorators.py +231 -0
  599. ccxt/static_dependencies/marshmallow/error_store.py +60 -0
  600. ccxt/static_dependencies/marshmallow/exceptions.py +71 -0
  601. ccxt/static_dependencies/marshmallow/fields.py +2114 -0
  602. ccxt/static_dependencies/marshmallow/orderedset.py +89 -0
  603. ccxt/static_dependencies/marshmallow/schema.py +1228 -0
  604. ccxt/static_dependencies/marshmallow/types.py +12 -0
  605. ccxt/static_dependencies/marshmallow/utils.py +378 -0
  606. ccxt/static_dependencies/marshmallow/validate.py +678 -0
  607. ccxt/static_dependencies/marshmallow/warnings.py +2 -0
  608. ccxt/static_dependencies/marshmallow_dataclass/__init__.py +1047 -0
  609. ccxt/static_dependencies/marshmallow_dataclass/collection_field.py +51 -0
  610. ccxt/static_dependencies/marshmallow_dataclass/lazy_class_attribute.py +45 -0
  611. ccxt/static_dependencies/marshmallow_dataclass/mypy.py +71 -0
  612. ccxt/static_dependencies/marshmallow_dataclass/typing.py +14 -0
  613. ccxt/static_dependencies/marshmallow_dataclass/union_field.py +82 -0
  614. ccxt/static_dependencies/marshmallow_oneofschema/__init__.py +1 -0
  615. ccxt/static_dependencies/marshmallow_oneofschema/one_of_schema.py +193 -0
  616. ccxt/static_dependencies/msgpack/__init__.py +55 -0
  617. ccxt/static_dependencies/msgpack/exceptions.py +48 -0
  618. ccxt/static_dependencies/msgpack/ext.py +168 -0
  619. ccxt/static_dependencies/msgpack/fallback.py +951 -0
  620. ccxt/static_dependencies/parsimonious/__init__.py +10 -0
  621. ccxt/static_dependencies/parsimonious/exceptions.py +105 -0
  622. ccxt/static_dependencies/parsimonious/expressions.py +479 -0
  623. ccxt/static_dependencies/parsimonious/grammar.py +487 -0
  624. ccxt/static_dependencies/parsimonious/nodes.py +325 -0
  625. ccxt/static_dependencies/parsimonious/utils.py +40 -0
  626. ccxt/static_dependencies/starknet/__init__.py +0 -0
  627. ccxt/static_dependencies/starknet/cairo/__init__.py +0 -0
  628. ccxt/static_dependencies/starknet/cairo/data_types.py +123 -0
  629. ccxt/static_dependencies/starknet/cairo/deprecated_parse/__init__.py +0 -0
  630. ccxt/static_dependencies/starknet/cairo/deprecated_parse/cairo_types.py +77 -0
  631. ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser.py +46 -0
  632. ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser_transformer.py +138 -0
  633. ccxt/static_dependencies/starknet/cairo/felt.py +64 -0
  634. ccxt/static_dependencies/starknet/cairo/type_parser.py +121 -0
  635. ccxt/static_dependencies/starknet/cairo/v1/__init__.py +0 -0
  636. ccxt/static_dependencies/starknet/cairo/v1/type_parser.py +59 -0
  637. ccxt/static_dependencies/starknet/cairo/v2/__init__.py +0 -0
  638. ccxt/static_dependencies/starknet/cairo/v2/type_parser.py +77 -0
  639. ccxt/static_dependencies/starknet/ccxt_utils.py +7 -0
  640. ccxt/static_dependencies/starknet/common.py +15 -0
  641. ccxt/static_dependencies/starknet/constants.py +39 -0
  642. ccxt/static_dependencies/starknet/hash/__init__.py +0 -0
  643. ccxt/static_dependencies/starknet/hash/address.py +79 -0
  644. ccxt/static_dependencies/starknet/hash/compiled_class_hash_objects.py +111 -0
  645. ccxt/static_dependencies/starknet/hash/selector.py +16 -0
  646. ccxt/static_dependencies/starknet/hash/storage.py +12 -0
  647. ccxt/static_dependencies/starknet/hash/utils.py +78 -0
  648. ccxt/static_dependencies/starknet/models/__init__.py +0 -0
  649. ccxt/static_dependencies/starknet/models/typed_data.py +45 -0
  650. ccxt/static_dependencies/starknet/serialization/__init__.py +24 -0
  651. ccxt/static_dependencies/starknet/serialization/_calldata_reader.py +40 -0
  652. ccxt/static_dependencies/starknet/serialization/_context.py +142 -0
  653. ccxt/static_dependencies/starknet/serialization/data_serializers/__init__.py +10 -0
  654. ccxt/static_dependencies/starknet/serialization/data_serializers/_common.py +82 -0
  655. ccxt/static_dependencies/starknet/serialization/data_serializers/array_serializer.py +43 -0
  656. ccxt/static_dependencies/starknet/serialization/data_serializers/bool_serializer.py +37 -0
  657. ccxt/static_dependencies/starknet/serialization/data_serializers/byte_array_serializer.py +66 -0
  658. ccxt/static_dependencies/starknet/serialization/data_serializers/cairo_data_serializer.py +71 -0
  659. ccxt/static_dependencies/starknet/serialization/data_serializers/enum_serializer.py +71 -0
  660. ccxt/static_dependencies/starknet/serialization/data_serializers/felt_serializer.py +50 -0
  661. ccxt/static_dependencies/starknet/serialization/data_serializers/named_tuple_serializer.py +58 -0
  662. ccxt/static_dependencies/starknet/serialization/data_serializers/option_serializer.py +43 -0
  663. ccxt/static_dependencies/starknet/serialization/data_serializers/output_serializer.py +40 -0
  664. ccxt/static_dependencies/starknet/serialization/data_serializers/payload_serializer.py +72 -0
  665. ccxt/static_dependencies/starknet/serialization/data_serializers/struct_serializer.py +36 -0
  666. ccxt/static_dependencies/starknet/serialization/data_serializers/tuple_serializer.py +36 -0
  667. ccxt/static_dependencies/starknet/serialization/data_serializers/uint256_serializer.py +76 -0
  668. ccxt/static_dependencies/starknet/serialization/data_serializers/uint_serializer.py +100 -0
  669. ccxt/static_dependencies/starknet/serialization/data_serializers/unit_serializer.py +32 -0
  670. ccxt/static_dependencies/starknet/serialization/errors.py +10 -0
  671. ccxt/static_dependencies/starknet/serialization/factory.py +229 -0
  672. ccxt/static_dependencies/starknet/serialization/function_serialization_adapter.py +110 -0
  673. ccxt/static_dependencies/starknet/serialization/tuple_dataclass.py +59 -0
  674. ccxt/static_dependencies/starknet/utils/__init__.py +0 -0
  675. ccxt/static_dependencies/starknet/utils/constructor_args_translator.py +86 -0
  676. ccxt/static_dependencies/starknet/utils/iterable.py +13 -0
  677. ccxt/static_dependencies/starknet/utils/schema.py +13 -0
  678. ccxt/static_dependencies/starknet/utils/typed_data.py +182 -0
  679. ccxt/static_dependencies/starkware/__init__.py +0 -0
  680. ccxt/static_dependencies/starkware/crypto/__init__.py +0 -0
  681. ccxt/static_dependencies/starkware/crypto/fast_pedersen_hash.py +50 -0
  682. ccxt/static_dependencies/starkware/crypto/math_utils.py +78 -0
  683. ccxt/static_dependencies/starkware/crypto/signature.py +2344 -0
  684. ccxt/static_dependencies/starkware/crypto/utils.py +63 -0
  685. ccxt/static_dependencies/sympy/__init__.py +0 -0
  686. ccxt/static_dependencies/sympy/core/__init__.py +0 -0
  687. ccxt/static_dependencies/sympy/core/intfunc.py +35 -0
  688. ccxt/static_dependencies/sympy/external/__init__.py +0 -0
  689. ccxt/static_dependencies/sympy/external/gmpy.py +345 -0
  690. ccxt/static_dependencies/sympy/external/importtools.py +187 -0
  691. ccxt/static_dependencies/sympy/external/ntheory.py +637 -0
  692. ccxt/static_dependencies/sympy/external/pythonmpq.py +341 -0
  693. ccxt/static_dependencies/toolz/__init__.py +26 -0
  694. ccxt/static_dependencies/toolz/_signatures.py +784 -0
  695. ccxt/static_dependencies/toolz/_version.py +520 -0
  696. ccxt/static_dependencies/toolz/compatibility.py +30 -0
  697. ccxt/static_dependencies/toolz/curried/__init__.py +101 -0
  698. ccxt/static_dependencies/toolz/curried/exceptions.py +22 -0
  699. ccxt/static_dependencies/toolz/curried/operator.py +22 -0
  700. ccxt/static_dependencies/toolz/dicttoolz.py +339 -0
  701. ccxt/static_dependencies/toolz/functoolz.py +1049 -0
  702. ccxt/static_dependencies/toolz/itertoolz.py +1057 -0
  703. ccxt/static_dependencies/toolz/recipes.py +46 -0
  704. ccxt/static_dependencies/toolz/utils.py +9 -0
  705. ccxt/static_dependencies/typing_inspect/__init__.py +0 -0
  706. ccxt/static_dependencies/typing_inspect/typing_inspect.py +851 -0
  707. ccxt/tabdeal.py +364 -0
  708. ccxt/test/__init__.py +3 -0
  709. ccxt/test/base/__init__.py +29 -0
  710. ccxt/test/base/test_account.py +26 -0
  711. ccxt/test/base/test_balance.py +56 -0
  712. ccxt/test/base/test_borrow_interest.py +35 -0
  713. ccxt/test/base/test_borrow_rate.py +32 -0
  714. ccxt/test/base/test_calculate_fee.py +51 -0
  715. ccxt/test/base/test_crypto.py +127 -0
  716. ccxt/test/base/test_currency.py +76 -0
  717. ccxt/test/base/test_datetime.py +109 -0
  718. ccxt/test/base/test_decimal_to_precision.py +392 -0
  719. ccxt/test/base/test_deep_extend.py +68 -0
  720. ccxt/test/base/test_deposit_withdrawal.py +50 -0
  721. ccxt/test/base/test_exchange_datetime_functions.py +76 -0
  722. ccxt/test/base/test_funding_rate_history.py +29 -0
  723. ccxt/test/base/test_last_price.py +31 -0
  724. ccxt/test/base/test_ledger_entry.py +45 -0
  725. ccxt/test/base/test_ledger_item.py +48 -0
  726. ccxt/test/base/test_leverage_tier.py +33 -0
  727. ccxt/test/base/test_liquidation.py +50 -0
  728. ccxt/test/base/test_margin_mode.py +24 -0
  729. ccxt/test/base/test_margin_modification.py +35 -0
  730. ccxt/test/base/test_market.py +193 -0
  731. ccxt/test/base/test_number.py +411 -0
  732. ccxt/test/base/test_ohlcv.py +33 -0
  733. ccxt/test/base/test_open_interest.py +32 -0
  734. ccxt/test/base/test_order.py +64 -0
  735. ccxt/test/base/test_order_book.py +69 -0
  736. ccxt/test/base/test_position.py +60 -0
  737. ccxt/test/base/test_shared_methods.py +353 -0
  738. ccxt/test/base/test_status.py +24 -0
  739. ccxt/test/base/test_throttle.py +126 -0
  740. ccxt/test/base/test_ticker.py +92 -0
  741. ccxt/test/base/test_trade.py +47 -0
  742. ccxt/test/base/test_trading_fee.py +26 -0
  743. ccxt/test/base/test_transaction.py +39 -0
  744. ccxt/test/test_async.py +1649 -0
  745. ccxt/test/test_sync.py +1648 -0
  746. ccxt/test/tests_async.py +1558 -0
  747. ccxt/test/tests_helpers.py +287 -0
  748. ccxt/test/tests_init.py +39 -0
  749. ccxt/test/tests_sync.py +1555 -0
  750. ccxt/tetherland.py +349 -0
  751. ccxt/timex.py +1593 -0
  752. ccxt/tokocrypto.py +2405 -0
  753. ccxt/tradeogre.py +608 -0
  754. ccxt/twox.py +326 -0
  755. ccxt/ubitex.py +409 -0
  756. ccxt/upbit.py +1833 -0
  757. ccxt/vertex.py +2922 -0
  758. ccxt/wallex.py +445 -0
  759. ccxt/wavesexchange.py +2472 -0
  760. ccxt/wazirx.py +1224 -0
  761. ccxt/whitebit.py +2469 -0
  762. ccxt/woo.py +3114 -0
  763. ccxt/woofipro.py +2533 -0
  764. ccxt/xt.py +4453 -0
  765. ccxt/yobit.py +1283 -0
  766. ccxt/zaif.py +725 -0
  767. ccxt/zonda.py +1828 -0
  768. ccxt_ir-4.3.46.0.1.dist-info/LICENSE.txt +21 -0
  769. ccxt_ir-4.3.46.0.1.dist-info/METADATA +655 -0
  770. ccxt_ir-4.3.46.0.1.dist-info/RECORD +772 -0
  771. ccxt_ir-4.3.46.0.1.dist-info/WHEEL +6 -0
  772. ccxt_ir-4.3.46.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,2015 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+
6
+ from ccxt.async_support.base.exchange import Exchange
7
+ from ccxt.abstract.paradex import ImplicitAPI
8
+ from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
9
+ from typing import List
10
+ from ccxt.base.errors import ExchangeError
11
+ from ccxt.base.errors import AuthenticationError
12
+ from ccxt.base.errors import PermissionDenied
13
+ from ccxt.base.errors import ArgumentsRequired
14
+ from ccxt.base.errors import BadRequest
15
+ from ccxt.base.errors import OperationRejected
16
+ from ccxt.base.errors import InvalidOrder
17
+ from ccxt.base.decimal_to_precision import TICK_SIZE
18
+ from ccxt.base.precise import Precise
19
+
20
+
21
+ class paradex(Exchange, ImplicitAPI):
22
+
23
+ def describe(self):
24
+ return self.deep_extend(super(paradex, self).describe(), {
25
+ 'id': 'paradex',
26
+ 'name': 'Paradex',
27
+ 'countries': [],
28
+ 'version': 'v1',
29
+ 'rateLimit': 50,
30
+ 'certified': False,
31
+ 'pro': True,
32
+ 'dex': True,
33
+ 'has': {
34
+ 'CORS': None,
35
+ 'spot': False,
36
+ 'margin': False,
37
+ 'swap': True,
38
+ 'future': False,
39
+ 'option': False,
40
+ 'addMargin': False,
41
+ 'borrowCrossMargin': False,
42
+ 'borrowIsolatedMargin': False,
43
+ 'cancelAllOrders': True,
44
+ 'cancelAllOrdersAfter': False,
45
+ 'cancelOrder': False,
46
+ 'cancelOrders': False,
47
+ 'cancelOrdersForSymbols': False,
48
+ 'closeAllPositions': False,
49
+ 'closePosition': False,
50
+ 'createMarketBuyOrderWithCost': False,
51
+ 'createMarketOrderWithCost': False,
52
+ 'createMarketSellOrderWithCost': False,
53
+ 'createOrder': True,
54
+ 'createOrders': False,
55
+ 'createReduceOnlyOrder': False,
56
+ 'editOrder': False,
57
+ 'fetchAccounts': False,
58
+ 'fetchBalance': True,
59
+ 'fetchBorrowInterest': False,
60
+ 'fetchBorrowRateHistories': False,
61
+ 'fetchBorrowRateHistory': False,
62
+ 'fetchCanceledOrders': False,
63
+ 'fetchClosedOrders': False,
64
+ 'fetchCrossBorrowRate': False,
65
+ 'fetchCrossBorrowRates': False,
66
+ 'fetchCurrencies': False,
67
+ 'fetchDepositAddress': False,
68
+ 'fetchDepositAddresses': False,
69
+ 'fetchDeposits': True,
70
+ 'fetchDepositWithdrawFee': False,
71
+ 'fetchDepositWithdrawFees': False,
72
+ 'fetchFundingHistory': False,
73
+ 'fetchFundingRate': False,
74
+ 'fetchFundingRateHistory': False,
75
+ 'fetchFundingRates': False,
76
+ 'fetchIndexOHLCV': False,
77
+ 'fetchIsolatedBorrowRate': False,
78
+ 'fetchIsolatedBorrowRates': False,
79
+ 'fetchLedger': False,
80
+ 'fetchLeverage': False,
81
+ 'fetchLeverageTiers': False,
82
+ 'fetchLiquidations': True,
83
+ 'fetchMarginMode': None,
84
+ 'fetchMarketLeverageTiers': False,
85
+ 'fetchMarkets': True,
86
+ 'fetchMarkOHLCV': False,
87
+ 'fetchMyLiquidations': False,
88
+ 'fetchMyTrades': True,
89
+ 'fetchOHLCV': True,
90
+ 'fetchOpenInterest': True,
91
+ 'fetchOpenInterestHistory': False,
92
+ 'fetchOpenOrders': True,
93
+ 'fetchOrder': True,
94
+ 'fetchOrderBook': True,
95
+ 'fetchOrders': True,
96
+ 'fetchOrderTrades': False,
97
+ 'fetchPosition': True,
98
+ 'fetchPositionMode': False,
99
+ 'fetchPositions': True,
100
+ 'fetchPositionsRisk': False,
101
+ 'fetchPremiumIndexOHLCV': False,
102
+ 'fetchStatus': True,
103
+ 'fetchTicker': True,
104
+ 'fetchTickers': True,
105
+ 'fetchTime': True,
106
+ 'fetchTrades': True,
107
+ 'fetchTradingFee': False,
108
+ 'fetchTradingFees': False,
109
+ 'fetchTransfer': False,
110
+ 'fetchTransfers': False,
111
+ 'fetchWithdrawal': False,
112
+ 'fetchWithdrawals': True,
113
+ 'reduceMargin': False,
114
+ 'repayCrossMargin': False,
115
+ 'repayIsolatedMargin': False,
116
+ 'sandbox': True,
117
+ 'setLeverage': False,
118
+ 'setMarginMode': False,
119
+ 'setPositionMode': False,
120
+ 'transfer': False,
121
+ 'withdraw': False,
122
+ },
123
+ 'timeframes': {
124
+ '1m': 1,
125
+ '3m': 3,
126
+ '5m': 5,
127
+ '15m': 15,
128
+ '30m': 30,
129
+ '1h': 60,
130
+ },
131
+ 'hostname': 'paradex.trade',
132
+ 'urls': {
133
+ 'logo': 'https://github.com/user-attachments/assets/84628770-784e-4ec4-a759-ec2fbb2244ea',
134
+ 'api': {
135
+ 'v1': 'https://api.prod.{hostname}/v1',
136
+ },
137
+ 'test': {
138
+ 'v1': 'https://api.testnet.{hostname}/v1',
139
+ },
140
+ 'www': 'https://www.paradex.trade/',
141
+ 'doc': 'https://docs.api.testnet.paradex.trade/',
142
+ 'fees': 'https://docs.paradex.trade/getting-started/trading-fees',
143
+ 'referral': 'https://app.paradex.trade/r/ccxt24',
144
+ },
145
+ 'api': {
146
+ 'public': {
147
+ 'get': {
148
+ 'bbo/{market}': 1,
149
+ 'funding/data': 1,
150
+ 'markets': 1,
151
+ 'markets/klines': 1,
152
+ 'markets/summary': 1,
153
+ 'orderbook/{market}': 1,
154
+ 'insurance': 1,
155
+ 'referrals/config': 1,
156
+ 'system/config': 1,
157
+ 'system/state': 1,
158
+ 'system/time': 1,
159
+ 'trades': 1,
160
+ },
161
+ },
162
+ 'private': {
163
+ 'get': {
164
+ 'account': 1,
165
+ 'account/profile': 1,
166
+ 'balance': 1,
167
+ 'fills': 1,
168
+ 'funding/payments': 1,
169
+ 'positions': 1,
170
+ 'tradebusts': 1,
171
+ 'transactions': 1,
172
+ 'liquidations': 1,
173
+ 'orders': 1,
174
+ 'orders-history': 1,
175
+ 'orders/by_client_id/{client_id}': 1,
176
+ 'orders/{order_id}': 1,
177
+ 'points_data/{market}/{program}': 1,
178
+ 'referrals/summary': 1,
179
+ 'transfers': 1,
180
+ },
181
+ 'post': {
182
+ 'account/profile/referral_code': 1,
183
+ 'account/profile/username': 1,
184
+ 'auth': 1,
185
+ 'onboarding': 1,
186
+ 'orders': 1,
187
+ },
188
+ 'delete': {
189
+ 'orders': 1,
190
+ 'orders/by_client_id/{client_id}': 1,
191
+ 'orders/{order_id}': 1,
192
+ },
193
+ },
194
+ },
195
+ 'fees': {
196
+ 'swap': {
197
+ 'taker': self.parse_number('0.0002'),
198
+ 'maker': self.parse_number('0.0002'),
199
+ },
200
+ 'spot': {
201
+ 'taker': self.parse_number('0.0002'),
202
+ 'maker': self.parse_number('0.0002'),
203
+ },
204
+ },
205
+ 'requiredCredentials': {
206
+ 'apiKey': False,
207
+ 'secret': False,
208
+ 'walletAddress': True,
209
+ 'privateKey': True,
210
+ },
211
+ 'exceptions': {
212
+ 'exact': {
213
+ 'VALIDATION_ERROR': AuthenticationError,
214
+ 'BINDING_ERROR': OperationRejected,
215
+ 'INTERNAL_ERROR': ExchangeError,
216
+ 'NOT_FOUND': BadRequest,
217
+ 'SERVICE_UNAVAILABLE': ExchangeError,
218
+ 'INVALID_REQUEST_PARAMETER': BadRequest,
219
+ 'ORDER_ID_NOT_FOUND': InvalidOrder,
220
+ 'ORDER_IS_CLOSED': InvalidOrder,
221
+ 'ORDER_IS_NOT_OPEN_YET': InvalidOrder,
222
+ 'CLIENT_ORDER_ID_NOT_FOUND': InvalidOrder,
223
+ 'DUPLICATED_CLIENT_ID': InvalidOrder,
224
+ 'INVALID_PRICE_PRECISION': OperationRejected,
225
+ 'INVALID_SYMBOL': OperationRejected,
226
+ 'INVALID_TOKEN': OperationRejected,
227
+ 'INVALID_ETHEREUM_ADDRESS': OperationRejected,
228
+ 'INVALID_ETHEREUM_SIGNATURE': OperationRejected,
229
+ 'INVALID_STARKNET_ADDRESS': OperationRejected,
230
+ 'INVALID_STARKNET_SIGNATURE': OperationRejected,
231
+ 'STARKNET_SIGNATURE_VERIFICATION_FAILED': AuthenticationError,
232
+ 'BAD_STARKNET_REQUEST': BadRequest,
233
+ 'ETHEREUM_SIGNER_MISMATCH': BadRequest,
234
+ 'ETHEREUM_HASH_MISMATCH': BadRequest,
235
+ 'NOT_ONBOARDED': BadRequest,
236
+ 'INVALID_TIMESTAMP': BadRequest,
237
+ 'INVALID_SIGNATURE_EXPIRATION': AuthenticationError,
238
+ 'ACCOUNT_NOT_FOUND': AuthenticationError,
239
+ 'INVALID_ORDER_SIGNATURE': AuthenticationError,
240
+ 'PUBLIC_KEY_INVALID': BadRequest,
241
+ 'UNAUTHORIZED_ETHEREUM_ADDRESS': BadRequest,
242
+ 'ETHEREUM_ADDRESS_ALREADY_ONBOARDED': BadRequest,
243
+ 'MARKET_NOT_FOUND': BadRequest,
244
+ 'ALLOWLIST_ENTRY_NOT_FOUND': BadRequest,
245
+ 'USERNAME_IN_USE': AuthenticationError,
246
+ 'GEO_IP_BLOCK': PermissionDenied,
247
+ 'ETHEREUM_ADDRESS_BLOCKED': PermissionDenied,
248
+ 'PROGRAM_NOT_FOUND': BadRequest,
249
+ 'INVALID_DASHBOARD': OperationRejected,
250
+ 'MARKET_NOT_OPEN': BadRequest,
251
+ 'INVALID_REFERRAL_CODE': OperationRejected,
252
+ 'PARENT_ADDRESS_ALREADY_ONBOARDED': BadRequest,
253
+ 'INVALID_PARENT_ACCOUNT': OperationRejected,
254
+ 'INVALID_VAULT_OPERATOR_CHAIN': OperationRejected,
255
+ 'VAULT_OPERATOR_ALREADY_ONBOARDED': OperationRejected,
256
+ 'VAULT_NAME_IN_USE': OperationRejected,
257
+ 'BATCH_SIZE_OUT_OF_RANGE': OperationRejected,
258
+ 'ISOLATED_MARKET_ACCOUNT_MISMATCH': OperationRejected,
259
+ 'POINTS_SUMMARY_NOT_FOUND': OperationRejected,
260
+ '-32700': BadRequest, # Parse error
261
+ '-32600': BadRequest, # Invalid request
262
+ '-32601': BadRequest, # Method not found
263
+ '-32602': BadRequest, # Invalid parameterss
264
+ '-32603': ExchangeError, # Internal error
265
+ '100': BadRequest, # Method error
266
+ '40110': AuthenticationError, # Malformed Bearer Token
267
+ '40111': AuthenticationError, # Invalid Bearer Token
268
+ '40112': PermissionDenied, # Geo IP blocked
269
+ },
270
+ 'broad': {
271
+ },
272
+ },
273
+ 'precisionMode': TICK_SIZE,
274
+ 'commonCurrencies': {
275
+ },
276
+ 'options': {
277
+ 'broker': 'CCXT',
278
+ },
279
+ })
280
+
281
+ async def fetch_time(self, params={}):
282
+ """
283
+ fetches the current integer timestamp in milliseconds from the exchange server
284
+
285
+ https://docs.api.testnet.paradex.trade/#get-system-time-unix-milliseconds
286
+
287
+ :param dict [params]: extra parameters specific to the exchange API endpoint
288
+ :returns int: the current integer timestamp in milliseconds from the exchange server
289
+ """
290
+ response = await self.publicGetSystemTime(params)
291
+ #
292
+ # {
293
+ # "server_time": "1681493415023"
294
+ # }
295
+ #
296
+ return self.safe_integer(response, 'server_time')
297
+
298
+ async def fetch_status(self, params={}):
299
+ """
300
+ the latest known information on the availability of the exchange API
301
+
302
+ https://docs.api.testnet.paradex.trade/#get-system-state
303
+
304
+ :param dict [params]: extra parameters specific to the exchange API endpoint
305
+ :returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
306
+ """
307
+ response = await self.publicGetSystemState(params)
308
+ #
309
+ # {
310
+ # "status": "ok"
311
+ # }
312
+ #
313
+ status = self.safe_string(response, 'status')
314
+ return {
315
+ 'status': 'ok' if (status == 'ok') else 'maintenance',
316
+ 'updated': None,
317
+ 'eta': None,
318
+ 'url': None,
319
+ 'info': response,
320
+ }
321
+
322
+ async def fetch_markets(self, params={}) -> List[Market]:
323
+ """
324
+ retrieves data on all markets for bitget
325
+
326
+ https://docs.api.testnet.paradex.trade/#list-available-markets
327
+
328
+ :param dict [params]: extra parameters specific to the exchange API endpoint
329
+ :returns dict[]: an array of objects representing market data
330
+ """
331
+ response = await self.publicGetMarkets(params)
332
+ #
333
+ # {
334
+ # "results": [
335
+ # {
336
+ # "symbol": "BODEN-USD-PERP",
337
+ # "base_currency": "BODEN",
338
+ # "quote_currency": "USD",
339
+ # "settlement_currency": "USDC",
340
+ # "order_size_increment": "1",
341
+ # "price_tick_size": "0.00001",
342
+ # "min_notional": "200",
343
+ # "open_at": 1717065600000,
344
+ # "expiry_at": 0,
345
+ # "asset_kind": "PERP",
346
+ # "position_limit": "2000000",
347
+ # "price_bands_width": "0.2",
348
+ # "max_open_orders": 50,
349
+ # "max_funding_rate": "0.05",
350
+ # "delta1_cross_margin_params": {
351
+ # "imf_base": "0.2",
352
+ # "imf_shift": "180000",
353
+ # "imf_factor": "0.00071",
354
+ # "mmf_factor": "0.5"
355
+ # },
356
+ # "price_feed_id": "9LScEHse1ioZt2rUuhwiN6bmYnqpMqvZkQJDNUpxVHN5",
357
+ # "oracle_ewma_factor": "0.14999987905913592",
358
+ # "max_order_size": "520000",
359
+ # "max_funding_rate_change": "0.0005",
360
+ # "max_tob_spread": "0.2"
361
+ # }
362
+ # ]
363
+ # }
364
+ #
365
+ data = self.safe_list(response, 'results')
366
+ return self.parse_markets(data)
367
+
368
+ def parse_market(self, market: dict) -> Market:
369
+ #
370
+ # {
371
+ # "symbol": "BODEN-USD-PERP",
372
+ # "base_currency": "BODEN",
373
+ # "quote_currency": "USD",
374
+ # "settlement_currency": "USDC",
375
+ # "order_size_increment": "1",
376
+ # "price_tick_size": "0.00001",
377
+ # "min_notional": "200",
378
+ # "open_at": 1717065600000,
379
+ # "expiry_at": 0,
380
+ # "asset_kind": "PERP",
381
+ # "position_limit": "2000000",
382
+ # "price_bands_width": "0.2",
383
+ # "max_open_orders": 50,
384
+ # "max_funding_rate": "0.05",
385
+ # "delta1_cross_margin_params": {
386
+ # "imf_base": "0.2",
387
+ # "imf_shift": "180000",
388
+ # "imf_factor": "0.00071",
389
+ # "mmf_factor": "0.5"
390
+ # },
391
+ # "price_feed_id": "9LScEHse1ioZt2rUuhwiN6bmYnqpMqvZkQJDNUpxVHN5",
392
+ # "oracle_ewma_factor": "0.14999987905913592",
393
+ # "max_order_size": "520000",
394
+ # "max_funding_rate_change": "0.0005",
395
+ # "max_tob_spread": "0.2"
396
+ # }
397
+ #
398
+ marketId = self.safe_string(market, 'symbol')
399
+ quoteId = self.safe_string(market, 'quote_currency')
400
+ baseId = self.safe_string(market, 'base_currency')
401
+ quote = self.safe_currency_code(quoteId)
402
+ base = self.safe_currency_code(baseId)
403
+ settleId = self.safe_string(market, 'settlement_currency')
404
+ settle = self.safe_currency_code(settleId)
405
+ symbol = base + '/' + quote + ':' + settle
406
+ expiry = self.safe_integer(market, 'expiry_at')
407
+ takerFee = self.parse_number('0.0003')
408
+ makerFee = self.parse_number('-0.00005')
409
+ return self.safe_market_structure({
410
+ 'id': marketId,
411
+ 'symbol': symbol,
412
+ 'base': base,
413
+ 'quote': quote,
414
+ 'settle': settle,
415
+ 'baseId': baseId,
416
+ 'quoteId': quoteId,
417
+ 'settleId': settleId,
418
+ 'type': 'swap',
419
+ 'spot': False,
420
+ 'margin': None,
421
+ 'swap': True,
422
+ 'future': False,
423
+ 'option': False,
424
+ 'active': self.safe_bool(market, 'enableTrading'),
425
+ 'contract': True,
426
+ 'linear': True,
427
+ 'inverse': None,
428
+ 'taker': takerFee,
429
+ 'maker': makerFee,
430
+ 'contractSize': self.parse_number('1'),
431
+ 'expiry': None if (expiry == 0) else expiry,
432
+ 'expiryDatetime': None if (expiry == 0) else self.iso8601(expiry),
433
+ 'strike': None,
434
+ 'optionType': None,
435
+ 'precision': {
436
+ 'amount': self.safe_number(market, 'order_size_increment'),
437
+ 'price': self.safe_number(market, 'price_tick_size'),
438
+ },
439
+ 'limits': {
440
+ 'leverage': {
441
+ 'min': None,
442
+ 'max': None,
443
+ },
444
+ 'amount': {
445
+ 'min': None,
446
+ 'max': self.safe_number(market, 'max_order_size'),
447
+ },
448
+ 'price': {
449
+ 'min': None,
450
+ 'max': None,
451
+ },
452
+ 'cost': {
453
+ 'min': self.safe_number(market, 'min_notional'),
454
+ 'max': None,
455
+ },
456
+ },
457
+ 'created': None,
458
+ 'info': market,
459
+ })
460
+
461
+ async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
462
+ """
463
+ fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
464
+
465
+ https://docs.api.testnet.paradex.trade/#ohlcv-for-a-symbol
466
+
467
+ :param str symbol: unified symbol of the market to fetch OHLCV data for
468
+ :param str timeframe: the length of time each candle represents
469
+ :param int [since]: timestamp in ms of the earliest candle to fetch
470
+ :param int [limit]: the maximum amount of candles to fetch
471
+ :param dict [params]: extra parameters specific to the exchange API endpoint
472
+ :param int [params.until]: timestamp in ms of the latest candle to fetch
473
+ :returns int[][]: A list of candles ordered, open, high, low, close, volume
474
+ """
475
+ await self.load_markets()
476
+ market = self.market(symbol)
477
+ request: dict = {
478
+ 'resolution': self.safe_string(self.timeframes, timeframe, timeframe),
479
+ 'symbol': market['id'],
480
+ }
481
+ now = self.milliseconds()
482
+ duration = self.parse_timeframe(timeframe)
483
+ until = self.safe_integer_2(params, 'until', 'till', now)
484
+ params = self.omit(params, ['until', 'till'])
485
+ if since is not None:
486
+ request['start_at'] = since
487
+ if limit is not None:
488
+ request['end_at'] = self.sum(since, duration * (limit + 1) * 1000) - 1
489
+ else:
490
+ request['end_at'] = until
491
+ else:
492
+ request['end_at'] = until
493
+ if limit is not None:
494
+ request['start_at'] = until - duration * (limit + 1) * 1000 + 1
495
+ else:
496
+ request['start_at'] = until - duration * 101 * 1000 + 1
497
+ response = await self.publicGetMarketsKlines(self.extend(request, params))
498
+ #
499
+ # {
500
+ # "results": [
501
+ # [
502
+ # 1720071900000,
503
+ # 58961.3,
504
+ # 58961.3,
505
+ # 58961.3,
506
+ # 58961.3,
507
+ # 1591
508
+ # ]
509
+ # ]
510
+ # }
511
+ #
512
+ data = self.safe_list(response, 'results', [])
513
+ return self.parse_ohlcvs(data, market, timeframe, since, limit)
514
+
515
+ def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
516
+ #
517
+ # [
518
+ # 1720071900000,
519
+ # 58961.3,
520
+ # 58961.3,
521
+ # 58961.3,
522
+ # 58961.3,
523
+ # 1591
524
+ # ]
525
+ #
526
+ return [
527
+ self.safe_integer(ohlcv, 0),
528
+ self.safe_number(ohlcv, 1),
529
+ self.safe_number(ohlcv, 2),
530
+ self.safe_number(ohlcv, 3),
531
+ self.safe_number(ohlcv, 4),
532
+ self.safe_number(ohlcv, 5),
533
+ ]
534
+
535
+ async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
536
+ """
537
+ fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
538
+
539
+ https://docs.api.testnet.paradex.trade/#list-available-markets-summary
540
+
541
+ :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
542
+ :param dict [params]: extra parameters specific to the exchange API endpoint
543
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
544
+ """
545
+ await self.load_markets()
546
+ symbols = self.market_symbols(symbols)
547
+ request: dict = {}
548
+ if symbols is not None:
549
+ if isinstance(symbols, list):
550
+ request['market'] = self.market_id(symbols[0])
551
+ else:
552
+ request['market'] = self.market_id(symbols)
553
+ else:
554
+ request['market'] = 'ALL'
555
+ response = await self.publicGetMarketsSummary(self.extend(request, params))
556
+ #
557
+ # {
558
+ # "results": [
559
+ # {
560
+ # "symbol": "BTC-USD-PERP",
561
+ # "oracle_price": "68465.17449906",
562
+ # "mark_price": "68465.17449906",
563
+ # "last_traded_price": "68495.1",
564
+ # "bid": "68477.6",
565
+ # "ask": "69578.2",
566
+ # "volume_24h": "5815541.397939004",
567
+ # "total_volume": "584031465.525259686",
568
+ # "created_at": 1718170156580,
569
+ # "underlying_price": "67367.37268422",
570
+ # "open_interest": "162.272",
571
+ # "funding_rate": "0.01629574927887",
572
+ # "price_change_rate_24h": "0.009032"
573
+ # }
574
+ # ]
575
+ # }
576
+ #
577
+ data = self.safe_list(response, 'results', [])
578
+ return self.parse_tickers(data, symbols)
579
+
580
+ async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
581
+ """
582
+ fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
583
+
584
+ https://docs.api.testnet.paradex.trade/#list-available-markets-summary
585
+
586
+ :param str symbol: unified symbol of the market to fetch the ticker for
587
+ :param dict [params]: extra parameters specific to the exchange API endpoint
588
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
589
+ """
590
+ await self.load_markets()
591
+ market = self.market(symbol)
592
+ request: dict = {
593
+ 'market': market['id'],
594
+ }
595
+ response = await self.publicGetMarketsSummary(self.extend(request, params))
596
+ #
597
+ # {
598
+ # "results": [
599
+ # {
600
+ # "symbol": "BTC-USD-PERP",
601
+ # "oracle_price": "68465.17449906",
602
+ # "mark_price": "68465.17449906",
603
+ # "last_traded_price": "68495.1",
604
+ # "bid": "68477.6",
605
+ # "ask": "69578.2",
606
+ # "volume_24h": "5815541.397939004",
607
+ # "total_volume": "584031465.525259686",
608
+ # "created_at": 1718170156580,
609
+ # "underlying_price": "67367.37268422",
610
+ # "open_interest": "162.272",
611
+ # "funding_rate": "0.01629574927887",
612
+ # "price_change_rate_24h": "0.009032"
613
+ # }
614
+ # ]
615
+ # }
616
+ #
617
+ data = self.safe_list(response, 'results', [])
618
+ ticker = self.safe_dict(data, 0, {})
619
+ return self.parse_ticker(ticker, market)
620
+
621
+ def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
622
+ #
623
+ # {
624
+ # "symbol": "BTC-USD-PERP",
625
+ # "oracle_price": "68465.17449906",
626
+ # "mark_price": "68465.17449906",
627
+ # "last_traded_price": "68495.1",
628
+ # "bid": "68477.6",
629
+ # "ask": "69578.2",
630
+ # "volume_24h": "5815541.397939004",
631
+ # "total_volume": "584031465.525259686",
632
+ # "created_at": 1718170156580,
633
+ # "underlying_price": "67367.37268422",
634
+ # "open_interest": "162.272",
635
+ # "funding_rate": "0.01629574927887",
636
+ # "price_change_rate_24h": "0.009032"
637
+ # }
638
+ #
639
+ percentage = self.safe_string(ticker, 'price_change_rate_24h')
640
+ if percentage is not None:
641
+ percentage = Precise.string_mul(percentage, '100')
642
+ last = self.safe_string(ticker, 'last_traded_price')
643
+ marketId = self.safe_string(ticker, 'symbol')
644
+ market = self.safe_market(marketId, market)
645
+ symbol = market['symbol']
646
+ timestamp = self.safe_integer(ticker, 'created_at')
647
+ return self.safe_ticker({
648
+ 'symbol': symbol,
649
+ 'timestamp': timestamp,
650
+ 'datetime': self.iso8601(timestamp),
651
+ 'high': None,
652
+ 'low': None,
653
+ 'bid': self.safe_string(ticker, 'bid'),
654
+ 'bidVolume': None,
655
+ 'ask': self.safe_string(ticker, 'ask'),
656
+ 'askVolume': None,
657
+ 'vwap': None,
658
+ 'open': None,
659
+ 'close': last,
660
+ 'last': last,
661
+ 'previousClose': None,
662
+ 'change': None,
663
+ 'percentage': percentage,
664
+ 'average': None,
665
+ 'baseVolume': None,
666
+ 'quoteVolume': self.safe_string(ticker, 'volume_24h'),
667
+ 'markPrice': self.safe_string(ticker, 'mark_price'),
668
+ 'info': ticker,
669
+ }, market)
670
+
671
+ async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
672
+ """
673
+ fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
674
+
675
+ https://docs.api.testnet.paradex.trade/#get-market-orderbook
676
+
677
+ :param str symbol: unified symbol of the market to fetch the order book for
678
+ :param int [limit]: the maximum amount of order book entries to return
679
+ :param dict [params]: extra parameters specific to the exchange API endpoint
680
+ :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
681
+ """
682
+ await self.load_markets()
683
+ market = self.market(symbol)
684
+ request: dict = {'market': market['id']}
685
+ response = await self.publicGetOrderbookMarket(self.extend(request, params))
686
+ #
687
+ # {
688
+ # "market": "BTC-USD-PERP",
689
+ # "seq_no": 14115975,
690
+ # "last_updated_at": 1718172538340,
691
+ # "asks": [
692
+ # [
693
+ # "69578.2",
694
+ # "3.019"
695
+ # ]
696
+ # ],
697
+ # "bids": [
698
+ # [
699
+ # "68477.6",
700
+ # "0.1"
701
+ # ]
702
+ # ]
703
+ # }
704
+ #
705
+ if limit is not None:
706
+ request['depth'] = limit
707
+ timestamp = self.safe_integer(response, 'last_updated_at')
708
+ orderbook = self.parse_order_book(response, market['symbol'], timestamp)
709
+ orderbook['nonce'] = self.safe_integer(response, 'seq_no')
710
+ return orderbook
711
+
712
+ async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
713
+ """
714
+ get the list of most recent trades for a particular symbol
715
+
716
+ https://docs.api.testnet.paradex.trade/#trade-tape
717
+
718
+ :param str symbol: unified symbol of the market to fetch trades for
719
+ :param int [since]: timestamp in ms of the earliest trade to fetch
720
+ :param int [limit]: the maximum amount of trades to fetch
721
+ :param dict [params]: extra parameters specific to the exchange API endpoint
722
+ :param int [params.until]: the latest time in ms to fetch trades for
723
+ :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times
724
+ :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
725
+ """
726
+ await self.load_markets()
727
+ paginate = False
728
+ paginate, params = self.handle_option_and_params(params, 'fetchTrades', 'paginate')
729
+ if paginate:
730
+ return await self.fetch_paginated_call_cursor('fetchTrades', symbol, since, limit, params, 'next', 'cursor', None, 100)
731
+ market = self.market(symbol)
732
+ request: dict = {
733
+ 'market': market['id'],
734
+ }
735
+ if limit is not None:
736
+ request['page_size'] = limit
737
+ if since is not None:
738
+ request['start_at'] = since
739
+ request, params = self.handle_until_option('end_at', request, params)
740
+ response = await self.publicGetTrades(self.extend(request, params))
741
+ #
742
+ # {
743
+ # "next": "...",
744
+ # "prev": "...",
745
+ # "results": [
746
+ # {
747
+ # "id": "1718154353750201703989430001",
748
+ # "market": "BTC-USD-PERP",
749
+ # "side": "BUY",
750
+ # "size": "0.026",
751
+ # "price": "69578.2",
752
+ # "created_at": 1718154353750,
753
+ # "trade_type": "FILL"
754
+ # }
755
+ # ]
756
+ # }
757
+ #
758
+ trades = self.safe_list(response, 'results', [])
759
+ for i in range(0, len(trades)):
760
+ trades[i]['next'] = self.safe_string(response, 'next')
761
+ return self.parse_trades(trades, market, since, limit)
762
+
763
+ def parse_trade(self, trade: dict, market: Market = None) -> Trade:
764
+ #
765
+ # fetchTrades(public)
766
+ #
767
+ # {
768
+ # "id": "1718154353750201703989430001",
769
+ # "market": "BTC-USD-PERP",
770
+ # "side": "BUY",
771
+ # "size": "0.026",
772
+ # "price": "69578.2",
773
+ # "created_at": 1718154353750,
774
+ # "trade_type": "FILL"
775
+ # }
776
+ #
777
+ # fetchMyTrades(private)
778
+ #
779
+ # {
780
+ # "id": "1718947571560201703986670001",
781
+ # "side": "BUY",
782
+ # "liquidity": "TAKER",
783
+ # "market": "BTC-USD-PERP",
784
+ # "order_id": "1718947571540201703992340000",
785
+ # "price": "64852.9",
786
+ # "size": "0.01",
787
+ # "fee": "0.1945587",
788
+ # "fee_currency": "USDC",
789
+ # "created_at": 1718947571569,
790
+ # "remaining_size": "0",
791
+ # "client_id": "",
792
+ # "fill_type": "FILL"
793
+ # }
794
+ #
795
+ marketId = self.safe_string(trade, 'market')
796
+ market = self.safe_market(marketId, market)
797
+ id = self.safe_string(trade, 'id')
798
+ timestamp = self.safe_integer(trade, 'created_at')
799
+ priceString = self.safe_string(trade, 'price')
800
+ amountString = self.safe_string(trade, 'size')
801
+ side = self.safe_string_lower(trade, 'side')
802
+ liability = self.safe_string_lower(trade, 'liquidity', 'taker')
803
+ isTaker = liability == 'taker'
804
+ takerOrMaker = 'taker' if (isTaker) else 'maker'
805
+ currencyId = self.safe_string(trade, 'fee_currency')
806
+ code = self.safe_currency_code(currencyId)
807
+ return self.safe_trade({
808
+ 'info': trade,
809
+ 'id': id,
810
+ 'order': self.safe_string(trade, 'order_id'),
811
+ 'timestamp': timestamp,
812
+ 'datetime': self.iso8601(timestamp),
813
+ 'symbol': market['symbol'],
814
+ 'type': None,
815
+ 'takerOrMaker': takerOrMaker,
816
+ 'side': side,
817
+ 'price': priceString,
818
+ 'amount': amountString,
819
+ 'cost': None,
820
+ 'fee': {
821
+ 'cost': self.safe_string(trade, 'fee'),
822
+ 'currency': code,
823
+ 'rate': None,
824
+ },
825
+ }, market)
826
+
827
+ async def fetch_open_interest(self, symbol: str, params={}):
828
+ """
829
+ retrieves the open interest of a contract trading pair
830
+
831
+ https://docs.api.testnet.paradex.trade/#list-available-markets-summary
832
+
833
+ :param str symbol: unified CCXT market symbol
834
+ :param dict [params]: exchange specific parameters
835
+ :returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
836
+ """
837
+ await self.load_markets()
838
+ market = self.market(symbol)
839
+ if not market['contract']:
840
+ raise BadRequest(self.id + ' fetchOpenInterest() supports contract markets only')
841
+ request: dict = {
842
+ 'market': market['id'],
843
+ }
844
+ response = await self.publicGetMarketsSummary(self.extend(request, params))
845
+ #
846
+ # {
847
+ # "results": [
848
+ # {
849
+ # "symbol": "BTC-USD-PERP",
850
+ # "oracle_price": "68465.17449906",
851
+ # "mark_price": "68465.17449906",
852
+ # "last_traded_price": "68495.1",
853
+ # "bid": "68477.6",
854
+ # "ask": "69578.2",
855
+ # "volume_24h": "5815541.397939004",
856
+ # "total_volume": "584031465.525259686",
857
+ # "created_at": 1718170156580,
858
+ # "underlying_price": "67367.37268422",
859
+ # "open_interest": "162.272",
860
+ # "funding_rate": "0.01629574927887",
861
+ # "price_change_rate_24h": "0.009032"
862
+ # }
863
+ # ]
864
+ # }
865
+ #
866
+ data = self.safe_list(response, 'results', [])
867
+ interest = self.safe_dict(data, 0, {})
868
+ return self.parse_open_interest(interest, market)
869
+
870
+ def parse_open_interest(self, interest, market: Market = None):
871
+ #
872
+ # {
873
+ # "symbol": "BTC-USD-PERP",
874
+ # "oracle_price": "68465.17449906",
875
+ # "mark_price": "68465.17449906",
876
+ # "last_traded_price": "68495.1",
877
+ # "bid": "68477.6",
878
+ # "ask": "69578.2",
879
+ # "volume_24h": "5815541.397939004",
880
+ # "total_volume": "584031465.525259686",
881
+ # "created_at": 1718170156580,
882
+ # "underlying_price": "67367.37268422",
883
+ # "open_interest": "162.272",
884
+ # "funding_rate": "0.01629574927887",
885
+ # "price_change_rate_24h": "0.009032"
886
+ # }
887
+ #
888
+ timestamp = self.safe_integer(interest, 'created_at')
889
+ marketId = self.safe_string(interest, 'symbol')
890
+ market = self.safe_market(marketId, market)
891
+ symbol = market['symbol']
892
+ return self.safe_open_interest({
893
+ 'symbol': symbol,
894
+ 'openInterestAmount': self.safe_string(interest, 'open_interest'),
895
+ 'openInterestValue': None,
896
+ 'timestamp': timestamp,
897
+ 'datetime': self.iso8601(timestamp),
898
+ 'info': interest,
899
+ }, market)
900
+
901
+ def hash_message(self, message):
902
+ return '0x' + self.hash(message, 'keccak', 'hex')
903
+
904
+ def sign_hash(self, hash, privateKey):
905
+ signature = self.ecdsa(hash[-64:], privateKey[-64:], 'secp256k1', None)
906
+ r = signature['r']
907
+ s = signature['s']
908
+ v = self.int_to_base16(self.sum(27, signature['v']))
909
+ return '0x' + r.rjust(64, '0') + s.rjust(64, '0') + v
910
+
911
+ def sign_message(self, message, privateKey):
912
+ return self.sign_hash(self.hash_message(message), privateKey[-64:])
913
+
914
+ async def get_system_config(self):
915
+ cachedConfig: dict = self.safe_dict(self.options, 'systemConfig')
916
+ if cachedConfig is not None:
917
+ return cachedConfig
918
+ response = await self.publicGetSystemConfig()
919
+ #
920
+ # {
921
+ # "starknet_gateway_url": "https://potc-testnet-sepolia.starknet.io",
922
+ # "starknet_fullnode_rpc_url": "https://pathfinder.api.testnet.paradex.trade/rpc/v0_7",
923
+ # "starknet_chain_id": "PRIVATE_SN_POTC_SEPOLIA",
924
+ # "block_explorer_url": "https://voyager.testnet.paradex.trade/",
925
+ # "paraclear_address": "0x286003f7c7bfc3f94e8f0af48b48302e7aee2fb13c23b141479ba00832ef2c6",
926
+ # "paraclear_decimals": 8,
927
+ # "paraclear_account_proxy_hash": "0x3530cc4759d78042f1b543bf797f5f3d647cde0388c33734cf91b7f7b9314a9",
928
+ # "paraclear_account_hash": "0x41cb0280ebadaa75f996d8d92c6f265f6d040bb3ba442e5f86a554f1765244e",
929
+ # "oracle_address": "0x2c6a867917ef858d6b193a0ff9e62b46d0dc760366920d631715d58baeaca1f",
930
+ # "bridged_tokens": [
931
+ # {
932
+ # "name": "TEST USDC",
933
+ # "symbol": "USDC",
934
+ # "decimals": 6,
935
+ # "l1_token_address": "0x29A873159D5e14AcBd63913D4A7E2df04570c666",
936
+ # "l1_bridge_address": "0x8586e05adc0C35aa11609023d4Ae6075Cb813b4C",
937
+ # "l2_token_address": "0x6f373b346561036d98ea10fb3e60d2f459c872b1933b50b21fe6ef4fda3b75e",
938
+ # "l2_bridge_address": "0x46e9237f5408b5f899e72125dd69bd55485a287aaf24663d3ebe00d237fc7ef"
939
+ # }
940
+ # ],
941
+ # "l1_core_contract_address": "0x582CC5d9b509391232cd544cDF9da036e55833Af",
942
+ # "l1_operator_address": "0x11bACdFbBcd3Febe5e8CEAa75E0Ef6444d9B45FB",
943
+ # "l1_chain_id": "11155111",
944
+ # "liquidation_fee": "0.2"
945
+ # }
946
+ #
947
+ self.options['systemConfig'] = response
948
+ return response
949
+
950
+ async def prepare_paradex_domain(self, l1=False):
951
+ systemConfig = await self.get_system_config()
952
+ if l1 is True:
953
+ return {
954
+ 'name': 'Paradex',
955
+ 'chainId': systemConfig['l1_chain_id'],
956
+ 'version': '1',
957
+ }
958
+ return {
959
+ 'name': 'Paradex',
960
+ 'chainId': systemConfig['starknet_chain_id'],
961
+ 'version': 1,
962
+ }
963
+
964
+ async def retrieve_account(self):
965
+ self.check_required_credentials()
966
+ cachedAccount: dict = self.safe_dict(self.options, 'paradexAccount')
967
+ if cachedAccount is not None:
968
+ return cachedAccount
969
+ systemConfig = await self.get_system_config()
970
+ domain = await self.prepare_paradex_domain(True)
971
+ messageTypes = {
972
+ 'Constant': [
973
+ {'name': 'action', 'type': 'string'},
974
+ ],
975
+ }
976
+ message = {
977
+ 'action': 'STARK Key',
978
+ }
979
+ msg = self.eth_encode_structured_data(domain, messageTypes, message)
980
+ signature = self.sign_message(msg, self.privateKey)
981
+ account = self.retrieve_stark_account(
982
+ signature,
983
+ systemConfig['paraclear_account_hash'],
984
+ systemConfig['paraclear_account_proxy_hash']
985
+ )
986
+ self.options['paradexAccount'] = account
987
+ return account
988
+
989
+ async def onboarding(self, params={}):
990
+ account = await self.retrieve_account()
991
+ req = {
992
+ 'action': 'Onboarding',
993
+ }
994
+ domain = await self.prepare_paradex_domain()
995
+ messageTypes = {
996
+ 'Constant': [
997
+ {'name': 'action', 'type': 'felt'},
998
+ ],
999
+ }
1000
+ msg = self.starknet_encode_structured_data(domain, messageTypes, req, account['address'])
1001
+ signature = self.starknet_sign(msg, account['privateKey'])
1002
+ params['signature'] = signature
1003
+ params['account'] = account['address']
1004
+ params['public_key'] = account['publicKey']
1005
+ response = await self.privatePostOnboarding(params)
1006
+ return response
1007
+
1008
+ async def authenticate_rest(self, params={}):
1009
+ cachedToken = self.safe_string(self.options, 'authToken')
1010
+ now = self.nonce()
1011
+ if cachedToken is not None:
1012
+ cachedExpires = self.safe_integer(self.options, 'expires')
1013
+ if now < cachedExpires:
1014
+ return cachedToken
1015
+ account = await self.retrieve_account()
1016
+ expires = now + 86400 * 7
1017
+ req = {
1018
+ 'method': 'POST',
1019
+ 'path': '/v1/auth',
1020
+ 'body': '',
1021
+ 'timestamp': now,
1022
+ 'expiration': expires,
1023
+ }
1024
+ domain = await self.prepare_paradex_domain()
1025
+ messageTypes = {
1026
+ 'Request': [
1027
+ {'name': 'method', 'type': 'felt'},
1028
+ {'name': 'path', 'type': 'felt'},
1029
+ {'name': 'body', 'type': 'felt'},
1030
+ {'name': 'timestamp', 'type': 'felt'},
1031
+ {'name': 'expiration', 'type': 'felt'},
1032
+ ],
1033
+ }
1034
+ msg = self.starknet_encode_structured_data(domain, messageTypes, req, account['address'])
1035
+ signature = self.starknet_sign(msg, account['privateKey'])
1036
+ params['signature'] = signature
1037
+ params['account'] = account['address']
1038
+ params['timestamp'] = req['timestamp']
1039
+ params['expiration'] = req['expiration']
1040
+ response = await self.privatePostAuth(params)
1041
+ #
1042
+ # {
1043
+ # jwt_token: "ooooccxtooootoooootheoooomoonooooo"
1044
+ # }
1045
+ #
1046
+ token = self.safe_string(response, 'jwt_token')
1047
+ self.options['authToken'] = token
1048
+ self.options['expires'] = expires
1049
+ return token
1050
+
1051
+ def parse_order(self, order: dict, market: Market = None) -> Order:
1052
+ #
1053
+ # {
1054
+ # "account": "0x4638e3041366aa71720be63e32e53e1223316c7f0d56f7aa617542ed1e7512x",
1055
+ # "avg_fill_price": "26000",
1056
+ # "client_id": "x1234",
1057
+ # "cancel_reason": "NOT_ENOUGH_MARGIN",
1058
+ # "created_at": 1681493746016,
1059
+ # "flags": [
1060
+ # "REDUCE_ONLY"
1061
+ # ],
1062
+ # "id": "123456",
1063
+ # "instruction": "GTC",
1064
+ # "last_updated_at": 1681493746016,
1065
+ # "market": "BTC-USD-PERP",
1066
+ # "price": "26000",
1067
+ # "published_at": 1681493746016,
1068
+ # "received_at": 1681493746016,
1069
+ # "remaining_size": "0",
1070
+ # "seq_no": 1681471234972000000,
1071
+ # "side": "BUY",
1072
+ # "size": "0.05",
1073
+ # "status": "NEW",
1074
+ # "stp": "EXPIRE_MAKER",
1075
+ # "timestamp": 1681493746016,
1076
+ # "trigger_price": "26000",
1077
+ # "type": "MARKET"
1078
+ # }
1079
+ #
1080
+ timestamp = self.safe_integer(order, 'created_at')
1081
+ orderId = self.safe_string(order, 'id')
1082
+ clientOrderId = self.omit_zero(self.safe_string(order, 'client_id'))
1083
+ marketId = self.safe_string(order, 'market')
1084
+ market = self.safe_market(marketId, market)
1085
+ symbol = market['symbol']
1086
+ price = self.safe_string(order, 'price')
1087
+ amount = self.safe_string(order, 'size')
1088
+ orderType = self.safe_string(order, 'type')
1089
+ status = self.safe_string(order, 'status')
1090
+ side = self.safe_string_lower(order, 'side')
1091
+ average = self.omit_zero(self.safe_string(order, 'avg_fill_price'))
1092
+ remaining = self.omit_zero(self.safe_string(order, 'remaining_size'))
1093
+ stopPrice = self.safe_string(order, 'trigger_price')
1094
+ lastUpdateTimestamp = self.safe_integer(order, 'last_updated_at')
1095
+ return self.safe_order({
1096
+ 'id': orderId,
1097
+ 'clientOrderId': clientOrderId,
1098
+ 'timestamp': timestamp,
1099
+ 'datetime': self.iso8601(timestamp),
1100
+ 'lastTradeTimestamp': None,
1101
+ 'lastUpdateTimestamp': lastUpdateTimestamp,
1102
+ 'status': self.parse_order_status(status),
1103
+ 'symbol': symbol,
1104
+ 'type': self.parse_order_type(orderType),
1105
+ 'timeInForce': self.parse_time_in_force(self.safe_string(order, 'instrunction')),
1106
+ 'postOnly': None,
1107
+ 'reduceOnly': None,
1108
+ 'side': side,
1109
+ 'price': price,
1110
+ 'stopPrice': stopPrice,
1111
+ 'triggerPrice': stopPrice,
1112
+ 'takeProfitPrice': None,
1113
+ 'stopLossPrice': None,
1114
+ 'average': average,
1115
+ 'amount': amount,
1116
+ 'filled': None,
1117
+ 'remaining': remaining,
1118
+ 'cost': None,
1119
+ 'trades': None,
1120
+ 'fee': {
1121
+ 'cost': None,
1122
+ 'currency': None,
1123
+ },
1124
+ 'info': order,
1125
+ }, market)
1126
+
1127
+ def parse_time_in_force(self, timeInForce: Str):
1128
+ timeInForces: dict = {
1129
+ 'IOC': 'IOC',
1130
+ 'GTC': 'GTC',
1131
+ 'POST_ONLY': 'PO',
1132
+ }
1133
+ return self.safe_string(timeInForces, timeInForce, None)
1134
+
1135
+ def parse_order_status(self, status: Str):
1136
+ if status is not None:
1137
+ statuses: dict = {
1138
+ 'NEW': 'open',
1139
+ 'UNTRIGGERED': 'open',
1140
+ 'OPEN': 'open',
1141
+ 'CLOSED': 'closed',
1142
+ }
1143
+ return self.safe_string(statuses, status, status)
1144
+ return status
1145
+
1146
+ def parse_order_type(self, type: Str):
1147
+ types: dict = {
1148
+ 'LIMIT': 'limit',
1149
+ 'MARKET': 'market',
1150
+ 'STOP_LIMIT': 'limit',
1151
+ 'STOP_MARKET': 'market',
1152
+ }
1153
+ return self.safe_string_lower(types, type, type)
1154
+
1155
+ def convert_short_string(self, str: str):
1156
+ # TODO: add stringToBase16 in exchange
1157
+ return '0x' + self.binary_to_base16(self.base64_to_binary(self.string_to_base64(str)))
1158
+
1159
+ def scale_number(self, num: str):
1160
+ return Precise.string_mul(num, '100000000')
1161
+
1162
+ async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1163
+ """
1164
+ create a trade order
1165
+
1166
+ https://docs.api.prod.paradex.trade/#create-order
1167
+
1168
+ :param str symbol: unified symbol of the market to create an order in
1169
+ :param str type: 'market' or 'limit'
1170
+ :param str side: 'buy' or 'sell'
1171
+ :param float amount: how much of currency you want to trade in units of base currency
1172
+ :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1173
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1174
+ :param float [params.stopPrice]: The price a trigger order is triggered at
1175
+ :param float [params.triggerPrice]: The price a trigger order is triggered at
1176
+ :param str [params.timeInForce]: "GTC", "IOC", or "POST_ONLY"
1177
+ :param bool [params.postOnly]: True or False
1178
+ :param bool [params.reduceOnly]: Ensures that the executed order does not flip the opened position.
1179
+ :param str [params.clientOrderId]: a unique id for the order
1180
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1181
+ """
1182
+ await self.authenticate_rest()
1183
+ await self.load_markets()
1184
+ market = self.market(symbol)
1185
+ reduceOnly = self.safe_bool_2(params, 'reduceOnly', 'reduce_only')
1186
+ orderType = type.upper()
1187
+ orderSide = side.upper()
1188
+ request: dict = {
1189
+ 'market': market['id'],
1190
+ 'side': orderSide,
1191
+ 'type': orderType, # LIMIT/MARKET/STOP_LIMIT/STOP_MARKET
1192
+ 'size': self.amount_to_precision(symbol, amount),
1193
+ }
1194
+ stopPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
1195
+ isMarket = orderType == 'MARKET'
1196
+ timeInForce = self.safe_string_upper(params, 'timeInForce')
1197
+ postOnly = self.is_post_only(isMarket, None, params)
1198
+ if not isMarket:
1199
+ if postOnly:
1200
+ request['instruction'] = 'POST_ONLY'
1201
+ elif timeInForce == 'ioc':
1202
+ request['instruction'] = 'IOC'
1203
+ if reduceOnly:
1204
+ request['flags'] = [
1205
+ 'REDUCE_ONLY',
1206
+ ]
1207
+ if price is not None:
1208
+ request['price'] = self.price_to_precision(symbol, price)
1209
+ clientOrderId = self.safe_string_n(params, ['clOrdID', 'clientOrderId', 'client_order_id'])
1210
+ if clientOrderId is not None:
1211
+ request['client_id'] = clientOrderId
1212
+ if stopPrice is not None:
1213
+ if isMarket:
1214
+ request['type'] = 'STOP_MARKET'
1215
+ else:
1216
+ request['type'] = 'STOP_LIMIT'
1217
+ request['trigger_price'] = self.price_to_precision(symbol, stopPrice)
1218
+ params = self.omit(params, ['reduceOnly', 'reduce_only', 'clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce', 'stopPrice', 'triggerPrice'])
1219
+ account = await self.retrieve_account()
1220
+ now = self.nonce()
1221
+ orderReq = {
1222
+ 'timestamp': now * 1000,
1223
+ 'market': self.convert_short_string(request['market']),
1224
+ 'side': '1' if (orderSide == 'BUY') else '2',
1225
+ 'orderType': self.convert_short_string(request['type']),
1226
+ 'size': self.scale_number(request['size']),
1227
+ 'price': '0' if (isMarket) else self.scale_number(request['price']),
1228
+ }
1229
+ domain = await self.prepare_paradex_domain()
1230
+ messageTypes = {
1231
+ 'Order': [
1232
+ {'name': 'timestamp', 'type': 'felt'},
1233
+ {'name': 'market', 'type': 'felt'},
1234
+ {'name': 'side', 'type': 'felt'},
1235
+ {'name': 'orderType', 'type': 'felt'},
1236
+ {'name': 'size', 'type': 'felt'},
1237
+ {'name': 'price', 'type': 'felt'},
1238
+ ],
1239
+ }
1240
+ msg = self.starknet_encode_structured_data(domain, messageTypes, orderReq, account['address'])
1241
+ signature = self.starknet_sign(msg, account['privateKey'])
1242
+ request['signature'] = signature
1243
+ request['signature_timestamp'] = orderReq['timestamp']
1244
+ response = await self.privatePostOrders(self.extend(request, params))
1245
+ #
1246
+ # {
1247
+ # "account": "0x4638e3041366aa71720be63e32e53e1223316c7f0d56f7aa617542ed1e7512x",
1248
+ # "avg_fill_price": "26000",
1249
+ # "cancel_reason": "NOT_ENOUGH_MARGIN",
1250
+ # "client_id": "x1234",
1251
+ # "created_at": 1681493746016,
1252
+ # "flags": [
1253
+ # "REDUCE_ONLY"
1254
+ # ],
1255
+ # "id": "123456",
1256
+ # "instruction": "GTC",
1257
+ # "last_updated_at": 1681493746016,
1258
+ # "market": "BTC-USD-PERP",
1259
+ # "price": "26000",
1260
+ # "published_at": 1681493746016,
1261
+ # "received_at": 1681493746016,
1262
+ # "remaining_size": "0",
1263
+ # "seq_no": 1681471234972000000,
1264
+ # "side": "BUY",
1265
+ # "size": "0.05",
1266
+ # "status": "NEW",
1267
+ # "stp": "EXPIRE_MAKER",
1268
+ # "timestamp": 1681493746016,
1269
+ # "trigger_price": "26000",
1270
+ # "type": "MARKET"
1271
+ # }
1272
+ #
1273
+ order = self.parse_order(response, market)
1274
+ return order
1275
+
1276
+ async def cancel_order(self, id: str, symbol: Str = None, params={}):
1277
+ """
1278
+ cancels an open order
1279
+
1280
+ https://docs.api.prod.paradex.trade/#cancel-order
1281
+ https://docs.api.prod.paradex.trade/#cancel-open-order-by-client-order-id
1282
+
1283
+ :param str id: order id
1284
+ :param str symbol: unified symbol of the market the order was made in
1285
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1286
+ :param str [params.clientOrderId]: a unique id for the order
1287
+ :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1288
+ """
1289
+ await self.authenticate_rest()
1290
+ await self.load_markets()
1291
+ request: dict = {}
1292
+ clientOrderId = self.safe_string_n(params, ['clOrdID', 'clientOrderId', 'client_order_id'])
1293
+ response = None
1294
+ if clientOrderId is not None:
1295
+ request['client_id'] = clientOrderId
1296
+ response = await self.privateDeleteOrdersByClientIdClientId(self.extend(request, params))
1297
+ else:
1298
+ request['order_id'] = id
1299
+ response = await self.privateDeleteOrdersOrderId(self.extend(request, params))
1300
+ #
1301
+ # if success, no response...
1302
+ #
1303
+ return self.parse_order(response)
1304
+
1305
+ async def cancel_all_orders(self, symbol: Str = None, params={}):
1306
+ """
1307
+ cancel all open orders in a market
1308
+
1309
+ https://docs.api.prod.paradex.trade/#cancel-all-open-orders
1310
+
1311
+ :param str symbol: unified market symbol of the market to cancel orders in
1312
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1313
+ :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1314
+ """
1315
+ if symbol is None:
1316
+ raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
1317
+ await self.authenticate_rest()
1318
+ await self.load_markets()
1319
+ market = self.market(symbol)
1320
+ request: dict = {
1321
+ 'market': market['id'],
1322
+ }
1323
+ response = await self.privateDeleteOrders(self.extend(request, params))
1324
+ #
1325
+ # if success, no response...
1326
+ #
1327
+ return response
1328
+
1329
+ async def fetch_order(self, id: str, symbol: Str = None, params={}):
1330
+ """
1331
+ fetches information on an order made by the user
1332
+
1333
+ https://docs.api.prod.paradex.trade/#get-order
1334
+ https://docs.api.prod.paradex.trade/#get-order-by-client-id
1335
+
1336
+ :param str id: the order id
1337
+ :param str symbol: unified symbol of the market the order was made in
1338
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1339
+ :param str [params.clientOrderId]: a unique id for the order
1340
+ :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1341
+ """
1342
+ await self.authenticate_rest()
1343
+ await self.load_markets()
1344
+ request: dict = {}
1345
+ clientOrderId = self.safe_string_n(params, ['clOrdID', 'clientOrderId', 'client_order_id'])
1346
+ params = self.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id'])
1347
+ response = None
1348
+ if clientOrderId is not None:
1349
+ request['client_id'] = clientOrderId
1350
+ response = await self.privateGetOrdersByClientIdClientId(self.extend(request, params))
1351
+ else:
1352
+ request['order_id'] = id
1353
+ response = await self.privateGetOrdersOrderId(self.extend(request, params))
1354
+ #
1355
+ # {
1356
+ # "id": "1718941725080201704028870000",
1357
+ # "account": "0x49ddd7a564c978f6e4089ff8355b56a42b7e2d48ba282cb5aad60f04bea0ec3",
1358
+ # "market": "BTC-USD-PERP",
1359
+ # "side": "SELL",
1360
+ # "type": "LIMIT",
1361
+ # "size": "10.153",
1362
+ # "remaining_size": "10.153",
1363
+ # "price": "70784.5",
1364
+ # "status": "CLOSED",
1365
+ # "created_at": 1718941725082,
1366
+ # "last_updated_at": 1718958002991,
1367
+ # "timestamp": 1718941724678,
1368
+ # "cancel_reason": "USER_CANCELED",
1369
+ # "client_id": "",
1370
+ # "seq_no": 1718958002991595738,
1371
+ # "instruction": "GTC",
1372
+ # "avg_fill_price": "",
1373
+ # "stp": "EXPIRE_TAKER",
1374
+ # "received_at": 1718958510959,
1375
+ # "published_at": 1718958510960,
1376
+ # "flags": [],
1377
+ # "trigger_price": "0"
1378
+ # }
1379
+ #
1380
+ return self.parse_order(response)
1381
+
1382
+ async def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1383
+ """
1384
+ fetches information on multiple orders made by the user
1385
+
1386
+ https://docs.api.prod.paradex.trade/#get-orders
1387
+
1388
+ :param str symbol: unified market symbol of the market orders were made in
1389
+ :param int [since]: the earliest time in ms to fetch orders for
1390
+ :param int [limit]: the maximum number of order structures to retrieve
1391
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1392
+ :param str [params.side]: 'buy' or 'sell'
1393
+ :param boolean [params.paginate]: set to True if you want to fetch orders with pagination
1394
+ :param int params['until']: timestamp in ms of the latest order to fetch
1395
+ :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1396
+ """
1397
+ await self.authenticate_rest()
1398
+ await self.load_markets()
1399
+ paginate = False
1400
+ paginate, params = self.handle_option_and_params(params, 'fetchOrders', 'paginate')
1401
+ if paginate:
1402
+ return await self.fetch_paginated_call_cursor('fetchOrders', symbol, since, limit, params, 'next', 'cursor', None, 50)
1403
+ request: dict = {}
1404
+ market: Market = None
1405
+ if symbol is not None:
1406
+ market = self.market(symbol)
1407
+ request['market'] = market['id']
1408
+ if since is not None:
1409
+ request['start_at'] = since
1410
+ if limit is not None:
1411
+ request['page_size'] = limit
1412
+ request, params = self.handle_until_option('end_at', request, params)
1413
+ response = await self.privateGetOrdersHistory(self.extend(request, params))
1414
+ #
1415
+ # {
1416
+ # "next": "eyJmaWx0ZXIiMsIm1hcmtlciI6eyJtYXJrZXIiOiIxNjc1NjUwMDE3NDMxMTAxNjk5N=",
1417
+ # "prev": "eyJmaWx0ZXIiOnsiTGltaXQiOjkwfSwidGltZSI6MTY4MTY3OTgzNzk3MTMwOTk1MywibWFya2VyIjp7Im1zMjExMD==",
1418
+ # "results": [
1419
+ # {
1420
+ # "account": "0x4638e3041366aa71720be63e32e53e1223316c7f0d56f7aa617542ed1e7512x",
1421
+ # "avg_fill_price": "26000",
1422
+ # "cancel_reason": "NOT_ENOUGH_MARGIN",
1423
+ # "client_id": "x1234",
1424
+ # "created_at": 1681493746016,
1425
+ # "flags": [
1426
+ # "REDUCE_ONLY"
1427
+ # ],
1428
+ # "id": "123456",
1429
+ # "instruction": "GTC",
1430
+ # "last_updated_at": 1681493746016,
1431
+ # "market": "BTC-USD-PERP",
1432
+ # "price": "26000",
1433
+ # "published_at": 1681493746016,
1434
+ # "received_at": 1681493746016,
1435
+ # "remaining_size": "0",
1436
+ # "seq_no": 1681471234972000000,
1437
+ # "side": "BUY",
1438
+ # "size": "0.05",
1439
+ # "status": "NEW",
1440
+ # "stp": "EXPIRE_MAKER",
1441
+ # "timestamp": 1681493746016,
1442
+ # "trigger_price": "26000",
1443
+ # "type": "MARKET"
1444
+ # }
1445
+ # ]
1446
+ # }
1447
+ #
1448
+ orders = self.safe_list(response, 'results', [])
1449
+ paginationCursor = self.safe_string(response, 'next')
1450
+ ordersLength = len(orders)
1451
+ if (paginationCursor is not None) and (ordersLength > 0):
1452
+ first = orders[0]
1453
+ first['next'] = paginationCursor
1454
+ orders[0] = first
1455
+ return self.parse_orders(orders, market, since, limit)
1456
+
1457
+ async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1458
+ """
1459
+ fetches information on multiple orders made by the user
1460
+
1461
+ https://docs.api.prod.paradex.trade/#paradex-rest-api-orders
1462
+
1463
+ :param str symbol: unified market symbol of the market orders were made in
1464
+ :param int [since]: the earliest time in ms to fetch orders for
1465
+ :param int [limit]: the maximum number of order structures to retrieve
1466
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1467
+ :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1468
+ """
1469
+ await self.authenticate_rest()
1470
+ await self.load_markets()
1471
+ request: dict = {}
1472
+ market: Market = None
1473
+ if symbol is not None:
1474
+ market = self.market(symbol)
1475
+ request['market'] = market['id']
1476
+ response = await self.privateGetOrders(self.extend(request, params))
1477
+ #
1478
+ # {
1479
+ # "results": [
1480
+ # {
1481
+ # "account": "0x4638e3041366aa71720be63e32e53e1223316c7f0d56f7aa617542ed1e7512x",
1482
+ # "avg_fill_price": "26000",
1483
+ # "client_id": "x1234",
1484
+ # "cancel_reason": "NOT_ENOUGH_MARGIN",
1485
+ # "created_at": 1681493746016,
1486
+ # "flags": [
1487
+ # "REDUCE_ONLY"
1488
+ # ],
1489
+ # "id": "123456",
1490
+ # "instruction": "GTC",
1491
+ # "last_updated_at": 1681493746016,
1492
+ # "market": "BTC-USD-PERP",
1493
+ # "price": "26000",
1494
+ # "published_at": 1681493746016,
1495
+ # "received_at": 1681493746016,
1496
+ # "remaining_size": "0",
1497
+ # "seq_no": 1681471234972000000,
1498
+ # "side": "BUY",
1499
+ # "size": "0.05",
1500
+ # "status": "NEW",
1501
+ # "stp": "EXPIRE_MAKER",
1502
+ # "timestamp": 1681493746016,
1503
+ # "trigger_price": "26000",
1504
+ # "type": "MARKET"
1505
+ # }
1506
+ # ]
1507
+ # }
1508
+ #
1509
+ orders = self.safe_list(response, 'results', [])
1510
+ return self.parse_orders(orders, market, since, limit)
1511
+
1512
+ async def fetch_balance(self, params={}) -> Balances:
1513
+ """
1514
+ query for balance and get the amount of funds available for trading or funds locked in orders
1515
+
1516
+ https://docs.api.prod.paradex.trade/#list-balances
1517
+
1518
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1519
+ :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
1520
+ """
1521
+ await self.authenticate_rest()
1522
+ await self.load_markets()
1523
+ response = await self.privateGetBalance()
1524
+ #
1525
+ # {
1526
+ # "results": [
1527
+ # {
1528
+ # "token": "USDC",
1529
+ # "size": "99980.2382266290601",
1530
+ # "last_updated_at": 1718529757240
1531
+ # }
1532
+ # ]
1533
+ # }
1534
+ #
1535
+ data = self.safe_list(response, 'results', [])
1536
+ return self.parse_balance(data)
1537
+
1538
+ def parse_balance(self, response) -> Balances:
1539
+ result: dict = {'info': response}
1540
+ for i in range(0, len(response)):
1541
+ balance = self.safe_dict(response, i, {})
1542
+ currencyId = self.safe_string(balance, 'token')
1543
+ code = self.safe_currency_code(currencyId)
1544
+ account = self.account()
1545
+ account['total'] = self.safe_string(balance, 'size')
1546
+ result[code] = account
1547
+ return self.safe_balance(result)
1548
+
1549
+ async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1550
+ """
1551
+ fetch all trades made by the user
1552
+
1553
+ https://docs.api.prod.paradex.trade/#list-fills
1554
+
1555
+ :param str symbol: unified market symbol
1556
+ :param int [since]: the earliest time in ms to fetch trades for
1557
+ :param int [limit]: the maximum number of trades structures to retrieve
1558
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1559
+ :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1560
+ :param int [params.until]: the latest time in ms to fetch entries for
1561
+ :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
1562
+ """
1563
+ await self.authenticate_rest()
1564
+ await self.load_markets()
1565
+ paginate = False
1566
+ paginate, params = self.handle_option_and_params(params, 'fetchMyTrades', 'paginate')
1567
+ if paginate:
1568
+ return await self.fetch_paginated_call_cursor('fetchMyTrades', symbol, since, limit, params, 'next', 'cursor', None, 100)
1569
+ request: dict = {}
1570
+ market: Market = None
1571
+ if symbol is not None:
1572
+ market = self.market(symbol)
1573
+ request['market'] = market['id']
1574
+ if limit is not None:
1575
+ request['page_size'] = limit
1576
+ if since is not None:
1577
+ request['start_at'] = since
1578
+ request, params = self.handle_until_option('end_at', request, params)
1579
+ response = await self.privateGetFills(self.extend(request, params))
1580
+ #
1581
+ # {
1582
+ # "next": null,
1583
+ # "prev": null,
1584
+ # "results": [
1585
+ # {
1586
+ # "id": "1718947571560201703986670001",
1587
+ # "side": "BUY",
1588
+ # "liquidity": "TAKER",
1589
+ # "market": "BTC-USD-PERP",
1590
+ # "order_id": "1718947571540201703992340000",
1591
+ # "price": "64852.9",
1592
+ # "size": "0.01",
1593
+ # "fee": "0.1945587",
1594
+ # "fee_currency": "USDC",
1595
+ # "created_at": 1718947571569,
1596
+ # "remaining_size": "0",
1597
+ # "client_id": "",
1598
+ # "fill_type": "FILL"
1599
+ # }
1600
+ # ]
1601
+ # }
1602
+ #
1603
+ trades = self.safe_list(response, 'results', [])
1604
+ for i in range(0, len(trades)):
1605
+ trades[i]['next'] = self.safe_string(response, 'next')
1606
+ return self.parse_trades(trades, market, since, limit)
1607
+
1608
+ async def fetch_position(self, symbol: str, params={}):
1609
+ """
1610
+ fetch data on an open position
1611
+
1612
+ https://docs.api.prod.paradex.trade/#list-open-positions
1613
+
1614
+ :param str symbol: unified market symbol of the market the position is held in
1615
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1616
+ :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
1617
+ """
1618
+ await self.authenticate_rest()
1619
+ await self.load_markets()
1620
+ market = self.market(symbol)
1621
+ positions = await self.fetch_positions([market['symbol']], params)
1622
+ return self.safe_dict(positions, 0, {})
1623
+
1624
+ async def fetch_positions(self, symbols: Strings = None, params={}):
1625
+ """
1626
+ fetch all open positions
1627
+
1628
+ https://docs.api.prod.paradex.trade/#list-open-positions
1629
+
1630
+ :param str[] [symbols]: list of unified market symbols
1631
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1632
+ :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
1633
+ """
1634
+ await self.authenticate_rest()
1635
+ await self.load_markets()
1636
+ symbols = self.market_symbols(symbols)
1637
+ response = await self.privateGetPositions()
1638
+ #
1639
+ # {
1640
+ # "results": [
1641
+ # {
1642
+ # "id": "0x49ddd7a564c978f6e4089ff8355b56a42b7e2d48ba282cb5aad60f04bea0ec3-BTC-USD-PERP",
1643
+ # "market": "BTC-USD-PERP",
1644
+ # "status": "OPEN",
1645
+ # "side": "LONG",
1646
+ # "size": "0.01",
1647
+ # "average_entry_price": "64839.96053748",
1648
+ # "average_entry_price_usd": "64852.9",
1649
+ # "realized_pnl": "0",
1650
+ # "unrealized_pnl": "-2.39677214",
1651
+ # "unrealized_funding_pnl": "-0.11214013",
1652
+ # "cost": "648.39960537",
1653
+ # "cost_usd": "648.529",
1654
+ # "cached_funding_index": "35202.1002351",
1655
+ # "last_updated_at": 1718950074249,
1656
+ # "last_fill_id": "1718947571560201703986670001",
1657
+ # "seq_no": 1718950074249176253,
1658
+ # "liquidation_price": ""
1659
+ # }
1660
+ # ]
1661
+ # }
1662
+ #
1663
+ data = self.safe_list(response, 'results', [])
1664
+ return self.parse_positions(data, symbols)
1665
+
1666
+ def parse_position(self, position: dict, market: Market = None):
1667
+ #
1668
+ # {
1669
+ # "id": "0x49ddd7a564c978f6e4089ff8355b56a42b7e2d48ba282cb5aad60f04bea0ec3-BTC-USD-PERP",
1670
+ # "market": "BTC-USD-PERP",
1671
+ # "status": "OPEN",
1672
+ # "side": "LONG",
1673
+ # "size": "0.01",
1674
+ # "average_entry_price": "64839.96053748",
1675
+ # "average_entry_price_usd": "64852.9",
1676
+ # "realized_pnl": "0",
1677
+ # "unrealized_pnl": "-2.39677214",
1678
+ # "unrealized_funding_pnl": "-0.11214013",
1679
+ # "cost": "648.39960537",
1680
+ # "cost_usd": "648.529",
1681
+ # "cached_funding_index": "35202.1002351",
1682
+ # "last_updated_at": 1718950074249,
1683
+ # "last_fill_id": "1718947571560201703986670001",
1684
+ # "seq_no": 1718950074249176253,
1685
+ # "liquidation_price": ""
1686
+ # }
1687
+ #
1688
+ marketId = self.safe_string(position, 'market')
1689
+ market = self.safe_market(marketId, market)
1690
+ symbol = market['symbol']
1691
+ side = self.safe_string_lower(position, 'side')
1692
+ quantity = self.safe_string(position, 'size')
1693
+ if side != 'long':
1694
+ quantity = Precise.string_mul('-1', quantity)
1695
+ timestamp = self.safe_integer(position, 'time')
1696
+ return self.safe_position({
1697
+ 'info': position,
1698
+ 'id': self.safe_string(position, 'id'),
1699
+ 'symbol': symbol,
1700
+ 'entryPrice': self.safe_string(position, 'average_entry_price'),
1701
+ 'markPrice': None,
1702
+ 'notional': None,
1703
+ 'collateral': self.safe_string(position, 'cost'),
1704
+ 'unrealizedPnl': self.safe_string(position, 'unrealized_pnl'),
1705
+ 'side': side,
1706
+ 'contracts': self.parse_number(quantity),
1707
+ 'contractSize': None,
1708
+ 'timestamp': timestamp,
1709
+ 'datetime': self.iso8601(timestamp),
1710
+ 'hedged': None,
1711
+ 'maintenanceMargin': None,
1712
+ 'maintenanceMarginPercentage': None,
1713
+ 'initialMargin': None,
1714
+ 'initialMarginPercentage': None,
1715
+ 'leverage': None,
1716
+ 'liquidationPrice': None,
1717
+ 'marginRatio': None,
1718
+ 'marginMode': None,
1719
+ 'percentage': None,
1720
+ })
1721
+
1722
+ async def fetch_liquidations(self, symbol: str, since: Int = None, limit: Int = None, params={}):
1723
+ """
1724
+ retrieves the public liquidations of a trading pair
1725
+
1726
+ https://docs.api.prod.paradex.trade/#list-liquidations
1727
+
1728
+ :param str symbol: unified CCXT market symbol
1729
+ :param int [since]: the earliest time in ms to fetch liquidations for
1730
+ :param int [limit]: the maximum number of liquidation structures to retrieve
1731
+ :param dict [params]: exchange specific parameters for the huobi api endpoint
1732
+ :param int [params.until]: timestamp in ms of the latest liquidation
1733
+ :returns dict: an array of `liquidation structures <https://docs.ccxt.com/#/?id=liquidation-structure>`
1734
+ """
1735
+ await self.authenticate_rest()
1736
+ request: dict = {}
1737
+ if since is not None:
1738
+ request['from'] = since
1739
+ else:
1740
+ request['from'] = 1
1741
+ market = self.market(symbol)
1742
+ request, params = self.handle_until_option('to', request, params)
1743
+ response = await self.privateGetLiquidations(self.extend(request, params))
1744
+ #
1745
+ # {
1746
+ # "results": [
1747
+ # {
1748
+ # "created_at": 1697213130097,
1749
+ # "id": "0x123456789"
1750
+ # }
1751
+ # ]
1752
+ # }
1753
+ #
1754
+ data = self.safe_list(response, 'results', [])
1755
+ return self.parse_liquidations(data, market, since, limit)
1756
+
1757
+ def parse_liquidation(self, liquidation, market: Market = None):
1758
+ #
1759
+ # {
1760
+ # "created_at": 1697213130097,
1761
+ # "id": "0x123456789"
1762
+ # }
1763
+ #
1764
+ timestamp = self.safe_integer(liquidation, 'created_at')
1765
+ return self.safe_liquidation({
1766
+ 'info': liquidation,
1767
+ 'symbol': None,
1768
+ 'contracts': None,
1769
+ 'contractSize': None,
1770
+ 'price': None,
1771
+ 'baseValue': None,
1772
+ 'quoteValue': None,
1773
+ 'timestamp': timestamp,
1774
+ 'datetime': self.iso8601(timestamp),
1775
+ })
1776
+
1777
+ async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
1778
+ """
1779
+ fetch all deposits made to an account
1780
+
1781
+ https://docs.api.prod.paradex.trade/#paradex-rest-api-transfers
1782
+
1783
+ :param str code: unified currency code
1784
+ :param int [since]: the earliest time in ms to fetch deposits for
1785
+ :param int [limit]: the maximum number of deposits structures to retrieve
1786
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1787
+ :param int [params.until]: the latest time in ms to fetch entries for
1788
+ :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1789
+ :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
1790
+ """
1791
+ await self.authenticate_rest()
1792
+ await self.load_markets()
1793
+ paginate = False
1794
+ paginate, params = self.handle_option_and_params(params, 'fetchDeposits', 'paginate')
1795
+ if paginate:
1796
+ return await self.fetch_paginated_call_cursor('fetchDeposits', code, since, limit, params, 'next', 'cursor', None, 100)
1797
+ request: dict = {}
1798
+ if limit is not None:
1799
+ request['page_size'] = limit
1800
+ if since is not None:
1801
+ request['start_at'] = since
1802
+ request, params = self.handle_until_option('end_at', request, params)
1803
+ response = await self.privateGetTransfers(self.extend(request, params))
1804
+ #
1805
+ # {
1806
+ # "next": null,
1807
+ # "prev": null,
1808
+ # "results": [
1809
+ # {
1810
+ # "id": "1718940471200201703989430000",
1811
+ # "account": "0x49ddd7a564c978f6e4089ff8355b56a42b7e2d48ba282cb5aad60f04bea0ec3",
1812
+ # "kind": "DEPOSIT",
1813
+ # "status": "COMPLETED",
1814
+ # "amount": "100000",
1815
+ # "token": "USDC",
1816
+ # "created_at": 1718940471208,
1817
+ # "last_updated_at": 1718941455546,
1818
+ # "txn_hash": "0x73a415ca558a97bbdcd1c43e52b45f1e0486a0a84b3bb4958035ad6c59cb866",
1819
+ # "external_txn_hash": "",
1820
+ # "socialized_loss_factor": ""
1821
+ # }
1822
+ # ]
1823
+ # }
1824
+ #
1825
+ rows = self.safe_list(response, 'results', [])
1826
+ deposits = []
1827
+ for i in range(0, len(rows)):
1828
+ row = rows[i]
1829
+ if row['kind'] == 'DEPOSIT':
1830
+ deposits.append(row)
1831
+ return self.parse_transactions(deposits, None, since, limit)
1832
+
1833
+ async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
1834
+ """
1835
+ fetch all withdrawals made from an account
1836
+
1837
+ https://docs.api.prod.paradex.trade/#paradex-rest-api-transfers
1838
+
1839
+ :param str code: unified currency code
1840
+ :param int [since]: the earliest time in ms to fetch withdrawals for
1841
+ :param int [limit]: the maximum number of withdrawals structures to retrieve
1842
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1843
+ :param int [params.until]: the latest time in ms to fetch withdrawals for
1844
+ :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1845
+ :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
1846
+ """
1847
+ await self.authenticate_rest()
1848
+ await self.load_markets()
1849
+ paginate = False
1850
+ paginate, params = self.handle_option_and_params(params, 'fetchWithdrawals', 'paginate')
1851
+ if paginate:
1852
+ return await self.fetch_paginated_call_cursor('fetchWithdrawals', code, since, limit, params, 'next', 'cursor', None, 100)
1853
+ request: dict = {}
1854
+ if limit is not None:
1855
+ request['page_size'] = limit
1856
+ if since is not None:
1857
+ request['start_at'] = since
1858
+ request, params = self.handle_until_option('end_at', request, params)
1859
+ response = await self.privateGetTransfers(self.extend(request, params))
1860
+ #
1861
+ # {
1862
+ # "next": null,
1863
+ # "prev": null,
1864
+ # "results": [
1865
+ # {
1866
+ # "id": "1718940471200201703989430000",
1867
+ # "account": "0x49ddd7a564c978f6e4089ff8355b56a42b7e2d48ba282cb5aad60f04bea0ec3",
1868
+ # "kind": "DEPOSIT",
1869
+ # "status": "COMPLETED",
1870
+ # "amount": "100000",
1871
+ # "token": "USDC",
1872
+ # "created_at": 1718940471208,
1873
+ # "last_updated_at": 1718941455546,
1874
+ # "txn_hash": "0x73a415ca558a97bbdcd1c43e52b45f1e0486a0a84b3bb4958035ad6c59cb866",
1875
+ # "external_txn_hash": "",
1876
+ # "socialized_loss_factor": ""
1877
+ # }
1878
+ # ]
1879
+ # }
1880
+ #
1881
+ rows = self.safe_list(response, 'results', [])
1882
+ deposits = []
1883
+ for i in range(0, len(rows)):
1884
+ row = rows[i]
1885
+ if row['kind'] == 'WITHDRAWAL':
1886
+ deposits.append(row)
1887
+ return self.parse_transactions(deposits, None, since, limit)
1888
+
1889
+ def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
1890
+ #
1891
+ # fetchDeposits & fetchWithdrawals
1892
+ #
1893
+ # {
1894
+ # "id": "1718940471200201703989430000",
1895
+ # "account": "0x49ddd7a564c978f6e4089ff8355b56a42b7e2d48ba282cb5aad60f04bea0ec3",
1896
+ # "kind": "DEPOSIT",
1897
+ # "status": "COMPLETED",
1898
+ # "amount": "100000",
1899
+ # "token": "USDC",
1900
+ # "created_at": 1718940471208,
1901
+ # "last_updated_at": 1718941455546,
1902
+ # "txn_hash": "0x73a415ca558a97bbdcd1c43e52b45f1e0486a0a84b3bb4958035ad6c59cb866",
1903
+ # "external_txn_hash": "",
1904
+ # "socialized_loss_factor": ""
1905
+ # }
1906
+ #
1907
+ id = self.safe_string(transaction, 'id')
1908
+ address = self.safe_string(transaction, 'account')
1909
+ txid = self.safe_string(transaction, 'txn_hash')
1910
+ currencyId = self.safe_string(transaction, 'token')
1911
+ code = self.safe_currency_code(currencyId, currency)
1912
+ timestamp = self.safe_integer(transaction, 'created_at')
1913
+ updated = self.safe_integer(transaction, 'last_updated_at')
1914
+ type = self.safe_string(transaction, 'kind')
1915
+ type = 'deposit' if (type == 'DEPOSIT') else 'withdrawal'
1916
+ status = self.parse_transaction_status(self.safe_string(transaction, 'status'))
1917
+ amount = self.safe_number(transaction, 'amount')
1918
+ return {
1919
+ 'info': transaction,
1920
+ 'id': id,
1921
+ 'txid': txid,
1922
+ 'timestamp': timestamp,
1923
+ 'datetime': self.iso8601(timestamp),
1924
+ 'network': None,
1925
+ 'address': address,
1926
+ 'addressTo': address,
1927
+ 'addressFrom': None,
1928
+ 'tag': None,
1929
+ 'tagTo': None,
1930
+ 'tagFrom': None,
1931
+ 'type': type,
1932
+ 'amount': amount,
1933
+ 'currency': code,
1934
+ 'status': status,
1935
+ 'updated': updated,
1936
+ 'internal': None,
1937
+ 'comment': None,
1938
+ 'fee': None,
1939
+ }
1940
+
1941
+ def parse_transaction_status(self, status: Str):
1942
+ statuses: dict = {
1943
+ 'PENDING': 'pending',
1944
+ 'AVAILABLE': 'pending',
1945
+ 'COMPLETED': 'ok',
1946
+ 'FAILED': 'failed',
1947
+ }
1948
+ return self.safe_string(statuses, status, status)
1949
+
1950
+ def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
1951
+ url = self.implode_hostname(self.urls['api'][self.version]) + '/' + self.implode_params(path, params)
1952
+ query = self.omit(params, self.extract_params(path))
1953
+ if api == 'public':
1954
+ if query:
1955
+ url += '?' + self.urlencode(query)
1956
+ elif api == 'private':
1957
+ self.check_required_credentials()
1958
+ headers = {
1959
+ 'Accept': 'application/json',
1960
+ 'PARADEX-PARTNER': self.safe_string(self.options, 'broker', 'CCXT'),
1961
+ }
1962
+ # TODO: optimize
1963
+ if path == 'auth':
1964
+ headers['PARADEX-STARKNET-ACCOUNT'] = query['account']
1965
+ headers['PARADEX-STARKNET-SIGNATURE'] = query['signature']
1966
+ headers['PARADEX-TIMESTAMP'] = str(query['timestamp'])
1967
+ headers['PARADEX-SIGNATURE-EXPIRATION'] = str(query['expiration'])
1968
+ elif path == 'onboarding':
1969
+ headers['PARADEX-ETHEREUM-ACCOUNT'] = self.walletAddress
1970
+ headers['PARADEX-STARKNET-ACCOUNT'] = query['account']
1971
+ headers['PARADEX-STARKNET-SIGNATURE'] = query['signature']
1972
+ headers['PARADEX-TIMESTAMP'] = str(self.nonce())
1973
+ headers['Content-Type'] = 'application/json'
1974
+ body = self.json({
1975
+ 'public_key': query['public_key'],
1976
+ })
1977
+ else:
1978
+ token = self.options['authToken']
1979
+ headers['Authorization'] = 'Bearer ' + token
1980
+ if method == 'POST':
1981
+ headers['Content-Type'] = 'application/json'
1982
+ body = self.json(query)
1983
+ else:
1984
+ url = url + '?' + self.urlencode(query)
1985
+ # headers = {
1986
+ # 'Accept': 'application/json',
1987
+ # 'Authorization': 'Bearer ' + self.apiKey,
1988
+ # }
1989
+ # if method == 'POST':
1990
+ # body = self.json(query)
1991
+ # headers['Content-Type'] = 'application/json'
1992
+ # else:
1993
+ # if query:
1994
+ # url += '?' + self.urlencode(query)
1995
+ # }
1996
+ # }
1997
+ return {'url': url, 'method': method, 'body': body, 'headers': headers}
1998
+
1999
+ def handle_errors(self, httpCode: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
2000
+ if not response:
2001
+ return None # fallback to default error handler
2002
+ #
2003
+ # {
2004
+ # "data": null,
2005
+ # "error": "NOT_ONBOARDED",
2006
+ # "message": "User has never called /onboarding endpoint"
2007
+ # }
2008
+ #
2009
+ errorCode = self.safe_string(response, 'error')
2010
+ if errorCode is not None:
2011
+ feedback = self.id + ' ' + body
2012
+ self.throw_broadly_matched_exception(self.exceptions['broad'], body, feedback)
2013
+ self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
2014
+ raise ExchangeError(feedback) # unknown message
2015
+ return None