Merge 5cdbf5b2d7bb560b1a370f225db1dd5a614130c9 into ce8179f07e4fb8740b43570aa2c5826447c2af26
This commit is contained in:
commit
6c4d981343
@ -1,16 +1,20 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import List
|
from typing import List
|
||||||
|
import time
|
||||||
|
|
||||||
from pycoingecko import CoinGeckoAPI
|
from pycoingecko import CoinGeckoAPI
|
||||||
|
|
||||||
from mev_inspect.schemas.prices import COINGECKO_ID_BY_ADDRESS, TOKEN_ADDRESSES, Price
|
from mev_inspect.schemas.prices import COINGECKO_ID_BY_ADDRESS, TOKEN_ADDRESSES, Price
|
||||||
|
|
||||||
|
SLEEP_TIME = 10
|
||||||
|
|
||||||
def fetch_prices() -> List[Price]:
|
def fetch_prices() -> List[Price]:
|
||||||
coingecko_api = CoinGeckoAPI()
|
coingecko_api = CoinGeckoAPI()
|
||||||
prices = []
|
prices = []
|
||||||
|
|
||||||
for token_address in TOKEN_ADDRESSES:
|
for token_address in TOKEN_ADDRESSES:
|
||||||
|
# Avoid Coingecko's API rate limits
|
||||||
|
time.sleep(SLEEP_TIME)
|
||||||
coingecko_price_data = coingecko_api.get_coin_market_chart_by_id(
|
coingecko_price_data = coingecko_api.get_coin_market_chart_by_id(
|
||||||
id=COINGECKO_ID_BY_ADDRESS[token_address],
|
id=COINGECKO_ID_BY_ADDRESS[token_address],
|
||||||
vs_currency="usd",
|
vs_currency="usd",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user