hi, this part of my code gives me headache but i guess because i am a beginner/ the .dv and ‘data’ is returning errors in replit. could someone help? thank you
Convert to DataFrame - handle different API response formats
try:
df = bars.dv <====================
except AttributeError:
# Fallback for newer API versions
import pandas as pd
import pandas as pd
if hasattr(bars, 'data') and isinstance(bars.data, dict) and symbol in bars.data: <=====
bars_data = bars.data[symbol] <=====
df = pd.DataFrame([{
'timestamp': bar.timestamp,
'open': bar.open,
'high': bar.high,
'low': bar.low,
'close': bar.close,
'volume': bar.volume,
'symbol': symbol
} for bar in bars_data])
df.set_index('timestamp', inplace=True)
else:
df = None
if df is None:
raise Exception("No data for symbol")