fxyz 0.1.0__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.
fxyz-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: fxyz
3
+ Version: 0.1.0
4
+ Summary: Fxyz是专业的金融数据API平台,为量化交易与投资研究提供可靠的全市场行情数据API。
5
+ Project-URL: Homepage, https://www.fxyz.site/
6
+ Project-URL: Repository, https://github.com/fxyzsite/FxyzSkill
7
+ Project-URL: Documentation, https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/references/apidoc.md
8
+ Keywords: fxyz,黑狼数据,A-share-data,stock-quotes,实时股票数据API,中国股票行情,沪深京A股,ETF行情,股票K线,买卖五档数据,股票分钟数据,实时行情数据,资金流向,集合竞价数据
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.7
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Office/Business :: Financial :: Investment
21
+ Requires-Python: >=3.7
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: requests>=2.20
24
+
25
+ # Fxyz Python SDK:黑狼数据股票行情 API
26
+
27
+ Fxyz Python SDK 是黑狼数据(FXYZ)的 Python 客户端示例包,可通过 HTTP API 获取沪深京 A 股、ETF 和指数相关行情。它覆盖实时行情、K 线、盘口、逐笔成交、涨跌停板与资金流向等数据,适用于 Python 数据分析、量化研究和行情应用开发。
28
+
29
+ 本仓库同时包含 Fxyz Skill 说明、API 参考文档和 SDK 源码。
30
+ - Fxyz 官网:[http://www.fxyz.site/](https://www.fxyz.site/)
31
+ - API 服务地址:`http://api.fxyz.site`
32
+ - 开源仓库:[https://github.com/fxyzsite/FxyzSkill](https://github.com/fxyzsite/FxyzSkill)
33
+ - API 接口文档:[fxyz/references/apidoc.md](https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/references/apidoc.md)
34
+ - Fxyz Skill 指南:[fxyz/SKILL.md](https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/SKILL.md)
35
+
36
+ ---
37
+
38
+ ## 功能特点
39
+
40
+ - **股票与基金行情**:沪深京 A 股、ETF、指数的实时行情和股票列表。
41
+ - **K 线与历史行情**:支持1 分钟、 5 分钟、15 分钟、30 分钟、1 小时、日、周、月、年等周期及复权参数。
42
+ - **盘口与成交数据**:买卖五档、集合竞价、逐笔成交、分价统计和日线快照。
43
+ - **市场监控数据**:涨停、跌停、炸板、强势股和次新股数据。
44
+ - **资金流向**:按大单级别查看资金流向数据。
45
+
46
+ ## 核心优势
47
+
48
+ - ✅ **全面的数据覆盖** - 沪深京A股、ETF基金、主流指数
49
+ - ✅ **实时行情数据** - 30+行情指标,每分钟更新
50
+ - ✅ **特色监控数据** - 涨停板、跌停板、炸板、强势股实时追踪
51
+ - ✅ **多周期K线** - 9种时间周期(5分钟至年线),支持复权
52
+ - ✅ **深度盘口数据** - 买卖五档、竞价数据、逐笔交易
53
+ - ✅ **资金流向分析** - 特大单、大单、中单、小单分类统计
54
+ - ✅ **规范化日志** - 自动打印请求参数、返回记录数、示例数据
55
+
56
+ ---
57
+
58
+
59
+ ## 环境要求
60
+
61
+ - Python 3.7 或更高版本
62
+ - 依赖:`requests`
63
+ - 有效的 Fxyz API Token;接口可用范围取决于账号权限
64
+
65
+ ## 安装
66
+ 从 PyPI 安装:
67
+ ```bash
68
+ python -m pip install fxyz
69
+ ```
70
+
71
+ ## 获取 API Token
72
+
73
+ 访问 [Fxyz 官网](http://www.fxyz.site/),注册并登录后按账号页面指引获取 API Token。请勿将真实 Token 写入公开代码、提交到仓库或粘贴到公开日志中。Token 激活说明见 [官网申请页面](http://www.fxyz.site/#apply)。
74
+
75
+ ## 快速开始
76
+
77
+ SDK 保留仓库现有调用接口,Token 通过参数传入:
78
+
79
+ ```python
80
+ from fxyz.scripts.api.BoardApi import BoardApi
81
+ from fxyz.scripts.api.MarketApi import MarketApi
82
+
83
+ token = "YOUR_FXYZ_TOKEN"
84
+
85
+ # 获取单只股票实时行情
86
+ quote = BoardApi.getRealTimeQuote(
87
+ symbol="stock",
88
+ code="000001",
89
+ token=token,
90
+ )
91
+ print(quote)
92
+
93
+ # 获取日 K 线(cq: 1 不复权,2 前复权,3 后复权)
94
+ kline = MarketApi.getKLine(
95
+ symbol="stock",
96
+ code="000001",
97
+ period="1d",
98
+ cq="1",
99
+ startDate="2026-04-01",
100
+ endDate="2026-04-14",
101
+ token=token,
102
+ )
103
+ print(kline)
104
+ ```
105
+
106
+ API 返回 JSON 解码后的 Python 对象(通常为列表或字典)。全部接口、参数和返回字段请查看[完整 API 文档](https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/references/apidoc.md)。
107
+
108
+ ### 支持的 API
109
+
110
+ | 模块 | 方法 | 数据 |
111
+ |---|---|---|
112
+ | 基础 | `BaseApi.getStockList` | 股票、指数、ETF 等列表 |
113
+ | 市场 | `BoardApi.getRealTimeQuote` | 实时行情 |
114
+ | 市场 | `BoardApi.getZhangTingBan`、`getDieTingBan` | 涨停板、跌停板 |
115
+ | 市场 | `BoardApi.getZhaBan`、`getQiangShiGu`、`getCiXinGu` | 炸板、强势股、次新股 |
116
+ | 行情 | `MarketApi.getKLine`、`getDaySnapshot` | K 线、日线快照 |
117
+ | 行情 | `MarketApi.getFiveLevel`、`getBidData` | 五档盘口、集合竞价 |
118
+ | 行情 | `MarketApi.getDealData`、`getPriceData` | 逐笔成交、分价统计 |
119
+ | 行情 | `MarketApi.getMoneyFlow` | 资金流向 |
120
+
121
+ ## 本地开发与验证
122
+
123
+ ```bash
124
+ python -m pip install -e .
125
+ python -c "from fxyz.scripts.api.BoardApi import BoardApi; from fxyz.scripts.api.MarketApi import MarketApi; print('Fxyz SDK imports OK')"
126
+ ```
127
+
128
+ 仓库里的 `fxyz/scripts/StockApiClient.py` 是需要有效 Token 才能访问线上 API 的示例程序;导入检查和本地构建不需要 API Token。
129
+
130
+ ## 项目结构
131
+
132
+ ```text
133
+ fxyz/
134
+ ├── __init__.py
135
+ ├── SKILL.md
136
+ ├── references/
137
+ │ └── apidoc.md
138
+ └── scripts/
139
+ ├── Config.py
140
+ ├── StockApiClient.py
141
+ ├── api/
142
+ │ ├── BaseApi.py
143
+ │ ├── BoardApi.py
144
+ │ └── MarketApi.py
145
+ └── util/
146
+ └── DataUtil.py
147
+ pyproject.toml
148
+ README.md
149
+ ```
150
+
151
+ ## 安全与使用说明
152
+
153
+ - SDK 请求需要有效 Token;全市场查询等能力可能需要相应账号权限。
154
+ - 请遵循 Fxyz 官网服务条款和 API 调用限制,并合理控制请求频率。
155
+ - 行情数据仅供研究和开发使用;请以服务端返回及官方说明为准。
156
+ - 本 SDK 不提供投资建议,也不保证数据适合任何特定交易用途。
157
+ - 如遇接口或权限问题,请查阅[接口文档](https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/references/apidoc.md)并联系 Fxyz 官方。
158
+
159
+ ## 关键词
160
+
161
+ Fxyz Python SDK、黑狼数据 Python API、A 股行情 API、沪深京股票数据、ETF 行情接口、Python 实时股票行情、股票 K 线 API、量化数据接口、涨停板数据、资金流向 API。
fxyz-0.1.0/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # Fxyz Python SDK:黑狼数据股票行情 API
2
+
3
+ Fxyz Python SDK 是黑狼数据(FXYZ)的 Python 客户端示例包,可通过 HTTP API 获取沪深京 A 股、ETF 和指数相关行情。它覆盖实时行情、K 线、盘口、逐笔成交、涨跌停板与资金流向等数据,适用于 Python 数据分析、量化研究和行情应用开发。
4
+
5
+ 本仓库同时包含 Fxyz Skill 说明、API 参考文档和 SDK 源码。
6
+ - Fxyz 官网:[http://www.fxyz.site/](https://www.fxyz.site/)
7
+ - API 服务地址:`http://api.fxyz.site`
8
+ - 开源仓库:[https://github.com/fxyzsite/FxyzSkill](https://github.com/fxyzsite/FxyzSkill)
9
+ - API 接口文档:[fxyz/references/apidoc.md](https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/references/apidoc.md)
10
+ - Fxyz Skill 指南:[fxyz/SKILL.md](https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/SKILL.md)
11
+
12
+ ---
13
+
14
+ ## 功能特点
15
+
16
+ - **股票与基金行情**:沪深京 A 股、ETF、指数的实时行情和股票列表。
17
+ - **K 线与历史行情**:支持1 分钟、 5 分钟、15 分钟、30 分钟、1 小时、日、周、月、年等周期及复权参数。
18
+ - **盘口与成交数据**:买卖五档、集合竞价、逐笔成交、分价统计和日线快照。
19
+ - **市场监控数据**:涨停、跌停、炸板、强势股和次新股数据。
20
+ - **资金流向**:按大单级别查看资金流向数据。
21
+
22
+ ## 核心优势
23
+
24
+ - ✅ **全面的数据覆盖** - 沪深京A股、ETF基金、主流指数
25
+ - ✅ **实时行情数据** - 30+行情指标,每分钟更新
26
+ - ✅ **特色监控数据** - 涨停板、跌停板、炸板、强势股实时追踪
27
+ - ✅ **多周期K线** - 9种时间周期(5分钟至年线),支持复权
28
+ - ✅ **深度盘口数据** - 买卖五档、竞价数据、逐笔交易
29
+ - ✅ **资金流向分析** - 特大单、大单、中单、小单分类统计
30
+ - ✅ **规范化日志** - 自动打印请求参数、返回记录数、示例数据
31
+
32
+ ---
33
+
34
+
35
+ ## 环境要求
36
+
37
+ - Python 3.7 或更高版本
38
+ - 依赖:`requests`
39
+ - 有效的 Fxyz API Token;接口可用范围取决于账号权限
40
+
41
+ ## 安装
42
+ 从 PyPI 安装:
43
+ ```bash
44
+ python -m pip install fxyz
45
+ ```
46
+
47
+ ## 获取 API Token
48
+
49
+ 访问 [Fxyz 官网](http://www.fxyz.site/),注册并登录后按账号页面指引获取 API Token。请勿将真实 Token 写入公开代码、提交到仓库或粘贴到公开日志中。Token 激活说明见 [官网申请页面](http://www.fxyz.site/#apply)。
50
+
51
+ ## 快速开始
52
+
53
+ SDK 保留仓库现有调用接口,Token 通过参数传入:
54
+
55
+ ```python
56
+ from fxyz.scripts.api.BoardApi import BoardApi
57
+ from fxyz.scripts.api.MarketApi import MarketApi
58
+
59
+ token = "YOUR_FXYZ_TOKEN"
60
+
61
+ # 获取单只股票实时行情
62
+ quote = BoardApi.getRealTimeQuote(
63
+ symbol="stock",
64
+ code="000001",
65
+ token=token,
66
+ )
67
+ print(quote)
68
+
69
+ # 获取日 K 线(cq: 1 不复权,2 前复权,3 后复权)
70
+ kline = MarketApi.getKLine(
71
+ symbol="stock",
72
+ code="000001",
73
+ period="1d",
74
+ cq="1",
75
+ startDate="2026-04-01",
76
+ endDate="2026-04-14",
77
+ token=token,
78
+ )
79
+ print(kline)
80
+ ```
81
+
82
+ API 返回 JSON 解码后的 Python 对象(通常为列表或字典)。全部接口、参数和返回字段请查看[完整 API 文档](https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/references/apidoc.md)。
83
+
84
+ ### 支持的 API
85
+
86
+ | 模块 | 方法 | 数据 |
87
+ |---|---|---|
88
+ | 基础 | `BaseApi.getStockList` | 股票、指数、ETF 等列表 |
89
+ | 市场 | `BoardApi.getRealTimeQuote` | 实时行情 |
90
+ | 市场 | `BoardApi.getZhangTingBan`、`getDieTingBan` | 涨停板、跌停板 |
91
+ | 市场 | `BoardApi.getZhaBan`、`getQiangShiGu`、`getCiXinGu` | 炸板、强势股、次新股 |
92
+ | 行情 | `MarketApi.getKLine`、`getDaySnapshot` | K 线、日线快照 |
93
+ | 行情 | `MarketApi.getFiveLevel`、`getBidData` | 五档盘口、集合竞价 |
94
+ | 行情 | `MarketApi.getDealData`、`getPriceData` | 逐笔成交、分价统计 |
95
+ | 行情 | `MarketApi.getMoneyFlow` | 资金流向 |
96
+
97
+ ## 本地开发与验证
98
+
99
+ ```bash
100
+ python -m pip install -e .
101
+ python -c "from fxyz.scripts.api.BoardApi import BoardApi; from fxyz.scripts.api.MarketApi import MarketApi; print('Fxyz SDK imports OK')"
102
+ ```
103
+
104
+ 仓库里的 `fxyz/scripts/StockApiClient.py` 是需要有效 Token 才能访问线上 API 的示例程序;导入检查和本地构建不需要 API Token。
105
+
106
+ ## 项目结构
107
+
108
+ ```text
109
+ fxyz/
110
+ ├── __init__.py
111
+ ├── SKILL.md
112
+ ├── references/
113
+ │ └── apidoc.md
114
+ └── scripts/
115
+ ├── Config.py
116
+ ├── StockApiClient.py
117
+ ├── api/
118
+ │ ├── BaseApi.py
119
+ │ ├── BoardApi.py
120
+ │ └── MarketApi.py
121
+ └── util/
122
+ └── DataUtil.py
123
+ pyproject.toml
124
+ README.md
125
+ ```
126
+
127
+ ## 安全与使用说明
128
+
129
+ - SDK 请求需要有效 Token;全市场查询等能力可能需要相应账号权限。
130
+ - 请遵循 Fxyz 官网服务条款和 API 调用限制,并合理控制请求频率。
131
+ - 行情数据仅供研究和开发使用;请以服务端返回及官方说明为准。
132
+ - 本 SDK 不提供投资建议,也不保证数据适合任何特定交易用途。
133
+ - 如遇接口或权限问题,请查阅[接口文档](https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/references/apidoc.md)并联系 Fxyz 官方。
134
+
135
+ ## 关键词
136
+
137
+ Fxyz Python SDK、黑狼数据 Python API、A 股行情 API、沪深京股票数据、ETF 行情接口、Python 实时股票行情、股票 K 线 API、量化数据接口、涨停板数据、资金流向 API。
@@ -0,0 +1,3 @@
1
+ """Fxyz Python SDK and skill resources."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,3 @@
1
+ class Config:
2
+ SERVER_URL = "http://api.fxyz.site" # Api调用服务地址
3
+ TOKEN = "" # 请在运行时从安全配置中读取Token,不要提交真实Token
@@ -0,0 +1,90 @@
1
+ from fxyz.scripts.Config import Config
2
+ from fxyz.scripts.api import BaseApi
3
+ from fxyz.scripts.api.BoardApi import BoardApi
4
+ from fxyz.scripts.api.MarketApi import MarketApi
5
+
6
+
7
+ class StockApiClient(object):
8
+
9
+ def demoForAllApis(self):
10
+
11
+ token = Config.TOKEN
12
+ try:
13
+
14
+ # ========== Base Api 测试 ==========
15
+ # 1. 股票列表
16
+ data = BaseApi.getStockList(flag=0, token=token)
17
+
18
+ # 2. 概念成分股
19
+ data = BaseApi.getSector(symbol="gn", token=token)
20
+
21
+ # 3. 财务核心指标(单只股票)
22
+ data = BaseApi.getFinanceMetric(
23
+ code="000001",
24
+ startDate="2026-01-01",
25
+ endDate="2026-04-13",
26
+ token=token,
27
+ )
28
+
29
+ # ========== Board Api 测试 ==========
30
+ # 1. 实时行情
31
+ data = BoardApi.getRealTimeQuote(symbol="stock", code="000002", token=token)
32
+
33
+ # 2. 涨停板
34
+ data = BoardApi.getZhangTingBan(tradeDate="2026-04-13", token=token)
35
+
36
+ # 3. 跌停板
37
+ data = BoardApi.getDieTingBan(tradeDate="2026-04-13", token=token)
38
+
39
+ # 4. 炸板
40
+ data = BoardApi.getZhaBan(tradeDate="2026-04-13", token=token)
41
+
42
+ # 5. 强势股
43
+ data = BoardApi.getQiangShiGu(tradeDate="2026-04-13", token=token)
44
+
45
+ # 6. 次新股
46
+ data = BoardApi.getCiXinGu(token=token)
47
+
48
+ # ========== Market Api 测试 ==========
49
+ # 1. 实时K线
50
+ data = MarketApi.getKLine(
51
+ symbol="stock",
52
+ code="000002",
53
+ period="1d",
54
+ cq="1",
55
+ startDate="2026-04-01",
56
+ endDate="2026-04-13",
57
+ token=token
58
+ )
59
+
60
+ # 2. 日线快照
61
+ data = MarketApi.getDaySnapshot(symbol="stock", code="000002", token=token)
62
+
63
+ # 3. 买卖五档
64
+ data = MarketApi.getFiveLevel(symbol="stock", code="000002", token=token)
65
+
66
+ # 4. 竞价数据
67
+ data = MarketApi.getBidData(code="000002", token=token)
68
+
69
+ # 5. 逐笔交易
70
+ data = MarketApi.getDealData(code="000002", tradeDate="2026-04-13", token=token)
71
+
72
+ # 6. 分价数据
73
+ data = MarketApi.getPriceData(code="000002", tradeDate="2026-04-13", token=token)
74
+
75
+ # 7. 资金流向
76
+ data = MarketApi.getMoneyFlow(code="000002", tradeDate="2026-04-13", token=token)
77
+
78
+ # 8. 复权变更数据
79
+ data = MarketApi.getAdjustment(
80
+ symbol="stock", tradeDate="2026-04-13", token=token
81
+ )
82
+
83
+ except Exception as e:
84
+ print(f"调用失败: {e}")
85
+
86
+
87
+ if __name__ == "__main__":
88
+ # 创建客户端实例,测试所有API接口
89
+ client = StockApiClient()
90
+ client.demoForAllApis()
@@ -0,0 +1 @@
1
+ """Python API clients for Fxyz market data."""
@@ -0,0 +1,55 @@
1
+ import json
2
+ from typing import Any
3
+
4
+ from fxyz.scripts.Config import Config
5
+ from fxyz.scripts.util import DataUtil
6
+
7
+
8
+ def getStockList(flag: int, token: str, method: str = "get") -> Any:
9
+ """
10
+ 获取股票列表。
11
+ 历史数据收盘后六点更新。
12
+
13
+ :param flag: 股票类型,0-所有股票,1-深交所股票,2-上交所股票,3-北交所股票,4-指数,5-创业板股票,6-科创板股票,7-ETF,8-ST股票,9-退市股票,10-沪深可转债
14
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
15
+ :param method: 请求方法,默认get
16
+ :return: JSON解码后的数据
17
+ """
18
+ url = Config.SERVER_URL + "/wolf/list"
19
+ params = {"flag": flag, "token": token}
20
+ result = DataUtil.request(url, method, params)
21
+ data = json.loads(result)
22
+ DataUtil.printLog("/wolf/list", params, data)
23
+ return data
24
+
25
+
26
+ def getSector(symbol: str, token: str, method: str = "get") -> Any:
27
+ """获取行业板块、概念板块或特色板块的成分股数据。
28
+
29
+ :param symbol: 板块类型,hy-行业板块,gn-概念板块,ts-特色板块
30
+ :param token: 登录网站获取的API Token
31
+ :param method: 请求方法,默认get
32
+ :return: JSON解码后的数据
33
+ """
34
+ url = Config.SERVER_URL + "/wolf/sector"
35
+ params = {"symbol": symbol, "token": token}
36
+ result = DataUtil.request(url, method, params)
37
+ data = json.loads(result)
38
+ DataUtil.printLog("/wolf/sector", params, data)
39
+ return data
40
+
41
+
42
+ def getFinanceMetric(code: str, startDate: str, endDate: str, token: str,
43
+ method: str = "get") -> Any:
44
+ """获取单只股票在日期范围内的财务核心指标。"""
45
+ url = Config.SERVER_URL + "/wolf/financemetric"
46
+ params = {
47
+ "code": code,
48
+ "startDate": startDate,
49
+ "endDate": endDate,
50
+ "token": token,
51
+ }
52
+ result = DataUtil.request(url, method, params)
53
+ data = json.loads(result)
54
+ DataUtil.printLog("/wolf/financemetric", params, data)
55
+ return data
@@ -0,0 +1,115 @@
1
+ import json
2
+ from typing import Any
3
+
4
+ from fxyz.scripts.Config import Config
5
+ from fxyz.scripts.util import DataUtil
6
+
7
+
8
+ class BoardApi:
9
+ """
10
+ 黑狼数据外造接口API
11
+ 包括实时行情、涨停板、跌停板、炸板、强势股、次新股等接口
12
+ """
13
+
14
+ @staticmethod
15
+ def getRealTimeQuote(symbol: str, code: str, token: str, method: str = "get") -> Any:
16
+ """
17
+ 获取沪深A股实时行情数据。
18
+ 提供涨速、涨跌幅、换手率、振幅、量比、内盘、外盘、ROE等行情指标数据。
19
+
20
+ :param symbol: 股票类型,stock-沪深京A股,etf-ETF基金
21
+ :param code: 股票代码,all表示全推全市场数据,具体代码表示单个股票
22
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
23
+ :param method: 请求方法,默认get
24
+ :return: JSON格式的字符串数据
25
+ """
26
+ url = Config.SERVER_URL + "/wolf/time"
27
+ params = {"symbol": symbol, "code": code, "token": token}
28
+ result = DataUtil.request(url, method, params)
29
+ data = json.loads(result)
30
+ DataUtil.printLog("/wolf/time", params, data)
31
+ return data
32
+
33
+ @staticmethod
34
+ def getZhangTingBan(tradeDate: str, token: str, method: str = "get") -> Any:
35
+ """
36
+ 获取盘中涨停板实时数据。
37
+
38
+ :param tradeDate: 交易日期,格式:YYYY-MM-DD
39
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
40
+ :param method: 请求方法,默认get
41
+ :return: JSON格式的字符串数据
42
+ """
43
+ url = Config.SERVER_URL + "/wolf/zt"
44
+ params = {"tradeDate": tradeDate, "token": token}
45
+ result = DataUtil.request(url, method, params)
46
+ data = json.loads(result)
47
+ DataUtil.printLog("/wolf/zt", params, data)
48
+ return data
49
+
50
+ @staticmethod
51
+ def getDieTingBan(tradeDate: str, token: str, method: str = "get") -> Any:
52
+ """
53
+ 获取盘中跌停板实时数据。
54
+
55
+ :param tradeDate: 交易日期,格式:YYYY-MM-DD
56
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
57
+ :param method: 请求方法,默认get
58
+ :return: JSON格式的字符串数据
59
+ """
60
+ url = Config.SERVER_URL + "/wolf/dt"
61
+ params = {"tradeDate": tradeDate, "token": token}
62
+ result = DataUtil.request(url, method, params)
63
+ data = json.loads(result)
64
+ DataUtil.printLog("/wolf/dt", params, data)
65
+ return data
66
+
67
+ @staticmethod
68
+ def getZhaBan(tradeDate: str, token: str, method: str = "get") -> Any:
69
+ """
70
+ 获取盘中炸板实时数据。
71
+
72
+ :param tradeDate: 交易日期,格式:YYYY-MM-DD
73
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
74
+ :param method: 请求方法,默认get
75
+ :return: JSON格式的字符串数据
76
+ """
77
+ url = Config.SERVER_URL + "/wolf/zb"
78
+ params = {"tradeDate": tradeDate, "token": token}
79
+ result = DataUtil.request(url, method, params)
80
+ data = json.loads(result)
81
+ DataUtil.printLog("/wolf/zb", params, data)
82
+ return data
83
+
84
+ @staticmethod
85
+ def getQiangShiGu(tradeDate: str, token: str, method: str = "get") -> Any:
86
+ """
87
+ 获取盘中强势股票实时数据。
88
+
89
+ :param tradeDate: 交易日期,格式:YYYY-MM-DD
90
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
91
+ :param method: 请求方法,默认get
92
+ :return: JSON格式的字符串数据
93
+ """
94
+ url = Config.SERVER_URL + "/wolf/qs"
95
+ params = {"tradeDate": tradeDate, "token": token}
96
+ result = DataUtil.request(url, method, params)
97
+ data = json.loads(result)
98
+ DataUtil.printLog("/wolf/qs", params, data)
99
+ return data
100
+
101
+ @staticmethod
102
+ def getCiXinGu(token: str, method: str = "get") -> Any:
103
+ """
104
+ 获取次新股数据。
105
+
106
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
107
+ :param method: 请求方法,默认get
108
+ :return: JSON格式的字符串数据
109
+ """
110
+ url = Config.SERVER_URL + "/wolf/cx"
111
+ params = {"token": token}
112
+ result = DataUtil.request(url, method, params)
113
+ data = json.loads(result)
114
+ DataUtil.printLog("/wolf/cx", params, data)
115
+ return data
@@ -0,0 +1,169 @@
1
+ import json
2
+ from typing import Any
3
+
4
+ from fxyz.scripts.Config import Config
5
+ from fxyz.scripts.util import DataUtil
6
+
7
+
8
+ class MarketApi:
9
+ """
10
+ 黑狼数据盯盘接口API
11
+ 包括实时K线、日线快照、买卖五档、竞价数据、逐笔交易、分价数据、资金流向等接口
12
+ """
13
+
14
+ @staticmethod
15
+ def getKLine(symbol: str, code: str, period: str, cq: str, startDate: str, endDate: str,
16
+ token: str, method: str = "get") -> Any:
17
+ """
18
+ 获取沪深A股和ETF实时K线数据。
19
+
20
+ :param symbol: 股票类型,stock-沪深京A股,etf-ETF基金,bond-沪深可转债,index-指数
21
+ :param code: 股票代码。包年版可使用all获取盘后全市场数据,仅限最近一周内的日线数据
22
+ :param period: K线周期,1m/5m/15m/30m/1h/1d/1w/1mon/1y
23
+ :param cq: 复权类型,1-不复权,2-前复权,3-后复权
24
+ :param startDate: 开始日期,格式:YYYY-MM-DD
25
+ :param endDate: 结束日期,格式:YYYY-MM-DD
26
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
27
+ :param method: 请求方法,默认get
28
+ :return: JSON格式的字符串数据
29
+ """
30
+ url = Config.SERVER_URL + "/wolf/time/kline"
31
+ params = {
32
+ "symbol": symbol,
33
+ "code": code,
34
+ "period": period,
35
+ "cq": cq,
36
+ "startDate": startDate,
37
+ "endDate": endDate,
38
+ "token": token
39
+ }
40
+ result = DataUtil.request(url, method, params)
41
+ data = json.loads(result)
42
+ DataUtil.printLog("/wolf/time/kline", params, data)
43
+ return data
44
+
45
+ @staticmethod
46
+ def getDaySnapshot(symbol: str, code: str, token: str, method: str = "get") -> Any:
47
+ """
48
+ 获取沪深京A股、ETF、可转债和指数日线行情数据。
49
+
50
+ :param symbol: 股票类型,stock-沪深京A股,etf-ETF基金,bond-沪深可转债,index-指数
51
+ :param code: 股票代码,all表示全推全市场数据,具体代码表示单个股票
52
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
53
+ :param method: 请求方法,默认get
54
+ :return: JSON格式的字符串数据
55
+ """
56
+ url = Config.SERVER_URL + "/wolf/time/day"
57
+ params = {"symbol": symbol, "code": code, "token": token}
58
+ result = DataUtil.request(url, method, params)
59
+ data = json.loads(result)
60
+ DataUtil.printLog("/wolf/time/day", params, data)
61
+ return data
62
+
63
+ @staticmethod
64
+ def getFiveLevel(symbol: str, code: str, token: str, method: str = "get") -> Any:
65
+ """
66
+ 获取买卖五档实时数据。
67
+
68
+ :param symbol: 股票类型,stock-沪深京A股,etf-ETF基金,bond-沪深可转债,index-指数
69
+ :param code: 股票代码
70
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
71
+ :param method: 请求方法,默认get
72
+ :return: JSON格式的字符串数据
73
+ """
74
+ url = Config.SERVER_URL + "/wolf/time/five"
75
+ params = {"symbol": symbol, "code": code, "token": token}
76
+ result = DataUtil.request(url, method, params)
77
+ data = json.loads(result)
78
+ DataUtil.printLog("/wolf/time/five", params, data)
79
+ return data
80
+
81
+ @staticmethod
82
+ def getBidData(code: str, token: str, method: str = "get") -> Any:
83
+ """
84
+ 获取沪深A股实时竞价数据,竞价时间段:09:15-09:25
85
+
86
+ :param code: 股票代码
87
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
88
+ :param method: 请求方法,默认get
89
+ :return: JSON格式的字符串数据
90
+ """
91
+ url = Config.SERVER_URL + "/wolf/time/bid"
92
+ params = {"code": code, "token": token}
93
+ result = DataUtil.request(url, method, params)
94
+ data = json.loads(result)
95
+ DataUtil.printLog("/wolf/time/bid", params, data)
96
+ return data
97
+
98
+ @staticmethod
99
+ def getDealData(code: str, tradeDate: str, token: str, method: str = "get") -> Any:
100
+ """
101
+ 获取沪深A股逐笔交易数据。
102
+
103
+ :param code: 股票代码
104
+ :param tradeDate: 交易日期,格式:YYYY-MM-DD
105
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
106
+ :param method: 请求方法,默认get
107
+ :return: JSON格式的字符串数据
108
+ """
109
+ url = Config.SERVER_URL + "/wolf/deal"
110
+ params = {"code": code, "tradeDate": tradeDate, "token": token}
111
+ result = DataUtil.request(url, method, params)
112
+ data = json.loads(result)
113
+ DataUtil.printLog("/wolf/deal", params, data)
114
+ return data
115
+
116
+ @staticmethod
117
+ def getPriceData(code: str, tradeDate: str, token: str, method: str = "get") -> Any:
118
+ """
119
+ 获取沪深A股分价数据。
120
+
121
+ :param code: 股票代码
122
+ :param tradeDate: 交易日期,格式:YYYY-MM-DD
123
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
124
+ :param method: 请求方法,默认get
125
+ :return: JSON格式的字符串数据
126
+ """
127
+ url = Config.SERVER_URL + "/wolf/price"
128
+ params = {"code": code, "tradeDate": tradeDate, "token": token}
129
+ result = DataUtil.request(url, method, params)
130
+ data = json.loads(result)
131
+ DataUtil.printLog("/wolf/price", params, data)
132
+ return data
133
+
134
+ @staticmethod
135
+ def getMoneyFlow(code: str, tradeDate: str, token: str, method: str = "get") -> Any:
136
+ """
137
+ 获取沪深A股资金流向数据。
138
+ 资金流数据区分主买、主卖、特大单、大单、中单、小单等。
139
+
140
+ :param code: 股票代码
141
+ :param tradeDate: 交易日期,格式:YYYY-MM-DD
142
+ :param token: 激活Token参考 http://www.fxyz.site/#apply
143
+ :param method: 请求方法,默认get
144
+ :return: JSON格式的字符串数据
145
+ """
146
+ url = Config.SERVER_URL + "/wolf/money"
147
+ params = {"code": code, "tradeDate": tradeDate, "token": token}
148
+ result = DataUtil.request(url, method, params)
149
+ data = json.loads(result)
150
+ DataUtil.printLog("/wolf/money", params, data)
151
+ return data
152
+
153
+ @staticmethod
154
+ def getAdjustment(symbol: str, tradeDate: str, token: str,
155
+ method: str = "get") -> Any:
156
+ """获取沪深京A股或ETF的复权变更数据。
157
+
158
+ :param symbol: 股票类型,stock-沪深京A股,etf-ETF基金
159
+ :param tradeDate: 交易日期
160
+ :param token: 登录网站获取的API Token
161
+ :param method: 请求方法,默认get
162
+ :return: JSON解码后的数据
163
+ """
164
+ url = Config.SERVER_URL + "/wolf/fq"
165
+ params = {"symbol": symbol, "tradeDate": tradeDate, "token": token}
166
+ result = DataUtil.request(url, method, params)
167
+ data = json.loads(result)
168
+ DataUtil.printLog("/wolf/fq", params, data)
169
+ return data
@@ -0,0 +1,7 @@
1
+ """API modules for basic, board, and market data."""
2
+
3
+ from . import BaseApi
4
+ from .BoardApi import BoardApi
5
+ from .MarketApi import MarketApi
6
+
7
+ __all__ = ["BaseApi", "BoardApi", "MarketApi"]
@@ -0,0 +1,22 @@
1
+ import json
2
+ from typing import Any
3
+
4
+ import requests
5
+
6
+ def request(url: str, method: str = "get", params=None):
7
+ if method == 'post':
8
+ response = requests.post(url, params=params)
9
+ return response.content.decode('utf-8')
10
+ else:
11
+ response = requests.get(url, params=params)
12
+ return response.content.decode('utf-8')
13
+
14
+
15
+ def printLog(apiName: str, params: dict, data: Any) -> Any:
16
+ # Tokens are passed as query parameters by the API; never echo credentials to logs.
17
+ safe_params = {key: ("***" if key.lower() == "token" else value) for key, value in params.items()}
18
+ if isinstance(data, list):
19
+ print(f"{apiName},返回 {len(data)} 条记录,参数{safe_params},数据样例:{data[0] if len(data) > 0 else {} }")
20
+ else:
21
+ print(f"{apiName},返回异常信息,参数{safe_params},异常详情:{data}")
22
+ return data
@@ -0,0 +1,5 @@
1
+ """Internal HTTP and data utilities."""
2
+
3
+ from . import DataUtil
4
+
5
+ __all__ = ["DataUtil"]
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: fxyz
3
+ Version: 0.1.0
4
+ Summary: Fxyz是专业的金融数据API平台,为量化交易与投资研究提供可靠的全市场行情数据API。
5
+ Project-URL: Homepage, https://www.fxyz.site/
6
+ Project-URL: Repository, https://github.com/fxyzsite/FxyzSkill
7
+ Project-URL: Documentation, https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/references/apidoc.md
8
+ Keywords: fxyz,黑狼数据,A-share-data,stock-quotes,实时股票数据API,中国股票行情,沪深京A股,ETF行情,股票K线,买卖五档数据,股票分钟数据,实时行情数据,资金流向,集合竞价数据
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.7
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Office/Business :: Financial :: Investment
21
+ Requires-Python: >=3.7
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: requests>=2.20
24
+
25
+ # Fxyz Python SDK:黑狼数据股票行情 API
26
+
27
+ Fxyz Python SDK 是黑狼数据(FXYZ)的 Python 客户端示例包,可通过 HTTP API 获取沪深京 A 股、ETF 和指数相关行情。它覆盖实时行情、K 线、盘口、逐笔成交、涨跌停板与资金流向等数据,适用于 Python 数据分析、量化研究和行情应用开发。
28
+
29
+ 本仓库同时包含 Fxyz Skill 说明、API 参考文档和 SDK 源码。
30
+ - Fxyz 官网:[http://www.fxyz.site/](https://www.fxyz.site/)
31
+ - API 服务地址:`http://api.fxyz.site`
32
+ - 开源仓库:[https://github.com/fxyzsite/FxyzSkill](https://github.com/fxyzsite/FxyzSkill)
33
+ - API 接口文档:[fxyz/references/apidoc.md](https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/references/apidoc.md)
34
+ - Fxyz Skill 指南:[fxyz/SKILL.md](https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/SKILL.md)
35
+
36
+ ---
37
+
38
+ ## 功能特点
39
+
40
+ - **股票与基金行情**:沪深京 A 股、ETF、指数的实时行情和股票列表。
41
+ - **K 线与历史行情**:支持1 分钟、 5 分钟、15 分钟、30 分钟、1 小时、日、周、月、年等周期及复权参数。
42
+ - **盘口与成交数据**:买卖五档、集合竞价、逐笔成交、分价统计和日线快照。
43
+ - **市场监控数据**:涨停、跌停、炸板、强势股和次新股数据。
44
+ - **资金流向**:按大单级别查看资金流向数据。
45
+
46
+ ## 核心优势
47
+
48
+ - ✅ **全面的数据覆盖** - 沪深京A股、ETF基金、主流指数
49
+ - ✅ **实时行情数据** - 30+行情指标,每分钟更新
50
+ - ✅ **特色监控数据** - 涨停板、跌停板、炸板、强势股实时追踪
51
+ - ✅ **多周期K线** - 9种时间周期(5分钟至年线),支持复权
52
+ - ✅ **深度盘口数据** - 买卖五档、竞价数据、逐笔交易
53
+ - ✅ **资金流向分析** - 特大单、大单、中单、小单分类统计
54
+ - ✅ **规范化日志** - 自动打印请求参数、返回记录数、示例数据
55
+
56
+ ---
57
+
58
+
59
+ ## 环境要求
60
+
61
+ - Python 3.7 或更高版本
62
+ - 依赖:`requests`
63
+ - 有效的 Fxyz API Token;接口可用范围取决于账号权限
64
+
65
+ ## 安装
66
+ 从 PyPI 安装:
67
+ ```bash
68
+ python -m pip install fxyz
69
+ ```
70
+
71
+ ## 获取 API Token
72
+
73
+ 访问 [Fxyz 官网](http://www.fxyz.site/),注册并登录后按账号页面指引获取 API Token。请勿将真实 Token 写入公开代码、提交到仓库或粘贴到公开日志中。Token 激活说明见 [官网申请页面](http://www.fxyz.site/#apply)。
74
+
75
+ ## 快速开始
76
+
77
+ SDK 保留仓库现有调用接口,Token 通过参数传入:
78
+
79
+ ```python
80
+ from fxyz.scripts.api.BoardApi import BoardApi
81
+ from fxyz.scripts.api.MarketApi import MarketApi
82
+
83
+ token = "YOUR_FXYZ_TOKEN"
84
+
85
+ # 获取单只股票实时行情
86
+ quote = BoardApi.getRealTimeQuote(
87
+ symbol="stock",
88
+ code="000001",
89
+ token=token,
90
+ )
91
+ print(quote)
92
+
93
+ # 获取日 K 线(cq: 1 不复权,2 前复权,3 后复权)
94
+ kline = MarketApi.getKLine(
95
+ symbol="stock",
96
+ code="000001",
97
+ period="1d",
98
+ cq="1",
99
+ startDate="2026-04-01",
100
+ endDate="2026-04-14",
101
+ token=token,
102
+ )
103
+ print(kline)
104
+ ```
105
+
106
+ API 返回 JSON 解码后的 Python 对象(通常为列表或字典)。全部接口、参数和返回字段请查看[完整 API 文档](https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/references/apidoc.md)。
107
+
108
+ ### 支持的 API
109
+
110
+ | 模块 | 方法 | 数据 |
111
+ |---|---|---|
112
+ | 基础 | `BaseApi.getStockList` | 股票、指数、ETF 等列表 |
113
+ | 市场 | `BoardApi.getRealTimeQuote` | 实时行情 |
114
+ | 市场 | `BoardApi.getZhangTingBan`、`getDieTingBan` | 涨停板、跌停板 |
115
+ | 市场 | `BoardApi.getZhaBan`、`getQiangShiGu`、`getCiXinGu` | 炸板、强势股、次新股 |
116
+ | 行情 | `MarketApi.getKLine`、`getDaySnapshot` | K 线、日线快照 |
117
+ | 行情 | `MarketApi.getFiveLevel`、`getBidData` | 五档盘口、集合竞价 |
118
+ | 行情 | `MarketApi.getDealData`、`getPriceData` | 逐笔成交、分价统计 |
119
+ | 行情 | `MarketApi.getMoneyFlow` | 资金流向 |
120
+
121
+ ## 本地开发与验证
122
+
123
+ ```bash
124
+ python -m pip install -e .
125
+ python -c "from fxyz.scripts.api.BoardApi import BoardApi; from fxyz.scripts.api.MarketApi import MarketApi; print('Fxyz SDK imports OK')"
126
+ ```
127
+
128
+ 仓库里的 `fxyz/scripts/StockApiClient.py` 是需要有效 Token 才能访问线上 API 的示例程序;导入检查和本地构建不需要 API Token。
129
+
130
+ ## 项目结构
131
+
132
+ ```text
133
+ fxyz/
134
+ ├── __init__.py
135
+ ├── SKILL.md
136
+ ├── references/
137
+ │ └── apidoc.md
138
+ └── scripts/
139
+ ├── Config.py
140
+ ├── StockApiClient.py
141
+ ├── api/
142
+ │ ├── BaseApi.py
143
+ │ ├── BoardApi.py
144
+ │ └── MarketApi.py
145
+ └── util/
146
+ └── DataUtil.py
147
+ pyproject.toml
148
+ README.md
149
+ ```
150
+
151
+ ## 安全与使用说明
152
+
153
+ - SDK 请求需要有效 Token;全市场查询等能力可能需要相应账号权限。
154
+ - 请遵循 Fxyz 官网服务条款和 API 调用限制,并合理控制请求频率。
155
+ - 行情数据仅供研究和开发使用;请以服务端返回及官方说明为准。
156
+ - 本 SDK 不提供投资建议,也不保证数据适合任何特定交易用途。
157
+ - 如遇接口或权限问题,请查阅[接口文档](https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/references/apidoc.md)并联系 Fxyz 官方。
158
+
159
+ ## 关键词
160
+
161
+ Fxyz Python SDK、黑狼数据 Python API、A 股行情 API、沪深京股票数据、ETF 行情接口、Python 实时股票行情、股票 K 线 API、量化数据接口、涨停板数据、资金流向 API。
@@ -0,0 +1,17 @@
1
+ README.md
2
+ pyproject.toml
3
+ fxyz/__init__.py
4
+ fxyz.egg-info/PKG-INFO
5
+ fxyz.egg-info/SOURCES.txt
6
+ fxyz.egg-info/dependency_links.txt
7
+ fxyz.egg-info/requires.txt
8
+ fxyz.egg-info/top_level.txt
9
+ fxyz/scripts/Config.py
10
+ fxyz/scripts/StockApiClient.py
11
+ fxyz/scripts/__init__.py
12
+ fxyz/scripts/api/BaseApi.py
13
+ fxyz/scripts/api/BoardApi.py
14
+ fxyz/scripts/api/MarketApi.py
15
+ fxyz/scripts/api/__init__.py
16
+ fxyz/scripts/util/DataUtil.py
17
+ fxyz/scripts/util/__init__.py
@@ -0,0 +1 @@
1
+ requests>=2.20
@@ -0,0 +1 @@
1
+ fxyz
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "fxyz"
7
+ version = "0.1.0"
8
+ description = "Fxyz是专业的金融数据API平台,为量化交易与投资研究提供可靠的全市场行情数据API。"
9
+ readme = "README.md"
10
+ requires-python = ">=3.7"
11
+ dependencies = ["requests>=2.20"]
12
+ keywords = [
13
+ "fxyz","黑狼数据", "A-share-data", "stock-quotes",
14
+ "实时股票数据API", "中国股票行情", "沪深京A股", "ETF行情", "股票K线", "买卖五档数据",
15
+ "股票分钟数据", "实时行情数据", "资金流向", "集合竞价数据",
16
+ ]
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha",
19
+ "Intended Audience :: Developers",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3 :: Only",
23
+ "Programming Language :: Python :: 3.7",
24
+ "Programming Language :: Python :: 3.8",
25
+ "Programming Language :: Python :: 3.9",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Topic :: Office/Business :: Financial :: Investment",
30
+ ]
31
+
32
+ [project.urls]
33
+ Homepage = "https://www.fxyz.site/"
34
+ Repository = "https://github.com/fxyzsite/FxyzSkill"
35
+ Documentation = "https://github.com/fxyzsite/FxyzSkill/blob/main/fxyz/references/apidoc.md"
36
+
37
+ [tool.setuptools.packages.find]
38
+ include = ["fxyz", "fxyz.*"]
fxyz-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+