lixinger-python 0.3.15__py3-none-any.whl → 0.3.17__py3-none-any.whl
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.
- lixinger/__init__.py +9 -0
- lixinger/api/cn/industry/__init__.py +15 -0
- lixinger/api/cn/industry/constituents/__init__.py +19 -0
- lixinger/api/cn/industry/constituents/sw_2021.py +122 -0
- lixinger/api/cn/industry/fundamental/__init__.py +19 -0
- lixinger/api/cn/industry/fundamental/sw_2021.py +153 -0
- lixinger/api/cn/industry/industry.py +141 -0
- lixinger/api/cn/industry/namespace.py +71 -0
- lixinger/client.py +16 -0
- lixinger/models/cn/industry/__init__.py +6 -0
- lixinger/models/cn/industry/constituents/__init__.py +13 -0
- lixinger/models/cn/industry/constituents/sw_2021.py +24 -0
- lixinger/models/cn/industry/fundamental/__init__.py +13 -0
- lixinger/models/cn/industry/fundamental/sw_2021.py +23 -0
- lixinger/models/cn/industry/industry.py +26 -0
- {lixinger_python-0.3.15.dist-info → lixinger_python-0.3.17.dist-info}/METADATA +1 -1
- {lixinger_python-0.3.15.dist-info → lixinger_python-0.3.17.dist-info}/RECORD +19 -9
- {lixinger_python-0.3.15.dist-info → lixinger_python-0.3.17.dist-info}/WHEEL +0 -0
- {lixinger_python-0.3.15.dist-info → lixinger_python-0.3.17.dist-info}/licenses/LICENSE +0 -0
lixinger/__init__.py
CHANGED
|
@@ -43,8 +43,11 @@ from lixinger.api.cn.index import (
|
|
|
43
43
|
get_drawdown as get_index_drawdown,
|
|
44
44
|
)
|
|
45
45
|
from lixinger.api.cn.industry import (
|
|
46
|
+
get_industry,
|
|
46
47
|
get_industry_cni_margin_trading,
|
|
47
48
|
get_industry_sw_2021_bank_statements,
|
|
49
|
+
get_industry_sw_2021_constituents,
|
|
50
|
+
get_industry_sw_2021_fundamental,
|
|
48
51
|
get_industry_sw_2021_hybrid_statements,
|
|
49
52
|
get_industry_sw_2021_insurance_statements,
|
|
50
53
|
get_industry_sw_2021_margin_trading,
|
|
@@ -111,6 +114,8 @@ __all__ = [
|
|
|
111
114
|
"get_index_bank_statements",
|
|
112
115
|
"get_index_security_statements",
|
|
113
116
|
"get_index_hybrid_statements",
|
|
117
|
+
# Industry base info
|
|
118
|
+
"get_industry",
|
|
114
119
|
# Industry margin trading
|
|
115
120
|
"get_industry_sw_margin_trading",
|
|
116
121
|
"get_industry_sw_2021_margin_trading",
|
|
@@ -121,6 +126,10 @@ __all__ = [
|
|
|
121
126
|
"get_industry_sw_2021_insurance_statements",
|
|
122
127
|
"get_industry_sw_2021_non_financial_statements",
|
|
123
128
|
"get_industry_sw_2021_security_statements",
|
|
129
|
+
# Industry constituents (申万2021版)
|
|
130
|
+
"get_industry_sw_2021_constituents",
|
|
131
|
+
# Industry fundamental (申万2021版)
|
|
132
|
+
"get_industry_sw_2021_fundamental",
|
|
124
133
|
# Macro
|
|
125
134
|
"get_national_debt",
|
|
126
135
|
"get_rmb_deposits",
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"""Industry-related APIs."""
|
|
2
2
|
|
|
3
|
+
from lixinger.api.cn.industry.constituents import (
|
|
4
|
+
IndustrySw2021ConstituentsAPI,
|
|
5
|
+
get_industry_sw_2021_constituents,
|
|
6
|
+
)
|
|
3
7
|
from lixinger.api.cn.industry.fs import (
|
|
4
8
|
IndustrySw2021BankStatementAPI,
|
|
5
9
|
IndustrySw2021HybridStatementAPI,
|
|
@@ -12,6 +16,11 @@ from lixinger.api.cn.industry.fs import (
|
|
|
12
16
|
get_industry_sw_2021_non_financial_statements,
|
|
13
17
|
get_industry_sw_2021_security_statements,
|
|
14
18
|
)
|
|
19
|
+
from lixinger.api.cn.industry.fundamental import (
|
|
20
|
+
IndustrySw2021FundamentalAPI,
|
|
21
|
+
get_industry_sw_2021_fundamental,
|
|
22
|
+
)
|
|
23
|
+
from lixinger.api.cn.industry.industry import IndustryAPI, get_industry
|
|
15
24
|
from lixinger.api.cn.industry.margin_trading import (
|
|
16
25
|
IndustryCniMarginTradingAPI,
|
|
17
26
|
IndustrySw2021MarginTradingAPI,
|
|
@@ -23,8 +32,11 @@ from lixinger.api.cn.industry.margin_trading import (
|
|
|
23
32
|
|
|
24
33
|
__all__ = [
|
|
25
34
|
# API Classes
|
|
35
|
+
"IndustryAPI",
|
|
26
36
|
"IndustryCniMarginTradingAPI",
|
|
27
37
|
"IndustrySw2021BankStatementAPI",
|
|
38
|
+
"IndustrySw2021ConstituentsAPI",
|
|
39
|
+
"IndustrySw2021FundamentalAPI",
|
|
28
40
|
"IndustrySw2021HybridStatementAPI",
|
|
29
41
|
"IndustrySw2021InsuranceStatementAPI",
|
|
30
42
|
"IndustrySw2021MarginTradingAPI",
|
|
@@ -32,8 +44,11 @@ __all__ = [
|
|
|
32
44
|
"IndustrySw2021SecurityStatementAPI",
|
|
33
45
|
"IndustrySwMarginTradingAPI",
|
|
34
46
|
# Functional APIs
|
|
47
|
+
"get_industry",
|
|
35
48
|
"get_industry_cni_margin_trading",
|
|
36
49
|
"get_industry_sw_2021_bank_statements",
|
|
50
|
+
"get_industry_sw_2021_constituents",
|
|
51
|
+
"get_industry_sw_2021_fundamental",
|
|
37
52
|
"get_industry_sw_2021_hybrid_statements",
|
|
38
53
|
"get_industry_sw_2021_insurance_statements",
|
|
39
54
|
"get_industry_sw_2021_margin_trading",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Industry constituents APIs.
|
|
2
|
+
|
|
3
|
+
This module provides access to industry constituent APIs by industry
|
|
4
|
+
classification system:
|
|
5
|
+
|
|
6
|
+
- sw_2021: 申万2021版行业 (Shenwan 2021)
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from lixinger.api.cn.industry.constituents.sw_2021 import (
|
|
10
|
+
IndustrySw2021ConstituentsAPI,
|
|
11
|
+
get_industry_sw_2021_constituents,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
# API Classes
|
|
16
|
+
"IndustrySw2021ConstituentsAPI",
|
|
17
|
+
# Functional APIs
|
|
18
|
+
"get_industry_sw_2021_constituents",
|
|
19
|
+
]
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""Industry (申万2021版) constituents APIs."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import pandas as pd
|
|
6
|
+
|
|
7
|
+
from lixinger.api.base import BaseAPI
|
|
8
|
+
from lixinger.models.cn.industry.constituents.sw_2021 import IndustrySw2021Constituent
|
|
9
|
+
from lixinger.utils.api import api
|
|
10
|
+
from lixinger.utils.dataframe import get_response_df
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class IndustrySw2021ConstituentsAPI(BaseAPI):
|
|
14
|
+
"""申万2021版行业成分股 API."""
|
|
15
|
+
|
|
16
|
+
async def get_constituents(
|
|
17
|
+
self,
|
|
18
|
+
stock_codes: list[str],
|
|
19
|
+
date: str = "latest",
|
|
20
|
+
) -> pd.DataFrame:
|
|
21
|
+
"""获取申万2021版行业成分股列表.
|
|
22
|
+
|
|
23
|
+
获取申万2021版行业分类在指定日期的成分股列表. 可按行业代码批量查询获取
|
|
24
|
+
指定时间样本信息, 返回信息包括每只成分股的代码、地区和市场信息.
|
|
25
|
+
注意该行业划分多从2021年开始, 更早的时间可能没有数据. 当用户需要查看
|
|
26
|
+
申万2021行业成分股列表、获取成分股清单或确认股票行业分类时, 调用此接口.
|
|
27
|
+
|
|
28
|
+
API Endpoint: /cn/industry/constituents/sw_2021
|
|
29
|
+
API Method: POST
|
|
30
|
+
API Doc: https://www.lixinger.com/open/api/doc?api-key=cn/industry/constituents/sw_2021
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
stock_codes: 申万2021版行业代码列表, 长度 >=1 且 <=100, 例如
|
|
34
|
+
``["490000"]``. 请参考行业信息API获取合法的stockCode.
|
|
35
|
+
date: 信息日期 (YYYY-MM-DD, 北京时间) 或 ``"latest"``, 默认 ``"latest"``.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
DataFrame containing sw_2021 industry constituents with columns:
|
|
39
|
+
|
|
40
|
+
- industry_stock_code: 行业代码
|
|
41
|
+
- stock_code: 成分股代码
|
|
42
|
+
- area_code: 地区代码
|
|
43
|
+
- market: 市场
|
|
44
|
+
- stock_name_cn: 股票中文名称
|
|
45
|
+
- stock_name_en: 股票英文名称
|
|
46
|
+
|
|
47
|
+
Example:
|
|
48
|
+
获取申万2021版行业成分股列表::
|
|
49
|
+
|
|
50
|
+
from lixinger import AsyncLixingerClient
|
|
51
|
+
|
|
52
|
+
async with AsyncLixingerClient() as client:
|
|
53
|
+
df = await client.cn_industry.constituents.sw_2021.get_constituents(
|
|
54
|
+
stock_codes=["490000"],
|
|
55
|
+
date="latest",
|
|
56
|
+
)
|
|
57
|
+
print(df)
|
|
58
|
+
|
|
59
|
+
"""
|
|
60
|
+
payload: dict[str, Any] = {
|
|
61
|
+
"date": date,
|
|
62
|
+
}
|
|
63
|
+
if stock_codes:
|
|
64
|
+
payload["stockCodes"] = stock_codes
|
|
65
|
+
|
|
66
|
+
data = await self._request("POST", "/cn/industry/constituents/sw_2021", json=payload)
|
|
67
|
+
|
|
68
|
+
# Flatten nested response: one row per constituent per industry, with the
|
|
69
|
+
# nested stockName {cmn_hans_cn, en} broken out into separate columns.
|
|
70
|
+
flattened_data: list[dict[str, Any]] = []
|
|
71
|
+
for item in data:
|
|
72
|
+
industry_stock_code = item.get("stockCode")
|
|
73
|
+
for constituent in item.get("constituents", []):
|
|
74
|
+
stock_name = constituent.get("stockName") or {}
|
|
75
|
+
flattened_data.append(
|
|
76
|
+
{
|
|
77
|
+
"industry_stock_code": industry_stock_code,
|
|
78
|
+
"stock_code": constituent.get("stockCode"),
|
|
79
|
+
"area_code": constituent.get("areaCode"),
|
|
80
|
+
"market": constituent.get("market"),
|
|
81
|
+
"stock_name_cn": stock_name.get("cmn_hans_cn") if isinstance(stock_name, dict) else None,
|
|
82
|
+
"stock_name_en": stock_name.get("en") if isinstance(stock_name, dict) else None,
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
return get_response_df(flattened_data, IndustrySw2021Constituent)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# Functional API instance
|
|
90
|
+
_api_instance = IndustrySw2021ConstituentsAPI()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@api
|
|
94
|
+
async def get_industry_sw_2021_constituents(
|
|
95
|
+
stock_codes: list[str],
|
|
96
|
+
date: str = "latest",
|
|
97
|
+
) -> pd.DataFrame:
|
|
98
|
+
"""获取申万2021版行业成分股列表.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
stock_codes: 申万2021版行业代码列表.
|
|
102
|
+
date: 信息日期 (YYYY-MM-DD) 或 ``"latest"``, 默认 ``"latest"``.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
DataFrame containing sw_2021 industry constituents.
|
|
106
|
+
|
|
107
|
+
Example:
|
|
108
|
+
获取申万2021版行业成分股列表::
|
|
109
|
+
|
|
110
|
+
from lixinger import get_industry_sw_2021_constituents
|
|
111
|
+
|
|
112
|
+
df = await get_industry_sw_2021_constituents(
|
|
113
|
+
stock_codes=["490000"],
|
|
114
|
+
date="latest",
|
|
115
|
+
)
|
|
116
|
+
print(df)
|
|
117
|
+
|
|
118
|
+
"""
|
|
119
|
+
return await _api_instance.get_constituents(
|
|
120
|
+
stock_codes=stock_codes,
|
|
121
|
+
date=date,
|
|
122
|
+
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Industry fundamental data APIs.
|
|
2
|
+
|
|
3
|
+
This module provides access to industry fundamental (valuation) APIs by
|
|
4
|
+
industry classification system:
|
|
5
|
+
|
|
6
|
+
- sw_2021: 申万2021版行业 (Shenwan 2021)
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from lixinger.api.cn.industry.fundamental.sw_2021 import (
|
|
10
|
+
IndustrySw2021FundamentalAPI,
|
|
11
|
+
get_industry_sw_2021_fundamental,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
# API Classes
|
|
16
|
+
"IndustrySw2021FundamentalAPI",
|
|
17
|
+
# Functional APIs
|
|
18
|
+
"get_industry_sw_2021_fundamental",
|
|
19
|
+
]
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"""Industry (申万2021版) fundamental data APIs."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import pandas as pd
|
|
6
|
+
|
|
7
|
+
from lixinger.api.base import BaseAPI
|
|
8
|
+
from lixinger.models.cn.industry.fundamental.sw_2021 import IndustrySw2021Fundamental
|
|
9
|
+
from lixinger.utils.api import api
|
|
10
|
+
from lixinger.utils.dataframe import get_response_df
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class IndustrySw2021FundamentalAPI(BaseAPI):
|
|
14
|
+
"""申万2021版行业基本面数据 API."""
|
|
15
|
+
|
|
16
|
+
async def get_fundamental( # noqa: PLR0913
|
|
17
|
+
self,
|
|
18
|
+
stock_codes: list[str],
|
|
19
|
+
metrics: list[str],
|
|
20
|
+
date: str | None = None,
|
|
21
|
+
start_date: str | None = None,
|
|
22
|
+
end_date: str | None = None,
|
|
23
|
+
limit: int | None = None,
|
|
24
|
+
) -> pd.DataFrame:
|
|
25
|
+
"""获取申万2021版行业基本面估值数据.
|
|
26
|
+
|
|
27
|
+
获取申万2021版行业的基本面估值数据及相关统计数据. 可按行业代码、日期或
|
|
28
|
+
时间范围进行筛选, 由用户指定需要的指标返回对应的日数据. 指标包括
|
|
29
|
+
PE-TTM、PB、PS-TTM、股息率、市值、A股市值、流通市值、自由流通市值,
|
|
30
|
+
以及 PE-TTM、PB、PS-TTM、股息率的在不同时间周期(1年/3年/5年/10年/20年/
|
|
31
|
+
上市以来) 下的统计数据(分位点、20%分位点对应值、50%分位点对应值、
|
|
32
|
+
80%分位点对应值、最大值、最小值、平均值). 当用户需要比较不同申万2021版
|
|
33
|
+
行业的估值高低、查看历史估值分位或做行业估值择时分析时, 调用此接口.
|
|
34
|
+
|
|
35
|
+
API Endpoint: /cn/industry/fundamental/sw_2021
|
|
36
|
+
API Method: POST
|
|
37
|
+
API Doc: https://www.lixinger.com/open/api/doc?api-key=cn/industry/fundamental/sw_2021
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
stock_codes: 申万2021版行业代码列表, 长度 >=1 且 <=100. 需要注意的是,
|
|
41
|
+
当传入 start_date 时只能传入一个行业代码.
|
|
42
|
+
metrics: 指标数组, 例如 ``["mc", "pe_ttm.ew", "pe_ttm.y10.ew.cvpos"]``.
|
|
43
|
+
共有三种形式的指标格式:
|
|
44
|
+
|
|
45
|
+
- ``[metricsName].[granularity].[metricsType].[statisticsDataType]``:
|
|
46
|
+
支持指标有 pe_ttm, pb, ps_ttm, dyr (股息率)
|
|
47
|
+
- ``[metricsName].[metricsType]``: 支持指标有
|
|
48
|
+
dyr (股息率), pe_ttm, pb, ps_ttm
|
|
49
|
+
- ``[metricsName]``: 被剩余的指标支持, 如 mc (市值),
|
|
50
|
+
tv (成交量), ta (成交金额) 等
|
|
51
|
+
date: 指定日期 (YYYY-MM-DD, 北京时间), 与 start_date 二选一.
|
|
52
|
+
start_date: 信息起始时间 (YYYY-MM-DD, 北京时间), 与 date 二选一.
|
|
53
|
+
开始和结束的时间间隔不超过10年.
|
|
54
|
+
end_date: 信息结束时间 (YYYY-MM-DD, 北京时间), 默认值是上周一.
|
|
55
|
+
需要与 start_date 一起使用.
|
|
56
|
+
limit: 返回最近数据的数量, 仅在请求数据为 date range 的情况下生效.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
DataFrame containing sw_2021 industry fundamental data with columns:
|
|
60
|
+
|
|
61
|
+
- date: 数据时间
|
|
62
|
+
- stock_code: 行业代码
|
|
63
|
+
- 请求的指标列 (例如 ``pe_ttm.mcw``, ``pe_ttm.y10.mcw.cvpos``, ``mc``)
|
|
64
|
+
|
|
65
|
+
Example:
|
|
66
|
+
通过日期获取申万2021版行业基本面数据::
|
|
67
|
+
|
|
68
|
+
from lixinger import AsyncLixingerClient
|
|
69
|
+
|
|
70
|
+
async with AsyncLixingerClient() as client:
|
|
71
|
+
df = await client.cn_industry.fundamental.sw_2021.get_fundamental(
|
|
72
|
+
stock_codes=["490000"],
|
|
73
|
+
metrics=["pe_ttm.y10.mcw.cvpos", "pe_ttm.mcw", "mc"],
|
|
74
|
+
date="2026-06-02",
|
|
75
|
+
)
|
|
76
|
+
print(df)
|
|
77
|
+
|
|
78
|
+
通过时间范围获取申万2021版行业基本面数据::
|
|
79
|
+
|
|
80
|
+
async with AsyncLixingerClient() as client:
|
|
81
|
+
df = await client.cn_industry.fundamental.sw_2021.get_fundamental(
|
|
82
|
+
stock_codes=["490000"],
|
|
83
|
+
metrics=["pe_ttm.y10.mcw.cvpos", "pe_ttm.mcw", "mc"],
|
|
84
|
+
start_date="2025-06-13",
|
|
85
|
+
end_date="2026-06-13",
|
|
86
|
+
)
|
|
87
|
+
print(df)
|
|
88
|
+
|
|
89
|
+
"""
|
|
90
|
+
payload: dict[str, Any] = {
|
|
91
|
+
"stockCodes": stock_codes,
|
|
92
|
+
"metricsList": metrics,
|
|
93
|
+
}
|
|
94
|
+
if date is not None:
|
|
95
|
+
payload["date"] = date
|
|
96
|
+
if start_date is not None:
|
|
97
|
+
payload["startDate"] = start_date
|
|
98
|
+
if end_date is not None:
|
|
99
|
+
payload["endDate"] = end_date
|
|
100
|
+
if limit is not None:
|
|
101
|
+
payload["limit"] = limit
|
|
102
|
+
|
|
103
|
+
data = await self._request("POST", "/cn/industry/fundamental/sw_2021", json=payload)
|
|
104
|
+
return get_response_df(data, IndustrySw2021Fundamental)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# Functional API instance
|
|
108
|
+
_api_instance = IndustrySw2021FundamentalAPI()
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@api
|
|
112
|
+
async def get_industry_sw_2021_fundamental( # noqa: PLR0913
|
|
113
|
+
stock_codes: list[str],
|
|
114
|
+
metrics: list[str],
|
|
115
|
+
date: str | None = None,
|
|
116
|
+
start_date: str | None = None,
|
|
117
|
+
end_date: str | None = None,
|
|
118
|
+
limit: int | None = None,
|
|
119
|
+
) -> pd.DataFrame:
|
|
120
|
+
"""获取申万2021版行业基本面估值数据.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
stock_codes: 申万2021版行业代码列表.
|
|
124
|
+
metrics: 指标数组.
|
|
125
|
+
date: 指定日期 (YYYY-MM-DD), 与 start_date 二选一.
|
|
126
|
+
start_date: 信息起始时间 (YYYY-MM-DD), 与 date 二选一.
|
|
127
|
+
end_date: 信息结束时间 (YYYY-MM-DD).
|
|
128
|
+
limit: 返回最近数据的数量, 仅在 date range 请求下生效.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
DataFrame containing sw_2021 industry fundamental data.
|
|
132
|
+
|
|
133
|
+
Example:
|
|
134
|
+
通过日期获取申万2021版行业基本面数据::
|
|
135
|
+
|
|
136
|
+
from lixinger import get_industry_sw_2021_fundamental
|
|
137
|
+
|
|
138
|
+
df = await get_industry_sw_2021_fundamental(
|
|
139
|
+
stock_codes=["490000"],
|
|
140
|
+
metrics=["pe_ttm.y10.mcw.cvpos", "pe_ttm.mcw", "mc"],
|
|
141
|
+
date="2026-06-02",
|
|
142
|
+
)
|
|
143
|
+
print(df)
|
|
144
|
+
|
|
145
|
+
"""
|
|
146
|
+
return await _api_instance.get_fundamental(
|
|
147
|
+
stock_codes=stock_codes,
|
|
148
|
+
metrics=metrics,
|
|
149
|
+
date=date,
|
|
150
|
+
start_date=start_date,
|
|
151
|
+
end_date=end_date,
|
|
152
|
+
limit=limit,
|
|
153
|
+
)
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""行业基础信息 APIs."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import pandas as pd
|
|
6
|
+
|
|
7
|
+
from lixinger.api.base import BaseAPI
|
|
8
|
+
from lixinger.models.cn.industry.industry import Industry
|
|
9
|
+
from lixinger.utils.api import api
|
|
10
|
+
from lixinger.utils.dataframe import get_response_df
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class IndustryAPI(BaseAPI):
|
|
14
|
+
"""行业基础信息 API.
|
|
15
|
+
|
|
16
|
+
对应 API 端点 ``POST /cn/industry``, 用于获取大陆行业分类的基础信息.
|
|
17
|
+
支持申万 (sw)、申万2021版 (sw_2021)、国证 (cni) 三大分类体系, 并可按
|
|
18
|
+
一/二/三级行业级别筛选.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
async def get_industry(
|
|
22
|
+
self,
|
|
23
|
+
source: str,
|
|
24
|
+
stock_codes: list[str] | None = None,
|
|
25
|
+
level: str | None = None,
|
|
26
|
+
) -> pd.DataFrame:
|
|
27
|
+
"""获取行业基础信息.
|
|
28
|
+
|
|
29
|
+
获取大陆行业分类的基础信息, 支持申万 (sw)、申万2021版 (sw_2021)、
|
|
30
|
+
国证 (cni) 三大分类体系. 可按一/二/三级行业级别筛选, 返回行业代码、
|
|
31
|
+
名称、行业分类等级 (一级/二级/三级)、编制来源、货币单位、发布时间和
|
|
32
|
+
财务报表类型等属性. 当用户需要了解某行业分类的基本情况、获取行业代码
|
|
33
|
+
或确认行业归属体系时, 调用此接口.
|
|
34
|
+
|
|
35
|
+
API Endpoint: /cn/industry
|
|
36
|
+
API Method: POST
|
|
37
|
+
API Doc: https://www.lixinger.com/open/api/doc?api-key=cn/industry
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
source: 行业来源, 必填. 支持:
|
|
41
|
+
|
|
42
|
+
- ``"sw"``: 申万
|
|
43
|
+
- ``"sw_2021"``: 申万2021版
|
|
44
|
+
- ``"cni"``: 国证
|
|
45
|
+
stock_codes: 行业代码列表, 长度 >=1 且 <=100, 例如 ``["490000"]``.
|
|
46
|
+
不传则按 source (及 level) 返回全部行业信息.
|
|
47
|
+
level: 行业分类级别筛选, 可选. 支持:
|
|
48
|
+
|
|
49
|
+
- ``"one"``: 一级
|
|
50
|
+
- ``"two"``: 二级
|
|
51
|
+
- ``"three"``: 三级
|
|
52
|
+
|
|
53
|
+
不传则返回全部级别的行业信息.
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
DataFrame containing industry information with columns:
|
|
57
|
+
|
|
58
|
+
- stock_code: 行业代码
|
|
59
|
+
- name: 行业名称
|
|
60
|
+
- source: 行业来源 (cni/sw/sw_2021)
|
|
61
|
+
- level: 行业分类等级 (one/two/three)
|
|
62
|
+
- area_code: 地区代码
|
|
63
|
+
- market: 市场
|
|
64
|
+
- fs_table_type: 财务报表类型 (non_financial/bank/security/
|
|
65
|
+
insurance/reit/other_financial/hybrid)
|
|
66
|
+
- currency: 货币单位
|
|
67
|
+
- launch_date: 发布时间
|
|
68
|
+
|
|
69
|
+
Example:
|
|
70
|
+
获取行业基础信息::
|
|
71
|
+
|
|
72
|
+
from lixinger import AsyncLixingerClient
|
|
73
|
+
|
|
74
|
+
async with AsyncLixingerClient() as client:
|
|
75
|
+
# 获取指定行业信息
|
|
76
|
+
df = await client.cn_industry.industry.get_industry(
|
|
77
|
+
source="sw",
|
|
78
|
+
stock_codes=["490000"],
|
|
79
|
+
)
|
|
80
|
+
print(df)
|
|
81
|
+
|
|
82
|
+
# 获取申万一级行业全部信息
|
|
83
|
+
df = await client.cn_industry.industry.get_industry(
|
|
84
|
+
source="sw",
|
|
85
|
+
level="one",
|
|
86
|
+
)
|
|
87
|
+
print(df)
|
|
88
|
+
|
|
89
|
+
"""
|
|
90
|
+
payload: dict[str, Any] = {"source": source}
|
|
91
|
+
if stock_codes is not None:
|
|
92
|
+
payload["stockCodes"] = stock_codes
|
|
93
|
+
if level is not None:
|
|
94
|
+
payload["level"] = level
|
|
95
|
+
|
|
96
|
+
data = await self._request("POST", "/cn/industry", json=payload)
|
|
97
|
+
return get_response_df(data, Industry)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# Functional API instance
|
|
101
|
+
_api_instance = IndustryAPI()
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@api
|
|
105
|
+
async def get_industry(
|
|
106
|
+
source: str,
|
|
107
|
+
stock_codes: list[str] | None = None,
|
|
108
|
+
level: str | None = None,
|
|
109
|
+
) -> pd.DataFrame:
|
|
110
|
+
"""获取行业基础信息.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
source: 行业来源, 必填 (``"sw"`` / ``"sw_2021"`` / ``"cni"``).
|
|
114
|
+
stock_codes: 行业代码列表, 长度 >=1 且 <=100.
|
|
115
|
+
level: 行业分类级别 (``"one"`` / ``"two"`` / ``"three"``).
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
DataFrame containing industry information.
|
|
119
|
+
|
|
120
|
+
Example:
|
|
121
|
+
获取行业基础信息::
|
|
122
|
+
|
|
123
|
+
from lixinger import get_industry
|
|
124
|
+
|
|
125
|
+
# 获取指定行业信息
|
|
126
|
+
df = await get_industry(
|
|
127
|
+
source="sw",
|
|
128
|
+
stock_codes=["490000"],
|
|
129
|
+
)
|
|
130
|
+
print(df)
|
|
131
|
+
|
|
132
|
+
# 获取申万一级行业列表
|
|
133
|
+
df = await get_industry(source="sw", level="one")
|
|
134
|
+
print(df)
|
|
135
|
+
|
|
136
|
+
"""
|
|
137
|
+
return await _api_instance.get_industry(
|
|
138
|
+
source=source,
|
|
139
|
+
stock_codes=stock_codes,
|
|
140
|
+
level=level,
|
|
141
|
+
)
|
|
@@ -4,6 +4,7 @@ from typing import Any
|
|
|
4
4
|
|
|
5
5
|
import pandas as pd
|
|
6
6
|
|
|
7
|
+
from lixinger.api.cn.industry.constituents.sw_2021 import IndustrySw2021ConstituentsAPI
|
|
7
8
|
from lixinger.api.cn.industry.fs.sw_2021.bank import IndustrySw2021BankStatementAPI
|
|
8
9
|
from lixinger.api.cn.industry.fs.sw_2021.hybrid import IndustrySw2021HybridStatementAPI
|
|
9
10
|
from lixinger.api.cn.industry.fs.sw_2021.insurance import IndustrySw2021InsuranceStatementAPI
|
|
@@ -11,6 +12,8 @@ from lixinger.api.cn.industry.fs.sw_2021.non_financial import (
|
|
|
11
12
|
IndustrySw2021NonFinancialStatementAPI,
|
|
12
13
|
)
|
|
13
14
|
from lixinger.api.cn.industry.fs.sw_2021.security import IndustrySw2021SecurityStatementAPI
|
|
15
|
+
from lixinger.api.cn.industry.fundamental.sw_2021 import IndustrySw2021FundamentalAPI
|
|
16
|
+
from lixinger.api.cn.industry.industry import IndustryAPI
|
|
14
17
|
from lixinger.api.cn.industry.margin_trading.cni import IndustryCniMarginTradingAPI
|
|
15
18
|
from lixinger.api.cn.industry.margin_trading.sw import IndustrySwMarginTradingAPI
|
|
16
19
|
from lixinger.api.cn.industry.margin_trading.sw_2021 import (
|
|
@@ -106,12 +109,51 @@ class IndustryFSNamespace:
|
|
|
106
109
|
self.sw_2021 = sw_2021
|
|
107
110
|
|
|
108
111
|
|
|
112
|
+
class IndustryConstituentsNamespace:
|
|
113
|
+
"""Namespace for industry constituents APIs.
|
|
114
|
+
|
|
115
|
+
Groups all industry constituent APIs by industry classification system:
|
|
116
|
+
|
|
117
|
+
- sw_2021: 申万2021版行业成分股
|
|
118
|
+
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
def __init__(self, sw_2021: IndustrySw2021ConstituentsAPI) -> None:
|
|
122
|
+
"""Initialize the industry constituents namespace.
|
|
123
|
+
|
|
124
|
+
Args:
|
|
125
|
+
sw_2021: 申万2021版行业成分股 API
|
|
126
|
+
|
|
127
|
+
"""
|
|
128
|
+
self.sw_2021 = sw_2021
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class IndustryFundamentalNamespace:
|
|
132
|
+
"""Namespace for industry fundamental (valuation) APIs.
|
|
133
|
+
|
|
134
|
+
Groups all industry fundamental APIs by industry classification system:
|
|
135
|
+
|
|
136
|
+
- sw_2021: 申万2021版行业基本面数据
|
|
137
|
+
|
|
138
|
+
"""
|
|
139
|
+
|
|
140
|
+
def __init__(self, sw_2021: IndustrySw2021FundamentalAPI) -> None:
|
|
141
|
+
"""Initialize the industry fundamental namespace.
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
sw_2021: 申万2021版行业基本面数据 API
|
|
145
|
+
|
|
146
|
+
"""
|
|
147
|
+
self.sw_2021 = sw_2021
|
|
148
|
+
|
|
149
|
+
|
|
109
150
|
class IndustryNamespace:
|
|
110
151
|
"""Namespace for industry-related APIs.
|
|
111
152
|
|
|
112
153
|
This class groups all industry-related APIs under a single namespace.
|
|
113
154
|
Access APIs via their specific attributes:
|
|
114
155
|
|
|
156
|
+
- industry: 行业基础信息 API (get_industry)
|
|
115
157
|
- margin_trading: 行业融资融券 API 组
|
|
116
158
|
- margin_trading.sw: 申万行业
|
|
117
159
|
- margin_trading.sw_2021: 申万2021版行业
|
|
@@ -122,11 +164,16 @@ class IndustryNamespace:
|
|
|
122
164
|
- fs.sw_2021.insurance: 申万2021版保险类行业财报
|
|
123
165
|
- fs.sw_2021.non_financial: 申万2021版非金融类行业财报
|
|
124
166
|
- fs.sw_2021.security: 申万2021版证券类行业财报
|
|
167
|
+
- constituents: 行业成分股 API 组
|
|
168
|
+
- constituents.sw_2021: 申万2021版行业成分股
|
|
169
|
+
- fundamental: 行业基本面数据 API 组
|
|
170
|
+
- fundamental.sw_2021: 申万2021版行业基本面数据
|
|
125
171
|
|
|
126
172
|
"""
|
|
127
173
|
|
|
128
174
|
def __init__( # noqa: PLR0913
|
|
129
175
|
self,
|
|
176
|
+
industry: IndustryAPI,
|
|
130
177
|
margin_trading_sw: IndustrySwMarginTradingAPI,
|
|
131
178
|
margin_trading_sw_2021: IndustrySw2021MarginTradingAPI,
|
|
132
179
|
margin_trading_cni: IndustryCniMarginTradingAPI,
|
|
@@ -135,10 +182,13 @@ class IndustryNamespace:
|
|
|
135
182
|
fs_sw_2021_insurance: IndustrySw2021InsuranceStatementAPI,
|
|
136
183
|
fs_sw_2021_non_financial: IndustrySw2021NonFinancialStatementAPI,
|
|
137
184
|
fs_sw_2021_security: IndustrySw2021SecurityStatementAPI,
|
|
185
|
+
constituents_sw_2021: IndustrySw2021ConstituentsAPI,
|
|
186
|
+
fundamental_sw_2021: IndustrySw2021FundamentalAPI,
|
|
138
187
|
) -> None:
|
|
139
188
|
"""Initialize the industry namespace.
|
|
140
189
|
|
|
141
190
|
Args:
|
|
191
|
+
industry: 行业基础信息 API
|
|
142
192
|
margin_trading_sw: 申万行业融资融券 API
|
|
143
193
|
margin_trading_sw_2021: 申万2021版行业融资融券 API
|
|
144
194
|
margin_trading_cni: 国证行业融资融券 API
|
|
@@ -147,8 +197,11 @@ class IndustryNamespace:
|
|
|
147
197
|
fs_sw_2021_insurance: 申万2021版保险类行业财报 API
|
|
148
198
|
fs_sw_2021_non_financial: 申万2021版非金融类行业财报 API
|
|
149
199
|
fs_sw_2021_security: 申万2021版证券类行业财报 API
|
|
200
|
+
constituents_sw_2021: 申万2021版行业成分股 API
|
|
201
|
+
fundamental_sw_2021: 申万2021版行业基本面数据 API
|
|
150
202
|
|
|
151
203
|
"""
|
|
204
|
+
self.industry = industry
|
|
152
205
|
self.margin_trading = IndustryMarginTradingNamespace(
|
|
153
206
|
sw=margin_trading_sw,
|
|
154
207
|
sw_2021=margin_trading_sw_2021,
|
|
@@ -163,8 +216,18 @@ class IndustryNamespace:
|
|
|
163
216
|
security=fs_sw_2021_security,
|
|
164
217
|
),
|
|
165
218
|
)
|
|
219
|
+
self.constituents = IndustryConstituentsNamespace(
|
|
220
|
+
sw_2021=constituents_sw_2021,
|
|
221
|
+
)
|
|
222
|
+
self.fundamental = IndustryFundamentalNamespace(
|
|
223
|
+
sw_2021=fundamental_sw_2021,
|
|
224
|
+
)
|
|
166
225
|
|
|
167
226
|
# Convenience aliases for shorter access
|
|
227
|
+
async def get_industry(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
228
|
+
"""Alias for industry.get_industry."""
|
|
229
|
+
return await self.industry.get_industry(*args, **kwargs)
|
|
230
|
+
|
|
168
231
|
async def get_sw_margin_trading(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
169
232
|
"""Alias for margin_trading.sw.get_margin_trading."""
|
|
170
233
|
return await self.margin_trading.sw.get_margin_trading(*args, **kwargs)
|
|
@@ -196,3 +259,11 @@ class IndustryNamespace:
|
|
|
196
259
|
async def get_sw_2021_security_statements(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
197
260
|
"""Alias for fs.sw_2021.security.get_security_statements."""
|
|
198
261
|
return await self.fs.sw_2021.security.get_security_statements(*args, **kwargs)
|
|
262
|
+
|
|
263
|
+
async def get_sw_2021_constituents(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
264
|
+
"""Alias for constituents.sw_2021.get_constituents."""
|
|
265
|
+
return await self.constituents.sw_2021.get_constituents(*args, **kwargs)
|
|
266
|
+
|
|
267
|
+
async def get_sw_2021_fundamental(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
268
|
+
"""Alias for fundamental.sw_2021.get_fundamental."""
|
|
269
|
+
return await self.fundamental.sw_2021.get_fundamental(*args, **kwargs)
|
lixinger/client.py
CHANGED
|
@@ -45,8 +45,11 @@ from lixinger.api.cn.index import (
|
|
|
45
45
|
)
|
|
46
46
|
from lixinger.api.cn.index.namespace import IndexNamespace
|
|
47
47
|
from lixinger.api.cn.industry import (
|
|
48
|
+
IndustryAPI,
|
|
48
49
|
IndustryCniMarginTradingAPI,
|
|
49
50
|
IndustrySw2021BankStatementAPI,
|
|
51
|
+
IndustrySw2021ConstituentsAPI,
|
|
52
|
+
IndustrySw2021FundamentalAPI,
|
|
50
53
|
IndustrySw2021HybridStatementAPI,
|
|
51
54
|
IndustrySw2021InsuranceStatementAPI,
|
|
52
55
|
IndustrySw2021MarginTradingAPI,
|
|
@@ -243,6 +246,7 @@ class AsyncLixingerClient:
|
|
|
243
246
|
self.cn_index_fs_hybrid = cn_index_fs_hybrid
|
|
244
247
|
|
|
245
248
|
# Industry APIs
|
|
249
|
+
cn_industry = IndustryAPI(self._http_client, self.config, self._rate_limiter)
|
|
246
250
|
cn_industry_margin_trading_sw = IndustrySwMarginTradingAPI(self._http_client, self.config, self._rate_limiter)
|
|
247
251
|
cn_industry_margin_trading_sw_2021 = IndustrySw2021MarginTradingAPI(
|
|
248
252
|
self._http_client, self.config, self._rate_limiter
|
|
@@ -261,9 +265,16 @@ class AsyncLixingerClient:
|
|
|
261
265
|
cn_industry_fs_sw_2021_security = IndustrySw2021SecurityStatementAPI(
|
|
262
266
|
self._http_client, self.config, self._rate_limiter
|
|
263
267
|
)
|
|
268
|
+
cn_industry_constituents_sw_2021 = IndustrySw2021ConstituentsAPI(
|
|
269
|
+
self._http_client, self.config, self._rate_limiter
|
|
270
|
+
)
|
|
271
|
+
cn_industry_fundamental_sw_2021 = IndustrySw2021FundamentalAPI(
|
|
272
|
+
self._http_client, self.config, self._rate_limiter
|
|
273
|
+
)
|
|
264
274
|
|
|
265
275
|
# Industry namespace (groups all industry APIs)
|
|
266
276
|
self.cn_industry = IndustryNamespace(
|
|
277
|
+
industry=cn_industry,
|
|
267
278
|
margin_trading_sw=cn_industry_margin_trading_sw,
|
|
268
279
|
margin_trading_sw_2021=cn_industry_margin_trading_sw_2021,
|
|
269
280
|
margin_trading_cni=cn_industry_margin_trading_cni,
|
|
@@ -272,9 +283,12 @@ class AsyncLixingerClient:
|
|
|
272
283
|
fs_sw_2021_insurance=cn_industry_fs_sw_2021_insurance,
|
|
273
284
|
fs_sw_2021_non_financial=cn_industry_fs_sw_2021_non_financial,
|
|
274
285
|
fs_sw_2021_security=cn_industry_fs_sw_2021_security,
|
|
286
|
+
constituents_sw_2021=cn_industry_constituents_sw_2021,
|
|
287
|
+
fundamental_sw_2021=cn_industry_fundamental_sw_2021,
|
|
275
288
|
)
|
|
276
289
|
|
|
277
290
|
# Legacy flat access for industry APIs (deprecated, for backward compatibility)
|
|
291
|
+
self.cn_industry_info = cn_industry
|
|
278
292
|
self.cn_industry_margin_trading_sw = cn_industry_margin_trading_sw
|
|
279
293
|
self.cn_industry_margin_trading_sw_2021 = cn_industry_margin_trading_sw_2021
|
|
280
294
|
self.cn_industry_margin_trading_cni = cn_industry_margin_trading_cni
|
|
@@ -283,6 +297,8 @@ class AsyncLixingerClient:
|
|
|
283
297
|
self.cn_industry_fs_sw_2021_insurance = cn_industry_fs_sw_2021_insurance
|
|
284
298
|
self.cn_industry_fs_sw_2021_non_financial = cn_industry_fs_sw_2021_non_financial
|
|
285
299
|
self.cn_industry_fs_sw_2021_security = cn_industry_fs_sw_2021_security
|
|
300
|
+
self.cn_industry_constituents_sw_2021 = cn_industry_constituents_sw_2021
|
|
301
|
+
self.cn_industry_fundamental_sw_2021 = cn_industry_fundamental_sw_2021
|
|
286
302
|
|
|
287
303
|
# Macro APIs
|
|
288
304
|
macro_national_debt = NationalDebtAPI(self._http_client, self.config, self._rate_limiter)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Industry-related models."""
|
|
2
2
|
|
|
3
|
+
from lixinger.models.cn.industry.constituents import IndustrySw2021Constituent
|
|
3
4
|
from lixinger.models.cn.industry.fs import (
|
|
4
5
|
IndustrySw2021BankStatementSchema,
|
|
5
6
|
IndustrySw2021HybridStatementSchema,
|
|
@@ -7,6 +8,8 @@ from lixinger.models.cn.industry.fs import (
|
|
|
7
8
|
IndustrySw2021NonFinancialStatementSchema,
|
|
8
9
|
IndustrySw2021SecurityStatementSchema,
|
|
9
10
|
)
|
|
11
|
+
from lixinger.models.cn.industry.fundamental import IndustrySw2021Fundamental
|
|
12
|
+
from lixinger.models.cn.industry.industry import Industry
|
|
10
13
|
from lixinger.models.cn.industry.margin_trading import (
|
|
11
14
|
IndustryCniMarginTrading,
|
|
12
15
|
IndustrySw2021MarginTrading,
|
|
@@ -14,8 +17,11 @@ from lixinger.models.cn.industry.margin_trading import (
|
|
|
14
17
|
)
|
|
15
18
|
|
|
16
19
|
__all__ = [
|
|
20
|
+
"Industry",
|
|
17
21
|
"IndustryCniMarginTrading",
|
|
18
22
|
"IndustrySw2021BankStatementSchema",
|
|
23
|
+
"IndustrySw2021Constituent",
|
|
24
|
+
"IndustrySw2021Fundamental",
|
|
19
25
|
"IndustrySw2021HybridStatementSchema",
|
|
20
26
|
"IndustrySw2021InsuranceStatementSchema",
|
|
21
27
|
"IndustrySw2021MarginTrading",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Industry constituents models.
|
|
2
|
+
|
|
3
|
+
This module provides Pandera schemas for industry constituent stocks
|
|
4
|
+
organized by industry classification system:
|
|
5
|
+
|
|
6
|
+
- sw_2021: 申万2021版行业成分股
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from lixinger.models.cn.industry.constituents.sw_2021 import IndustrySw2021Constituent
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"IndustrySw2021Constituent",
|
|
13
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Industry (申万2021版) constituents model."""
|
|
2
|
+
|
|
3
|
+
import pandera.pandas as pa
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class IndustrySw2021Constituent(pa.DataFrameModel):
|
|
7
|
+
"""申万2021版行业成分股模型.
|
|
8
|
+
|
|
9
|
+
表示单个申万2021版行业下的一只成分股, 包含所属行业代码、股票代码、
|
|
10
|
+
地区、市场以及股票名称(中文/英文) 信息.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
class Config:
|
|
14
|
+
"""Pandera configuration."""
|
|
15
|
+
|
|
16
|
+
coerce = True
|
|
17
|
+
strict = False
|
|
18
|
+
|
|
19
|
+
industry_stock_code: pa.typing.Series[str]
|
|
20
|
+
stock_code: pa.typing.Series[str]
|
|
21
|
+
area_code: pa.typing.Series[str]
|
|
22
|
+
market: pa.typing.Series[str]
|
|
23
|
+
stock_name_cn: pa.typing.Series[str] | None = pa.Field(nullable=True)
|
|
24
|
+
stock_name_en: pa.typing.Series[str] | None = pa.Field(nullable=True)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Industry fundamental data models.
|
|
2
|
+
|
|
3
|
+
This module provides Pandera schemas for industry fundamental (valuation)
|
|
4
|
+
data organized by industry classification system:
|
|
5
|
+
|
|
6
|
+
- sw_2021: 申万2021版行业基本面数据
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from lixinger.models.cn.industry.fundamental.sw_2021 import IndustrySw2021Fundamental
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"IndustrySw2021Fundamental",
|
|
13
|
+
]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Industry (申万2021版) fundamental data model."""
|
|
2
|
+
|
|
3
|
+
import pandera.pandas as pa
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class IndustrySw2021Fundamental(pa.DataFrameModel):
|
|
7
|
+
"""申万2021版行业基本面数据模型.
|
|
8
|
+
|
|
9
|
+
每一行代表某一行业(stockCode)在指定日期(date) 的基本面指标.
|
|
10
|
+
指标列由请求参数 ``metricsList`` 动态生成(例如
|
|
11
|
+
``pe_ttm.mcw``, ``pe_ttm.y10.mcw.cvpos``, ``mc`` 等), 因此本 Schema
|
|
12
|
+
仅约束通用字段 ``date`` 与 ``stock_code``, 允许 DataFrame 包含额外
|
|
13
|
+
的指标列.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
class Config:
|
|
17
|
+
"""Pandera configuration."""
|
|
18
|
+
|
|
19
|
+
coerce = True
|
|
20
|
+
strict = False # Allow extra metrics columns
|
|
21
|
+
|
|
22
|
+
date: pa.typing.Series[pa.typing.DateTime]
|
|
23
|
+
stock_code: pa.typing.Series[str]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Industry information model."""
|
|
2
|
+
|
|
3
|
+
import pandera.pandas as pa
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Industry(pa.DataFrameModel):
|
|
7
|
+
"""行业基础信息 model.
|
|
8
|
+
|
|
9
|
+
对应 API: ``POST /cn/industry``. 覆盖申万 (sw)、申万2021版 (sw_2021) 及
|
|
10
|
+
国证 (cni) 三大行业分类体系的基础字段.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
class Config:
|
|
14
|
+
"""Pandera configuration."""
|
|
15
|
+
|
|
16
|
+
coerce = True
|
|
17
|
+
|
|
18
|
+
stock_code: pa.typing.Series[str]
|
|
19
|
+
name: pa.typing.Series[str]
|
|
20
|
+
source: pa.typing.Series[str]
|
|
21
|
+
level: pa.typing.Series[str] | None = pa.Field(nullable=True)
|
|
22
|
+
area_code: pa.typing.Series[str] | None = pa.Field(nullable=True)
|
|
23
|
+
market: pa.typing.Series[str] | None = pa.Field(nullable=True)
|
|
24
|
+
fs_table_type: pa.typing.Series[str] | None = pa.Field(nullable=True)
|
|
25
|
+
currency: pa.typing.Series[str] | None = pa.Field(nullable=True)
|
|
26
|
+
launch_date: pa.typing.Series[pa.typing.DateTime] | None = pa.Field(nullable=True)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
lixinger/__init__.py,sha256=
|
|
2
|
-
lixinger/client.py,sha256=
|
|
1
|
+
lixinger/__init__.py,sha256=jTZQGSqxFYDLCtTcVuKzRzR0LAPaJEByZBeOSHUnMJI,4120
|
|
2
|
+
lixinger/client.py,sha256=xLAp_sxUGrN95mYCjL_DlloGuHYoYWF-kiXhoZ6cm0I,17942
|
|
3
3
|
lixinger/config.py,sha256=JPz8EOrf1kP4Do-Z5-MsnOM0pMrNE1ZsP-Qoarh9y4c,2008
|
|
4
4
|
lixinger/exceptions.py,sha256=Gkv1z-LC09paYGVs430-gDgDs43dLyRHbglB3Frehd4,1069
|
|
5
5
|
lixinger/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -50,8 +50,11 @@ lixinger/api/cn/index/fs/bank.py,sha256=zjDB_d06E_gxAvVNyk9Byoa5ShlevNoc75z5gVBH
|
|
|
50
50
|
lixinger/api/cn/index/fs/hybrid.py,sha256=qs25ZXdCBiIRQ3mm2yyXQngSGtLIs1W93nvRxQDubIE,4429
|
|
51
51
|
lixinger/api/cn/index/fs/non_financial.py,sha256=XlP9Jl5bHUto6mybj4WGCb11LjYINzwYhJaG_WEHYww,4599
|
|
52
52
|
lixinger/api/cn/index/fs/security.py,sha256=l1Raf8GuYpthRDgNSMnVjDn9AcKLG5qP-wVKMd4GKQw,4458
|
|
53
|
-
lixinger/api/cn/industry/__init__.py,sha256=
|
|
54
|
-
lixinger/api/cn/industry/
|
|
53
|
+
lixinger/api/cn/industry/__init__.py,sha256=vhGauAdvOgEtaMT5Bo4X89_gv9elHZx4L975Zc4YarY,2023
|
|
54
|
+
lixinger/api/cn/industry/industry.py,sha256=IAFujGdk5jrDLOQeXm0qWvSwLaEW9bSCXz9ggaJF254,4585
|
|
55
|
+
lixinger/api/cn/industry/namespace.py,sha256=nPByaXnErP5MJ5o34p-yjOHNKhyGCcjAnj_1QvStezA,10559
|
|
56
|
+
lixinger/api/cn/industry/constituents/__init__.py,sha256=dwY1PVWeeoBADnooml_K24EPMTEc0hHoD6FrMeTlRIg,445
|
|
57
|
+
lixinger/api/cn/industry/constituents/sw_2021.py,sha256=nrjDQYy7Jpt7Vl1mNvYDaaqBL-k22zkm-M5JFDylKtA,4459
|
|
55
58
|
lixinger/api/cn/industry/fs/__init__.py,sha256=6incmfX-jJGo5AJ7yhD_5G3wSYUbZTpIKA-Oy-276FM,1173
|
|
56
59
|
lixinger/api/cn/industry/fs/sw_2021/__init__.py,sha256=PgVEwKY7MFznIGP-DYOLOlT8_heZAlutha_mOjH8D7I,1635
|
|
57
60
|
lixinger/api/cn/industry/fs/sw_2021/bank.py,sha256=NhcrDaa_DhArBmg0QYVEIfKIMX4dtq6gL_d7UD1Cjkw,4812
|
|
@@ -59,6 +62,8 @@ lixinger/api/cn/industry/fs/sw_2021/hybrid.py,sha256=mUZyBmeDEUZ7F5p3RB1BHcDe8I3
|
|
|
59
62
|
lixinger/api/cn/industry/fs/sw_2021/insurance.py,sha256=WVMt0Rn3qjXvHYqQPQjEiLkDBW7ZqxsvkeaH2W1vGPk,4960
|
|
60
63
|
lixinger/api/cn/industry/fs/sw_2021/non_financial.py,sha256=lOgcL21hgubNoo2ZEkt9tkXW1GaKRGdDJLsKMXtDyjk,4947
|
|
61
64
|
lixinger/api/cn/industry/fs/sw_2021/security.py,sha256=z2hDfXTELXVJAQMJ-Q7Vvjo9-nE9ZMbCWIfAx0jUx3A,4957
|
|
65
|
+
lixinger/api/cn/industry/fundamental/__init__.py,sha256=giibNA8ANlteap-GNGsSUn7BQDmOTnZvjdFV9bUw3jg,456
|
|
66
|
+
lixinger/api/cn/industry/fundamental/sw_2021.py,sha256=AT10HDnrYgoo4zxt-ypTuaUNJRP7HSxcsqIcZl7jdNU,6183
|
|
62
67
|
lixinger/api/cn/industry/margin_trading/__init__.py,sha256=4JZDCF6v2TPg9uyBLKXAfHKVrDGpshjQkoJejdKwCC4,944
|
|
63
68
|
lixinger/api/cn/industry/margin_trading/cni.py,sha256=7IqidE2N2_INiVybeiTt5qFRUY4PJsY6nUPEGtdWJlM,4600
|
|
64
69
|
lixinger/api/cn/industry/margin_trading/sw.py,sha256=hjC5Uf7XXSwiiqoloIWFx5nDzbxd_D5bB1QPQCEjUjg,4591
|
|
@@ -112,7 +117,10 @@ lixinger/models/cn/index/fs/bank.py,sha256=DA_sRFSsK5IE0JQtp3pHdvPJQxbipHsSyKahc
|
|
|
112
117
|
lixinger/models/cn/index/fs/hybrid.py,sha256=AlCoEfkkPdWGxE_K71rBKgwWpR4iWTaMJ8bc56YxYrk,565
|
|
113
118
|
lixinger/models/cn/index/fs/non_financial.py,sha256=UpWXDDMiOdJN6WNc5R-PsHy9l9Th3xsKnOjUbID4Gug,585
|
|
114
119
|
lixinger/models/cn/index/fs/security.py,sha256=VTYDvTQ5CKhqZsXeEyWqFNvugZ4UA3CLW0DkYTrOHtc,571
|
|
115
|
-
lixinger/models/cn/industry/__init__.py,sha256=
|
|
120
|
+
lixinger/models/cn/industry/__init__.py,sha256=fhYPO0FXOXkiSuxDZDmS393Ac6SsMlW6t_-GNheqclE,1078
|
|
121
|
+
lixinger/models/cn/industry/industry.py,sha256=NEaomVtgvR_emdY6Mzl5rNQPuHCIRQiFsEW91ekYZVE,904
|
|
122
|
+
lixinger/models/cn/industry/constituents/__init__.py,sha256=MLR6DlZL50kBczGEMwcU8phbksWUa3uk4PgFKcg3wQs,329
|
|
123
|
+
lixinger/models/cn/industry/constituents/sw_2021.py,sha256=SHFcGGjMRmvr6QwLDrzcIVwoZQUXZoYCjtcdVjs-ya0,755
|
|
116
124
|
lixinger/models/cn/industry/fs/__init__.py,sha256=JRgbHzfMKocZmUyOmK0rxtP-6fVCcB6MrxkcNzKrDls,552
|
|
117
125
|
lixinger/models/cn/industry/fs/sw_2021/__init__.py,sha256=TgGBHhteRuLcXd_uESeSocTlcbU65s_Bw-vWFohyGSs,780
|
|
118
126
|
lixinger/models/cn/industry/fs/sw_2021/bank.py,sha256=WvcyzTYcihtxhV9tIW2OPMtoqxRycf0vHWGKboGyEYw,610
|
|
@@ -120,6 +128,8 @@ lixinger/models/cn/industry/fs/sw_2021/hybrid.py,sha256=Su7kc7rgXjeoKwfhv6jhDH1_
|
|
|
120
128
|
lixinger/models/cn/industry/fs/sw_2021/insurance.py,sha256=ixd-x7ZcewSef_HngePEVL5vc2pU_Xx7NCGrIS-3lRw,615
|
|
121
129
|
lixinger/models/cn/industry/fs/sw_2021/non_financial.py,sha256=sZPTiMjbrOZhayDAbzTLi_A8x_dIlg4VXqr5XEvAXNc,624
|
|
122
130
|
lixinger/models/cn/industry/fs/sw_2021/security.py,sha256=VjZXFgy4OE0agEyiGXEQkkoUpzTPZZ6zoSAihjW4xT0,614
|
|
131
|
+
lixinger/models/cn/industry/fundamental/__init__.py,sha256=FUu-Sm5PZQbNnVHAaHI0Ud15I2l1zTFy52NXF16boMo,348
|
|
132
|
+
lixinger/models/cn/industry/fundamental/sw_2021.py,sha256=VojcgeJrvpI9xRYITJOKeUExAjVzkWzuAFjawk6VFQY,743
|
|
123
133
|
lixinger/models/cn/industry/margin_trading/__init__.py,sha256=JHzyvqzawYkgHa3HPNcY1B58PN2SZe-ZXhThHXlmSJ8,432
|
|
124
134
|
lixinger/models/cn/industry/margin_trading/cni.py,sha256=D8O-SXFR1_6lboRzMMNxaLA3KnSlHHeS1N5kjUIUPrs,1375
|
|
125
135
|
lixinger/models/cn/industry/margin_trading/sw.py,sha256=GyBhpZxSm1aoQHdzJvjb5INp_lrTFh4Alp2WaDyPhVM,1374
|
|
@@ -135,7 +145,7 @@ lixinger/utils/dataframe.py,sha256=tYBrNdmJ4poyuwD-9XgzHt3A_A8bBo0cdHiu8Yy9e9A,2
|
|
|
135
145
|
lixinger/utils/dict.py,sha256=yvbUtv8QpRmy0d_o_7gCuEwwiEfBji5_xB490ANxilw,589
|
|
136
146
|
lixinger/utils/rate_limiter.py,sha256=ZHlRTTL60L62uRA_f--LD26qkAfk-pHBllRqPapAXQM,1141
|
|
137
147
|
lixinger/utils/retry.py,sha256=C9QBcrpD7WYAuT8R4SJfWNUZFj1mZsv-qyTRIFQDmwc,2862
|
|
138
|
-
lixinger_python-0.3.
|
|
139
|
-
lixinger_python-0.3.
|
|
140
|
-
lixinger_python-0.3.
|
|
141
|
-
lixinger_python-0.3.
|
|
148
|
+
lixinger_python-0.3.17.dist-info/METADATA,sha256=vxF7oYJu2LkrWzWG56bAKakkdGxRfa0186h8IKWTGAk,9207
|
|
149
|
+
lixinger_python-0.3.17.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
150
|
+
lixinger_python-0.3.17.dist-info/licenses/LICENSE,sha256=5oOwRq1lHSOScbNGCHr2feuNnhNYdGcArj6fSUfsC5U,1064
|
|
151
|
+
lixinger_python-0.3.17.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|