-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #708 from tellor-io/CBETH-USD
Add CBETH/USD feed
- Loading branch information
Showing
7 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from telliot_feeds.datafeed import DataFeed | ||
from telliot_feeds.queries.price.spot_price import SpotPrice | ||
from telliot_feeds.sources.price.spot.coingecko import CoinGeckoSpotPriceSource | ||
from telliot_feeds.sources.price.spot.coinpaprika import CoinpaprikaSpotPriceSource | ||
from telliot_feeds.sources.price.spot.uniswapV3 import UniswapV3PriceSource | ||
from telliot_feeds.sources.price_aggregator import PriceAggregator | ||
|
||
cbeth_usd_median_feed = DataFeed( | ||
query=SpotPrice(asset="CBETH", currency="USD"), | ||
source=PriceAggregator( | ||
asset="cbeth", | ||
currency="usd", | ||
algorithm="median", | ||
sources=[ | ||
CoinGeckoSpotPriceSource(asset="cbeth", currency="usd"), | ||
UniswapV3PriceSource(asset="cbeth", currency="usd"), | ||
CoinpaprikaSpotPriceSource(asset="cbeth-coinbase-wrapped-staked-eth", currency="usd"), | ||
], | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ | |
"OETH/ETH", | ||
"WLD/USD", | ||
"DIVA/USD", | ||
"CBETH/USD", | ||
] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import statistics | ||
|
||
import pytest | ||
|
||
from telliot_feeds.feeds.cbeth_usd_feed import cbeth_usd_median_feed | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_cbeth_usd_median_feed(caplog): | ||
"""Retrieve median STETH/USD price.""" | ||
v, _ = await cbeth_usd_median_feed.source.fetch_new_datapoint() | ||
|
||
assert v is not None | ||
assert v > 0 | ||
assert "sources used in aggregate: 3" in caplog.text.lower() | ||
print(f"CBETH/USD Price: {v}") | ||
|
||
# Get list of data sources from sources dict | ||
source_prices = [source.latest[0] for source in cbeth_usd_median_feed.source.sources if source.latest[0]] | ||
|
||
# Make sure error is less than decimal tolerance | ||
assert (v - statistics.median(source_prices)) < 10**-6 |