File tree Expand file tree Collapse file tree 3 files changed +26
-5
lines changed
Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -441,8 +441,16 @@ async def get_top_categories() -> pd.DataFrame | None:
441441
442442 # Category column (including name and link)
443443 if i == 1 :
444- coin_data ["Name" ] = td .find ("a" ).text
445- coin_data ["Link" ] = "https://www.coingecko.com/" + td .find ("a" )["href" ]
444+ # Defaults
445+ coin_data ["Name" ] = "unknown"
446+ coin_data ["Link" ] = "https://www.coingecko.com/"
447+
448+ name_element = td .find ("a" )
449+ if name_element :
450+ coin_data ["Name" ] = name_element .text
451+ coin_data ["Link" ] = (
452+ "https://www.coingecko.com/" + name_element ["href" ]
453+ )
446454
447455 # 24h
448456 if i == 4 :
Original file line number Diff line number Diff line change 33import pandas as pd
44
55from api .http_client import get_json_data
6+ from constants .logger import logger
67
78
89async def get_etf_inflow (coin : str = "btc" ) -> float :
910 data = await get_json_data (f"https://farside.co.uk/{ coin } /" , text = True )
10- df = pd .read_html (StringIO (data ))[1 ]
11+ try :
12+ df = pd .read_html (StringIO (data ))[1 ]
13+ except ValueError :
14+ logger .error (f"Failed to parse ETF inflow data for { coin } " )
15+ return 0.0
1116
1217 # Use only top row for columns
1318 df .columns = [col [0 ] for col in df .columns ]
Original file line number Diff line number Diff line change @@ -90,7 +90,11 @@ def tv_market_data(self, url) -> pd.DataFrame:
9090 return
9191
9292 # Format the dataframe
93- df = df [columns ]
93+ try :
94+ df = df [columns ]
95+ except KeyError as e :
96+ logger .error (f"Failed to format TradingView market data: { e } " )
97+ return
9498
9599 # Create renaming dictionary dynamically
96100 rename_dict = {
@@ -235,7 +239,11 @@ async def crypto_categories(self) -> None:
235239 self .bot ,
236240 config ["LOOPS" ]["CRYPTO_CATEGORIES" ]["CHANNEL" ],
237241 )
238- df = await get_top_categories ()
242+ try :
243+ df = await get_top_categories ()
244+ except Exception as e :
245+ logger .error (f"Error getting coingecko crypto categories: { e } " )
246+ return
239247
240248 if df is None or df .empty :
241249 return
You can’t perform that action at this time.
0 commit comments