Skip to main content

Use this tool to extract historical on-chain price data from an archive node. Shoutout to @bantg and @nymmrx for their awesome work on yearn-exporter that made this library possible.

Project description

ypricemagic

PyPI Monthly Downloads

Use this tool to extract historical on-chain price data from an archive node.

ypricemagic is built to work seamlessly with both sync and async Python codebases using the ez-a-sync framework.

Requirements

  • Python 3.9 or higher.
  • At least 16GB of RAM.

Prerequisites

  • First, you will need to bring your own archive node. This can be one you run yourself, or one from one of the common providers (Tenderly, Alchemy, QuickNode, etc.)
  • You will also need an auth token for Etherscan's API. Follow their guide to get your key, and set env var ETHERSCAN_TOKEN with its value.

Installation

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

pip install ypricemagic

Network Configuration

ypricemagic utilizes the Brownie framework for Ethereum smart contract interactions. As such, it's essential that users configure a Brownie network to use their chosen RPC. Ensure you have access to an Ethereum node (e.g., through Infura or Alchemy) and add the provided API endpoint to your Brownie network configuration.

Refer to the Brownie documentation on network management for detailed guidance on setting up your networks. This setup is critical, as without it, ypricemagic will not be able to communicate with your RPC.

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.

Debug logging

If you need to spot long-running async calls, enable the y.stuck? logger at DEBUG to get periodic "still executing" messages. Details: y.stuck? logger.

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ypricemagic-5.2.26.dev0-cp313-cp313-win_amd64.whl (473.8 kB view details)

Uploaded CPython 3.13Windows x86-64

ypricemagic-5.2.26.dev0-cp313-cp313-win32.whl (444.3 kB view details)

Uploaded CPython 3.13Windows x86

ypricemagic-5.2.26.dev0-cp313-cp313-musllinux_1_2_x86_64.whl (742.9 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

ypricemagic-5.2.26.dev0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (747.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

ypricemagic-5.2.26.dev0-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (772.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ i686manylinux: glibc 2.5+ i686

ypricemagic-5.2.26.dev0-cp313-cp313-macosx_11_0_arm64.whl (540.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ypricemagic-5.2.26.dev0-cp312-cp312-win_amd64.whl (473.7 kB view details)

Uploaded CPython 3.12Windows x86-64

ypricemagic-5.2.26.dev0-cp312-cp312-win32.whl (444.5 kB view details)

Uploaded CPython 3.12Windows x86

ypricemagic-5.2.26.dev0-cp312-cp312-musllinux_1_2_x86_64.whl (750.3 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

ypricemagic-5.2.26.dev0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (756.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

ypricemagic-5.2.26.dev0-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (777.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ i686manylinux: glibc 2.5+ i686

ypricemagic-5.2.26.dev0-cp312-cp312-macosx_11_0_arm64.whl (541.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ypricemagic-5.2.26.dev0-cp311-cp311-win_amd64.whl (470.8 kB view details)

Uploaded CPython 3.11Windows x86-64

ypricemagic-5.2.26.dev0-cp311-cp311-win32.whl (441.8 kB view details)

Uploaded CPython 3.11Windows x86

ypricemagic-5.2.26.dev0-cp311-cp311-musllinux_1_2_x86_64.whl (724.1 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

ypricemagic-5.2.26.dev0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (730.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

ypricemagic-5.2.26.dev0-cp311-cp311-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (736.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ i686manylinux: glibc 2.5+ i686

ypricemagic-5.2.26.dev0-cp311-cp311-macosx_11_0_arm64.whl (539.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

ypricemagic-5.2.26.dev0-cp310-cp310-win_amd64.whl (470.8 kB view details)

Uploaded CPython 3.10Windows x86-64

ypricemagic-5.2.26.dev0-cp310-cp310-win32.whl (442.5 kB view details)

Uploaded CPython 3.10Windows x86

ypricemagic-5.2.26.dev0-cp310-cp310-musllinux_1_2_x86_64.whl (731.2 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

ypricemagic-5.2.26.dev0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (735.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

ypricemagic-5.2.26.dev0-cp310-cp310-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (745.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ i686manylinux: glibc 2.5+ i686

ypricemagic-5.2.26.dev0-cp310-cp310-macosx_11_0_arm64.whl (542.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file ypricemagic-5.2.26.dev0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 644da83714134aa0b86482f5b3293da5fd1464ed533e6a49bb768e5dfb1c6186
MD5 e608c6bdf63fbeb85b4d6b8c7aa5d904
BLAKE2b-256 e17fc9e724ae59297f46e85d4b9534a61d6ea7343f0b0a057081588c10ce364e

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp313-cp313-win32.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 a511b49b8ed619e99a244a5696f13415d0aa36e29bfb3ab41c2043f2cbac67bf
MD5 a68cca992f326dd9f09932594a4b4f77
BLAKE2b-256 9346d276602df82ad1d43373ef25850b4181cc1617abac717d6d39677de5c2e2

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7e22d5ba9481bb3ca81322903b4f81043ad759549108ea8354ccb3d62f0c95f4
MD5 ada92ae3c56cf714efd6673664774974
BLAKE2b-256 54454b6acf96add8a244a5730a85edab66ea2c0e20f15ee770abe633555fea5c

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 910ba863f254bac0f32d90895600496f544a17894478f26f9b17c8f79a30c97b
MD5 3cb6fd4771b226792a22ce3ae1afc3df
BLAKE2b-256 f24126d20b7b03ac1dc7fe3bf49adba15402ce5248294f0ae6c53f95da923643

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 c9e1de27f8092a289527fe4338f23ab27371f3a0da9ae5cb398f71ff5bd14a12
MD5 4ac9bd511348b8d77f6cfa2c4ac11c99
BLAKE2b-256 960228d57dbca5fe614647bee52a98ec68bab1dfb62169e84a08f29ecb0a0a84

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 78042d24a18318c945d574618e0dda25e2d7b10d3a6ffc7a819afe8b623396d2
MD5 bc4acdcfa461a97c300458ef8509b829
BLAKE2b-256 42a9960b78f136cf2abf0adf0d1fbe7b901b11b47840cefc5f8c430efed2e9ef

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cccd275aa01cefcd3054b23c1ce9b54b32677a643dfbba20655475a188e3831d
MD5 c7224d235e1a07c2636e9c122ff00af2
BLAKE2b-256 365702221b0e5944346cfdb984d3842cb22b2a93d610114cf0c53ec05127e9f4

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp312-cp312-win32.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 d54b5136794cb7c85c4705d67a93e7bb26229ba07b30ff06ce7a44e85d603765
MD5 d208f51215c1e0a4c01652be6ca8c9ce
BLAKE2b-256 e749eb2aa930ce33bf8e6c0ba9b03a66bf5f60c49e093f668de462ffe6a1a0a6

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 41bb4b049e20520e5ebdd1c0c903613b66d6742e0e952a12b2a0ae10874bcb07
MD5 621cd95f07a27b083e330d8c8717d901
BLAKE2b-256 0bd577f480799ac102b4f4983bc801c0ba990b5647e7b62bd2ee7a9886867be0

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4168894f4b2b8a1bca9a3fc99c7015dcec683eba1fc786d931f192782a18dc45
MD5 4fe1093c1e00dc8aa02e6a349dde52b6
BLAKE2b-256 6e5ba50e9ca249d4526c9138ec4a386354244c2c45fdb878631a87ce7462fcd1

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 92a79c3309f8d455230e46bbbed2aa9b4bf40d658848c847d90f1e52b476bc11
MD5 47d87b1effd95d2fcdab4896177ac362
BLAKE2b-256 c9aab4bb558cb0992c34c6212ed8da2f599eaae1636ead65e8b0d7dc96288ccc

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 023bbcac8bcab049f4fabafacf441fc6af470450cd11e160bbeed709916c2427
MD5 cb209960a7857b5e9215aad0da616d3c
BLAKE2b-256 c2fff316b64683e6a35aa6054b00ba5bc1ede83ef89d1c04d6f18a70bee37f83

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0cb67993c42371775f6e9301d9ce3f5e5327c525de596a06f26d6f79236d030c
MD5 0fe63cb92d8af287962534b6cf2c48d2
BLAKE2b-256 210120467ee7f34c86e97c7106ff7714a970c01a2d6efa0db9dfc45c68b5b4b8

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp311-cp311-win32.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 fd07b27c19fd5d885f6fcd615a3db630ebfc2068cfc455df8ad19f85d7862dd4
MD5 8143f56e1ccfec299d831d67abf884a1
BLAKE2b-256 68fb48d537642de3307725629739b94f9f83ec26ba0d4ae7203b6fe06cd7fd52

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 350be94a2cfa2eeb30384eba3caff975350884307d6920fa79c1ef818bd6f0f2
MD5 b5896fb827b06be4d93a226479c48104
BLAKE2b-256 932cbc418d7fca067b15cf06507dc5e1abe32870cdbfe69616d9d618ffffa1e7

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eb24f9f902d839fadd09e77768b95e0723f37e2527748eb3a171e3fc5902b50b
MD5 f73308d175fecef3cf793d5fdcf9f814
BLAKE2b-256 3f8c0f6bbc0529cc3b175844232163420902a6995a1d11d53479ea339ec923f7

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp311-cp311-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp311-cp311-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 9326b24bf664ccee6816f7f7a2e5f2ae48a0a719bfa15c5b283c97b6087cdf7c
MD5 d24bd3fa7c57aaebaf720546788c3a37
BLAKE2b-256 06c69d2e9f9dfae0012c1a4002aee640b4cae6d43cc51a6c2883368ade8fe0e7

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dc0575e5d60507cb16b64a883b11da6afafb91bf941af04ae341d27f369d9e4a
MD5 874545a6dbe81c66a60dfd5890599efb
BLAKE2b-256 60212650e1052e11061e90783680429d2c6c802ea021643946b4b3fe62f0677f

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 37a2f12cec66d62eee59445544b4945194c23897e76a0bf7d268afacb2584c28
MD5 89b3461cafa56439ef4a9da9a08da630
BLAKE2b-256 e5364614a5a79b5cae6620c269d33f1f2525d17fb4ed5b07d2f3ace174536d61

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp310-cp310-win32.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 b861dfaa5112e0468cca55330924752f6c1dc5c5806b2a2e2cedc89fb4f9bba9
MD5 d6a76ce16911c112e5bed2fedcece9b3
BLAKE2b-256 6a02926cac371892773298b19a93725c680e2264e6153b5451639e6c6e2e58a6

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7afce7f812a1b70f888a5ba31655ca8e7fa10f107b44c68277832f251a33f2f6
MD5 e6ba1818d61944fb7ad4b150af85c08a
BLAKE2b-256 b6983c6f7ed0a1a59996b4ddd069b11728af689244fb6684334f1d349bf3005f

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7c14b19db958c80c69f1728683a06f45a9be90c4fcfc47e89e7bc96ee4667c2a
MD5 85f1752913fe34aee9c88d2f98945e3e
BLAKE2b-256 e9d8700a616553874084e4480509bbdd569694c730b80be58392fef282d5eb08

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp310-cp310-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp310-cp310-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 b4ec4e045dc4a8608ccbaf9a10bd5df17d228fec25af888373a3e9c8d87c9b6b
MD5 ff95895a05327433c8334a4a625b3206
BLAKE2b-256 691eb9ec3f7f94a973ba3cc3168c47e2897097efd76d3fec708b8b5d90fa477c

See more details on using hashes here.

File details

Details for the file ypricemagic-5.2.26.dev0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ypricemagic-5.2.26.dev0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0e67bdb753f8d67e2e3bc2a89fafb66d518c9973a4635e45555cc486bd52e4c1
MD5 269a4450d460d1a13915896a197b0bd5
BLAKE2b-256 aa95cdcf75377c5e96ce13c42b0e89e817894dfbb033e1355d44af6841edf658

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page