zerone-cli 0.1.1__tar.gz → 0.1.3__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.
- zerone_cli-0.1.3/PKG-INFO +169 -0
- zerone_cli-0.1.3/README.md +142 -0
- zerone_cli-0.1.3/cli/__init__.py +1 -0
- zerone_cli-0.1.3/cli/client.py +176 -0
- zerone_cli-0.1.3/cli/commands/__init__.py +19 -0
- zerone_cli-0.1.3/cli/commands/basic_info.py +77 -0
- zerone_cli-0.1.3/cli/commands/config_cmd.py +47 -0
- zerone_cli-0.1.3/cli/commands/entity_exit_list.py +47 -0
- zerone_cli-0.1.3/cli/commands/entity_financial_list.py +42 -0
- zerone_cli-0.1.3/cli/commands/entity_invest_list.py +47 -0
- zerone_cli-0.1.3/cli/commands/entity_managed_funds_list.py +42 -0
- zerone_cli-0.1.3/cli/commands/entity_profile.py +40 -0
- zerone_cli-0.1.3/cli/commands/entity_search.py +31 -0
- zerone_cli-0.1.3/cli/commands/financing.py +84 -0
- zerone_cli-0.1.3/cli/commands/model_financing_probability.py +39 -0
- zerone_cli-0.1.3/cli/commands/shareholders.py +88 -0
- zerone_cli-0.1.3/cli/config.py +69 -0
- zerone_cli-0.1.3/cli/main.py +29 -0
- zerone_cli-0.1.3/cli/utils/__init__.py +3 -0
- zerone_cli-0.1.3/cli/utils/errors.py +0 -0
- zerone_cli-0.1.3/cli/utils/output.py +97 -0
- {zerone_cli-0.1.1 → zerone_cli-0.1.3}/pyproject.toml +4 -3
- zerone_cli-0.1.3/zerone_cli.egg-info/PKG-INFO +169 -0
- zerone_cli-0.1.3/zerone_cli.egg-info/SOURCES.txt +27 -0
- zerone_cli-0.1.3/zerone_cli.egg-info/dependency_links.txt +1 -0
- zerone_cli-0.1.3/zerone_cli.egg-info/entry_points.txt +3 -0
- zerone_cli-0.1.3/zerone_cli.egg-info/requires.txt +6 -0
- zerone_cli-0.1.3/zerone_cli.egg-info/top_level.txt +1 -0
- zerone_cli-0.1.1/PKG-INFO +0 -110
- zerone_cli-0.1.1/README.md +0 -83
- {zerone_cli-0.1.1 → zerone_cli-0.1.3}/setup.cfg +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: zerone-cli
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Zerone 私募股权数据 CLI 工具
|
|
5
|
+
Author-email: Zerone <tech@zerone.com.cn>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://ai.zerone.com.cn
|
|
8
|
+
Project-URL: Documentation, https://ai.zerone.com.cn
|
|
9
|
+
Keywords: cli,private-equity,finance,mcp,zerone
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Environment :: Console
|
|
17
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
18
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Requires-Dist: typer>=0.9.0
|
|
22
|
+
Requires-Dist: httpx>=0.24.0
|
|
23
|
+
Requires-Dist: pydantic>=2.0.0
|
|
24
|
+
Requires-Dist: pyyaml>=6.0
|
|
25
|
+
Requires-Dist: rich>=13.0.0
|
|
26
|
+
Requires-Dist: pandas>=2.0.0
|
|
27
|
+
|
|
28
|
+
# Zerone CLI
|
|
29
|
+
|
|
30
|
+
Zerone 私募股权数据命令行工具,通过 API Key 直接查询 Zerone 数据平台。
|
|
31
|
+
|
|
32
|
+
## 安装
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install zerone-cli
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 快速开始
|
|
39
|
+
|
|
40
|
+
### 1. 配置 API Key
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
zerone config set-api-key YOUR_API_KEY
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> 如何获取 API Key?请访问 [https://ai.zerone.com.cn](https://ai.zerone.com.cn) 注册账号后申请。
|
|
47
|
+
|
|
48
|
+
### 2. 查看帮助
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
zerone --help
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 3. 开始查询
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# 实体模糊搜索
|
|
58
|
+
zerone entity-search "字节跳动"
|
|
59
|
+
|
|
60
|
+
# 查询实体综合画像
|
|
61
|
+
zerone entity-profile "中国石油"
|
|
62
|
+
|
|
63
|
+
# 查询实体财务数据列表
|
|
64
|
+
zerone entity-financial-list "中国石油" --page 1 --page-size 20
|
|
65
|
+
|
|
66
|
+
# 查询管理基金列表
|
|
67
|
+
zerone entity-managed-funds-list "深创投" --page 1 --page-size 20
|
|
68
|
+
|
|
69
|
+
# 查询退出列表
|
|
70
|
+
zerone entity-exit-list "深创投" --exit-type IPO --page 1 --page-size 20
|
|
71
|
+
|
|
72
|
+
# 查询投资列表
|
|
73
|
+
zerone entity-invest-list "深创投" --invest-type 直接投资 --page 1 --page-size 20
|
|
74
|
+
|
|
75
|
+
# 查询融资概率预测
|
|
76
|
+
zerone model-financing-probability "字节跳动" --type COMPANY
|
|
77
|
+
|
|
78
|
+
# 查询机构匹配推荐
|
|
79
|
+
zerone model-company-match-gp "字节跳动" --page 1 --page-size 5
|
|
80
|
+
|
|
81
|
+
# 查询市场投融资事件
|
|
82
|
+
zerone evt-company-financing --start-date 2024-01-01 --end-date 2024-12-31 --province 北京 --city 北京市 --tag 人工智能 --page 1 --page-size 20
|
|
83
|
+
|
|
84
|
+
# 查询LP出资事件
|
|
85
|
+
zerone evt-lp-investment --start-date 2024-01-01 --end-date 2024-12-31 --province 广东 --city 深圳 --page 1 --page-size 20
|
|
86
|
+
|
|
87
|
+
# 查询老股转让事件
|
|
88
|
+
zerone evt-company-secondary --start-date 2024-01-01 --end-date 2024-12-31 --province 上海 --tag 半导体 --page 1 --page-size 20
|
|
89
|
+
|
|
90
|
+
# 查询回购事件
|
|
91
|
+
zerone evt-company-repurchase --start-date 2024-01-01 --end-date 2024-12-31 --province 浙江 --tag 医疗健康 --page 1 --page-size 20
|
|
92
|
+
|
|
93
|
+
# 查询并购事件
|
|
94
|
+
zerone evt-ma-company-deal --start-date 2024-01-01 --end-date 2024-12-31 --province 北京 --tag 新能源 --page 1 --page-size 20
|
|
95
|
+
|
|
96
|
+
# 查询IPO事件
|
|
97
|
+
zerone evt-company-ipo --start-date 2024-01-01 --end-date 2024-12-31 --province 广东 --tag 新材料 --page 1 --page-size 20
|
|
98
|
+
|
|
99
|
+
# 查询解禁事件
|
|
100
|
+
zerone evt-listing-company-unlock --start-date 2024-01-01 --end-date 2024-12-31 --province 江苏 --tag 高端制造 --page 1 --page-size 20
|
|
101
|
+
|
|
102
|
+
# 查询减持事件
|
|
103
|
+
zerone evt-listing-company-reduction --start-date 2024-01-01 --end-date 2024-12-31 --province 上海 --tag 集成电路 --page 1 --page-size 20
|
|
104
|
+
|
|
105
|
+
# 查询S基金交易事件
|
|
106
|
+
zerone evt-s-fund-deal --start-date 2024-01-01 --end-date 2024-12-31 --province 北京 --page 1 --page-size 20
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## 命令列表
|
|
110
|
+
|
|
111
|
+
| 命令 | 说明 |
|
|
112
|
+
|------|------|
|
|
113
|
+
| `zerone config set-api-key` | 设置 API Key |
|
|
114
|
+
| `zerone config set-server-url` | 设置服务器地址(可选) |
|
|
115
|
+
| `zerone config show` | 查看当前配置 |
|
|
116
|
+
| `zerone entity-search` | 实体模糊搜索 |
|
|
117
|
+
| `zerone entity-profile` | 查询实体综合画像 |
|
|
118
|
+
| `zerone entity-financial-list` | 查询实体财务数据列表(分页) |
|
|
119
|
+
| `zerone entity-managed-funds-list` | 查询管理基金列表(分页) |
|
|
120
|
+
| `zerone entity-exit-list` | 查询退出列表(分页) |
|
|
121
|
+
| `zerone entity-invest-list` | 查询投资列表(分页) |
|
|
122
|
+
| `zerone model-financing-probability` | 查询融资概率预测模型 |
|
|
123
|
+
| `zerone model-company-match-gp` | 基于推荐引擎为项目公司匹配潜在投资机构 |
|
|
124
|
+
| `zerone evt-company-financing` | 查询市场投融资事件列表 |
|
|
125
|
+
| `zerone evt-lp-investment` | 查询LP出资事件列表 |
|
|
126
|
+
| `zerone evt-company-secondary` | 查询老股转让事件列表 |
|
|
127
|
+
| `zerone evt-company-repurchase` | 查询回购事件列表 |
|
|
128
|
+
| `zerone evt-ma-company-deal` | 查询并购事件列表 |
|
|
129
|
+
| `zerone evt-company-ipo` | 查询IPO事件列表 |
|
|
130
|
+
| `zerone evt-listing-company-unlock` | 查询解禁事件列表 |
|
|
131
|
+
| `zerone evt-listing-company-reduction` | 查询减持事件列表 |
|
|
132
|
+
| `zerone evt-s-fund-deal` | 查询S基金交易事件列表 |
|
|
133
|
+
|
|
134
|
+
## 常用参数说明
|
|
135
|
+
|
|
136
|
+
### 日期参数
|
|
137
|
+
- `--start-date`: 开始日期,格式 YYYY-MM-DD
|
|
138
|
+
- `--end-date`: 结束日期,格式 YYYY-MM-DD
|
|
139
|
+
|
|
140
|
+
### 地区参数
|
|
141
|
+
- `--province`: 省级行政区划
|
|
142
|
+
- `--city`: 地级行政区划
|
|
143
|
+
- `--county`: 县级行政区划
|
|
144
|
+
|
|
145
|
+
### 分页参数
|
|
146
|
+
- `--page`: 页码,从1开始,默认1
|
|
147
|
+
- `--page-size`: 每页条数,默认20,上限20
|
|
148
|
+
|
|
149
|
+
### 其他参数
|
|
150
|
+
- `--tag`: 公司标签(经营业务类)
|
|
151
|
+
- `--output`: 输出格式,可选 table/json/csv,默认table
|
|
152
|
+
|
|
153
|
+
## 配置说明
|
|
154
|
+
|
|
155
|
+
配置文件保存在 `~/.zerone/config.yaml`,支持以下环境变量覆盖:
|
|
156
|
+
|
|
157
|
+
| 环境变量 | 说明 |
|
|
158
|
+
|----------|------|
|
|
159
|
+
| `ZERONE_API_KEY` | API Key |
|
|
160
|
+
| `ZERONE_SERVER_URL` | 服务器地址 |
|
|
161
|
+
|
|
162
|
+
## 系统要求
|
|
163
|
+
|
|
164
|
+
- Python 3.9+
|
|
165
|
+
- 有效的 Zerone API Key
|
|
166
|
+
|
|
167
|
+
## 许可证
|
|
168
|
+
|
|
169
|
+
MIT
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Zerone CLI
|
|
2
|
+
|
|
3
|
+
Zerone 私募股权数据命令行工具,通过 API Key 直接查询 Zerone 数据平台。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install zerone-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 快速开始
|
|
12
|
+
|
|
13
|
+
### 1. 配置 API Key
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
zerone config set-api-key YOUR_API_KEY
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
> 如何获取 API Key?请访问 [https://ai.zerone.com.cn](https://ai.zerone.com.cn) 注册账号后申请。
|
|
20
|
+
|
|
21
|
+
### 2. 查看帮助
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
zerone --help
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 3. 开始查询
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# 实体模糊搜索
|
|
31
|
+
zerone entity-search "字节跳动"
|
|
32
|
+
|
|
33
|
+
# 查询实体综合画像
|
|
34
|
+
zerone entity-profile "中国石油"
|
|
35
|
+
|
|
36
|
+
# 查询实体财务数据列表
|
|
37
|
+
zerone entity-financial-list "中国石油" --page 1 --page-size 20
|
|
38
|
+
|
|
39
|
+
# 查询管理基金列表
|
|
40
|
+
zerone entity-managed-funds-list "深创投" --page 1 --page-size 20
|
|
41
|
+
|
|
42
|
+
# 查询退出列表
|
|
43
|
+
zerone entity-exit-list "深创投" --exit-type IPO --page 1 --page-size 20
|
|
44
|
+
|
|
45
|
+
# 查询投资列表
|
|
46
|
+
zerone entity-invest-list "深创投" --invest-type 直接投资 --page 1 --page-size 20
|
|
47
|
+
|
|
48
|
+
# 查询融资概率预测
|
|
49
|
+
zerone model-financing-probability "字节跳动" --type COMPANY
|
|
50
|
+
|
|
51
|
+
# 查询机构匹配推荐
|
|
52
|
+
zerone model-company-match-gp "字节跳动" --page 1 --page-size 5
|
|
53
|
+
|
|
54
|
+
# 查询市场投融资事件
|
|
55
|
+
zerone evt-company-financing --start-date 2024-01-01 --end-date 2024-12-31 --province 北京 --city 北京市 --tag 人工智能 --page 1 --page-size 20
|
|
56
|
+
|
|
57
|
+
# 查询LP出资事件
|
|
58
|
+
zerone evt-lp-investment --start-date 2024-01-01 --end-date 2024-12-31 --province 广东 --city 深圳 --page 1 --page-size 20
|
|
59
|
+
|
|
60
|
+
# 查询老股转让事件
|
|
61
|
+
zerone evt-company-secondary --start-date 2024-01-01 --end-date 2024-12-31 --province 上海 --tag 半导体 --page 1 --page-size 20
|
|
62
|
+
|
|
63
|
+
# 查询回购事件
|
|
64
|
+
zerone evt-company-repurchase --start-date 2024-01-01 --end-date 2024-12-31 --province 浙江 --tag 医疗健康 --page 1 --page-size 20
|
|
65
|
+
|
|
66
|
+
# 查询并购事件
|
|
67
|
+
zerone evt-ma-company-deal --start-date 2024-01-01 --end-date 2024-12-31 --province 北京 --tag 新能源 --page 1 --page-size 20
|
|
68
|
+
|
|
69
|
+
# 查询IPO事件
|
|
70
|
+
zerone evt-company-ipo --start-date 2024-01-01 --end-date 2024-12-31 --province 广东 --tag 新材料 --page 1 --page-size 20
|
|
71
|
+
|
|
72
|
+
# 查询解禁事件
|
|
73
|
+
zerone evt-listing-company-unlock --start-date 2024-01-01 --end-date 2024-12-31 --province 江苏 --tag 高端制造 --page 1 --page-size 20
|
|
74
|
+
|
|
75
|
+
# 查询减持事件
|
|
76
|
+
zerone evt-listing-company-reduction --start-date 2024-01-01 --end-date 2024-12-31 --province 上海 --tag 集成电路 --page 1 --page-size 20
|
|
77
|
+
|
|
78
|
+
# 查询S基金交易事件
|
|
79
|
+
zerone evt-s-fund-deal --start-date 2024-01-01 --end-date 2024-12-31 --province 北京 --page 1 --page-size 20
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## 命令列表
|
|
83
|
+
|
|
84
|
+
| 命令 | 说明 |
|
|
85
|
+
|------|------|
|
|
86
|
+
| `zerone config set-api-key` | 设置 API Key |
|
|
87
|
+
| `zerone config set-server-url` | 设置服务器地址(可选) |
|
|
88
|
+
| `zerone config show` | 查看当前配置 |
|
|
89
|
+
| `zerone entity-search` | 实体模糊搜索 |
|
|
90
|
+
| `zerone entity-profile` | 查询实体综合画像 |
|
|
91
|
+
| `zerone entity-financial-list` | 查询实体财务数据列表(分页) |
|
|
92
|
+
| `zerone entity-managed-funds-list` | 查询管理基金列表(分页) |
|
|
93
|
+
| `zerone entity-exit-list` | 查询退出列表(分页) |
|
|
94
|
+
| `zerone entity-invest-list` | 查询投资列表(分页) |
|
|
95
|
+
| `zerone model-financing-probability` | 查询融资概率预测模型 |
|
|
96
|
+
| `zerone model-company-match-gp` | 基于推荐引擎为项目公司匹配潜在投资机构 |
|
|
97
|
+
| `zerone evt-company-financing` | 查询市场投融资事件列表 |
|
|
98
|
+
| `zerone evt-lp-investment` | 查询LP出资事件列表 |
|
|
99
|
+
| `zerone evt-company-secondary` | 查询老股转让事件列表 |
|
|
100
|
+
| `zerone evt-company-repurchase` | 查询回购事件列表 |
|
|
101
|
+
| `zerone evt-ma-company-deal` | 查询并购事件列表 |
|
|
102
|
+
| `zerone evt-company-ipo` | 查询IPO事件列表 |
|
|
103
|
+
| `zerone evt-listing-company-unlock` | 查询解禁事件列表 |
|
|
104
|
+
| `zerone evt-listing-company-reduction` | 查询减持事件列表 |
|
|
105
|
+
| `zerone evt-s-fund-deal` | 查询S基金交易事件列表 |
|
|
106
|
+
|
|
107
|
+
## 常用参数说明
|
|
108
|
+
|
|
109
|
+
### 日期参数
|
|
110
|
+
- `--start-date`: 开始日期,格式 YYYY-MM-DD
|
|
111
|
+
- `--end-date`: 结束日期,格式 YYYY-MM-DD
|
|
112
|
+
|
|
113
|
+
### 地区参数
|
|
114
|
+
- `--province`: 省级行政区划
|
|
115
|
+
- `--city`: 地级行政区划
|
|
116
|
+
- `--county`: 县级行政区划
|
|
117
|
+
|
|
118
|
+
### 分页参数
|
|
119
|
+
- `--page`: 页码,从1开始,默认1
|
|
120
|
+
- `--page-size`: 每页条数,默认20,上限20
|
|
121
|
+
|
|
122
|
+
### 其他参数
|
|
123
|
+
- `--tag`: 公司标签(经营业务类)
|
|
124
|
+
- `--output`: 输出格式,可选 table/json/csv,默认table
|
|
125
|
+
|
|
126
|
+
## 配置说明
|
|
127
|
+
|
|
128
|
+
配置文件保存在 `~/.zerone/config.yaml`,支持以下环境变量覆盖:
|
|
129
|
+
|
|
130
|
+
| 环境变量 | 说明 |
|
|
131
|
+
|----------|------|
|
|
132
|
+
| `ZERONE_API_KEY` | API Key |
|
|
133
|
+
| `ZERONE_SERVER_URL` | 服务器地址 |
|
|
134
|
+
|
|
135
|
+
## 系统要求
|
|
136
|
+
|
|
137
|
+
- Python 3.9+
|
|
138
|
+
- 有效的 Zerone API Key
|
|
139
|
+
|
|
140
|
+
## 许可证
|
|
141
|
+
|
|
142
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.0"
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
import httpx
|
|
4
|
+
|
|
5
|
+
from cli.config import config_manager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class MCPClient:
|
|
9
|
+
|
|
10
|
+
def __init__(self):
|
|
11
|
+
self.api_key = config_manager.get_api_key()
|
|
12
|
+
self.server_url = config_manager.get_server_url()
|
|
13
|
+
self.client = httpx.Client(timeout=30.0)
|
|
14
|
+
|
|
15
|
+
def _request(
|
|
16
|
+
self,
|
|
17
|
+
method: str,
|
|
18
|
+
path: str,
|
|
19
|
+
json_data: Optional[dict] = None,
|
|
20
|
+
params: Optional[dict] = None,
|
|
21
|
+
) -> dict:
|
|
22
|
+
url = f"{self.server_url}{path}"
|
|
23
|
+
headers = {
|
|
24
|
+
"Authorization": f"Bearer {self.api_key}",
|
|
25
|
+
"Content-Type": "application/json",
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try:
|
|
29
|
+
response = self.client.request(
|
|
30
|
+
method=method,
|
|
31
|
+
url=url,
|
|
32
|
+
headers=headers,
|
|
33
|
+
json=json_data,
|
|
34
|
+
params=params,
|
|
35
|
+
)
|
|
36
|
+
response.raise_for_status()
|
|
37
|
+
data = response.json()
|
|
38
|
+
if not data.get("success", True):
|
|
39
|
+
error = data.get("error", {})
|
|
40
|
+
raise ValueError(f"[{error.get('code', 'UNKNOWN')}] {error.get('message', '未知错误')}")
|
|
41
|
+
return data
|
|
42
|
+
except httpx.HTTPStatusError as e:
|
|
43
|
+
try:
|
|
44
|
+
error_data = e.response.json()
|
|
45
|
+
detail = error_data.get("detail", "")
|
|
46
|
+
if detail:
|
|
47
|
+
raise ValueError(f"[HTTP {e.response.status_code}] {detail}")
|
|
48
|
+
except ValueError:
|
|
49
|
+
raise
|
|
50
|
+
except Exception:
|
|
51
|
+
pass
|
|
52
|
+
raise ValueError(f"请求失败: {e.response.status_code} - {e.response.text}")
|
|
53
|
+
except httpx.ConnectError:
|
|
54
|
+
raise ValueError(f"无法连接到 MCP Server,请检查 server_url 配置:{self.server_url}")
|
|
55
|
+
except httpx.TimeoutException:
|
|
56
|
+
raise ValueError("请求超时,请检查网络连接或稍后重试")
|
|
57
|
+
|
|
58
|
+
def entity_search(self, keyword: str) -> dict:
|
|
59
|
+
return self._request(
|
|
60
|
+
"POST",
|
|
61
|
+
"/rest-api/tool/entity_search",
|
|
62
|
+
json_data={"keyword": keyword},
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
def entity_profile(
|
|
66
|
+
self,
|
|
67
|
+
entity_name: str,
|
|
68
|
+
entity_type: Optional[str] = None,
|
|
69
|
+
) -> dict:
|
|
70
|
+
return self._request(
|
|
71
|
+
"POST",
|
|
72
|
+
"/rest-api/tool/entity_profile",
|
|
73
|
+
json_data={
|
|
74
|
+
"entity_name": entity_name,
|
|
75
|
+
"entity_type": entity_type or "",
|
|
76
|
+
},
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
def entity_financial_list(
|
|
80
|
+
self,
|
|
81
|
+
entity_name: str,
|
|
82
|
+
entity_type: Optional[str] = None,
|
|
83
|
+
page: int = 1,
|
|
84
|
+
page_size: int = 20,
|
|
85
|
+
) -> dict:
|
|
86
|
+
return self._request(
|
|
87
|
+
"POST",
|
|
88
|
+
"/rest-api/tool/entity_financial_list",
|
|
89
|
+
json_data={
|
|
90
|
+
"entity_name": entity_name,
|
|
91
|
+
"entity_type": entity_type or "",
|
|
92
|
+
"page": page,
|
|
93
|
+
"page_size": page_size,
|
|
94
|
+
},
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def entity_managed_funds_list(
|
|
98
|
+
self,
|
|
99
|
+
entity_name: str,
|
|
100
|
+
entity_type: Optional[str] = None,
|
|
101
|
+
page: int = 1,
|
|
102
|
+
page_size: int = 20,
|
|
103
|
+
) -> dict:
|
|
104
|
+
return self._request(
|
|
105
|
+
"POST",
|
|
106
|
+
"/rest-api/tool/entity_managed_funds_list",
|
|
107
|
+
json_data={
|
|
108
|
+
"entity_name": entity_name,
|
|
109
|
+
"entity_type": entity_type or "",
|
|
110
|
+
"page": page,
|
|
111
|
+
"page_size": page_size,
|
|
112
|
+
},
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
def entity_exit_list(
|
|
116
|
+
self,
|
|
117
|
+
entity_name: str,
|
|
118
|
+
entity_type: Optional[str] = None,
|
|
119
|
+
exit_type: Optional[str] = None,
|
|
120
|
+
page: int = 1,
|
|
121
|
+
page_size: int = 20,
|
|
122
|
+
) -> dict:
|
|
123
|
+
return self._request(
|
|
124
|
+
"POST",
|
|
125
|
+
"/rest-api/tool/entity_exit_list",
|
|
126
|
+
json_data={
|
|
127
|
+
"entity_name": entity_name,
|
|
128
|
+
"entity_type": entity_type or "",
|
|
129
|
+
"exit_type": exit_type or "",
|
|
130
|
+
"page": page,
|
|
131
|
+
"page_size": page_size,
|
|
132
|
+
},
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
def entity_invest_list(
|
|
136
|
+
self,
|
|
137
|
+
entity_name: str,
|
|
138
|
+
entity_type: Optional[str] = None,
|
|
139
|
+
invest_type: Optional[str] = None,
|
|
140
|
+
page: int = 1,
|
|
141
|
+
page_size: int = 20,
|
|
142
|
+
) -> dict:
|
|
143
|
+
return self._request(
|
|
144
|
+
"POST",
|
|
145
|
+
"/rest-api/tool/entity_invest_list",
|
|
146
|
+
json_data={
|
|
147
|
+
"entity_name": entity_name,
|
|
148
|
+
"entity_type": entity_type or "",
|
|
149
|
+
"invest_type": invest_type or "",
|
|
150
|
+
"page": page,
|
|
151
|
+
"page_size": page_size,
|
|
152
|
+
},
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
def model_financing_probability(
|
|
156
|
+
self,
|
|
157
|
+
entity_name: str,
|
|
158
|
+
entity_type: Optional[str] = None,
|
|
159
|
+
) -> dict:
|
|
160
|
+
return self._request(
|
|
161
|
+
"POST",
|
|
162
|
+
"/rest-api/tool/model_financing_probability",
|
|
163
|
+
json_data={
|
|
164
|
+
"entity_name": entity_name,
|
|
165
|
+
"entity_type": entity_type or "",
|
|
166
|
+
},
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
def close(self):
|
|
170
|
+
self.client.close()
|
|
171
|
+
|
|
172
|
+
def __enter__(self):
|
|
173
|
+
return self
|
|
174
|
+
|
|
175
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
176
|
+
self.close()
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from cli.commands import config_cmd
|
|
2
|
+
from cli.commands.entity_search import entity_search
|
|
3
|
+
from cli.commands.entity_profile import entity_profile
|
|
4
|
+
from cli.commands.entity_financial_list import entity_financial_list
|
|
5
|
+
from cli.commands.entity_managed_funds_list import entity_managed_funds_list
|
|
6
|
+
from cli.commands.entity_exit_list import entity_exit_list
|
|
7
|
+
from cli.commands.entity_invest_list import entity_invest_list
|
|
8
|
+
from cli.commands.model_financing_probability import model_financing_probability
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"config_cmd",
|
|
12
|
+
"entity_search",
|
|
13
|
+
"entity_profile",
|
|
14
|
+
"entity_financial_list",
|
|
15
|
+
"entity_managed_funds_list",
|
|
16
|
+
"entity_exit_list",
|
|
17
|
+
"entity_invest_list",
|
|
18
|
+
"model_financing_probability",
|
|
19
|
+
]
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""
|
|
2
|
+
查询基本信息命令模块
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
from typing import Optional
|
|
7
|
+
|
|
8
|
+
import typer
|
|
9
|
+
|
|
10
|
+
from cli.config import config_manager
|
|
11
|
+
from cli.utils.output import print_result
|
|
12
|
+
from mcp_server.tools.executor import ToolExecutor
|
|
13
|
+
from mcp_server.router.entity_router import EntityRouter
|
|
14
|
+
from mcp_server.router.type_router import TypeRouter
|
|
15
|
+
from mcp_server.services.entity_service import EntityService
|
|
16
|
+
from mcp_server.utils.field_mapper import FieldMapper
|
|
17
|
+
from mcp_server.openapi_client.client import OpenAPIClient
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
async def execute(entity_name: str, entity_type: Optional[str] = None) -> dict:
|
|
21
|
+
"""
|
|
22
|
+
执行查询基本信息
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
entity_name: 实体名称
|
|
26
|
+
entity_type: 实体类型 (gp/lp/fund/company/preipo/list/neeq)
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
查询结果字典
|
|
30
|
+
"""
|
|
31
|
+
app_id, app_key = config_manager.get_credentials()
|
|
32
|
+
config = config_manager.load()
|
|
33
|
+
|
|
34
|
+
client = OpenAPIClient(base_url=config.base_url)
|
|
35
|
+
entity_service = EntityService()
|
|
36
|
+
executor = ToolExecutor(
|
|
37
|
+
entity_router=EntityRouter(entity_service),
|
|
38
|
+
type_router=TypeRouter(),
|
|
39
|
+
field_mapper=FieldMapper(),
|
|
40
|
+
openapi_client=client,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
result = await executor.execute_get_basic_info(
|
|
45
|
+
entity_name=entity_name,
|
|
46
|
+
entity_type=entity_type,
|
|
47
|
+
app_id=app_id,
|
|
48
|
+
app_key=app_key,
|
|
49
|
+
)
|
|
50
|
+
return result
|
|
51
|
+
finally:
|
|
52
|
+
await client.close()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def get_basic_info(
|
|
56
|
+
entity_name: str = typer.Argument(..., help="实体名称,如'字节跳动'"),
|
|
57
|
+
entity_type: Optional[str] = typer.Option(
|
|
58
|
+
None, "--type", "-t", help="实体类型:gp/lp/fund/company/preipo/list/neeq"
|
|
59
|
+
),
|
|
60
|
+
output: str = typer.Option(
|
|
61
|
+
"table", "--output", "-o", help="输出格式:table/json/csv"
|
|
62
|
+
),
|
|
63
|
+
):
|
|
64
|
+
"""
|
|
65
|
+
查询实体基本信息
|
|
66
|
+
|
|
67
|
+
示例:
|
|
68
|
+
zerone-cli get-basic-info "字节跳动"
|
|
69
|
+
zerone-cli get-basic-info "红杉资本" --type gp
|
|
70
|
+
zerone-cli get-basic-info "字节跳动" --output json
|
|
71
|
+
"""
|
|
72
|
+
try:
|
|
73
|
+
result = asyncio.run(execute(entity_name, entity_type))
|
|
74
|
+
print_result(result, output)
|
|
75
|
+
except ValueError as e:
|
|
76
|
+
typer.echo(f"[red]错误: {e}[/red]", err=True)
|
|
77
|
+
raise typer.Exit(1)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
|
|
3
|
+
from cli.config import config_manager
|
|
4
|
+
|
|
5
|
+
app = typer.Typer(help="管理 CLI 配置")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@app.command("show")
|
|
9
|
+
def show_config():
|
|
10
|
+
"""显示当前配置"""
|
|
11
|
+
config = config_manager.load()
|
|
12
|
+
typer.echo("=== 当前配置 ===")
|
|
13
|
+
typer.echo(f"api_key: {'*' * 10 if config.api_key else '(未设置)'}")
|
|
14
|
+
typer.echo(f"server_url: {config.server_url}")
|
|
15
|
+
typer.echo(f"output_format: {config.output_format}")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@app.command("set-api-key")
|
|
19
|
+
def set_api_key(api_key: str = typer.Argument(..., help="API Key(从平台获取)")):
|
|
20
|
+
"""设置 API Key"""
|
|
21
|
+
config = config_manager.load()
|
|
22
|
+
config.api_key = api_key
|
|
23
|
+
config_manager.save(config)
|
|
24
|
+
typer.echo("✓ API Key 已设置")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@app.command("set-server-url")
|
|
28
|
+
def set_server_url(url: str = typer.Argument(..., help="MCP Server 地址,如 http://localhost:8080")):
|
|
29
|
+
"""设置 MCP Server 地址"""
|
|
30
|
+
config = config_manager.load()
|
|
31
|
+
config.server_url = url
|
|
32
|
+
config_manager.save(config)
|
|
33
|
+
typer.echo(f"✓ Server URL 已设置: {url}")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@app.command("set-output-format")
|
|
37
|
+
def set_output_format(
|
|
38
|
+
fmt: str = typer.Argument(..., help="输出格式 (table/json/csv)")
|
|
39
|
+
):
|
|
40
|
+
"""设置默认输出格式"""
|
|
41
|
+
if fmt not in ("table", "json", "csv"):
|
|
42
|
+
typer.echo("✗ 无效的输出格式,请选择: table, json, csv")
|
|
43
|
+
raise typer.Exit(1)
|
|
44
|
+
config = config_manager.load()
|
|
45
|
+
config.output_format = fmt
|
|
46
|
+
config_manager.save(config)
|
|
47
|
+
typer.echo(f"✓ Output format 已设置: {fmt}")
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
|
|
5
|
+
from cli.client import MCPClient
|
|
6
|
+
from cli.utils.output import print_result
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def entity_exit_list(
|
|
10
|
+
entity_name: str = typer.Argument(..., help="实体名称,如'高瓴资本'"),
|
|
11
|
+
entity_type: Optional[str] = typer.Option(
|
|
12
|
+
None, "--type", "-t",
|
|
13
|
+
help="实体类型:GP/LP/FUND"
|
|
14
|
+
),
|
|
15
|
+
exit_type: Optional[str] = typer.Option(
|
|
16
|
+
None, "--exit-type", "-e",
|
|
17
|
+
help="退出类型:COMPANY/FUND"
|
|
18
|
+
),
|
|
19
|
+
page: int = typer.Option(1, "--page", "-p", help="页码,从 1 开始"),
|
|
20
|
+
page_size: int = typer.Option(20, "--page-size", "-s", help="每页条数,默认 20"),
|
|
21
|
+
output: str = typer.Option("table", "--output", "-o", help="输出格式:table/json/csv"),
|
|
22
|
+
):
|
|
23
|
+
"""
|
|
24
|
+
查询退出列表(分页)
|
|
25
|
+
|
|
26
|
+
支持 GP/LP/FUND 类型。
|
|
27
|
+
|
|
28
|
+
示例:
|
|
29
|
+
zerone entity-exit-list "高瓴资本" --type GP
|
|
30
|
+
zerone entity-exit-list "高瓴资本" --type GP --exit-type COMPANY
|
|
31
|
+
"""
|
|
32
|
+
try:
|
|
33
|
+
with MCPClient() as client:
|
|
34
|
+
result = client.entity_exit_list(
|
|
35
|
+
entity_name=entity_name,
|
|
36
|
+
entity_type=entity_type,
|
|
37
|
+
exit_type=exit_type,
|
|
38
|
+
page=page,
|
|
39
|
+
page_size=page_size,
|
|
40
|
+
)
|
|
41
|
+
print_result(result, output)
|
|
42
|
+
except ValueError as e:
|
|
43
|
+
typer.echo(f"错误: {e}", err=True)
|
|
44
|
+
raise typer.Exit(1)
|
|
45
|
+
except Exception as e:
|
|
46
|
+
typer.echo(f"请求失败: {e}", err=True)
|
|
47
|
+
raise typer.Exit(1)
|