-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
49 additions
and
0 deletions.
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,17 @@ | ||
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_aggregator import PriceAggregator | ||
|
||
|
||
superoethb_eth_median_feed = DataFeed( | ||
query=SpotPrice(asset="SUPEROETHB", currency="ETH"), | ||
source=PriceAggregator( | ||
asset="superoethb", | ||
currency="eth", | ||
algorithm="median", | ||
sources=[ | ||
CoinGeckoSpotPriceSource(asset="superoethb", currency="eth"), | ||
], | ||
), | ||
) |
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 |
---|---|---|
|
@@ -99,6 +99,7 @@ | |
"TARA/USD", | ||
"PUFETH/USD", | ||
"STONE/USD", | ||
"SUPEROETHB/ETH", | ||
] | ||
|
||
|
||
|
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.superoethb_eth_feed import superoethb_eth_median_feed | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_superoethb_eth_median_feed(caplog): | ||
"""Retrieve median superOETHb/ETH price.""" | ||
v, _ = await superoethb_eth_median_feed.source.fetch_new_datapoint() | ||
|
||
assert v is not None | ||
assert v > 0 | ||
assert "sources used in aggregate: 1" in caplog.text.lower() | ||
print(f"superOETHb/eth Price: {v}") | ||
|
||
# Get list of data sources from sources dict | ||
source_prices = [source.latest[0] for source in superoethb_eth_median_feed.source.sources if source.latest[0]] | ||
|
||
# Make sure error is less than decimal tolerance | ||
assert (v - statistics.median(source_prices)) < 10**-6 |