Align datetime import in fiat_convert

This commit is contained in:
Matthias 2022-10-07 14:00:04 +02:00
parent 1cabfe8d0a
commit fab6b2f105

View File

@ -3,8 +3,8 @@ Module that define classes to convert Crypto-currency to FIAT
e.g BTC to USD
"""
import datetime
import logging
from datetime import datetime
from typing import Dict, List
from cachetools import TTLCache
@ -67,7 +67,7 @@ class CryptoToFiatConverter(LoggingMixin):
logger.warning(
"Too many requests for CoinGecko API, backing off and trying again later.")
# Set backoff timestamp to 60 seconds in the future
self._backoff = datetime.datetime.now().timestamp() + 60
self._backoff = datetime.now().timestamp() + 60
return
# If the request is not a 429 error we want to raise the normal error
logger.error(
@ -81,7 +81,7 @@ class CryptoToFiatConverter(LoggingMixin):
def _get_gekko_id(self, crypto_symbol):
if not self._coinlistings:
if self._backoff <= datetime.datetime.now().timestamp():
if self._backoff <= datetime.now().timestamp():
self._load_cryptomap()
# Still not loaded.
if not self._coinlistings: