Chainlink
Examples
In [1]:
from ctc.protocols import chainlink_utils
In [2]:
feed = 'FEI_USD'
Summarize Feed¶
In [3]:
await chainlink_utils.async_summarize_feed(feed)
┌───────────────────────────────────┐ │ Chainlink Feed Summary: FEI / USD │ └───────────────────────────────────┘ - name: FEI / USD - address: 0x31e0a88fecb6ec0a411dbe0e9e76391498296ee9 - aggregator: 0x1d244648d5a63618751d006886268ae3550d0dfd - decimals: 8 Recent Updates ────────────── value │ age │ block │ timestamp │ time ──────────────┼──────────────┼────────────┼──────────────┼──────────────────────── 0.998108 │ 15 minutes │ 14662123 │ 1651003533 │ 2022-04-26 20:05:33Z 0.997365 │ 1 hours │ 14661863 │ 1650999925 │ 2022-04-26 19:05:25Z 0.995403 │ 2 hours │ 14661614 │ 1650996330 │ 2022-04-26 18:05:30Z 0.996719 │ 3 hours │ 14661346 │ 1650992723 │ 2022-04-26 17:05:23Z 0.996706 │ 4 hours │ 14661090 │ 1650989118 │ 2022-04-26 16:05:18Z 0.99725072 │ 5 hours │ 14660817 │ 1650985550 │ 2022-04-26 15:05:50Z 0.99548 │ 6 hours │ 14660562 │ 1650981933 │ 2022-04-26 14:05:33Z 0.996838 │ 7 hours │ 14660312 │ 1650978379 │ 2022-04-26 13:06:19Z 0.99830072 │ 8 hours │ 14660046 │ 1650974799 │ 2022-04-26 12:06:39Z 0.996877 │ 9 hours │ 14659806 │ 1650971206 │ 2022-04-26 11:06:46Z
Get current value of feed¶
In [4]:
await chainlink_utils.async_get_feed_datum(feed)
Out[4]:
0.998108
Get historical values of a feed¶
In [5]:
feed_data = await chainlink_utils.async_get_feed_data(feed)
feed_data
Out[5]:
block_number 12907805 1.005519 12908175 1.017371 12908243 1.007141 12914636 1.001345 12920910 1.002064 ... 14661090 0.996706 14661346 0.996719 14661614 0.995403 14661863 0.997365 14662123 0.998108 Name: answer, Length: 4432, dtype: object
Get interpolated historical values of a feed¶
In [6]:
feed_data = await chainlink_utils.async_get_feed_data(feed, interpolate=True)
feed_data
Out[6]:
block_number 12907805 1.005519 12907806 1.005519 12907807 1.005519 12907808 1.005519 12907809 1.005519 ... 14662171 0.998108 14662172 0.998108 14662173 0.998108 14662174 0.998108 14662175 0.998108 Name: answer, Length: 1754371, dtype: float64
Reference
- async ctc.protocols.chainlink_utils.async_summarize_feed(feed, n_recent=10)
- Parameters
feed (<class 'str'>) –
n_recent (<class 'int'>) –
- Return type
<class ‘NoneType’>