auto-sync: 2026-05-02 19:04:11

This commit is contained in:
cfdaily
2026-05-02 19:04:11 +08:00
parent 149a31f427
commit 660b3749bc
+7 -5
View File
@@ -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']]