lixinger-python 0.3.16__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 CHANGED
@@ -43,6 +43,7 @@ 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,
48
49
  get_industry_sw_2021_constituents,
@@ -113,6 +114,8 @@ __all__ = [
113
114
  "get_index_bank_statements",
114
115
  "get_index_security_statements",
115
116
  "get_index_hybrid_statements",
117
+ # Industry base info
118
+ "get_industry",
116
119
  # Industry margin trading
117
120
  "get_industry_sw_margin_trading",
118
121
  "get_industry_sw_2021_margin_trading",
@@ -20,6 +20,7 @@ from lixinger.api.cn.industry.fundamental import (
20
20
  IndustrySw2021FundamentalAPI,
21
21
  get_industry_sw_2021_fundamental,
22
22
  )
23
+ from lixinger.api.cn.industry.industry import IndustryAPI, get_industry
23
24
  from lixinger.api.cn.industry.margin_trading import (
24
25
  IndustryCniMarginTradingAPI,
25
26
  IndustrySw2021MarginTradingAPI,
@@ -31,6 +32,7 @@ from lixinger.api.cn.industry.margin_trading import (
31
32
 
32
33
  __all__ = [
33
34
  # API Classes
35
+ "IndustryAPI",
34
36
  "IndustryCniMarginTradingAPI",
35
37
  "IndustrySw2021BankStatementAPI",
36
38
  "IndustrySw2021ConstituentsAPI",
@@ -42,6 +44,7 @@ __all__ = [
42
44
  "IndustrySw2021SecurityStatementAPI",
43
45
  "IndustrySwMarginTradingAPI",
44
46
  # Functional APIs
47
+ "get_industry",
45
48
  "get_industry_cni_margin_trading",
46
49
  "get_industry_sw_2021_bank_statements",
47
50
  "get_industry_sw_2021_constituents",
@@ -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
+ )
@@ -13,6 +13,7 @@ from lixinger.api.cn.industry.fs.sw_2021.non_financial import (
13
13
  )
14
14
  from lixinger.api.cn.industry.fs.sw_2021.security import IndustrySw2021SecurityStatementAPI
15
15
  from lixinger.api.cn.industry.fundamental.sw_2021 import IndustrySw2021FundamentalAPI
16
+ from lixinger.api.cn.industry.industry import IndustryAPI
16
17
  from lixinger.api.cn.industry.margin_trading.cni import IndustryCniMarginTradingAPI
17
18
  from lixinger.api.cn.industry.margin_trading.sw import IndustrySwMarginTradingAPI
18
19
  from lixinger.api.cn.industry.margin_trading.sw_2021 import (
@@ -152,6 +153,7 @@ class IndustryNamespace:
152
153
  This class groups all industry-related APIs under a single namespace.
153
154
  Access APIs via their specific attributes:
154
155
 
156
+ - industry: 行业基础信息 API (get_industry)
155
157
  - margin_trading: 行业融资融券 API 组
156
158
  - margin_trading.sw: 申万行业
157
159
  - margin_trading.sw_2021: 申万2021版行业
@@ -171,6 +173,7 @@ class IndustryNamespace:
171
173
 
172
174
  def __init__( # noqa: PLR0913
173
175
  self,
176
+ industry: IndustryAPI,
174
177
  margin_trading_sw: IndustrySwMarginTradingAPI,
175
178
  margin_trading_sw_2021: IndustrySw2021MarginTradingAPI,
176
179
  margin_trading_cni: IndustryCniMarginTradingAPI,
@@ -185,6 +188,7 @@ class IndustryNamespace:
185
188
  """Initialize the industry namespace.
186
189
 
187
190
  Args:
191
+ industry: 行业基础信息 API
188
192
  margin_trading_sw: 申万行业融资融券 API
189
193
  margin_trading_sw_2021: 申万2021版行业融资融券 API
190
194
  margin_trading_cni: 国证行业融资融券 API
@@ -197,6 +201,7 @@ class IndustryNamespace:
197
201
  fundamental_sw_2021: 申万2021版行业基本面数据 API
198
202
 
199
203
  """
204
+ self.industry = industry
200
205
  self.margin_trading = IndustryMarginTradingNamespace(
201
206
  sw=margin_trading_sw,
202
207
  sw_2021=margin_trading_sw_2021,
@@ -219,6 +224,10 @@ class IndustryNamespace:
219
224
  )
220
225
 
221
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
+
222
231
  async def get_sw_margin_trading(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
223
232
  """Alias for margin_trading.sw.get_margin_trading."""
224
233
  return await self.margin_trading.sw.get_margin_trading(*args, **kwargs)
lixinger/client.py CHANGED
@@ -45,6 +45,7 @@ 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,
50
51
  IndustrySw2021ConstituentsAPI,
@@ -245,6 +246,7 @@ class AsyncLixingerClient:
245
246
  self.cn_index_fs_hybrid = cn_index_fs_hybrid
246
247
 
247
248
  # Industry APIs
249
+ cn_industry = IndustryAPI(self._http_client, self.config, self._rate_limiter)
248
250
  cn_industry_margin_trading_sw = IndustrySwMarginTradingAPI(self._http_client, self.config, self._rate_limiter)
249
251
  cn_industry_margin_trading_sw_2021 = IndustrySw2021MarginTradingAPI(
250
252
  self._http_client, self.config, self._rate_limiter
@@ -272,6 +274,7 @@ class AsyncLixingerClient:
272
274
 
273
275
  # Industry namespace (groups all industry APIs)
274
276
  self.cn_industry = IndustryNamespace(
277
+ industry=cn_industry,
275
278
  margin_trading_sw=cn_industry_margin_trading_sw,
276
279
  margin_trading_sw_2021=cn_industry_margin_trading_sw_2021,
277
280
  margin_trading_cni=cn_industry_margin_trading_cni,
@@ -285,6 +288,7 @@ class AsyncLixingerClient:
285
288
  )
286
289
 
287
290
  # Legacy flat access for industry APIs (deprecated, for backward compatibility)
291
+ self.cn_industry_info = cn_industry
288
292
  self.cn_industry_margin_trading_sw = cn_industry_margin_trading_sw
289
293
  self.cn_industry_margin_trading_sw_2021 = cn_industry_margin_trading_sw_2021
290
294
  self.cn_industry_margin_trading_cni = cn_industry_margin_trading_cni
@@ -9,6 +9,7 @@ from lixinger.models.cn.industry.fs import (
9
9
  IndustrySw2021SecurityStatementSchema,
10
10
  )
11
11
  from lixinger.models.cn.industry.fundamental import IndustrySw2021Fundamental
12
+ from lixinger.models.cn.industry.industry import Industry
12
13
  from lixinger.models.cn.industry.margin_trading import (
13
14
  IndustryCniMarginTrading,
14
15
  IndustrySw2021MarginTrading,
@@ -16,6 +17,7 @@ from lixinger.models.cn.industry.margin_trading import (
16
17
  )
17
18
 
18
19
  __all__ = [
20
+ "Industry",
19
21
  "IndustryCniMarginTrading",
20
22
  "IndustrySw2021BankStatementSchema",
21
23
  "IndustrySw2021Constituent",
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lixinger-python
3
- Version: 0.3.16
3
+ Version: 0.3.17
4
4
  Summary: Python SDK for Lixinger Financial Data API
5
5
  Project-URL: Homepage, https://www.lixinger.com
6
6
  Project-URL: Documentation, https://www.lixinger.com/open/api/doc
@@ -1,5 +1,5 @@
1
- lixinger/__init__.py,sha256=m0F0QLl0b-k0l1cmh2Mv4rh2y55Jt9_qn4DjAZNwZJY,4057
2
- lixinger/client.py,sha256=yOG7y9t9a-JMmYdx-hZy-a1XKfCAIB7nid4qx5Y3Jkc,17761
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,9 @@ 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=tgNdzXyl-b3tZT4eCyPlXFvwpYbQ5wczujwHoeH7uaI,1912
54
- lixinger/api/cn/industry/namespace.py,sha256=Tmti1AO-swzRKb0JlLMWMG1V47JflZBwxPXhKCZjTjk,10148
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
55
56
  lixinger/api/cn/industry/constituents/__init__.py,sha256=dwY1PVWeeoBADnooml_K24EPMTEc0hHoD6FrMeTlRIg,445
56
57
  lixinger/api/cn/industry/constituents/sw_2021.py,sha256=nrjDQYy7Jpt7Vl1mNvYDaaqBL-k22zkm-M5JFDylKtA,4459
57
58
  lixinger/api/cn/industry/fs/__init__.py,sha256=6incmfX-jJGo5AJ7yhD_5G3wSYUbZTpIKA-Oy-276FM,1173
@@ -116,7 +117,8 @@ lixinger/models/cn/index/fs/bank.py,sha256=DA_sRFSsK5IE0JQtp3pHdvPJQxbipHsSyKahc
116
117
  lixinger/models/cn/index/fs/hybrid.py,sha256=AlCoEfkkPdWGxE_K71rBKgwWpR4iWTaMJ8bc56YxYrk,565
117
118
  lixinger/models/cn/index/fs/non_financial.py,sha256=UpWXDDMiOdJN6WNc5R-PsHy9l9Th3xsKnOjUbID4Gug,585
118
119
  lixinger/models/cn/index/fs/security.py,sha256=VTYDvTQ5CKhqZsXeEyWqFNvugZ4UA3CLW0DkYTrOHtc,571
119
- lixinger/models/cn/industry/__init__.py,sha256=4V5WaOXSw8KCN1N_GERYV9gmeZpWGb-U9D7NfGC2mb8,1004
120
+ lixinger/models/cn/industry/__init__.py,sha256=fhYPO0FXOXkiSuxDZDmS393Ac6SsMlW6t_-GNheqclE,1078
121
+ lixinger/models/cn/industry/industry.py,sha256=NEaomVtgvR_emdY6Mzl5rNQPuHCIRQiFsEW91ekYZVE,904
120
122
  lixinger/models/cn/industry/constituents/__init__.py,sha256=MLR6DlZL50kBczGEMwcU8phbksWUa3uk4PgFKcg3wQs,329
121
123
  lixinger/models/cn/industry/constituents/sw_2021.py,sha256=SHFcGGjMRmvr6QwLDrzcIVwoZQUXZoYCjtcdVjs-ya0,755
122
124
  lixinger/models/cn/industry/fs/__init__.py,sha256=JRgbHzfMKocZmUyOmK0rxtP-6fVCcB6MrxkcNzKrDls,552
@@ -143,7 +145,7 @@ lixinger/utils/dataframe.py,sha256=tYBrNdmJ4poyuwD-9XgzHt3A_A8bBo0cdHiu8Yy9e9A,2
143
145
  lixinger/utils/dict.py,sha256=yvbUtv8QpRmy0d_o_7gCuEwwiEfBji5_xB490ANxilw,589
144
146
  lixinger/utils/rate_limiter.py,sha256=ZHlRTTL60L62uRA_f--LD26qkAfk-pHBllRqPapAXQM,1141
145
147
  lixinger/utils/retry.py,sha256=C9QBcrpD7WYAuT8R4SJfWNUZFj1mZsv-qyTRIFQDmwc,2862
146
- lixinger_python-0.3.16.dist-info/METADATA,sha256=PRU0-dt5Nm5Sl6tI5vOQb4wPG_dmffazcO_qUTp6Xs0,9207
147
- lixinger_python-0.3.16.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
148
- lixinger_python-0.3.16.dist-info/licenses/LICENSE,sha256=5oOwRq1lHSOScbNGCHr2feuNnhNYdGcArj6fSUfsC5U,1064
149
- lixinger_python-0.3.16.dist-info/RECORD,,
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,,