英文:
Reading the price of multiple Uniswap tokens using Python
问题
我是一个相当初学者,正在制作一个Python机器人,用于比较交易所的价格,使用REST API来比较中心化交易所(CEXs)的价格非常容易明了。但是如何获取Uniswap的价格却一点也不明了。请问有人能告诉我获取大量代币的实际价格的最有效方法是什么吗?一一获取可能不适用,因为会耗费大量时间。是否有可能一次获取1000个代币的实际价格?就像你可以使用常规交易所的REST API一样。有什么工具可以做到这一点吗?我会非常感激任何建议,我甚至不知道从哪里开始。
我尝试使用Uniswap Subgraph V3,但似乎不适用于我,因为其中给出的特定池子价格忽略了流动性因素,只适用于1个代币的交换。如果你需要获取100个代币,实际价格将完全不同。
英文:
I'm quite a beginner and I'm doing a Python bot which is comparing prices on exchanges, it is easy and obvious to do it with REST API for CEXs but it's not obvious at all how to fetch prices for Uniswap. Could anybody please tell me what is the most efficient way of getting actual prices for a lot of tokens? One by one - I guess it is not the case cuz it takes a lot of time. Is it possible somehow to fetch actual prices for 1000 tokens at once? Like you can do it with REST API for usual exchanges. Is there any instruments for that? I would be really grateful for any advice, I don't even know where to look.
I tried it with Uniswap Subgraph V3 but it seems that it is not something that is going to work out for me cuz the prices given there for particular pools ignore the liquidity fact and it is actual only for 1 token swap. And it you need to get like 100 tokens - it would be completely different number in fact.
答案1
得分: 0
交易策略具有Uniswap v2(和兼容的版本)和Uniswap v3池的数据集。
-
作为Parquet文件的数据集,包含150,000个代币 - 您可以下载所有代币的每日价格数据,保存在一个几吉字节大小的文件中,然后可以使用Python Pandas轻松读取。
免责声明:我是作者。
英文:
Trading Strategy has datasets for Uniswap v2 (and compatible) and Uniswap v3 pools
-
Datasets as a Parquet file for 150k tokens - you can download the daily prices of all tokens in one nice file of few gigabytes which you can then easily read with Python Pandas
Disclaimer: I am the author
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论