Skip to content

Commit 1aaf9a4

Browse files
committed
address delisted exception when coin is gone
1 parent 42c0df2 commit 1aaf9a4

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

lib/bot.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,27 +1783,31 @@ def load_klines_for_coin(self, coin: Coin) -> bool:
17831783
"""fetches from binance or a local cache klines for a coin"""
17841784

17851785
ok: bool = False
1786-
data: Dict[str, Dict[str, List[List[float]]]] = {}
1787-
# fetch all the available klines for this coin, for the last
1788-
# 60min, 24h, and 1000 days
1789-
logging.debug("calling klines_caching_service_url")
1790-
response: requests.Response = requests.get(
1791-
self.klines_caching_service_url
1792-
+ f"?symbol={coin.symbol}"
1793-
+ f"&date={coin.date}"
1794-
+ f"&mode={self.mode}"
1795-
+ f"&debug={self.debug}",
1796-
timeout=30,
1797-
)
1798-
data = response.json()
1799-
if data:
1800-
logging.debug("klines_caching_service_url reponse: ok")
1801-
ok = True
1802-
coin.lowest = data["lowest"]
1803-
coin.averages = data["averages"]
1804-
coin.highest = data["highest"]
1805-
logging.debug(f"klines_caching_service_url reponse: {data}")
1806-
1786+
try:
1787+
# fetch all the available klines for this coin, for the last
1788+
# 60min, 24h, and 1000 days
1789+
logging.debug("calling klines_caching_service_url")
1790+
response: requests.Response = requests.get(
1791+
self.klines_caching_service_url
1792+
+ f"?symbol={coin.symbol}"
1793+
+ f"&date={coin.date}"
1794+
+ f"&mode={self.mode}"
1795+
+ f"&debug={self.debug}",
1796+
timeout=30,
1797+
)
1798+
data: Dict[str, Dict[str, List[List[float]]]] = response.json()
1799+
if data:
1800+
logging.debug("klines_caching_service_url reponse: ok")
1801+
coin.lowest = data["lowest"]
1802+
coin.averages = data["averages"]
1803+
coin.highest = data["highest"]
1804+
logging.debug(f"klines_caching_service_url reponse: {data}")
1805+
ok = True
1806+
except Exception as error_msg: # pylint: disable=broad-except
1807+
logging.warning(
1808+
f"Error calling klines_caching_serice {coin.symbol} {coin.date}"
1809+
)
1810+
logging.debug(f"Exception: {error_msg}")
18071811
return ok
18081812

18091813
@retry(wait=wait_exponential(multiplier=1, max=3))

0 commit comments

Comments
 (0)