Skip to content

BobTheBuidler/ypricemagic

Repository files navigation

Summary

Use this tool to extract historical on-chain price data from an archive node. ypricemagic will work with both sync and async python codebases.

Installation

To install:

ypricemagic is published on pypi. Simply install it just as you would any other library.

pip install ypricemagic
Known Issues:

Make sure you are using Python >= 3.8 and < 3.11
If you have a PyYaml Issue with 3.4.1 not installing due to an issue with cython, try the following:

pip install wheel
pip install --no-build-isolation "Cython<3" "pyyaml==5.4.1"

then try again pip install ypricemagic

Usage

There are 2 main entrypoints to ypricemagic, y.get_price and y.get_prices.

from y import get_price
price = get_price(token,block)

# OR

from y import get_prices
prices = get_prices(tokens, block)

You can also use ypricemagic asynchronously:

price = await get_price(token,block, sync=False)

# OR

prices = await get_prices(tokens, block, sync=False)

See the docs for more usage information.

Extras

You can also import protocol specific modules. For example:

from ypricemagic import uniswap
uniswap.get_price(token, block)
from ypricemagic.compound import get_price
get_price(compoundToken, block)

These are not 'supported' per se and are subject to change at any time. But they can come in handy. The not-very-organized docs site will be your friend here.

Enjoy!

Shoutouts

Shoutout to Banteg (@bantg) and nymmrx (@nymmrx) for their awesome work on yearn-exporter that made this library possible.