Spaces:
Sleeping
Sleeping
Commit ·
8eaee9b
1
Parent(s): 775c66a
fix(dashboard): Correct data fetching for Feature Simulator
Browse filesFiles changed (2)
16 unmodified lines1718192021222324252627282930313233343536373816 unmodified lines@st.cache_data(ttl=300) # Cache for 5 minutesdef fetch_volume_data(token_symbol: str):"""Fetches historical 24h volume data for a specific token."""conn = get_db_connection()# Get token_id from symboltoken_id_query = "SELECT id FROM tokens WHERE symbol = ?"token_id_df = pd.read_sql_query(token_id_query, conn, params=(token_symbol,))if token_id_df.empty:conn.close()return pd.Series(dtype='float64') # Return empty series if token not foundtoken_id = token_id_df.iloc[0, 0]# Fetch volume datavolume_query = "SELECT volume_24h FROM prices WHERE token_id = ?"df_volume = pd.read_sql_query(volume_query, conn, params=(token_id,))conn.close()return df_volume['volume_24h']def render_feature_view():16 unmodified lines1718192021222324252627282930313233343536373839404142434416 unmodified lines@st.cache_data(ttl=300) # Cache for 5 minutesdef fetch_volume_data(token_symbol: str):"""Fetches historical 24h volume data for a specific token using a single, robust JOIN query."""conn = get_db_connection()# --- NEW: A single, more reliable query using a JOIN ---query = """SELECT p.volume_24hFROM prices pJOIN tokens t ON p.token_id = t.idWHERE t.symbol = ?AND p.source = 'Binance'AND p.volume_24h IS NOT NULL"""try:df_volume = pd.read_sql_query(query, conn, params=(token_symbol,))except Exception as e:st.error(f"Database query failed: {e}")df_volume = pd.DataFrame({'volume_24h': []}) # Return empty dataframe on errorfinally:conn.close()return df_volume['volume_24h']def render_feature_view():
__pycache__/config.cpython-313.pyc
dashboard/feature_view.py+18-12