diff --git a/data_platform/updater.py b/data_platform/updater.py index a83f287d..bb28a1fb 100644 --- a/data_platform/updater.py +++ b/data_platform/updater.py @@ -82,11 +82,13 @@ def fetch_tencent_daily(code: str, start_date: str, end_date: str): if not klines: return None - # kline format: [date, open, close, high, low, volume] - df = pd.DataFrame(klines, columns=['date', 'open', 'close', 'high', 'low', 'volume']) - for c in ['open', 'close', 'high', 'low', 'volume']: - df[c] = pd.to_numeric(df[c], errors='coerce').fillna(0) - df['amount'] = 0.0 + # kline format: [date, open, close, high, low, volume] or 7 cols with amount + ncols = len(klines[0]) if klines else 6 + if ncols == 7: + df = pd.DataFrame(klines, columns=['date', 'open', 'close', 'high', 'low', 'volume', 'amount']) + else: + df = pd.DataFrame(klines, columns=['date', 'open', 'close', 'high', 'low', 'volume']) + df['amount'] = 0.0 df['date'] = pd.to_datetime(df['date']).dt.strftime('%Y-%m-%d') mask = (df['date'] >= start_date) & (df['date'] <= end_date) result = df.loc[mask, ['date', 'open', 'high', 'low', 'close', 'volume', 'amount']]