🛠️ refactor(data_downloader.py): 修正更新时间逻辑,并修复更新模式查询逻辑
This commit is contained in:
parent
741a7c2d34
commit
541d39139b
@ -339,7 +339,7 @@ def split_list_into_chunks(data_list, num_chunks):
|
||||
return chunks
|
||||
|
||||
|
||||
def process_stock_batch(batch, config, update_mode, start_date, end_date, update_time):
|
||||
def process_stock_batch(batch, config, update_mode, start_date, end_date):
|
||||
"""
|
||||
处理一批股票的工作函数(在单独进程中运行)
|
||||
|
||||
@ -349,7 +349,6 @@ def process_stock_batch(batch, config, update_mode, start_date, end_date, update
|
||||
update_mode: 更新模式 'full' 或 'incremental'
|
||||
start_date: 开始日期
|
||||
end_date: 结束日期
|
||||
update_time: 当前更新时间戳
|
||||
|
||||
Returns:
|
||||
dict: 包含处理结果统计信息的字典
|
||||
@ -373,6 +372,8 @@ def process_stock_batch(batch, config, update_mode, start_date, end_date, update
|
||||
total_stocks = len(batch)
|
||||
|
||||
for i, stock_info in enumerate(batch):
|
||||
# 当前更新时间
|
||||
update_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
# 根据更新模式获取不同的参数
|
||||
if update_mode == 'full':
|
||||
ts_code = stock_info
|
||||
@ -588,7 +589,7 @@ def perform_full_update(start_year=2020, processes=4, resume=False):
|
||||
query = """
|
||||
SELECT ts_code
|
||||
FROM stock_metadata
|
||||
WHERE list_status = 'L' AND status = 2
|
||||
WHERE list_status = 'L' AND status != 1
|
||||
"""
|
||||
else:
|
||||
# 查询所有已上市的股票
|
||||
@ -610,9 +611,6 @@ def perform_full_update(start_year=2020, processes=4, resume=False):
|
||||
|
||||
print(f"共找到 {len(stock_codes)} 只股票需要{update_type}")
|
||||
|
||||
# 当前更新时间
|
||||
update_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
# 将股票列表分成多个批次
|
||||
batches = split_list_into_chunks(stock_codes, processes)
|
||||
|
||||
@ -624,8 +622,7 @@ def perform_full_update(start_year=2020, processes=4, resume=False):
|
||||
config=config,
|
||||
update_mode='full',
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
update_time=update_time
|
||||
end_date=end_date
|
||||
)
|
||||
|
||||
# 启动多进程处理并收集结果
|
||||
|
Loading…
Reference in New Issue
Block a user