# tushare_data **Repository Path**: wang_chuanxiang/tushare_data ## Basic Information - **Project Name**: tushare_data - **Description**: tushare数据抓取 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2025-09-05 - **Last Updated**: 2026-07-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Tushare 股票数据抓取 通过 Tushare 接口抓取全市场股票日线行情,写入本地 PostgreSQL;打包为 Windows 可执行程序后注册为 Windows 服务定时执行。 ## 环境依赖 ```bash pip install -r requirements.txt ``` 主要依赖:SQLAlchemy、psycopg2、tushare、requests、PyYAML。 ## 配置 所有可配置项集中在项目根目录的 `config.yaml`(数据库连接、Tushare token、通知地址、限频间隔、默认抓取天数、日志等)。修改配置无需改动代码。 > 说明:`config.yaml` 中含 Tushare token 与数据库密码,本项目按内部使用处理,直接纳入版本库。 ## 运行(开发调试) ```bash # 默认抓取最近 3 天(由 config.yaml 的 fetch.default_lookback_days 控制) python index.py # 指定日期范围 python index.py --start_date 20260101 --end_date 20260715 ``` 程序启动时会自动建表(CREATE TABLE IF NOT EXISTS,不会修改已存在的表结构)。 ## 打包为 Windows 可执行程序 ```bash pip install pyinstaller pyinstaller --onefile index.py ``` ### 部署运行(Windows 服务) - 产物 `dist\index.exe` 可独立运行,目标机器无需安装 Python。 - **必须**将 `config.yaml` 放到 `index.exe` 同级目录:程序按 exe 所在目录读取配置、写入 `app.log`,这样无需重新打包即可修改配置。 - 将 `index.exe` 注册为 Windows 服务(如借助 nssm)或用任务计划程序定时调度。 - 每次运行依赖本地 PostgreSQL 可连通,以及 `config.yaml` 中 `notify.url` 指定的完成通知服务在线。 ## 数据库表 DDL 见 `docs/ddl/` 下的 `.sql` 文件(仅供查阅;实际建表以 ORM 实体为准,启动时由程序自动执行)。