lixinger-python 0.3.9__py3-none-any.whl → 0.3.11__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/base.py +1 -1
- lixinger/api/cn/company/namespace.py +3 -3
- lixinger/api/cn/index/namespace.py +22 -18
- lixinger/api/cn/industry/__init__.py +21 -0
- lixinger/api/cn/industry/margin_trading/__init__.py +33 -0
- lixinger/api/cn/industry/margin_trading/cni.py +129 -0
- lixinger/api/cn/industry/margin_trading/sw.py +129 -0
- lixinger/api/cn/industry/margin_trading/sw_2021.py +129 -0
- lixinger/api/cn/industry/namespace.py +88 -0
- lixinger/client.py +41 -4
- lixinger/exceptions.py +1 -1
- lixinger/models/cn/industry/__init__.py +13 -0
- lixinger/models/cn/industry/margin_trading/__init__.py +11 -0
- lixinger/models/cn/industry/margin_trading/cni.py +29 -0
- lixinger/models/cn/industry/margin_trading/sw.py +29 -0
- lixinger/models/cn/industry/margin_trading/sw_2021.py +29 -0
- lixinger/utils/rate_limiter.py +1 -1
- {lixinger_python-0.3.9.dist-info → lixinger_python-0.3.11.dist-info}/METADATA +1 -1
- {lixinger_python-0.3.9.dist-info → lixinger_python-0.3.11.dist-info}/RECORD +22 -11
- {lixinger_python-0.3.9.dist-info → lixinger_python-0.3.11.dist-info}/WHEEL +0 -0
- {lixinger_python-0.3.9.dist-info → lixinger_python-0.3.11.dist-info}/licenses/LICENSE +0 -0
lixinger/__init__.py
CHANGED
|
@@ -42,6 +42,11 @@ from lixinger.api.cn.index import (
|
|
|
42
42
|
from lixinger.api.cn.index import (
|
|
43
43
|
get_drawdown as get_index_drawdown,
|
|
44
44
|
)
|
|
45
|
+
from lixinger.api.cn.industry import (
|
|
46
|
+
get_industry_cni_margin_trading,
|
|
47
|
+
get_industry_sw_2021_margin_trading,
|
|
48
|
+
get_industry_sw_margin_trading,
|
|
49
|
+
)
|
|
45
50
|
from lixinger.client import AsyncLixingerClient
|
|
46
51
|
from lixinger.config import set_token
|
|
47
52
|
from lixinger.exceptions import (
|
|
@@ -95,4 +100,8 @@ __all__ = [
|
|
|
95
100
|
"get_index_bank_statements",
|
|
96
101
|
"get_index_security_statements",
|
|
97
102
|
"get_index_hybrid_statements",
|
|
103
|
+
# Industry margin trading
|
|
104
|
+
"get_industry_sw_margin_trading",
|
|
105
|
+
"get_industry_sw_2021_margin_trading",
|
|
106
|
+
"get_industry_cni_margin_trading",
|
|
98
107
|
]
|
lixinger/api/base.py
CHANGED
|
@@ -37,7 +37,7 @@ class BaseAPI:
|
|
|
37
37
|
client: httpx.AsyncClient | None = None,
|
|
38
38
|
config: Config | None = None,
|
|
39
39
|
rate_limiter: AsyncRateLimiter | None = None,
|
|
40
|
-
):
|
|
40
|
+
) -> None:
|
|
41
41
|
self._client = client
|
|
42
42
|
self._config = config or settings
|
|
43
43
|
self._rate_limiter = rate_limiter or _global_rate_limiter
|
|
@@ -37,7 +37,7 @@ class FundamentalNamespace:
|
|
|
37
37
|
insurance: InsuranceFundamentalAPI,
|
|
38
38
|
security: SecurityFundamentalAPI,
|
|
39
39
|
other_financial: OtherFinancialFundamentalAPI,
|
|
40
|
-
):
|
|
40
|
+
) -> None:
|
|
41
41
|
"""Initialize the fundamental namespace."""
|
|
42
42
|
self.non_financial = non_financial
|
|
43
43
|
self.bank = bank
|
|
@@ -65,7 +65,7 @@ class FSNamespace:
|
|
|
65
65
|
insurance: InsuranceStatementAPI,
|
|
66
66
|
security: SecurityStatementAPI,
|
|
67
67
|
other_financial: OtherFinancialStatementAPI,
|
|
68
|
-
):
|
|
68
|
+
) -> None:
|
|
69
69
|
"""Initialize the financial statement namespace."""
|
|
70
70
|
self.non_financial = non_financial
|
|
71
71
|
self.bank = bank
|
|
@@ -121,7 +121,7 @@ class CompanyNamespace:
|
|
|
121
121
|
indices: IndicesAPI,
|
|
122
122
|
dividend: DividendAPI,
|
|
123
123
|
announcement: AnnouncementAPI,
|
|
124
|
-
):
|
|
124
|
+
) -> None:
|
|
125
125
|
"""Initialize the company namespace.
|
|
126
126
|
|
|
127
127
|
Args:
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"""Index namespace for grouping related APIs."""
|
|
2
2
|
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import pandas as pd
|
|
6
|
+
|
|
3
7
|
from lixinger.api.cn.index.candlestick import IndexCandlestickAPI
|
|
4
8
|
from lixinger.api.cn.index.constituent_weightings import ConstituentWeightingsAPI
|
|
5
9
|
from lixinger.api.cn.index.constituents import ConstituentsAPI
|
|
@@ -32,7 +36,7 @@ class IndexFSNamespace:
|
|
|
32
36
|
bank: IndexBankStatementAPI,
|
|
33
37
|
security: IndexSecurityStatementAPI,
|
|
34
38
|
hybrid: IndexHybridStatementAPI,
|
|
35
|
-
):
|
|
39
|
+
) -> None:
|
|
36
40
|
"""Initialize the index financial statement namespace.
|
|
37
41
|
|
|
38
42
|
Args:
|
|
@@ -84,7 +88,7 @@ class IndexNamespace:
|
|
|
84
88
|
fs_bank: IndexBankStatementAPI,
|
|
85
89
|
fs_security: IndexSecurityStatementAPI,
|
|
86
90
|
fs_hybrid: IndexHybridStatementAPI,
|
|
87
|
-
):
|
|
91
|
+
) -> None:
|
|
88
92
|
"""Initialize the index namespace.
|
|
89
93
|
|
|
90
94
|
Args:
|
|
@@ -118,34 +122,34 @@ class IndexNamespace:
|
|
|
118
122
|
)
|
|
119
123
|
|
|
120
124
|
# Convenience aliases for shorter access
|
|
121
|
-
def get_index(self, *args, **kwargs):
|
|
125
|
+
async def get_index(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
122
126
|
"""Alias for index.get_index."""
|
|
123
|
-
return self.index.get_index(*args, **kwargs)
|
|
127
|
+
return await self.index.get_index(*args, **kwargs)
|
|
124
128
|
|
|
125
|
-
def get_constituents(self, *args, **kwargs):
|
|
129
|
+
async def get_constituents(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
126
130
|
"""Alias for constituents.get_constituents."""
|
|
127
|
-
return self.constituents.get_constituents(*args, **kwargs)
|
|
131
|
+
return await self.constituents.get_constituents(*args, **kwargs)
|
|
128
132
|
|
|
129
|
-
def get_constituent_weightings(self, *args, **kwargs):
|
|
133
|
+
async def get_constituent_weightings(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
130
134
|
"""Alias for constituent_weightings.get_constituent_weightings."""
|
|
131
|
-
return self.constituent_weightings.get_constituent_weightings(*args, **kwargs)
|
|
135
|
+
return await self.constituent_weightings.get_constituent_weightings(*args, **kwargs)
|
|
132
136
|
|
|
133
|
-
def get_fundamental(self, *args, **kwargs):
|
|
137
|
+
async def get_fundamental(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
134
138
|
"""Alias for fundamental.get_fundamental."""
|
|
135
|
-
return self.fundamental.get_fundamental(*args, **kwargs)
|
|
139
|
+
return await self.fundamental.get_fundamental(*args, **kwargs)
|
|
136
140
|
|
|
137
|
-
def get_candlestick(self, *args, **kwargs):
|
|
141
|
+
async def get_candlestick(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
138
142
|
"""Alias for candlestick.get_candlestick."""
|
|
139
|
-
return self.candlestick.get_candlestick(*args, **kwargs)
|
|
143
|
+
return await self.candlestick.get_candlestick(*args, **kwargs)
|
|
140
144
|
|
|
141
|
-
def get_drawdown(self, *args, **kwargs):
|
|
145
|
+
async def get_drawdown(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
142
146
|
"""Alias for drawdown.get_drawdown."""
|
|
143
|
-
return self.drawdown.get_drawdown(*args, **kwargs)
|
|
147
|
+
return await self.drawdown.get_drawdown(*args, **kwargs)
|
|
144
148
|
|
|
145
|
-
def get_tracking_fund(self, *args, **kwargs):
|
|
149
|
+
async def get_tracking_fund(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
146
150
|
"""Alias for tracking_fund.get_tracking_fund."""
|
|
147
|
-
return self.tracking_fund.get_tracking_fund(*args, **kwargs)
|
|
151
|
+
return await self.tracking_fund.get_tracking_fund(*args, **kwargs)
|
|
148
152
|
|
|
149
|
-
def get_margin_trading(self, *args, **kwargs):
|
|
153
|
+
async def get_margin_trading(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
150
154
|
"""Alias for margin_trading.get_margin_trading."""
|
|
151
|
-
return self.margin_trading.get_margin_trading(*args, **kwargs)
|
|
155
|
+
return await self.margin_trading.get_margin_trading(*args, **kwargs)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Industry-related APIs."""
|
|
2
|
+
|
|
3
|
+
from lixinger.api.cn.industry.margin_trading import (
|
|
4
|
+
IndustryCniMarginTradingAPI,
|
|
5
|
+
IndustrySw2021MarginTradingAPI,
|
|
6
|
+
IndustrySwMarginTradingAPI,
|
|
7
|
+
get_industry_cni_margin_trading,
|
|
8
|
+
get_industry_sw_2021_margin_trading,
|
|
9
|
+
get_industry_sw_margin_trading,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
# API Classes
|
|
14
|
+
"IndustryCniMarginTradingAPI",
|
|
15
|
+
"IndustrySw2021MarginTradingAPI",
|
|
16
|
+
"IndustrySwMarginTradingAPI",
|
|
17
|
+
# Functional APIs
|
|
18
|
+
"get_industry_cni_margin_trading",
|
|
19
|
+
"get_industry_sw_2021_margin_trading",
|
|
20
|
+
"get_industry_sw_margin_trading",
|
|
21
|
+
]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Industry margin trading and securities lending APIs.
|
|
2
|
+
|
|
3
|
+
This module provides access to industry margin trading APIs by industry
|
|
4
|
+
classification system:
|
|
5
|
+
|
|
6
|
+
- sw: 申万行业 (Shenwan / SW)
|
|
7
|
+
- sw_2021: 申万2021版行业 (Shenwan 2021)
|
|
8
|
+
- cni: 国证行业 (CNI)
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from lixinger.api.cn.industry.margin_trading.cni import (
|
|
12
|
+
IndustryCniMarginTradingAPI,
|
|
13
|
+
get_industry_cni_margin_trading,
|
|
14
|
+
)
|
|
15
|
+
from lixinger.api.cn.industry.margin_trading.sw import (
|
|
16
|
+
IndustrySwMarginTradingAPI,
|
|
17
|
+
get_industry_sw_margin_trading,
|
|
18
|
+
)
|
|
19
|
+
from lixinger.api.cn.industry.margin_trading.sw_2021 import (
|
|
20
|
+
IndustrySw2021MarginTradingAPI,
|
|
21
|
+
get_industry_sw_2021_margin_trading,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
# API Classes
|
|
26
|
+
"IndustryCniMarginTradingAPI",
|
|
27
|
+
"IndustrySw2021MarginTradingAPI",
|
|
28
|
+
"IndustrySwMarginTradingAPI",
|
|
29
|
+
# Functional APIs
|
|
30
|
+
"get_industry_cni_margin_trading",
|
|
31
|
+
"get_industry_sw_2021_margin_trading",
|
|
32
|
+
"get_industry_sw_margin_trading",
|
|
33
|
+
]
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""Industry (国证) margin trading and securities lending 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.margin_trading.cni import IndustryCniMarginTrading
|
|
9
|
+
from lixinger.utils.api import api
|
|
10
|
+
from lixinger.utils.dataframe import get_response_df
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class IndustryCniMarginTradingAPI(BaseAPI):
|
|
14
|
+
"""国证行业融资融券 API."""
|
|
15
|
+
|
|
16
|
+
async def get_margin_trading(
|
|
17
|
+
self,
|
|
18
|
+
stock_code: str,
|
|
19
|
+
start_date: str,
|
|
20
|
+
end_date: str | None = None,
|
|
21
|
+
limit: int | None = None,
|
|
22
|
+
) -> pd.DataFrame:
|
|
23
|
+
"""获取国证行业融资融券数据.
|
|
24
|
+
|
|
25
|
+
获取国证(cni)行业每日的融资融券数据. 可按行业代码批量查询返回每日行业融资买入金额、
|
|
26
|
+
融资偿还金额、融资净买入金额、融资余额、融券卖出金额、融券偿还金额、
|
|
27
|
+
融券净卖出金额、融券余额等数据. 当用户想了解国证(cni)行业每日的融资融券余额
|
|
28
|
+
以及变动情况、观察杠杆资金进出节奏或分析做空力量时, 调用此接口.
|
|
29
|
+
|
|
30
|
+
API Endpoint: /cn/industry/margin-trading-and-securities-lending/cni
|
|
31
|
+
API Method: POST
|
|
32
|
+
API Doc: https://www.lixinger.com/open/api/doc?api-key=cn/industry/margin-trading-and-securities-lending/cni
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
stock_code: 国证行业代码, 请参考行业信息API获取合法的stockCode
|
|
36
|
+
start_date: 信息起始时间 (YYYY-MM-DD, 北京时间), 开始和结束的时间间隔不超过10年
|
|
37
|
+
end_date: 结束信息日期 (YYYY-MM-DD, 北京时间), 默认为今天结束
|
|
38
|
+
limit: 返回最近数据的数量
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
DataFrame containing margin trading data with columns:
|
|
42
|
+
|
|
43
|
+
- date: 数据时间
|
|
44
|
+
- stock_code: 行业代码
|
|
45
|
+
- financing_purchase_amount: 融资买入金额
|
|
46
|
+
- financing_repayment_amount: 融资偿还金额
|
|
47
|
+
- financing_net_purchase_amount: 融资净买入金额
|
|
48
|
+
- financing_balance: 融资余额
|
|
49
|
+
- securities_sell_amount: 融券卖出金额
|
|
50
|
+
- securities_repayment_amount: 融券偿还金额
|
|
51
|
+
- securities_net_sell_amount: 融券净卖出金额
|
|
52
|
+
- securities_balance: 融券余额
|
|
53
|
+
- financing_balance_to_market_cap: 融资余额占流通市值比例
|
|
54
|
+
- securities_balance_to_market_cap: 融券余额占流通市值比例
|
|
55
|
+
|
|
56
|
+
Example:
|
|
57
|
+
获取国证行业融资融券数据::
|
|
58
|
+
|
|
59
|
+
from lixinger import AsyncLixingerClient
|
|
60
|
+
|
|
61
|
+
async with AsyncLixingerClient() as client:
|
|
62
|
+
df = await client.cn_industry.margin_trading.cni.get_margin_trading(
|
|
63
|
+
stock_code="C07",
|
|
64
|
+
start_date="2025-06-13",
|
|
65
|
+
end_date="2026-06-13",
|
|
66
|
+
)
|
|
67
|
+
print(df)
|
|
68
|
+
|
|
69
|
+
"""
|
|
70
|
+
payload: dict[str, Any] = {
|
|
71
|
+
"stockCode": stock_code,
|
|
72
|
+
"startDate": start_date,
|
|
73
|
+
}
|
|
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(
|
|
80
|
+
"POST",
|
|
81
|
+
"/cn/industry/margin-trading-and-securities-lending/cni",
|
|
82
|
+
json=payload,
|
|
83
|
+
)
|
|
84
|
+
for item in data:
|
|
85
|
+
item["stockCode"] = stock_code
|
|
86
|
+
return get_response_df(data, IndustryCniMarginTrading)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# Functional API instance
|
|
90
|
+
_api_instance = IndustryCniMarginTradingAPI()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@api
|
|
94
|
+
async def get_industry_cni_margin_trading(
|
|
95
|
+
stock_code: str,
|
|
96
|
+
start_date: str,
|
|
97
|
+
end_date: str | None = None,
|
|
98
|
+
limit: int | None = None,
|
|
99
|
+
) -> pd.DataFrame:
|
|
100
|
+
"""获取国证行业融资融券数据.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
stock_code: 国证行业代码
|
|
104
|
+
start_date: 信息起始时间 (YYYY-MM-DD)
|
|
105
|
+
end_date: 结束信息日期 (YYYY-MM-DD)
|
|
106
|
+
limit: 返回最近数据的数量
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
DataFrame containing cni industry margin trading data
|
|
110
|
+
|
|
111
|
+
Example:
|
|
112
|
+
获取国证行业融资融券数据::
|
|
113
|
+
|
|
114
|
+
from lixinger import get_industry_cni_margin_trading
|
|
115
|
+
|
|
116
|
+
df = await get_industry_cni_margin_trading(
|
|
117
|
+
stock_code="C07",
|
|
118
|
+
start_date="2025-06-13",
|
|
119
|
+
end_date="2026-06-13",
|
|
120
|
+
)
|
|
121
|
+
print(df)
|
|
122
|
+
|
|
123
|
+
"""
|
|
124
|
+
return await _api_instance.get_margin_trading(
|
|
125
|
+
stock_code=stock_code,
|
|
126
|
+
start_date=start_date,
|
|
127
|
+
end_date=end_date,
|
|
128
|
+
limit=limit,
|
|
129
|
+
)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""Industry (申万) margin trading and securities lending 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.margin_trading.sw import IndustrySwMarginTrading
|
|
9
|
+
from lixinger.utils.api import api
|
|
10
|
+
from lixinger.utils.dataframe import get_response_df
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class IndustrySwMarginTradingAPI(BaseAPI):
|
|
14
|
+
"""申万行业融资融券 API."""
|
|
15
|
+
|
|
16
|
+
async def get_margin_trading(
|
|
17
|
+
self,
|
|
18
|
+
stock_code: str,
|
|
19
|
+
start_date: str,
|
|
20
|
+
end_date: str | None = None,
|
|
21
|
+
limit: int | None = None,
|
|
22
|
+
) -> pd.DataFrame:
|
|
23
|
+
"""获取申万行业融资融券数据.
|
|
24
|
+
|
|
25
|
+
获取申万(sw)行业每日的融资融券数据. 可按行业代码批量查询返回每日行业融资买入金额、
|
|
26
|
+
融资偿还金额、融资净买入金额、融资余额、融券卖出金额、融券偿还金额、
|
|
27
|
+
融券净卖出金额、融券余额等数据. 当用户想了解申万(sw)行业每日的融资融券余额
|
|
28
|
+
以及变动情况、观察杠杆资金进出节奏或分析做空力量时, 调用此接口.
|
|
29
|
+
|
|
30
|
+
API Endpoint: /cn/industry/margin-trading-and-securities-lending/sw
|
|
31
|
+
API Method: POST
|
|
32
|
+
API Doc: https://www.lixinger.com/open/api/doc?api-key=cn/industry/margin-trading-and-securities-lending/sw
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
stock_code: 申万行业代码, 请参考行业信息API获取合法的stockCode
|
|
36
|
+
start_date: 信息起始时间 (YYYY-MM-DD, 北京时间), 开始和结束的时间间隔不超过10年
|
|
37
|
+
end_date: 结束信息日期 (YYYY-MM-DD, 北京时间), 默认为今天结束
|
|
38
|
+
limit: 返回最近数据的数量
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
DataFrame containing margin trading data with columns:
|
|
42
|
+
|
|
43
|
+
- date: 数据时间
|
|
44
|
+
- stock_code: 行业代码
|
|
45
|
+
- financing_purchase_amount: 融资买入金额
|
|
46
|
+
- financing_repayment_amount: 融资偿还金额
|
|
47
|
+
- financing_net_purchase_amount: 融资净买入金额
|
|
48
|
+
- financing_balance: 融资余额
|
|
49
|
+
- securities_sell_amount: 融券卖出金额
|
|
50
|
+
- securities_repayment_amount: 融券偿还金额
|
|
51
|
+
- securities_net_sell_amount: 融券净卖出金额
|
|
52
|
+
- securities_balance: 融券余额
|
|
53
|
+
- financing_balance_to_market_cap: 融资余额占流通市值比例
|
|
54
|
+
- securities_balance_to_market_cap: 融券余额占流通市值比例
|
|
55
|
+
|
|
56
|
+
Example:
|
|
57
|
+
获取申万行业融资融券数据::
|
|
58
|
+
|
|
59
|
+
from lixinger import AsyncLixingerClient
|
|
60
|
+
|
|
61
|
+
async with AsyncLixingerClient() as client:
|
|
62
|
+
df = await client.cn_industry.margin_trading.sw.get_margin_trading(
|
|
63
|
+
stock_code="490000",
|
|
64
|
+
start_date="2025-06-13",
|
|
65
|
+
end_date="2026-06-13",
|
|
66
|
+
)
|
|
67
|
+
print(df)
|
|
68
|
+
|
|
69
|
+
"""
|
|
70
|
+
payload: dict[str, Any] = {
|
|
71
|
+
"stockCode": stock_code,
|
|
72
|
+
"startDate": start_date,
|
|
73
|
+
}
|
|
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(
|
|
80
|
+
"POST",
|
|
81
|
+
"/cn/industry/margin-trading-and-securities-lending/sw",
|
|
82
|
+
json=payload,
|
|
83
|
+
)
|
|
84
|
+
for item in data:
|
|
85
|
+
item["stockCode"] = stock_code
|
|
86
|
+
return get_response_df(data, IndustrySwMarginTrading)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# Functional API instance
|
|
90
|
+
_api_instance = IndustrySwMarginTradingAPI()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@api
|
|
94
|
+
async def get_industry_sw_margin_trading(
|
|
95
|
+
stock_code: str,
|
|
96
|
+
start_date: str,
|
|
97
|
+
end_date: str | None = None,
|
|
98
|
+
limit: int | None = None,
|
|
99
|
+
) -> pd.DataFrame:
|
|
100
|
+
"""获取申万行业融资融券数据.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
stock_code: 申万行业代码
|
|
104
|
+
start_date: 信息起始时间 (YYYY-MM-DD)
|
|
105
|
+
end_date: 结束信息日期 (YYYY-MM-DD)
|
|
106
|
+
limit: 返回最近数据的数量
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
DataFrame containing sw industry margin trading data
|
|
110
|
+
|
|
111
|
+
Example:
|
|
112
|
+
获取申万行业融资融券数据::
|
|
113
|
+
|
|
114
|
+
from lixinger import get_industry_sw_margin_trading
|
|
115
|
+
|
|
116
|
+
df = await get_industry_sw_margin_trading(
|
|
117
|
+
stock_code="490000",
|
|
118
|
+
start_date="2025-06-13",
|
|
119
|
+
end_date="2026-06-13",
|
|
120
|
+
)
|
|
121
|
+
print(df)
|
|
122
|
+
|
|
123
|
+
"""
|
|
124
|
+
return await _api_instance.get_margin_trading(
|
|
125
|
+
stock_code=stock_code,
|
|
126
|
+
start_date=start_date,
|
|
127
|
+
end_date=end_date,
|
|
128
|
+
limit=limit,
|
|
129
|
+
)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""Industry (申万2021版) margin trading and securities lending 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.margin_trading.sw_2021 import IndustrySw2021MarginTrading
|
|
9
|
+
from lixinger.utils.api import api
|
|
10
|
+
from lixinger.utils.dataframe import get_response_df
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class IndustrySw2021MarginTradingAPI(BaseAPI):
|
|
14
|
+
"""申万2021版行业融资融券 API."""
|
|
15
|
+
|
|
16
|
+
async def get_margin_trading(
|
|
17
|
+
self,
|
|
18
|
+
stock_code: str,
|
|
19
|
+
start_date: str,
|
|
20
|
+
end_date: str | None = None,
|
|
21
|
+
limit: int | None = None,
|
|
22
|
+
) -> pd.DataFrame:
|
|
23
|
+
"""获取申万2021版行业融资融券数据.
|
|
24
|
+
|
|
25
|
+
获取申万2021版行业每日的融资融券数据. 可按行业代码批量查询返回每日行业融资买入金额、
|
|
26
|
+
融资偿还金额、融资净买入金额、融资余额、融券卖出金额、融券偿还金额、
|
|
27
|
+
融券净卖出金额、融券余额等数据. 当用户想了解申万2021版行业每日的融资融券余额
|
|
28
|
+
以及变动情况、观察杠杆资金进出节奏或分析做空力量时, 调用此接口.
|
|
29
|
+
|
|
30
|
+
API Endpoint: /cn/industry/margin-trading-and-securities-lending/sw_2021
|
|
31
|
+
API Method: POST
|
|
32
|
+
API Doc: https://www.lixinger.com/open/api/doc?api-key=cn/industry/margin-trading-and-securities-lending/sw_2021
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
stock_code: 申万2021版行业代码, 请参考行业信息API获取合法的stockCode
|
|
36
|
+
start_date: 信息起始时间 (YYYY-MM-DD, 北京时间), 开始和结束的时间间隔不超过10年
|
|
37
|
+
end_date: 结束信息日期 (YYYY-MM-DD, 北京时间), 默认为今天结束
|
|
38
|
+
limit: 返回最近数据的数量
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
DataFrame containing margin trading data with columns:
|
|
42
|
+
|
|
43
|
+
- date: 数据时间
|
|
44
|
+
- stock_code: 行业代码
|
|
45
|
+
- financing_purchase_amount: 融资买入金额
|
|
46
|
+
- financing_repayment_amount: 融资偿还金额
|
|
47
|
+
- financing_net_purchase_amount: 融资净买入金额
|
|
48
|
+
- financing_balance: 融资余额
|
|
49
|
+
- securities_sell_amount: 融券卖出金额
|
|
50
|
+
- securities_repayment_amount: 融券偿还金额
|
|
51
|
+
- securities_net_sell_amount: 融券净卖出金额
|
|
52
|
+
- securities_balance: 融券余额
|
|
53
|
+
- financing_balance_to_market_cap: 融资余额占流通市值比例
|
|
54
|
+
- securities_balance_to_market_cap: 融券余额占流通市值比例
|
|
55
|
+
|
|
56
|
+
Example:
|
|
57
|
+
获取申万2021版行业融资融券数据::
|
|
58
|
+
|
|
59
|
+
from lixinger import AsyncLixingerClient
|
|
60
|
+
|
|
61
|
+
async with AsyncLixingerClient() as client:
|
|
62
|
+
df = await client.cn_industry.margin_trading.sw_2021.get_margin_trading(
|
|
63
|
+
stock_code="490000",
|
|
64
|
+
start_date="2025-06-13",
|
|
65
|
+
end_date="2026-06-13",
|
|
66
|
+
)
|
|
67
|
+
print(df)
|
|
68
|
+
|
|
69
|
+
"""
|
|
70
|
+
payload: dict[str, Any] = {
|
|
71
|
+
"stockCode": stock_code,
|
|
72
|
+
"startDate": start_date,
|
|
73
|
+
}
|
|
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(
|
|
80
|
+
"POST",
|
|
81
|
+
"/cn/industry/margin-trading-and-securities-lending/sw_2021",
|
|
82
|
+
json=payload,
|
|
83
|
+
)
|
|
84
|
+
for item in data:
|
|
85
|
+
item["stockCode"] = stock_code
|
|
86
|
+
return get_response_df(data, IndustrySw2021MarginTrading)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# Functional API instance
|
|
90
|
+
_api_instance = IndustrySw2021MarginTradingAPI()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@api
|
|
94
|
+
async def get_industry_sw_2021_margin_trading(
|
|
95
|
+
stock_code: str,
|
|
96
|
+
start_date: str,
|
|
97
|
+
end_date: str | None = None,
|
|
98
|
+
limit: int | None = None,
|
|
99
|
+
) -> pd.DataFrame:
|
|
100
|
+
"""获取申万2021版行业融资融券数据.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
stock_code: 申万2021版行业代码
|
|
104
|
+
start_date: 信息起始时间 (YYYY-MM-DD)
|
|
105
|
+
end_date: 结束信息日期 (YYYY-MM-DD)
|
|
106
|
+
limit: 返回最近数据的数量
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
DataFrame containing sw_2021 industry margin trading data
|
|
110
|
+
|
|
111
|
+
Example:
|
|
112
|
+
获取申万2021版行业融资融券数据::
|
|
113
|
+
|
|
114
|
+
from lixinger import get_industry_sw_2021_margin_trading
|
|
115
|
+
|
|
116
|
+
df = await get_industry_sw_2021_margin_trading(
|
|
117
|
+
stock_code="490000",
|
|
118
|
+
start_date="2025-06-13",
|
|
119
|
+
end_date="2026-06-13",
|
|
120
|
+
)
|
|
121
|
+
print(df)
|
|
122
|
+
|
|
123
|
+
"""
|
|
124
|
+
return await _api_instance.get_margin_trading(
|
|
125
|
+
stock_code=stock_code,
|
|
126
|
+
start_date=start_date,
|
|
127
|
+
end_date=end_date,
|
|
128
|
+
limit=limit,
|
|
129
|
+
)
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""Industry namespace for grouping related APIs."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import pandas as pd
|
|
6
|
+
|
|
7
|
+
from lixinger.api.cn.industry.margin_trading.cni import IndustryCniMarginTradingAPI
|
|
8
|
+
from lixinger.api.cn.industry.margin_trading.sw import IndustrySwMarginTradingAPI
|
|
9
|
+
from lixinger.api.cn.industry.margin_trading.sw_2021 import (
|
|
10
|
+
IndustrySw2021MarginTradingAPI,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class IndustryMarginTradingNamespace:
|
|
15
|
+
"""Namespace for industry margin trading APIs.
|
|
16
|
+
|
|
17
|
+
Groups all industry margin trading APIs by industry classification system:
|
|
18
|
+
|
|
19
|
+
- sw: 申万行业 (Shenwan / SW)
|
|
20
|
+
- sw_2021: 申万2021版行业 (Shenwan 2021)
|
|
21
|
+
- cni: 国证行业 (CNI)
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
sw: IndustrySwMarginTradingAPI,
|
|
28
|
+
sw_2021: IndustrySw2021MarginTradingAPI,
|
|
29
|
+
cni: IndustryCniMarginTradingAPI,
|
|
30
|
+
) -> None:
|
|
31
|
+
"""Initialize the industry margin trading namespace.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
sw: 申万行业融资融券 API
|
|
35
|
+
sw_2021: 申万2021版行业融资融券 API
|
|
36
|
+
cni: 国证行业融资融券 API
|
|
37
|
+
|
|
38
|
+
"""
|
|
39
|
+
self.sw = sw
|
|
40
|
+
self.sw_2021 = sw_2021
|
|
41
|
+
self.cni = cni
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class IndustryNamespace:
|
|
45
|
+
"""Namespace for industry-related APIs.
|
|
46
|
+
|
|
47
|
+
This class groups all industry-related APIs under a single namespace.
|
|
48
|
+
Access APIs via their specific attributes:
|
|
49
|
+
|
|
50
|
+
- margin_trading: 行业融资融券 API 组
|
|
51
|
+
- margin_trading.sw: 申万行业
|
|
52
|
+
- margin_trading.sw_2021: 申万2021版行业
|
|
53
|
+
- margin_trading.cni: 国证行业
|
|
54
|
+
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
def __init__(
|
|
58
|
+
self,
|
|
59
|
+
margin_trading_sw: IndustrySwMarginTradingAPI,
|
|
60
|
+
margin_trading_sw_2021: IndustrySw2021MarginTradingAPI,
|
|
61
|
+
margin_trading_cni: IndustryCniMarginTradingAPI,
|
|
62
|
+
) -> None:
|
|
63
|
+
"""Initialize the industry namespace.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
margin_trading_sw: 申万行业融资融券 API
|
|
67
|
+
margin_trading_sw_2021: 申万2021版行业融资融券 API
|
|
68
|
+
margin_trading_cni: 国证行业融资融券 API
|
|
69
|
+
|
|
70
|
+
"""
|
|
71
|
+
self.margin_trading = IndustryMarginTradingNamespace(
|
|
72
|
+
sw=margin_trading_sw,
|
|
73
|
+
sw_2021=margin_trading_sw_2021,
|
|
74
|
+
cni=margin_trading_cni,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# Convenience aliases for shorter access
|
|
78
|
+
async def get_sw_margin_trading(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
79
|
+
"""Alias for margin_trading.sw.get_margin_trading."""
|
|
80
|
+
return await self.margin_trading.sw.get_margin_trading(*args, **kwargs)
|
|
81
|
+
|
|
82
|
+
async def get_sw_2021_margin_trading(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
83
|
+
"""Alias for margin_trading.sw_2021.get_margin_trading."""
|
|
84
|
+
return await self.margin_trading.sw_2021.get_margin_trading(*args, **kwargs)
|
|
85
|
+
|
|
86
|
+
async def get_cni_margin_trading(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
87
|
+
"""Alias for margin_trading.cni.get_margin_trading."""
|
|
88
|
+
return await self.margin_trading.cni.get_margin_trading(*args, **kwargs)
|
lixinger/client.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from types import TracebackType
|
|
2
|
+
|
|
1
3
|
import httpx
|
|
2
4
|
|
|
3
5
|
from lixinger.api.cn.company.announcement import AnnouncementAPI
|
|
@@ -42,6 +44,12 @@ from lixinger.api.cn.index import (
|
|
|
42
44
|
TrackingFundAPI,
|
|
43
45
|
)
|
|
44
46
|
from lixinger.api.cn.index.namespace import IndexNamespace
|
|
47
|
+
from lixinger.api.cn.industry import (
|
|
48
|
+
IndustryCniMarginTradingAPI,
|
|
49
|
+
IndustrySw2021MarginTradingAPI,
|
|
50
|
+
IndustrySwMarginTradingAPI,
|
|
51
|
+
)
|
|
52
|
+
from lixinger.api.cn.industry.namespace import IndustryNamespace
|
|
45
53
|
from lixinger.config import get_config_from_env
|
|
46
54
|
from lixinger.utils.rate_limiter import AsyncRateLimiter
|
|
47
55
|
|
|
@@ -62,7 +70,7 @@ class AsyncLixingerClient:
|
|
|
62
70
|
max_retries: int | None = None,
|
|
63
71
|
proxy: str | None = None,
|
|
64
72
|
max_requests_per_minute: int = 1000,
|
|
65
|
-
):
|
|
73
|
+
) -> None:
|
|
66
74
|
"""Initialize the async Lixinger API client.
|
|
67
75
|
|
|
68
76
|
The API key is ALWAYS loaded from the LIXINGER_API_KEY environment variable.
|
|
@@ -222,6 +230,25 @@ class AsyncLixingerClient:
|
|
|
222
230
|
self.cn_index_fs_security = cn_index_fs_security
|
|
223
231
|
self.cn_index_fs_hybrid = cn_index_fs_hybrid
|
|
224
232
|
|
|
233
|
+
# Industry APIs
|
|
234
|
+
cn_industry_margin_trading_sw = IndustrySwMarginTradingAPI(self._http_client, self.config, self._rate_limiter)
|
|
235
|
+
cn_industry_margin_trading_sw_2021 = IndustrySw2021MarginTradingAPI(
|
|
236
|
+
self._http_client, self.config, self._rate_limiter
|
|
237
|
+
)
|
|
238
|
+
cn_industry_margin_trading_cni = IndustryCniMarginTradingAPI(self._http_client, self.config, self._rate_limiter)
|
|
239
|
+
|
|
240
|
+
# Industry namespace (groups all industry APIs)
|
|
241
|
+
self.cn_industry = IndustryNamespace(
|
|
242
|
+
margin_trading_sw=cn_industry_margin_trading_sw,
|
|
243
|
+
margin_trading_sw_2021=cn_industry_margin_trading_sw_2021,
|
|
244
|
+
margin_trading_cni=cn_industry_margin_trading_cni,
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
# Legacy flat access for industry APIs (deprecated, for backward compatibility)
|
|
248
|
+
self.cn_industry_margin_trading_sw = cn_industry_margin_trading_sw
|
|
249
|
+
self.cn_industry_margin_trading_sw_2021 = cn_industry_margin_trading_sw_2021
|
|
250
|
+
self.cn_industry_margin_trading_cni = cn_industry_margin_trading_cni
|
|
251
|
+
|
|
225
252
|
# Fund APIs
|
|
226
253
|
self.cn_fund = FundAPI(self._http_client, self.config, self._rate_limiter)
|
|
227
254
|
self.cn_fund_profile = FundProfileAPI(self._http_client, self.config, self._rate_limiter)
|
|
@@ -233,13 +260,18 @@ class AsyncLixingerClient:
|
|
|
233
260
|
)
|
|
234
261
|
self.cn_fund_announcement = FundAnnouncementAPI(self._http_client, self.config, self._rate_limiter)
|
|
235
262
|
|
|
236
|
-
async def __aenter__(self):
|
|
263
|
+
async def __aenter__(self) -> "AsyncLixingerClient":
|
|
237
264
|
return self
|
|
238
265
|
|
|
239
|
-
async def __aexit__(
|
|
266
|
+
async def __aexit__(
|
|
267
|
+
self,
|
|
268
|
+
exc_type: type[BaseException] | None,
|
|
269
|
+
exc_val: BaseException | None,
|
|
270
|
+
exc_tb: TracebackType | None,
|
|
271
|
+
) -> None:
|
|
240
272
|
await self.close()
|
|
241
273
|
|
|
242
|
-
async def close(self):
|
|
274
|
+
async def close(self) -> None:
|
|
243
275
|
"""Close the underlying HTTP client."""
|
|
244
276
|
await self._http_client.aclose()
|
|
245
277
|
|
|
@@ -253,6 +285,11 @@ class AsyncLixingerClient:
|
|
|
253
285
|
"""Alias for cn_index."""
|
|
254
286
|
return self.cn_index
|
|
255
287
|
|
|
288
|
+
@property
|
|
289
|
+
def industry(self) -> IndustryNamespace:
|
|
290
|
+
"""Alias for cn_industry."""
|
|
291
|
+
return self.cn_industry
|
|
292
|
+
|
|
256
293
|
@property
|
|
257
294
|
def candlestick(self) -> CandlestickAPI:
|
|
258
295
|
"""Alias for cn_company_candlestick."""
|
lixinger/exceptions.py
CHANGED
|
@@ -5,7 +5,7 @@ class LixingerError(Exception):
|
|
|
5
5
|
class APIError(LixingerError):
|
|
6
6
|
"""API request failed."""
|
|
7
7
|
|
|
8
|
-
def __init__(self, message: str, status_code: int | None = None):
|
|
8
|
+
def __init__(self, message: str, status_code: int | None = None) -> None:
|
|
9
9
|
super().__init__(message)
|
|
10
10
|
self.status_code = status_code
|
|
11
11
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Industry-related models."""
|
|
2
|
+
|
|
3
|
+
from lixinger.models.cn.industry.margin_trading import (
|
|
4
|
+
IndustryCniMarginTrading,
|
|
5
|
+
IndustrySw2021MarginTrading,
|
|
6
|
+
IndustrySwMarginTrading,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"IndustryCniMarginTrading",
|
|
11
|
+
"IndustrySw2021MarginTrading",
|
|
12
|
+
"IndustrySwMarginTrading",
|
|
13
|
+
]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Industry margin trading and securities lending models."""
|
|
2
|
+
|
|
3
|
+
from lixinger.models.cn.industry.margin_trading.cni import IndustryCniMarginTrading
|
|
4
|
+
from lixinger.models.cn.industry.margin_trading.sw import IndustrySwMarginTrading
|
|
5
|
+
from lixinger.models.cn.industry.margin_trading.sw_2021 import IndustrySw2021MarginTrading
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"IndustryCniMarginTrading",
|
|
9
|
+
"IndustrySw2021MarginTrading",
|
|
10
|
+
"IndustrySwMarginTrading",
|
|
11
|
+
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Industry (国证) margin trading and securities lending model."""
|
|
2
|
+
|
|
3
|
+
import pandera.pandas as pa
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class IndustryCniMarginTrading(pa.DataFrameModel):
|
|
7
|
+
"""国证行业融资融券数据模型.
|
|
8
|
+
|
|
9
|
+
表示单个国证行业每日的融资(financing)与融券(securities lending)指标.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
class Config:
|
|
13
|
+
"""Pandera configuration."""
|
|
14
|
+
|
|
15
|
+
coerce = True
|
|
16
|
+
strict = False
|
|
17
|
+
|
|
18
|
+
date: pa.typing.Series[pa.typing.DateTime]
|
|
19
|
+
stock_code: pa.typing.Series[str]
|
|
20
|
+
financing_purchase_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
21
|
+
financing_repayment_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
22
|
+
financing_net_purchase_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
23
|
+
financing_balance: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
24
|
+
securities_sell_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
25
|
+
securities_repayment_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
26
|
+
securities_net_sell_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
27
|
+
securities_balance: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
28
|
+
financing_balance_to_market_cap: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
29
|
+
securities_balance_to_market_cap: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Industry (申万) margin trading and securities lending model."""
|
|
2
|
+
|
|
3
|
+
import pandera.pandas as pa
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class IndustrySwMarginTrading(pa.DataFrameModel):
|
|
7
|
+
"""申万行业融资融券数据模型.
|
|
8
|
+
|
|
9
|
+
表示单个申万行业每日的融资(financing)与融券(securities lending)指标.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
class Config:
|
|
13
|
+
"""Pandera configuration."""
|
|
14
|
+
|
|
15
|
+
coerce = True
|
|
16
|
+
strict = False
|
|
17
|
+
|
|
18
|
+
date: pa.typing.Series[pa.typing.DateTime]
|
|
19
|
+
stock_code: pa.typing.Series[str]
|
|
20
|
+
financing_purchase_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
21
|
+
financing_repayment_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
22
|
+
financing_net_purchase_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
23
|
+
financing_balance: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
24
|
+
securities_sell_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
25
|
+
securities_repayment_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
26
|
+
securities_net_sell_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
27
|
+
securities_balance: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
28
|
+
financing_balance_to_market_cap: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
29
|
+
securities_balance_to_market_cap: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Industry (申万2021版) margin trading and securities lending model."""
|
|
2
|
+
|
|
3
|
+
import pandera.pandas as pa
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class IndustrySw2021MarginTrading(pa.DataFrameModel):
|
|
7
|
+
"""申万2021版行业融资融券数据模型.
|
|
8
|
+
|
|
9
|
+
表示单个申万2021版行业每日的融资(financing)与融券(securities lending)指标.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
class Config:
|
|
13
|
+
"""Pandera configuration."""
|
|
14
|
+
|
|
15
|
+
coerce = True
|
|
16
|
+
strict = False
|
|
17
|
+
|
|
18
|
+
date: pa.typing.Series[pa.typing.DateTime]
|
|
19
|
+
stock_code: pa.typing.Series[str]
|
|
20
|
+
financing_purchase_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
21
|
+
financing_repayment_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
22
|
+
financing_net_purchase_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
23
|
+
financing_balance: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
24
|
+
securities_sell_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
25
|
+
securities_repayment_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
26
|
+
securities_net_sell_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
27
|
+
securities_balance: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
28
|
+
financing_balance_to_market_cap: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
29
|
+
securities_balance_to_market_cap: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
lixinger/utils/rate_limiter.py
CHANGED
|
@@ -6,7 +6,7 @@ import time
|
|
|
6
6
|
class AsyncRateLimiter:
|
|
7
7
|
"""Async token bucket rate limiter."""
|
|
8
8
|
|
|
9
|
-
def __init__(self, max_requests: int, window: float = 60.0):
|
|
9
|
+
def __init__(self, max_requests: int, window: float = 60.0) -> None:
|
|
10
10
|
self.max_requests = max_requests
|
|
11
11
|
self.window = window
|
|
12
12
|
self.requests: deque[float] = deque()
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
lixinger/__init__.py,sha256=
|
|
2
|
-
lixinger/client.py,sha256=
|
|
1
|
+
lixinger/__init__.py,sha256=mDw-kB3UVdtderRekHCA2xPsWr2GiPuBPyBOelEkgE0,3055
|
|
2
|
+
lixinger/client.py,sha256=EXxE1hEczIaVpe3HxgQ7wWd71YjzkRNIAitPnhyV9MY,14290
|
|
3
3
|
lixinger/config.py,sha256=JPz8EOrf1kP4Do-Z5-MsnOM0pMrNE1ZsP-Qoarh9y4c,2008
|
|
4
|
-
lixinger/exceptions.py,sha256=
|
|
4
|
+
lixinger/exceptions.py,sha256=haJOQzZinH0tKk_e2BTUzJfPbtnyLHyRR7HSnWHeKfk,516
|
|
5
5
|
lixinger/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
lixinger/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
lixinger/api/base.py,sha256=
|
|
7
|
+
lixinger/api/base.py,sha256=j90uXrBEIHyPkTu-4hF1876HtsWIPM_J7tunFi-1O1Q,3182
|
|
8
8
|
lixinger/api/cn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
lixinger/api/cn/company/__init__.py,sha256=K8aNp2gGj4iQOvc8KjXA5668QUAhwyTfMBPhP3tgtMg,961
|
|
10
10
|
lixinger/api/cn/company/announcement.py,sha256=lYt4AWOV5b9OTKfvJ7ZOqWP61pcPcyIQzb5N2DqFT6k,1920
|
|
@@ -13,7 +13,7 @@ lixinger/api/cn/company/company.py,sha256=D6yhmFPzhdWadBsNka-8h4mkbKjD4HoBFQCw72
|
|
|
13
13
|
lixinger/api/cn/company/dividend.py,sha256=21AWQbi56G7wVf8sv_YSy-Qy36OFKSvB9L2M3cbslGc,2658
|
|
14
14
|
lixinger/api/cn/company/equity_change.py,sha256=hf2SZhvCcYvu1lRhEz-b61yo9D7mDckKJSerAxGvsXI,2356
|
|
15
15
|
lixinger/api/cn/company/indices.py,sha256=GFoCf58DDh1a4Fx4lGaqPmk9NBW0hlRbnaIYoXBtFXI,1161
|
|
16
|
-
lixinger/api/cn/company/namespace.py,sha256=
|
|
16
|
+
lixinger/api/cn/company/namespace.py,sha256=0YVK79MZJpH6p70vdNFgjkm0K0bc4QO9feFq8B3mYJY,6878
|
|
17
17
|
lixinger/api/cn/company/profile.py,sha256=iMwR5REcJNhKvS3hpWg6bCD1DOH-7fSN21zoIeRIh3k,1691
|
|
18
18
|
lixinger/api/cn/company/fs/__init__.py,sha256=B21nlQ_kwTvtwGbRovbsPQfDuj5rf3YqNp03orgpV0g,1281
|
|
19
19
|
lixinger/api/cn/company/fs/bank.py,sha256=rdUvFNVWwF1ZCMzy_a6Sc7e-NUykb8OfU4MnAL-EUI4,4514
|
|
@@ -43,13 +43,19 @@ lixinger/api/cn/index/drawdown.py,sha256=D-fhA-Sv2-gf6VzX0zG1dm7Tn5Wy7NK1IB-f5kF
|
|
|
43
43
|
lixinger/api/cn/index/fundamental.py,sha256=MyhGmMk7GkOZflpT0JMoiLsCs3DLMLLkopyUsD94Y4Q,2474
|
|
44
44
|
lixinger/api/cn/index/index.py,sha256=5gDwE5K3tYNlCrV-EsSC4HXhfIi58uqWpHQxTt9LJMk,4177
|
|
45
45
|
lixinger/api/cn/index/margin_trading.py,sha256=Tr5nXXC5H38FoAB5RoiTysr2wQEB0K4i4eKcEZnV4dw,4161
|
|
46
|
-
lixinger/api/cn/index/namespace.py,sha256=
|
|
46
|
+
lixinger/api/cn/index/namespace.py,sha256=GQrvboQiqXOpY7KULhIt-BwOqYktpelHp-fSQUSq120,6413
|
|
47
47
|
lixinger/api/cn/index/tracking_fund.py,sha256=su0zJRROKuTZlHe0XkIQz8kJOyPZmyg7HxZIbmpM_YM,1960
|
|
48
48
|
lixinger/api/cn/index/fs/__init__.py,sha256=eQTxjzZfiqxDU8WdLA-deAtus-nYEiO2mLq2gOkFTts,1060
|
|
49
49
|
lixinger/api/cn/index/fs/bank.py,sha256=zjDB_d06E_gxAvVNyk9Byoa5ShlevNoc75z5gVBH6aY,4416
|
|
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=RyBtbJuc-4DEgcpv3soXtmCI_NJtHlD-HiG96Ehwo9Q,583
|
|
54
|
+
lixinger/api/cn/industry/namespace.py,sha256=GBl4gYrP6CYp9qeC7UelID2qhzrk4DeK_uh5F_G1rhM,2966
|
|
55
|
+
lixinger/api/cn/industry/margin_trading/__init__.py,sha256=4JZDCF6v2TPg9uyBLKXAfHKVrDGpshjQkoJejdKwCC4,944
|
|
56
|
+
lixinger/api/cn/industry/margin_trading/cni.py,sha256=7IqidE2N2_INiVybeiTt5qFRUY4PJsY6nUPEGtdWJlM,4600
|
|
57
|
+
lixinger/api/cn/industry/margin_trading/sw.py,sha256=hjC5Uf7XXSwiiqoloIWFx5nDzbxd_D5bB1QPQCEjUjg,4591
|
|
58
|
+
lixinger/api/cn/industry/margin_trading/sw_2021.py,sha256=uZWAiIdPPLWnvYduAULPythgzgNzLFeVkqP5OEMq_vw,4706
|
|
53
59
|
lixinger/models/__init__.py,sha256=OAUYpI_JaGZExFqZ0H6l8fJ5qyLW0oFnnO4JGJQknTE,154
|
|
54
60
|
lixinger/models/cn/__init__.py,sha256=mhTq_PfPJ_0720E1rTKdqBTpb9A14_ZDDWLfJXjcVck,27
|
|
55
61
|
lixinger/models/cn/company/__init__.py,sha256=7E7p1NED5qr0yf_wcmOq_DDvOq2hzXv3bD4cLjHTtSQ,957
|
|
@@ -93,13 +99,18 @@ lixinger/models/cn/index/fs/bank.py,sha256=DA_sRFSsK5IE0JQtp3pHdvPJQxbipHsSyKahc
|
|
|
93
99
|
lixinger/models/cn/index/fs/hybrid.py,sha256=AlCoEfkkPdWGxE_K71rBKgwWpR4iWTaMJ8bc56YxYrk,565
|
|
94
100
|
lixinger/models/cn/index/fs/non_financial.py,sha256=UpWXDDMiOdJN6WNc5R-PsHy9l9Th3xsKnOjUbID4Gug,585
|
|
95
101
|
lixinger/models/cn/index/fs/security.py,sha256=VTYDvTQ5CKhqZsXeEyWqFNvugZ4UA3CLW0DkYTrOHtc,571
|
|
102
|
+
lixinger/models/cn/industry/__init__.py,sha256=TlUmf_uAoCdyO8uNJDoXWUV7-P8C3H8FLJKF8HN2b9Q,296
|
|
103
|
+
lixinger/models/cn/industry/margin_trading/__init__.py,sha256=JHzyvqzawYkgHa3HPNcY1B58PN2SZe-ZXhThHXlmSJ8,432
|
|
104
|
+
lixinger/models/cn/industry/margin_trading/cni.py,sha256=D8O-SXFR1_6lboRzMMNxaLA3KnSlHHeS1N5kjUIUPrs,1375
|
|
105
|
+
lixinger/models/cn/industry/margin_trading/sw.py,sha256=GyBhpZxSm1aoQHdzJvjb5INp_lrTFh4Alp2WaDyPhVM,1374
|
|
106
|
+
lixinger/models/cn/industry/margin_trading/sw_2021.py,sha256=JWdEVXarlKso3JOpMJ7zvkw-I5tsLlXagJFXEJxYC3s,1399
|
|
96
107
|
lixinger/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
97
108
|
lixinger/utils/api.py,sha256=BktR40JtKCMe9excFWo4ujsq3GiQK4ypJLG3MpJgo2s,402
|
|
98
109
|
lixinger/utils/dataframe.py,sha256=tYBrNdmJ4poyuwD-9XgzHt3A_A8bBo0cdHiu8Yy9e9A,2208
|
|
99
110
|
lixinger/utils/dict.py,sha256=yvbUtv8QpRmy0d_o_7gCuEwwiEfBji5_xB490ANxilw,589
|
|
100
|
-
lixinger/utils/rate_limiter.py,sha256=
|
|
111
|
+
lixinger/utils/rate_limiter.py,sha256=ZHlRTTL60L62uRA_f--LD26qkAfk-pHBllRqPapAXQM,1141
|
|
101
112
|
lixinger/utils/retry.py,sha256=sXtb0ESp12_JedjzDxoeIH48TlOrbxtIA0j1V33DW7M,1026
|
|
102
|
-
lixinger_python-0.3.
|
|
103
|
-
lixinger_python-0.3.
|
|
104
|
-
lixinger_python-0.3.
|
|
105
|
-
lixinger_python-0.3.
|
|
113
|
+
lixinger_python-0.3.11.dist-info/METADATA,sha256=wqCIHQktxMBfmP8Wzz45QT1_belv6nIcck0YZ_Dhkhg,9207
|
|
114
|
+
lixinger_python-0.3.11.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
115
|
+
lixinger_python-0.3.11.dist-info/licenses/LICENSE,sha256=5oOwRq1lHSOScbNGCHr2feuNnhNYdGcArj6fSUfsC5U,1064
|
|
116
|
+
lixinger_python-0.3.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|