auto-sync: 2026-04-06 23:15:02

This commit is contained in:
cfdaily
2026-04-06 23:15:02 +08:00
parent 0b8afe76bd
commit b4927c871c
7 changed files with 154 additions and 31 deletions
@@ -51,7 +51,7 @@ class AStockDailyDownloader:
start_date: str = "2010-01-01",
end_date: Optional[str] = None,
retry_count: int = 3,
request_delay: float = 0.3
request_delay: float = 1.0
):
"""初始化下载器"""
self.base_dir = Path(base_dir)
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
"""
启动A股日线数据全量下载
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from a_stock_daily_data_downloader import AStockDailyDownloader
print("="*70)
print("🚀 赵云启动A股日线数据全量下载")
print("="*70)
# 创建下载器
downloader = AStockDailyDownloader(
base_dir="/Users/chufeng/.openclaw/sanguo_projects/sanguo_quant_live/zhaoyun-data/data/raw/daily",
start_date="2010-01-01",
end_date=None, # 到今天
retry_count=3,
request_delay=0.3
)
# 开始全量下载
result = downloader.download_all_stocks(
skip_downloaded=True,
batch_size=10
)
# 保存结果
result_file = "/Users/chufeng/.openclaw/sanguo_projects/sanguo_quant_live/zhaoyun-data/data/raw/running_data/daily_download_stats.json"
with open(result_file, 'w', encoding='utf-8') as f:
import json
json.dump(result, f, ensure_ascii=False, indent=2)
print("\n" + "="*70)
print("📊 日线数据全量下载完成")
print(f" 总股票数: {result['total_stocks']}")
print(f" 下载成功: {result['downloaded_stocks']}")
print(f" 下载失败: {result['failed_stocks']}")
print(f" 结果已保存: {result_file}")
print("="*70)
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
"""
测试单个股票下载看看具体问题
"""
import akshare as ak
import pandas as pd
import time
print("测试单个股票日线下载测试...")
# 测试一只正常股票
test_codes = ["000001", "600000"]
for code in test_codes:
print(f"\n{'='*60}")
print(f"测试股票代码: {code}")
print(f"{'='*60}")
for attempt in range(3):
try:
print(f"尝试 {attempt+1}/3...")
df = ak.stock_zh_a_hist(
symbol=code,
period="daily",
start_date="20240101",
end_date="20250101",
adjust="hfq"
)
if df is not None and not df.empty:
print(f"✅ 成功!获取到 {len(df)} 条记录")
print(f"列名: {list(df.columns)}")
print(f"\n前5行:\n{df.head()}")
break
else:
print("❌ 返回空数据")
time.sleep(2)
except Exception as e:
print(f"❌ 异常: {e}")
time.sleep(2)
print("\n{'='*60}")
print("测试完成")