finshare 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- finshare-0.1.1/LICENSE +21 -0
- finshare-0.1.1/PKG-INFO +212 -0
- finshare-0.1.1/README.md +179 -0
- finshare-0.1.1/finshare/__init__.py +85 -0
- finshare-0.1.1/finshare/__version__.py +4 -0
- finshare-0.1.1/finshare/config/__init__.py +9 -0
- finshare-0.1.1/finshare/config/settings.py +57 -0
- finshare-0.1.1/finshare/logger.py +152 -0
- finshare-0.1.1/finshare/models/__init__.py +34 -0
- finshare-0.1.1/finshare/models/data_models.py +125 -0
- finshare-0.1.1/finshare/sources/__init__.py +54 -0
- finshare-0.1.1/finshare/sources/baostock_source.py +268 -0
- finshare-0.1.1/finshare/sources/base_source.py +228 -0
- finshare-0.1.1/finshare/sources/data_source_manager.py +10 -0
- finshare-0.1.1/finshare/sources/eastmoney_source.py +482 -0
- finshare-0.1.1/finshare/sources/manager.py +336 -0
- finshare-0.1.1/finshare/sources/sina_source.py +312 -0
- finshare-0.1.1/finshare/sources/tdx_source.py +432 -0
- finshare-0.1.1/finshare/sources/tencent_source.py +406 -0
- finshare-0.1.1/finshare/utils/__init__.py +43 -0
- finshare-0.1.1/finshare/utils/validators.py +156 -0
- finshare-0.1.1/finshare.egg-info/PKG-INFO +212 -0
- finshare-0.1.1/finshare.egg-info/SOURCES.txt +30 -0
- finshare-0.1.1/finshare.egg-info/dependency_links.txt +1 -0
- finshare-0.1.1/finshare.egg-info/requires.txt +7 -0
- finshare-0.1.1/finshare.egg-info/top_level.txt +1 -0
- finshare-0.1.1/pyproject.toml +42 -0
- finshare-0.1.1/setup.cfg +4 -0
- finshare-0.1.1/setup.py +7 -0
- finshare-0.1.1/tests/test_models.py +77 -0
- finshare-0.1.1/tests/test_sources.py +124 -0
- finshare-0.1.1/tests/test_utils.py +83 -0
finshare-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Meepo Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
finshare-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: finshare
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: A professional financial data fetching toolkit for Python
|
|
5
|
+
Author-email: Meepo Team <support@meepoquant.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://meepoquant.com
|
|
8
|
+
Project-URL: Repository, https://github.com/finvfamily/finshare
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/finvfamily/finshare/issues
|
|
10
|
+
Keywords: quantitative,trading,data,finance,stock,quant
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: numpy>=1.20.0
|
|
26
|
+
Requires-Dist: pandas>=1.3.0
|
|
27
|
+
Requires-Dist: baostock>=0.8.9
|
|
28
|
+
Requires-Dist: pytdx>=1.72
|
|
29
|
+
Requires-Dist: pydantic>=2.0.0
|
|
30
|
+
Requires-Dist: loguru>=0.7.0
|
|
31
|
+
Requires-Dist: requests>=2.31.0
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# finshare
|
|
35
|
+
|
|
36
|
+
<div align="center">
|
|
37
|
+
<h3>专业的金融数据获取工具库</h3>
|
|
38
|
+
<p>A Professional Financial Data Fetching Toolkit for Python</p>
|
|
39
|
+
|
|
40
|
+
<p>
|
|
41
|
+
<a href="https://meepoquant.com">官网</a> •
|
|
42
|
+
<a href="https://github.com/finvfamily/finshare">GitHub</a> •
|
|
43
|
+
<a href="https://github.com/finvfamily/finshare/issues">问题反馈</a>
|
|
44
|
+
</p>
|
|
45
|
+
|
|
46
|
+
<p>
|
|
47
|
+
<img src="https://img.shields.io/pypi/v/finshare" alt="PyPI"/>
|
|
48
|
+
<img src="https://img.shields.io/github/stars/finvfamily/finshare" alt="Stars"/>
|
|
49
|
+
<img src="https://img.shields.io/pypi/dm/finshare" alt="Downloads"/>
|
|
50
|
+
<img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="Python"/>
|
|
51
|
+
<img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"/>
|
|
52
|
+
</p>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 🚀 快速开始
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from finshare import get_data_manager
|
|
61
|
+
|
|
62
|
+
# 获取数据管理器
|
|
63
|
+
manager = get_data_manager()
|
|
64
|
+
|
|
65
|
+
# 获取 K线数据(只需传入股票代码,无需市场后缀)
|
|
66
|
+
data = manager.get_kline('000001', start='2024-01-01', end='2024-01-31')
|
|
67
|
+
print(data.head())
|
|
68
|
+
|
|
69
|
+
# 获取实时快照
|
|
70
|
+
snapshot = manager.get_snapshot('000001')
|
|
71
|
+
print(f"最新价: {snapshot.last_price}")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## ✨ 核心特性
|
|
75
|
+
|
|
76
|
+
- 📊 **多数据源支持** - 东方财富、腾讯、新浪、通达信、BaoStock
|
|
77
|
+
- 🔄 **自动故障切换** - 数据源失败时自动切换到备用源
|
|
78
|
+
- 📈 **统一数据格式** - 所有数据源返回统一的 DataFrame 格式
|
|
79
|
+
- ⚡ **高性能获取** - 优化的数据获取和解析性能
|
|
80
|
+
- 🔧 **简单易用** - 简洁的 API 设计,开箱即用
|
|
81
|
+
- 🤖 **AI 驱动开发** - 完全由 Claude AI 实现,代码质量有保障
|
|
82
|
+
|
|
83
|
+
## 📦 安装
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install finshare
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**注意**: 包名为 `finshare`,但导入时使用 `finshare`:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
import finshare
|
|
93
|
+
from finshare import get_data_manager
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 📚 支持的数据源
|
|
97
|
+
|
|
98
|
+
| 数据源 | K线数据 | 实时快照 | 复权数据 |
|
|
99
|
+
|--------|---------|----------|----------|
|
|
100
|
+
| 东方财富 | ✅ | ✅ | ✅ |
|
|
101
|
+
| 腾讯财经 | ✅ | ✅ | ✅ |
|
|
102
|
+
| 新浪财经 | ❌ | ✅ | ❌ |
|
|
103
|
+
| 通达信 | ✅ | ✅ | ✅ |
|
|
104
|
+
| BaoStock | ✅ | ✅ | ✅ |
|
|
105
|
+
|
|
106
|
+
## 💡 使用示例
|
|
107
|
+
|
|
108
|
+
### 基础用法
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from finshare import get_data_manager
|
|
112
|
+
|
|
113
|
+
manager = get_data_manager()
|
|
114
|
+
|
|
115
|
+
# 获取日线数据(只需传入6位股票代码)
|
|
116
|
+
data = manager.get_kline(
|
|
117
|
+
code='000001', # 平安银行
|
|
118
|
+
start='2024-01-01',
|
|
119
|
+
end='2024-01-31',
|
|
120
|
+
adjust='qfq' # 前复权
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
# 获取实时快照
|
|
124
|
+
snapshot = manager.get_snapshot('000001')
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 批量获取
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from finshare import get_data_manager
|
|
131
|
+
|
|
132
|
+
manager = get_data_manager()
|
|
133
|
+
|
|
134
|
+
# 批量获取多只股票(使用6位代码)
|
|
135
|
+
codes = ['000001', '000002', '600000']
|
|
136
|
+
data_dict = manager.batch_get_kline(codes, start='2024-01-01')
|
|
137
|
+
|
|
138
|
+
for code, data in data_dict.items():
|
|
139
|
+
print(f"{code}: {len(data)} 条数据")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 使用特定数据源
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
from finshare import EastMoneyDataSource, TencentDataSource
|
|
146
|
+
|
|
147
|
+
# 使用东方财富
|
|
148
|
+
eastmoney = EastMoneyDataSource()
|
|
149
|
+
data = eastmoney.get_kline('000001', start='2024-01-01')
|
|
150
|
+
|
|
151
|
+
# 使用腾讯财经
|
|
152
|
+
tencent = TencentDataSource()
|
|
153
|
+
data = tencent.get_kline('000001', start='2024-01-01')
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## 🌟 为什么选择 finshare?
|
|
157
|
+
|
|
158
|
+
finshare 是 [米波量化平台](https://meepoquant.com) 的数据层,经过生产环境验证,稳定可靠。
|
|
159
|
+
|
|
160
|
+
### 完整的量化交易解决方案
|
|
161
|
+
|
|
162
|
+
如果你需要更强大的功能,可以使用米波平台:
|
|
163
|
+
|
|
164
|
+
| 功能 | finshare | 米波平台 |
|
|
165
|
+
|------|-----------|----------|
|
|
166
|
+
| 数据获取 | ✅ 免费 | ✅ |
|
|
167
|
+
| 策略回测 | ❌ | ✅ |
|
|
168
|
+
| 实时监控 | ❌ | ✅ |
|
|
169
|
+
| 策略市场 | ❌ | ✅ |
|
|
170
|
+
| 实盘交易 | ❌ | ✅ |
|
|
171
|
+
| 移动端 | ❌ | ✅ |
|
|
172
|
+
|
|
173
|
+
👉 [立即体验米波平台](https://meepoquant.com/signup?from=github)
|
|
174
|
+
|
|
175
|
+
## 📖 文档
|
|
176
|
+
|
|
177
|
+
- [快速开始](https://github.com/finvfamily/finshare#-快速开始)
|
|
178
|
+
- [使用示例](https://github.com/finvfamily/finshare#-使用示例)
|
|
179
|
+
- [数据源说明](https://github.com/finvfamily/finshare#-支持的数据源)
|
|
180
|
+
- [示例代码](https://github.com/finvfamily/finshare/tree/main/examples)
|
|
181
|
+
|
|
182
|
+
## 🤝 贡献
|
|
183
|
+
|
|
184
|
+
欢迎贡献代码!查看 [贡献指南](CONTRIBUTING.md)。
|
|
185
|
+
|
|
186
|
+
## 📄 许可证
|
|
187
|
+
|
|
188
|
+
MIT License - 详见 [LICENSE](LICENSE)
|
|
189
|
+
|
|
190
|
+
## 🔗 相关链接
|
|
191
|
+
|
|
192
|
+
- **官方网站**: https://meepoquant.com
|
|
193
|
+
- **GitHub**: https://github.com/finvfamily/finshare
|
|
194
|
+
- **PyPI**: https://pypi.org/project/finshare
|
|
195
|
+
- **问题反馈**: https://github.com/finvfamily/finshare/issues
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
<div align="center">
|
|
200
|
+
<p>
|
|
201
|
+
<strong>由 <a href="https://meepoquant.com">米波量化</a> 团队开发和维护</strong>
|
|
202
|
+
</p>
|
|
203
|
+
<p>
|
|
204
|
+
🤖 本项目完全由 AI (Claude) 实现,展示了 AI 在软件工程领域的强大能力
|
|
205
|
+
</p>
|
|
206
|
+
<p>
|
|
207
|
+
⭐ 如果这个项目对你有帮助,请给我们一个 Star!
|
|
208
|
+
</p>
|
|
209
|
+
<p>
|
|
210
|
+
💡 需要完整的量化交易平台?访问 <a href="https://meepoquant.com">米波量化</a>
|
|
211
|
+
</p>
|
|
212
|
+
</div>
|
finshare-0.1.1/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# finshare
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<h3>专业的金融数据获取工具库</h3>
|
|
5
|
+
<p>A Professional Financial Data Fetching Toolkit for Python</p>
|
|
6
|
+
|
|
7
|
+
<p>
|
|
8
|
+
<a href="https://meepoquant.com">官网</a> •
|
|
9
|
+
<a href="https://github.com/finvfamily/finshare">GitHub</a> •
|
|
10
|
+
<a href="https://github.com/finvfamily/finshare/issues">问题反馈</a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p>
|
|
14
|
+
<img src="https://img.shields.io/pypi/v/finshare" alt="PyPI"/>
|
|
15
|
+
<img src="https://img.shields.io/github/stars/finvfamily/finshare" alt="Stars"/>
|
|
16
|
+
<img src="https://img.shields.io/pypi/dm/finshare" alt="Downloads"/>
|
|
17
|
+
<img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="Python"/>
|
|
18
|
+
<img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"/>
|
|
19
|
+
</p>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 🚀 快速开始
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from finshare import get_data_manager
|
|
28
|
+
|
|
29
|
+
# 获取数据管理器
|
|
30
|
+
manager = get_data_manager()
|
|
31
|
+
|
|
32
|
+
# 获取 K线数据(只需传入股票代码,无需市场后缀)
|
|
33
|
+
data = manager.get_kline('000001', start='2024-01-01', end='2024-01-31')
|
|
34
|
+
print(data.head())
|
|
35
|
+
|
|
36
|
+
# 获取实时快照
|
|
37
|
+
snapshot = manager.get_snapshot('000001')
|
|
38
|
+
print(f"最新价: {snapshot.last_price}")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## ✨ 核心特性
|
|
42
|
+
|
|
43
|
+
- 📊 **多数据源支持** - 东方财富、腾讯、新浪、通达信、BaoStock
|
|
44
|
+
- 🔄 **自动故障切换** - 数据源失败时自动切换到备用源
|
|
45
|
+
- 📈 **统一数据格式** - 所有数据源返回统一的 DataFrame 格式
|
|
46
|
+
- ⚡ **高性能获取** - 优化的数据获取和解析性能
|
|
47
|
+
- 🔧 **简单易用** - 简洁的 API 设计,开箱即用
|
|
48
|
+
- 🤖 **AI 驱动开发** - 完全由 Claude AI 实现,代码质量有保障
|
|
49
|
+
|
|
50
|
+
## 📦 安装
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install finshare
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**注意**: 包名为 `finshare`,但导入时使用 `finshare`:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
import finshare
|
|
60
|
+
from finshare import get_data_manager
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 📚 支持的数据源
|
|
64
|
+
|
|
65
|
+
| 数据源 | K线数据 | 实时快照 | 复权数据 |
|
|
66
|
+
|--------|---------|----------|----------|
|
|
67
|
+
| 东方财富 | ✅ | ✅ | ✅ |
|
|
68
|
+
| 腾讯财经 | ✅ | ✅ | ✅ |
|
|
69
|
+
| 新浪财经 | ❌ | ✅ | ❌ |
|
|
70
|
+
| 通达信 | ✅ | ✅ | ✅ |
|
|
71
|
+
| BaoStock | ✅ | ✅ | ✅ |
|
|
72
|
+
|
|
73
|
+
## 💡 使用示例
|
|
74
|
+
|
|
75
|
+
### 基础用法
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from finshare import get_data_manager
|
|
79
|
+
|
|
80
|
+
manager = get_data_manager()
|
|
81
|
+
|
|
82
|
+
# 获取日线数据(只需传入6位股票代码)
|
|
83
|
+
data = manager.get_kline(
|
|
84
|
+
code='000001', # 平安银行
|
|
85
|
+
start='2024-01-01',
|
|
86
|
+
end='2024-01-31',
|
|
87
|
+
adjust='qfq' # 前复权
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# 获取实时快照
|
|
91
|
+
snapshot = manager.get_snapshot('000001')
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 批量获取
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from finshare import get_data_manager
|
|
98
|
+
|
|
99
|
+
manager = get_data_manager()
|
|
100
|
+
|
|
101
|
+
# 批量获取多只股票(使用6位代码)
|
|
102
|
+
codes = ['000001', '000002', '600000']
|
|
103
|
+
data_dict = manager.batch_get_kline(codes, start='2024-01-01')
|
|
104
|
+
|
|
105
|
+
for code, data in data_dict.items():
|
|
106
|
+
print(f"{code}: {len(data)} 条数据")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 使用特定数据源
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from finshare import EastMoneyDataSource, TencentDataSource
|
|
113
|
+
|
|
114
|
+
# 使用东方财富
|
|
115
|
+
eastmoney = EastMoneyDataSource()
|
|
116
|
+
data = eastmoney.get_kline('000001', start='2024-01-01')
|
|
117
|
+
|
|
118
|
+
# 使用腾讯财经
|
|
119
|
+
tencent = TencentDataSource()
|
|
120
|
+
data = tencent.get_kline('000001', start='2024-01-01')
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## 🌟 为什么选择 finshare?
|
|
124
|
+
|
|
125
|
+
finshare 是 [米波量化平台](https://meepoquant.com) 的数据层,经过生产环境验证,稳定可靠。
|
|
126
|
+
|
|
127
|
+
### 完整的量化交易解决方案
|
|
128
|
+
|
|
129
|
+
如果你需要更强大的功能,可以使用米波平台:
|
|
130
|
+
|
|
131
|
+
| 功能 | finshare | 米波平台 |
|
|
132
|
+
|------|-----------|----------|
|
|
133
|
+
| 数据获取 | ✅ 免费 | ✅ |
|
|
134
|
+
| 策略回测 | ❌ | ✅ |
|
|
135
|
+
| 实时监控 | ❌ | ✅ |
|
|
136
|
+
| 策略市场 | ❌ | ✅ |
|
|
137
|
+
| 实盘交易 | ❌ | ✅ |
|
|
138
|
+
| 移动端 | ❌ | ✅ |
|
|
139
|
+
|
|
140
|
+
👉 [立即体验米波平台](https://meepoquant.com/signup?from=github)
|
|
141
|
+
|
|
142
|
+
## 📖 文档
|
|
143
|
+
|
|
144
|
+
- [快速开始](https://github.com/finvfamily/finshare#-快速开始)
|
|
145
|
+
- [使用示例](https://github.com/finvfamily/finshare#-使用示例)
|
|
146
|
+
- [数据源说明](https://github.com/finvfamily/finshare#-支持的数据源)
|
|
147
|
+
- [示例代码](https://github.com/finvfamily/finshare/tree/main/examples)
|
|
148
|
+
|
|
149
|
+
## 🤝 贡献
|
|
150
|
+
|
|
151
|
+
欢迎贡献代码!查看 [贡献指南](CONTRIBUTING.md)。
|
|
152
|
+
|
|
153
|
+
## 📄 许可证
|
|
154
|
+
|
|
155
|
+
MIT License - 详见 [LICENSE](LICENSE)
|
|
156
|
+
|
|
157
|
+
## 🔗 相关链接
|
|
158
|
+
|
|
159
|
+
- **官方网站**: https://meepoquant.com
|
|
160
|
+
- **GitHub**: https://github.com/finvfamily/finshare
|
|
161
|
+
- **PyPI**: https://pypi.org/project/finshare
|
|
162
|
+
- **问题反馈**: https://github.com/finvfamily/finshare/issues
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
<div align="center">
|
|
167
|
+
<p>
|
|
168
|
+
<strong>由 <a href="https://meepoquant.com">米波量化</a> 团队开发和维护</strong>
|
|
169
|
+
</p>
|
|
170
|
+
<p>
|
|
171
|
+
🤖 本项目完全由 AI (Claude) 实现,展示了 AI 在软件工程领域的强大能力
|
|
172
|
+
</p>
|
|
173
|
+
<p>
|
|
174
|
+
⭐ 如果这个项目对你有帮助,请给我们一个 Star!
|
|
175
|
+
</p>
|
|
176
|
+
<p>
|
|
177
|
+
💡 需要完整的量化交易平台?访问 <a href="https://meepoquant.com">米波量化</a>
|
|
178
|
+
</p>
|
|
179
|
+
</div>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""
|
|
2
|
+
finshare - 专业的金融数据获取工具库
|
|
3
|
+
|
|
4
|
+
finshare 提供稳定、高效的金融数据获取服务,支持多数据源、
|
|
5
|
+
自动故障切换、统一的数据格式。
|
|
6
|
+
|
|
7
|
+
官方网站: https://meepoquant.com
|
|
8
|
+
文档: https://finshare.readthedocs.io
|
|
9
|
+
GitHub: https://github.com/meepo-quant/finshare
|
|
10
|
+
|
|
11
|
+
获取数据后,您可以:
|
|
12
|
+
- 使用 pandas 进行数据分析
|
|
13
|
+
- 使用 米波平台 进行策略回测: https://meepoquant.com
|
|
14
|
+
- 开发自己的量化策略
|
|
15
|
+
|
|
16
|
+
完整的量化交易平台: https://meepoquant.com
|
|
17
|
+
|
|
18
|
+
主要功能:
|
|
19
|
+
- 多数据源支持(东方财富、腾讯、新浪、通达信、BaoStock)
|
|
20
|
+
- 自动故障切换
|
|
21
|
+
- 统一的数据格式
|
|
22
|
+
- 高性能数据获取
|
|
23
|
+
|
|
24
|
+
快速开始:
|
|
25
|
+
>>> from finshare import get_data_manager
|
|
26
|
+
>>>
|
|
27
|
+
>>> # 获取数据管理器
|
|
28
|
+
>>> manager = get_data_manager()
|
|
29
|
+
>>>
|
|
30
|
+
>>> # 获取 K线数据
|
|
31
|
+
>>> data = manager.get_kline('000001.SZ', start='2024-01-01')
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
from finshare.__version__ import __version__, __author__, __website__
|
|
35
|
+
|
|
36
|
+
# 数据源
|
|
37
|
+
from finshare.sources import (
|
|
38
|
+
BaseDataSource,
|
|
39
|
+
EastMoneyDataSource,
|
|
40
|
+
TencentDataSource,
|
|
41
|
+
SinaDataSource,
|
|
42
|
+
get_data_manager,
|
|
43
|
+
get_baostock_source,
|
|
44
|
+
get_tdx_source,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# 数据模型
|
|
48
|
+
from finshare.models import (
|
|
49
|
+
KLineData,
|
|
50
|
+
SnapshotData,
|
|
51
|
+
StockInfo,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
# 工具函数
|
|
55
|
+
from finshare.utils import (
|
|
56
|
+
validate_stock_code,
|
|
57
|
+
validate_date,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# 日志
|
|
61
|
+
from finshare.logger import logger
|
|
62
|
+
|
|
63
|
+
__all__ = [
|
|
64
|
+
# 版本信息
|
|
65
|
+
"__version__",
|
|
66
|
+
"__author__",
|
|
67
|
+
"__website__",
|
|
68
|
+
# 数据源
|
|
69
|
+
"BaseDataSource",
|
|
70
|
+
"EastMoneyDataSource",
|
|
71
|
+
"TencentDataSource",
|
|
72
|
+
"SinaDataSource",
|
|
73
|
+
"get_data_manager",
|
|
74
|
+
"get_baostock_source",
|
|
75
|
+
"get_tdx_source",
|
|
76
|
+
# 数据模型
|
|
77
|
+
"KLineData",
|
|
78
|
+
"SnapshotData",
|
|
79
|
+
"StockInfo",
|
|
80
|
+
# 工具函数
|
|
81
|
+
"validate_stock_code",
|
|
82
|
+
"validate_date",
|
|
83
|
+
# 日志
|
|
84
|
+
"logger",
|
|
85
|
+
]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""
|
|
2
|
+
finshare Config Module
|
|
3
|
+
|
|
4
|
+
配置管理模块
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class LoggingConfig:
|
|
11
|
+
"""日志配置"""
|
|
12
|
+
|
|
13
|
+
def __init__(self):
|
|
14
|
+
self.log_dir = os.path.join(os.path.expanduser("~"), ".finshare", "logs")
|
|
15
|
+
self.log_level = "INFO"
|
|
16
|
+
self.log_format = (
|
|
17
|
+
"<green>{time:YYYY-MM-DD HH:mm:ss}</green> | "
|
|
18
|
+
"<level>{level: <8}</level> | "
|
|
19
|
+
"<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - "
|
|
20
|
+
"<level>{message}</level>"
|
|
21
|
+
)
|
|
22
|
+
self.rotation = "10 MB"
|
|
23
|
+
self.retention = "30 days"
|
|
24
|
+
self.enable_remote_logging = False
|
|
25
|
+
self.remote_log_url = None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class DataSourceConfig:
|
|
29
|
+
"""数据源配置"""
|
|
30
|
+
|
|
31
|
+
def __init__(self):
|
|
32
|
+
self.source_priority = ["eastmoney", "tencent", "sina", "tdx", "baostock"]
|
|
33
|
+
self.timeout = 30
|
|
34
|
+
self.request_timeout = 30 # 请求超时时间(秒)
|
|
35
|
+
self.retry_times = 3
|
|
36
|
+
self.request_interval = 0.1 # 请求间隔(秒)
|
|
37
|
+
self.max_workers = 5 # 最大并发数
|
|
38
|
+
self.failure_cooldown_hours = 24 # 数据源失败后的冷却时间(小时)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class Config:
|
|
42
|
+
"""全局配置"""
|
|
43
|
+
|
|
44
|
+
def __init__(self):
|
|
45
|
+
self.timeout = 30
|
|
46
|
+
self.logging = LoggingConfig()
|
|
47
|
+
self.data_source = DataSourceConfig()
|
|
48
|
+
|
|
49
|
+
def get(self, key, default=None):
|
|
50
|
+
"""获取配置项"""
|
|
51
|
+
return getattr(self, key, default)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# 全局配置实例
|
|
55
|
+
config = Config()
|
|
56
|
+
|
|
57
|
+
__all__ = ["Config", "config"]
|