auto-sync: 2026-05-02 19:05:29

This commit is contained in:
cfdaily
2026-05-02 19:05:29 +08:00
parent 3fef9fddba
commit a639debf94
+6 -4
View File
@@ -83,11 +83,13 @@ def fetch_tencent_daily(code: str, start_date: str, end_date: str):
return None
# 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'])
df = pd.DataFrame(klines)
ncols = len(df.columns)
if ncols >= 7:
df.columns = ['date', 'open', 'close', 'high', 'low', 'volume', 'amount'][:ncols]
else:
df = pd.DataFrame(klines, columns=['date', 'open', 'close', 'high', 'low', 'volume'])
df.columns = ['date', 'open', 'close', 'high', 'low', 'volume'][:ncols]
if 'amount' not in df.columns:
df['amount'] = 0.0
for c in ['open', 'close', 'high', 'low', 'volume', 'amount']:
df[c] = pd.to_numeric(df[c], errors='coerce').fillna(0)