fix(flask_api): 保留code列确保本地与线上数据结构一致
FlaskAPIDataSource.fetch() 原硬编码只选择 OHLCV 列,丢失 code 列 修改为动态判断:若 API 返回包含 code 列则保留 确保本地 UniversalDataFetcher 与线上 FlaskAPIDataSource 返回数据结构一致
This commit is contained in:
@@ -146,8 +146,11 @@ class FlaskAPIDataSource:
|
||||
df['date'] = pd.to_datetime(df['date'])
|
||||
df = df.set_index('date')
|
||||
|
||||
# 确保列名标准化
|
||||
df = df[['open', 'high', 'low', 'close', 'volume']]
|
||||
# 确保列名标准化(保留 code 列如果存在)
|
||||
standard_cols = ['open', 'high', 'low', 'close', 'volume']
|
||||
if 'code' in df.columns:
|
||||
standard_cols = ['code'] + standard_cols
|
||||
df = df[standard_cols]
|
||||
|
||||
# 使用 API 返回的实际数据范围(而非请求参数)
|
||||
actual_start = data.get('date_range', {}).get('start', start_date)
|
||||
|
||||
Reference in New Issue
Block a user