-
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
7 changed files
with
54 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,20 @@ | ||
from telliot_feeds.datafeed import DataFeed | ||
from telliot_feeds.queries.price.spot_price import SpotPrice | ||
from telliot_feeds.sources.price.spot.okx import OKXSpotPriceSource | ||
from telliot_feeds.sources.price.spot.kraken import KrakenSpotPriceSource | ||
from telliot_feeds.sources.price.spot.uniswapV3 import UniswapV3PriceSource | ||
from telliot_feeds.sources.price_aggregator import PriceAggregator | ||
|
||
lsk_usd_median_feed = DataFeed( | ||
query=SpotPrice(asset="LSK", currency="USD"), | ||
source=PriceAggregator( | ||
asset="lsk", | ||
currency="usd", | ||
algorithm="median", | ||
sources=[ | ||
OKXSpotPriceSource(asset="lsk", currency="usdt"), | ||
KrakenSpotPriceSource(asset="lsk", currency="usd"), | ||
UniswapV3PriceSource(asset="lsk", 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 |
---|---|---|
|
@@ -100,6 +100,7 @@ | |
"PUFETH/USD", | ||
"STONE/USD", | ||
"SUPEROETHB/ETH", | ||
"LSK/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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
"FIL", | ||
"LINK", | ||
"PYTH", | ||
"LSK", | ||
} | ||
KRAKEN_CURRENCIES = {"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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import statistics | ||
|
||
import pytest | ||
|
||
from telliot_feeds.feeds.lsk_usd_feed import lsk_usd_median_feed | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_lsk_usd_median_feed(caplog): | ||
"""Retrieve median lsk/usd price.""" | ||
v, _ = await lsk_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"lsk/usd Price: {v}") | ||
|
||
# Get list of data sources from sources dict | ||
source_prices = [source.latest[0] for source in lsk_usd_median_feed.source.sources] | ||
print(source_prices) | ||
|
||
# Make sure error is less than decimal tolerance | ||
assert (v - statistics.median(source_prices)) < 10**-6 |