lixinger-python 0.3.14__py3-none-any.whl → 0.3.16__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.
Files changed (31) hide show
  1. lixinger/__init__.py +17 -0
  2. lixinger/api/cn/industry/__init__.py +34 -0
  3. lixinger/api/cn/industry/constituents/__init__.py +19 -0
  4. lixinger/api/cn/industry/constituents/sw_2021.py +122 -0
  5. lixinger/api/cn/industry/fs/__init__.py +35 -0
  6. lixinger/api/cn/industry/fs/sw_2021/__init__.py +47 -0
  7. lixinger/api/cn/industry/fs/sw_2021/bank.py +133 -0
  8. lixinger/api/cn/industry/fs/sw_2021/hybrid.py +133 -0
  9. lixinger/api/cn/industry/fs/sw_2021/insurance.py +134 -0
  10. lixinger/api/cn/industry/fs/sw_2021/non_financial.py +133 -0
  11. lixinger/api/cn/industry/fs/sw_2021/security.py +134 -0
  12. lixinger/api/cn/industry/fundamental/__init__.py +19 -0
  13. lixinger/api/cn/industry/fundamental/sw_2021.py +153 -0
  14. lixinger/api/cn/industry/namespace.py +173 -1
  15. lixinger/client.py +40 -0
  16. lixinger/models/cn/industry/__init__.py +16 -0
  17. lixinger/models/cn/industry/constituents/__init__.py +13 -0
  18. lixinger/models/cn/industry/constituents/sw_2021.py +24 -0
  19. lixinger/models/cn/industry/fs/__init__.py +17 -0
  20. lixinger/models/cn/industry/fs/sw_2021/__init__.py +15 -0
  21. lixinger/models/cn/industry/fs/sw_2021/bank.py +20 -0
  22. lixinger/models/cn/industry/fs/sw_2021/hybrid.py +20 -0
  23. lixinger/models/cn/industry/fs/sw_2021/insurance.py +20 -0
  24. lixinger/models/cn/industry/fs/sw_2021/non_financial.py +20 -0
  25. lixinger/models/cn/industry/fs/sw_2021/security.py +20 -0
  26. lixinger/models/cn/industry/fundamental/__init__.py +13 -0
  27. lixinger/models/cn/industry/fundamental/sw_2021.py +23 -0
  28. {lixinger_python-0.3.14.dist-info → lixinger_python-0.3.16.dist-info}/METADATA +1 -1
  29. {lixinger_python-0.3.14.dist-info → lixinger_python-0.3.16.dist-info}/RECORD +31 -9
  30. {lixinger_python-0.3.14.dist-info → lixinger_python-0.3.16.dist-info}/WHEEL +0 -0
  31. {lixinger_python-0.3.14.dist-info → lixinger_python-0.3.16.dist-info}/licenses/LICENSE +0 -0
lixinger/__init__.py CHANGED
@@ -44,7 +44,14 @@ from lixinger.api.cn.index import (
44
44
  )
45
45
  from lixinger.api.cn.industry import (
46
46
  get_industry_cni_margin_trading,
47
+ get_industry_sw_2021_bank_statements,
48
+ get_industry_sw_2021_constituents,
49
+ get_industry_sw_2021_fundamental,
50
+ get_industry_sw_2021_hybrid_statements,
51
+ get_industry_sw_2021_insurance_statements,
47
52
  get_industry_sw_2021_margin_trading,
53
+ get_industry_sw_2021_non_financial_statements,
54
+ get_industry_sw_2021_security_statements,
48
55
  get_industry_sw_margin_trading,
49
56
  )
50
57
  from lixinger.api.macro import (
@@ -110,6 +117,16 @@ __all__ = [
110
117
  "get_industry_sw_margin_trading",
111
118
  "get_industry_sw_2021_margin_trading",
112
119
  "get_industry_cni_margin_trading",
120
+ # Industry financial statements (申万2021版)
121
+ "get_industry_sw_2021_bank_statements",
122
+ "get_industry_sw_2021_hybrid_statements",
123
+ "get_industry_sw_2021_insurance_statements",
124
+ "get_industry_sw_2021_non_financial_statements",
125
+ "get_industry_sw_2021_security_statements",
126
+ # Industry constituents (申万2021版)
127
+ "get_industry_sw_2021_constituents",
128
+ # Industry fundamental (申万2021版)
129
+ "get_industry_sw_2021_fundamental",
113
130
  # Macro
114
131
  "get_national_debt",
115
132
  "get_rmb_deposits",
@@ -1,5 +1,25 @@
1
1
  """Industry-related APIs."""
2
2
 
3
+ from lixinger.api.cn.industry.constituents import (
4
+ IndustrySw2021ConstituentsAPI,
5
+ get_industry_sw_2021_constituents,
6
+ )
7
+ from lixinger.api.cn.industry.fs import (
8
+ IndustrySw2021BankStatementAPI,
9
+ IndustrySw2021HybridStatementAPI,
10
+ IndustrySw2021InsuranceStatementAPI,
11
+ IndustrySw2021NonFinancialStatementAPI,
12
+ IndustrySw2021SecurityStatementAPI,
13
+ get_industry_sw_2021_bank_statements,
14
+ get_industry_sw_2021_hybrid_statements,
15
+ get_industry_sw_2021_insurance_statements,
16
+ get_industry_sw_2021_non_financial_statements,
17
+ get_industry_sw_2021_security_statements,
18
+ )
19
+ from lixinger.api.cn.industry.fundamental import (
20
+ IndustrySw2021FundamentalAPI,
21
+ get_industry_sw_2021_fundamental,
22
+ )
3
23
  from lixinger.api.cn.industry.margin_trading import (
4
24
  IndustryCniMarginTradingAPI,
5
25
  IndustrySw2021MarginTradingAPI,
@@ -12,10 +32,24 @@ from lixinger.api.cn.industry.margin_trading import (
12
32
  __all__ = [
13
33
  # API Classes
14
34
  "IndustryCniMarginTradingAPI",
35
+ "IndustrySw2021BankStatementAPI",
36
+ "IndustrySw2021ConstituentsAPI",
37
+ "IndustrySw2021FundamentalAPI",
38
+ "IndustrySw2021HybridStatementAPI",
39
+ "IndustrySw2021InsuranceStatementAPI",
15
40
  "IndustrySw2021MarginTradingAPI",
41
+ "IndustrySw2021NonFinancialStatementAPI",
42
+ "IndustrySw2021SecurityStatementAPI",
16
43
  "IndustrySwMarginTradingAPI",
17
44
  # Functional APIs
18
45
  "get_industry_cni_margin_trading",
46
+ "get_industry_sw_2021_bank_statements",
47
+ "get_industry_sw_2021_constituents",
48
+ "get_industry_sw_2021_fundamental",
49
+ "get_industry_sw_2021_hybrid_statements",
50
+ "get_industry_sw_2021_insurance_statements",
19
51
  "get_industry_sw_2021_margin_trading",
52
+ "get_industry_sw_2021_non_financial_statements",
53
+ "get_industry_sw_2021_security_statements",
20
54
  "get_industry_sw_margin_trading",
21
55
  ]
@@ -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,35 @@
1
+ """Industry financial statement APIs.
2
+
3
+ This module provides access to industry financial statement APIs by
4
+ industry classification system:
5
+
6
+ - sw_2021: 申万2021版行业财报数据
7
+ """
8
+
9
+ from lixinger.api.cn.industry.fs.sw_2021 import (
10
+ IndustrySw2021BankStatementAPI,
11
+ IndustrySw2021HybridStatementAPI,
12
+ IndustrySw2021InsuranceStatementAPI,
13
+ IndustrySw2021NonFinancialStatementAPI,
14
+ IndustrySw2021SecurityStatementAPI,
15
+ get_industry_sw_2021_bank_statements,
16
+ get_industry_sw_2021_hybrid_statements,
17
+ get_industry_sw_2021_insurance_statements,
18
+ get_industry_sw_2021_non_financial_statements,
19
+ get_industry_sw_2021_security_statements,
20
+ )
21
+
22
+ __all__ = [
23
+ # API Classes
24
+ "IndustrySw2021BankStatementAPI",
25
+ "IndustrySw2021HybridStatementAPI",
26
+ "IndustrySw2021InsuranceStatementAPI",
27
+ "IndustrySw2021NonFinancialStatementAPI",
28
+ "IndustrySw2021SecurityStatementAPI",
29
+ # Functional APIs
30
+ "get_industry_sw_2021_bank_statements",
31
+ "get_industry_sw_2021_hybrid_statements",
32
+ "get_industry_sw_2021_insurance_statements",
33
+ "get_industry_sw_2021_non_financial_statements",
34
+ "get_industry_sw_2021_security_statements",
35
+ ]
@@ -0,0 +1,47 @@
1
+ """申万2021版行业财报数据 API.
2
+
3
+ This module provides access to industry financial statement APIs for the
4
+ Shenwan 2021 classification, grouped by industry sample type:
5
+
6
+ - bank: 银行类行业财报
7
+ - hybrid: 混合型行业财报(同时包含金融和非金融公司)
8
+ - insurance: 保险类行业财报
9
+ - non_financial: 非金融类行业财报
10
+ - security: 证券类行业财报
11
+ """
12
+
13
+ from lixinger.api.cn.industry.fs.sw_2021.bank import (
14
+ IndustrySw2021BankStatementAPI,
15
+ get_industry_sw_2021_bank_statements,
16
+ )
17
+ from lixinger.api.cn.industry.fs.sw_2021.hybrid import (
18
+ IndustrySw2021HybridStatementAPI,
19
+ get_industry_sw_2021_hybrid_statements,
20
+ )
21
+ from lixinger.api.cn.industry.fs.sw_2021.insurance import (
22
+ IndustrySw2021InsuranceStatementAPI,
23
+ get_industry_sw_2021_insurance_statements,
24
+ )
25
+ from lixinger.api.cn.industry.fs.sw_2021.non_financial import (
26
+ IndustrySw2021NonFinancialStatementAPI,
27
+ get_industry_sw_2021_non_financial_statements,
28
+ )
29
+ from lixinger.api.cn.industry.fs.sw_2021.security import (
30
+ IndustrySw2021SecurityStatementAPI,
31
+ get_industry_sw_2021_security_statements,
32
+ )
33
+
34
+ __all__ = [
35
+ # API Classes
36
+ "IndustrySw2021BankStatementAPI",
37
+ "IndustrySw2021HybridStatementAPI",
38
+ "IndustrySw2021InsuranceStatementAPI",
39
+ "IndustrySw2021NonFinancialStatementAPI",
40
+ "IndustrySw2021SecurityStatementAPI",
41
+ # Functional APIs
42
+ "get_industry_sw_2021_bank_statements",
43
+ "get_industry_sw_2021_hybrid_statements",
44
+ "get_industry_sw_2021_insurance_statements",
45
+ "get_industry_sw_2021_non_financial_statements",
46
+ "get_industry_sw_2021_security_statements",
47
+ ]
@@ -0,0 +1,133 @@
1
+ """申万2021版行业 - 银行类财报数据 API."""
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.fs.sw_2021.bank import IndustrySw2021BankStatementSchema
9
+ from lixinger.utils.api import api
10
+ from lixinger.utils.dataframe import get_response_df
11
+ from lixinger.utils.dict import flatten_dict
12
+
13
+
14
+ class IndustrySw2021BankStatementAPI(BaseAPI):
15
+ """申万2021版银行类行业财报数据 API."""
16
+
17
+ async def get_bank_statements( # noqa: PLR0913
18
+ self,
19
+ stock_codes: list[str],
20
+ metrics: list[str],
21
+ date: str | None = None,
22
+ start_date: str | None = None,
23
+ end_date: str | None = None,
24
+ limit: int | None = None,
25
+ ) -> pd.DataFrame:
26
+ """获取申万2021版银行类行业的财报数据.
27
+
28
+ API Endpoint: /cn/industry/fs/sw_2021/bank
29
+ API Method: POST
30
+ API Doc: https://www.lixinger.com/open/api/doc?api-key=cn/industry/fs/sw_2021/bank
31
+
32
+ 获取申万2021年版银行类大陆行业(样本仅包含银行)的财务数据,包括利润表、
33
+ 资产负债表、现金流量表、财务指标。注意该行业划分多从2021年开始,
34
+ 更早的时间可能没有数据。
35
+
36
+ Args:
37
+ stock_codes: 行业代码列表,长度 >=1 且 <=100。当传入 start_date
38
+ 时只能传入一个行业代码。
39
+ metrics: 指标列表,格式为
40
+ ``[granularity].[tableName].[fieldName].[expressionCalculateType]``,
41
+ 例如 ``"q.ps.oi.t"``。当 stock_codes 长度大于 1 时最多 48 个
42
+ 指标;等于 1 时最多 128 个指标。
43
+ date: 日期 (YYYY-MM-DD),与 start_date 二选一。支持 ``"latest"``。
44
+ start_date: 开始日期 (YYYY-MM-DD),与 date 二选一。开始和结束的时间
45
+ 间隔不超过 10 年。
46
+ end_date: 结束日期 (YYYY-MM-DD),可选,默认上周一。
47
+ limit: 返回最近数据的数量,仅在 date range 请求下生效。
48
+
49
+ Returns:
50
+ 包含申万2021版银行类行业财报数据的 DataFrame。
51
+
52
+ Example:
53
+ 获取申万2021版银行行业的营业收入::
54
+
55
+ from lixinger import AsyncLixingerClient
56
+
57
+ async with AsyncLixingerClient() as client:
58
+ df = await client.industry.fs.sw_2021.bank.get_bank_statements(
59
+ stock_codes=["480000"],
60
+ metrics=["q.ps.oi.t"],
61
+ date="2026-03-31",
62
+ )
63
+ print(df)
64
+
65
+ """
66
+ payload: dict[str, Any] = {
67
+ "stockCodes": stock_codes,
68
+ "metricsList": metrics,
69
+ }
70
+ if date is not None:
71
+ payload["date"] = date
72
+ if start_date is not None:
73
+ payload["startDate"] = start_date
74
+ if end_date is not None:
75
+ payload["endDate"] = end_date
76
+ if limit is not None:
77
+ payload["limit"] = limit
78
+
79
+ data = await self._request("POST", "/cn/industry/fs/sw_2021/bank", json=payload)
80
+
81
+ # Flatten nested metrics (e.g. {"q": {"ps": {"oi": {"t": ...}}}})
82
+ flattened_data = [flatten_dict(item) for item in data]
83
+
84
+ return get_response_df(flattened_data, IndustrySw2021BankStatementSchema)
85
+
86
+
87
+ # Functional API instance
88
+ _api_instance = IndustrySw2021BankStatementAPI()
89
+
90
+
91
+ @api
92
+ async def get_industry_sw_2021_bank_statements( # noqa: PLR0913
93
+ stock_codes: list[str],
94
+ metrics: list[str],
95
+ date: str | None = None,
96
+ start_date: str | None = None,
97
+ end_date: str | None = None,
98
+ limit: int | None = None,
99
+ ) -> pd.DataFrame:
100
+ """获取申万2021版银行类行业的财报数据.
101
+
102
+ Args:
103
+ stock_codes: 行业代码列表。
104
+ metrics: 指标列表。
105
+ date: 日期 (YYYY-MM-DD),与 start_date 二选一。
106
+ start_date: 开始日期 (YYYY-MM-DD),与 date 二选一。
107
+ end_date: 结束日期 (YYYY-MM-DD),可选。
108
+ limit: 返回最近数据的数量,仅在 date range 请求下生效。
109
+
110
+ Returns:
111
+ 包含申万2021版银行类行业财报数据的 DataFrame。
112
+
113
+ Example:
114
+ 获取申万2021版银行行业的营业收入::
115
+
116
+ from lixinger import get_industry_sw_2021_bank_statements
117
+
118
+ df = await get_industry_sw_2021_bank_statements(
119
+ stock_codes=["480000"],
120
+ metrics=["q.ps.oi.t"],
121
+ date="2026-03-31",
122
+ )
123
+ print(df)
124
+
125
+ """
126
+ return await _api_instance.get_bank_statements(
127
+ stock_codes=stock_codes,
128
+ metrics=metrics,
129
+ date=date,
130
+ start_date=start_date,
131
+ end_date=end_date,
132
+ limit=limit,
133
+ )
@@ -0,0 +1,133 @@
1
+ """申万2021版行业 - 混合型财报数据 API."""
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.fs.sw_2021.hybrid import IndustrySw2021HybridStatementSchema
9
+ from lixinger.utils.api import api
10
+ from lixinger.utils.dataframe import get_response_df
11
+ from lixinger.utils.dict import flatten_dict
12
+
13
+
14
+ class IndustrySw2021HybridStatementAPI(BaseAPI):
15
+ """申万2021版混合型行业财报数据 API."""
16
+
17
+ async def get_hybrid_statements( # noqa: PLR0913
18
+ self,
19
+ stock_codes: list[str],
20
+ metrics: list[str],
21
+ date: str | None = None,
22
+ start_date: str | None = None,
23
+ end_date: str | None = None,
24
+ limit: int | None = None,
25
+ ) -> pd.DataFrame:
26
+ """获取申万2021版混合型行业的财报数据.
27
+
28
+ API Endpoint: /cn/industry/fs/sw_2021/hybrid
29
+ API Method: POST
30
+ API Doc: https://www.lixinger.com/open/api/doc?api-key=cn/industry/fs/sw_2021/hybrid
31
+
32
+ 获取申万2021年版混合型行业(样本同时包含金融公司和非金融公司)的财务数据,
33
+ 包括利润表、资产负债表、现金流量表、财务指标。注意该行业划分多从2021年
34
+ 开始,更早的时间可能没有数据。
35
+
36
+ Args:
37
+ stock_codes: 行业代码列表,长度 >=1 且 <=100。当传入 start_date
38
+ 时只能传入一个行业代码。
39
+ metrics: 指标列表,格式为
40
+ ``[granularity].[tableName].[fieldName].[expressionCalculateType]``,
41
+ 例如 ``"q.ps.toi.t"``。当 stock_codes 长度大于 1 时最多 48 个
42
+ 指标;等于 1 时最多 128 个指标。
43
+ date: 日期 (YYYY-MM-DD),与 start_date 二选一。支持 ``"latest"``。
44
+ start_date: 开始日期 (YYYY-MM-DD),与 date 二选一。开始和结束的时间
45
+ 间隔不超过 10 年。
46
+ end_date: 结束日期 (YYYY-MM-DD),可选,默认上周一。
47
+ limit: 返回最近数据的数量,仅在 date range 请求下生效。
48
+
49
+ Returns:
50
+ 包含申万2021版混合型行业财报数据的 DataFrame。
51
+
52
+ Example:
53
+ 获取申万2021版非银金融行业的营业总收入::
54
+
55
+ from lixinger import AsyncLixingerClient
56
+
57
+ async with AsyncLixingerClient() as client:
58
+ df = await client.industry.fs.sw_2021.hybrid.get_hybrid_statements(
59
+ stock_codes=["490000"],
60
+ metrics=["q.ps.toi.t"],
61
+ date="2026-03-31",
62
+ )
63
+ print(df)
64
+
65
+ """
66
+ payload: dict[str, Any] = {
67
+ "stockCodes": stock_codes,
68
+ "metricsList": metrics,
69
+ }
70
+ if date is not None:
71
+ payload["date"] = date
72
+ if start_date is not None:
73
+ payload["startDate"] = start_date
74
+ if end_date is not None:
75
+ payload["endDate"] = end_date
76
+ if limit is not None:
77
+ payload["limit"] = limit
78
+
79
+ data = await self._request("POST", "/cn/industry/fs/sw_2021/hybrid", json=payload)
80
+
81
+ # Flatten nested metrics (e.g. {"q": {"ps": {"toi": {"t": ...}}}})
82
+ flattened_data = [flatten_dict(item) for item in data]
83
+
84
+ return get_response_df(flattened_data, IndustrySw2021HybridStatementSchema)
85
+
86
+
87
+ # Functional API instance
88
+ _api_instance = IndustrySw2021HybridStatementAPI()
89
+
90
+
91
+ @api
92
+ async def get_industry_sw_2021_hybrid_statements( # noqa: PLR0913
93
+ stock_codes: list[str],
94
+ metrics: list[str],
95
+ date: str | None = None,
96
+ start_date: str | None = None,
97
+ end_date: str | None = None,
98
+ limit: int | None = None,
99
+ ) -> pd.DataFrame:
100
+ """获取申万2021版混合型行业的财报数据.
101
+
102
+ Args:
103
+ stock_codes: 行业代码列表。
104
+ metrics: 指标列表。
105
+ date: 日期 (YYYY-MM-DD),与 start_date 二选一。
106
+ start_date: 开始日期 (YYYY-MM-DD),与 date 二选一。
107
+ end_date: 结束日期 (YYYY-MM-DD),可选。
108
+ limit: 返回最近数据的数量,仅在 date range 请求下生效。
109
+
110
+ Returns:
111
+ 包含申万2021版混合型行业财报数据的 DataFrame。
112
+
113
+ Example:
114
+ 获取申万2021版非银金融行业的营业总收入::
115
+
116
+ from lixinger import get_industry_sw_2021_hybrid_statements
117
+
118
+ df = await get_industry_sw_2021_hybrid_statements(
119
+ stock_codes=["490000"],
120
+ metrics=["q.ps.toi.t"],
121
+ date="2026-03-31",
122
+ )
123
+ print(df)
124
+
125
+ """
126
+ return await _api_instance.get_hybrid_statements(
127
+ stock_codes=stock_codes,
128
+ metrics=metrics,
129
+ date=date,
130
+ start_date=start_date,
131
+ end_date=end_date,
132
+ limit=limit,
133
+ )