{"repo":"VeKiner/akshare-stock-data-fetcher","free":true,"listed":false,"github":"https://github.com/VeKiner/akshare-stock-data-fetcher","clone":"git clone https://github.com/VeKiner/akshare-stock-data-fetcher.git","description":"基于 AKShare 的 A 股行情批量采集工具，支持分钟线、实时行情，内置代理轮转 + MongoDB 存储 + 定时调度，解决RemoteDisconnected问题。","language":"Python","stars":110,"topics":["a-share","akshare","mongodb","proxy","python","quantitative-finance","stock"],"license":"MIT","category":"trading","readme_excerpt":"akshare-stock-data-fetcher 基于 AKShare 的 A 股行情数据批量采集工具，支持分钟线历史数据、实时行情快照，内置代理轮转、MongoDB 持久化存储与定时调度，开箱即用。 English 中文 --- ✨ Features - 分钟线历史数据 ：批量抓取全市场 A 股 5 分钟 K 线，多进程并行 + 超时自动重试 - 实时行情快照 ：定时抓取 stock zh a spot em 全量行情，自动写入 MongoDB - 代理轮转 ：内置健壮的代理池管理，支持多代理轮转 + 直连兜底，彻底解决 AKShare 被限频/封 IP 问题 - 交易日判断 ：自动跳过非交易日，无需手动维护日历 - 股票代码同步 ：每日自动更新全量股票代码到本地文件 - 定时调度 ：基于 schedule 库，支持任意时间点触发 --- 📁 Project Structure --- 🚀 Quick Start 1. 安装依赖 2. 配置代理（可选但强烈推荐） 在 utils.py / utils spot.py / utils spot1.py 中，将以下占位符替换为你自己的代理 API 地址： 推荐使用按量付费的动态住宅代理（如 极量IP、快代理 等），返回格式为 ip:port:user:password 。 如果不使用代理， stock zh a spot em proxy strength.py 的 build rotating get 中已内置 include direct=True 直连兜底，可在低频场景下直接使用。 3. 配置 MongoDB 在各主脚本的 main 块中填入你的 MongoDB 连接信息： 4. 同步股票代码 生成 stock codes.txt ，供分钟线抓取脚本使用。 5. 抓取分钟线历史数据 默认每天 16:00 触发，抓取全市场当日 5 分钟 K 线并存入 MongoDB，支持失败自动重试（默认重试 6 次）。 6. 抓取实时行情快照 基础版（简单代理）： 强代理轮转版（推荐用于生产环境）： 默认每天 15:50 触发。 --- ⚙️ Configuration 参数 位置 说明 ------ ------ ------ num workers stock zh a hist min em.py 并行进程数，默认 32，按机器性能调整 max timeout scheduled task() 单只股票最长处理时间（秒），默认 30 max retries scheduled task() 失败重试次数，默认 6 total ak retries stock zh a spot em proxy strength.py AKShare 调用重试次数，默认 3 schedule time 各主脚本 main 定时触发时间，按需修改 --- 🔧 Why Proxy? AKShare 底层直接请求东财等数据源，高频批量请求容易触发限流（429）或封 IP。本项目的代理方案： 1. 请求前动态从代理 API 获取最新 IP 2. 多代理顺序轮转，失败自动切换 3. 支持直连兜底（ include direct=True ） 4. 内置 urllib3.Retry 应对 429/5xx 自动退避重试 5. 使用 unittest.mock.patch 无侵入地替换 AKShare 内部的 requests.get ，无需修改 AKShare 源码 --- 📦 Dependencies - akshar","default_branch":null,"files":null,"tree":[],"storefront":"/r/VeKiner","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/VeKiner/akshare-stock-data-fetcher/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}