lixinger-python 0.3.8__py3-none-any.whl → 0.3.10__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 +2 -0
- lixinger/api/base.py +1 -1
- lixinger/api/cn/company/namespace.py +3 -3
- lixinger/api/cn/index/__init__.py +6 -0
- lixinger/api/cn/index/margin_trading.py +117 -0
- lixinger/api/cn/index/namespace.py +29 -16
- lixinger/client.py +15 -4
- lixinger/exceptions.py +1 -1
- lixinger/models/cn/index/__init__.py +2 -0
- lixinger/models/cn/index/margin_trading.py +30 -0
- lixinger/utils/rate_limiter.py +1 -1
- {lixinger_python-0.3.8.dist-info → lixinger_python-0.3.10.dist-info}/METADATA +1 -1
- {lixinger_python-0.3.8.dist-info → lixinger_python-0.3.10.dist-info}/RECORD +15 -13
- {lixinger_python-0.3.8.dist-info → lixinger_python-0.3.10.dist-info}/WHEEL +0 -0
- {lixinger_python-0.3.8.dist-info → lixinger_python-0.3.10.dist-info}/licenses/LICENSE +0 -0
lixinger/__init__.py
CHANGED
|
@@ -34,6 +34,7 @@ from lixinger.api.cn.index import (
|
|
|
34
34
|
get_index_bank_statements,
|
|
35
35
|
get_index_fundamental,
|
|
36
36
|
get_index_hybrid_statements,
|
|
37
|
+
get_index_margin_trading,
|
|
37
38
|
get_index_non_financial_statements,
|
|
38
39
|
get_index_security_statements,
|
|
39
40
|
get_tracking_fund,
|
|
@@ -75,6 +76,7 @@ __all__ = [
|
|
|
75
76
|
"get_constituent_weightings",
|
|
76
77
|
"get_index_fundamental",
|
|
77
78
|
"get_tracking_fund",
|
|
79
|
+
"get_index_margin_trading",
|
|
78
80
|
"get_candlestick",
|
|
79
81
|
"get_index_candlestick",
|
|
80
82
|
"get_index_drawdown",
|
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:
|
|
@@ -22,6 +22,10 @@ from lixinger.api.cn.index.fundamental import (
|
|
|
22
22
|
get_index_fundamental,
|
|
23
23
|
)
|
|
24
24
|
from lixinger.api.cn.index.index import IndexAPI, get_index
|
|
25
|
+
from lixinger.api.cn.index.margin_trading import (
|
|
26
|
+
IndexMarginTradingAPI,
|
|
27
|
+
get_index_margin_trading,
|
|
28
|
+
)
|
|
25
29
|
from lixinger.api.cn.index.tracking_fund import TrackingFundAPI, get_tracking_fund
|
|
26
30
|
|
|
27
31
|
__all__ = [
|
|
@@ -37,6 +41,8 @@ __all__ = [
|
|
|
37
41
|
"get_drawdown",
|
|
38
42
|
"IndexFundamentalAPI",
|
|
39
43
|
"get_index_fundamental",
|
|
44
|
+
"IndexMarginTradingAPI",
|
|
45
|
+
"get_index_margin_trading",
|
|
40
46
|
"TrackingFundAPI",
|
|
41
47
|
"get_tracking_fund",
|
|
42
48
|
# Index financial statements
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""Index 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.index.margin_trading import IndexMarginTrading
|
|
9
|
+
from lixinger.utils.api import api
|
|
10
|
+
from lixinger.utils.dataframe import get_response_df
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class IndexMarginTradingAPI(BaseAPI):
|
|
14
|
+
"""Index margin trading and securities lending APIs."""
|
|
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
|
+
获取大陆指数每日的融资融券数据. 可按指数代码批量查询返回每日指数融资买入金额、
|
|
26
|
+
融资偿还金额、融资净买入金额、融资余额、融券卖出金额、融券偿还金额、
|
|
27
|
+
融券净卖出金额、融券余额等数据. 当用户想了解某指数每日的融资融券余额以及变动情况、
|
|
28
|
+
观察杠杆资金进出节奏或分析做空力量时, 调用此接口.
|
|
29
|
+
|
|
30
|
+
API Endpoint: /cn/index/margin-trading-and-securities-lending
|
|
31
|
+
API Method: POST
|
|
32
|
+
API Doc: https://www.lixinger.com/open/api/doc?api-key=cn/index/margin-trading-and-securities-lending
|
|
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
|
+
获取上证50指数融资融券数据::
|
|
58
|
+
|
|
59
|
+
from lixinger import AsyncLixingerClient
|
|
60
|
+
|
|
61
|
+
async with AsyncLixingerClient() as client:
|
|
62
|
+
df = await client.cn_index.margin_trading.get_margin_trading(
|
|
63
|
+
stock_code="000016",
|
|
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/index/margin-trading-and-securities-lending",
|
|
82
|
+
json=payload,
|
|
83
|
+
)
|
|
84
|
+
for item in data:
|
|
85
|
+
item["stockCode"] = stock_code
|
|
86
|
+
return get_response_df(data, IndexMarginTrading)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# Functional API instance
|
|
90
|
+
_api_instance = IndexMarginTradingAPI()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@api
|
|
94
|
+
async def get_index_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 index margin trading data
|
|
110
|
+
|
|
111
|
+
"""
|
|
112
|
+
return await _api_instance.get_margin_trading(
|
|
113
|
+
stock_code=stock_code,
|
|
114
|
+
start_date=start_date,
|
|
115
|
+
end_date=end_date,
|
|
116
|
+
limit=limit,
|
|
117
|
+
)
|
|
@@ -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
|
|
@@ -10,6 +14,7 @@ from lixinger.api.cn.index.fs.non_financial import IndexNonFinancialStatementAPI
|
|
|
10
14
|
from lixinger.api.cn.index.fs.security import IndexSecurityStatementAPI
|
|
11
15
|
from lixinger.api.cn.index.fundamental import IndexFundamentalAPI
|
|
12
16
|
from lixinger.api.cn.index.index import IndexAPI
|
|
17
|
+
from lixinger.api.cn.index.margin_trading import IndexMarginTradingAPI
|
|
13
18
|
from lixinger.api.cn.index.tracking_fund import TrackingFundAPI
|
|
14
19
|
|
|
15
20
|
|
|
@@ -31,7 +36,7 @@ class IndexFSNamespace:
|
|
|
31
36
|
bank: IndexBankStatementAPI,
|
|
32
37
|
security: IndexSecurityStatementAPI,
|
|
33
38
|
hybrid: IndexHybridStatementAPI,
|
|
34
|
-
):
|
|
39
|
+
) -> None:
|
|
35
40
|
"""Initialize the index financial statement namespace.
|
|
36
41
|
|
|
37
42
|
Args:
|
|
@@ -60,6 +65,7 @@ class IndexNamespace:
|
|
|
60
65
|
- candlestick: Index candlestick data API (get_candlestick)
|
|
61
66
|
- drawdown: Index drawdown data API (get_drawdown)
|
|
62
67
|
- tracking_fund: Index tracking fund API (get_tracking_fund)
|
|
68
|
+
- margin_trading: Index margin trading API (get_margin_trading)
|
|
63
69
|
- fs: Index financial statement APIs (sub-APIs for different index types)
|
|
64
70
|
- fs.non_financial: Non-financial index statements
|
|
65
71
|
- fs.bank: Bank index statements
|
|
@@ -77,11 +83,12 @@ class IndexNamespace:
|
|
|
77
83
|
candlestick: IndexCandlestickAPI,
|
|
78
84
|
drawdown: DrawdownAPI,
|
|
79
85
|
tracking_fund: TrackingFundAPI,
|
|
86
|
+
margin_trading: IndexMarginTradingAPI,
|
|
80
87
|
fs_non_financial: IndexNonFinancialStatementAPI,
|
|
81
88
|
fs_bank: IndexBankStatementAPI,
|
|
82
89
|
fs_security: IndexSecurityStatementAPI,
|
|
83
90
|
fs_hybrid: IndexHybridStatementAPI,
|
|
84
|
-
):
|
|
91
|
+
) -> None:
|
|
85
92
|
"""Initialize the index namespace.
|
|
86
93
|
|
|
87
94
|
Args:
|
|
@@ -92,6 +99,7 @@ class IndexNamespace:
|
|
|
92
99
|
candlestick: Index candlestick data API
|
|
93
100
|
drawdown: Index drawdown data API
|
|
94
101
|
tracking_fund: Index tracking fund API
|
|
102
|
+
margin_trading: Index margin trading and securities lending API
|
|
95
103
|
fs_non_financial: Non-financial index statement API
|
|
96
104
|
fs_bank: Bank index statement API
|
|
97
105
|
fs_security: Security index statement API
|
|
@@ -105,6 +113,7 @@ class IndexNamespace:
|
|
|
105
113
|
self.candlestick = candlestick
|
|
106
114
|
self.drawdown = drawdown
|
|
107
115
|
self.tracking_fund = tracking_fund
|
|
116
|
+
self.margin_trading = margin_trading
|
|
108
117
|
self.fs = IndexFSNamespace(
|
|
109
118
|
non_financial=fs_non_financial,
|
|
110
119
|
bank=fs_bank,
|
|
@@ -113,30 +122,34 @@ class IndexNamespace:
|
|
|
113
122
|
)
|
|
114
123
|
|
|
115
124
|
# Convenience aliases for shorter access
|
|
116
|
-
def get_index(self, *args, **kwargs):
|
|
125
|
+
async def get_index(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
117
126
|
"""Alias for index.get_index."""
|
|
118
|
-
return self.index.get_index(*args, **kwargs)
|
|
127
|
+
return await self.index.get_index(*args, **kwargs)
|
|
119
128
|
|
|
120
|
-
def get_constituents(self, *args, **kwargs):
|
|
129
|
+
async def get_constituents(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
121
130
|
"""Alias for constituents.get_constituents."""
|
|
122
|
-
return self.constituents.get_constituents(*args, **kwargs)
|
|
131
|
+
return await self.constituents.get_constituents(*args, **kwargs)
|
|
123
132
|
|
|
124
|
-
def get_constituent_weightings(self, *args, **kwargs):
|
|
133
|
+
async def get_constituent_weightings(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
125
134
|
"""Alias for constituent_weightings.get_constituent_weightings."""
|
|
126
|
-
return self.constituent_weightings.get_constituent_weightings(*args, **kwargs)
|
|
135
|
+
return await self.constituent_weightings.get_constituent_weightings(*args, **kwargs)
|
|
127
136
|
|
|
128
|
-
def get_fundamental(self, *args, **kwargs):
|
|
137
|
+
async def get_fundamental(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
129
138
|
"""Alias for fundamental.get_fundamental."""
|
|
130
|
-
return self.fundamental.get_fundamental(*args, **kwargs)
|
|
139
|
+
return await self.fundamental.get_fundamental(*args, **kwargs)
|
|
131
140
|
|
|
132
|
-
def get_candlestick(self, *args, **kwargs):
|
|
141
|
+
async def get_candlestick(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
133
142
|
"""Alias for candlestick.get_candlestick."""
|
|
134
|
-
return self.candlestick.get_candlestick(*args, **kwargs)
|
|
143
|
+
return await self.candlestick.get_candlestick(*args, **kwargs)
|
|
135
144
|
|
|
136
|
-
def get_drawdown(self, *args, **kwargs):
|
|
145
|
+
async def get_drawdown(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
137
146
|
"""Alias for drawdown.get_drawdown."""
|
|
138
|
-
return self.drawdown.get_drawdown(*args, **kwargs)
|
|
147
|
+
return await self.drawdown.get_drawdown(*args, **kwargs)
|
|
139
148
|
|
|
140
|
-
def get_tracking_fund(self, *args, **kwargs):
|
|
149
|
+
async def get_tracking_fund(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
141
150
|
"""Alias for tracking_fund.get_tracking_fund."""
|
|
142
|
-
return self.tracking_fund.get_tracking_fund(*args, **kwargs)
|
|
151
|
+
return await self.tracking_fund.get_tracking_fund(*args, **kwargs)
|
|
152
|
+
|
|
153
|
+
async def get_margin_trading(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
|
|
154
|
+
"""Alias for margin_trading.get_margin_trading."""
|
|
155
|
+
return await self.margin_trading.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
|
|
@@ -36,6 +38,7 @@ from lixinger.api.cn.index import (
|
|
|
36
38
|
IndexCandlestickAPI,
|
|
37
39
|
IndexFundamentalAPI,
|
|
38
40
|
IndexHybridStatementAPI,
|
|
41
|
+
IndexMarginTradingAPI,
|
|
39
42
|
IndexNonFinancialStatementAPI,
|
|
40
43
|
IndexSecurityStatementAPI,
|
|
41
44
|
TrackingFundAPI,
|
|
@@ -61,7 +64,7 @@ class AsyncLixingerClient:
|
|
|
61
64
|
max_retries: int | None = None,
|
|
62
65
|
proxy: str | None = None,
|
|
63
66
|
max_requests_per_minute: int = 1000,
|
|
64
|
-
):
|
|
67
|
+
) -> None:
|
|
65
68
|
"""Initialize the async Lixinger API client.
|
|
66
69
|
|
|
67
70
|
The API key is ALWAYS loaded from the LIXINGER_API_KEY environment variable.
|
|
@@ -186,6 +189,7 @@ class AsyncLixingerClient:
|
|
|
186
189
|
cn_index_drawdown = DrawdownAPI(self._http_client, self.config, self._rate_limiter)
|
|
187
190
|
cn_index_fundamental = IndexFundamentalAPI(self._http_client, self.config, self._rate_limiter)
|
|
188
191
|
cn_index_tracking_fund = TrackingFundAPI(self._http_client, self.config, self._rate_limiter)
|
|
192
|
+
cn_index_margin_trading = IndexMarginTradingAPI(self._http_client, self.config, self._rate_limiter)
|
|
189
193
|
cn_index_fs_non_financial = IndexNonFinancialStatementAPI(self._http_client, self.config, self._rate_limiter)
|
|
190
194
|
cn_index_fs_bank = IndexBankStatementAPI(self._http_client, self.config, self._rate_limiter)
|
|
191
195
|
cn_index_fs_security = IndexSecurityStatementAPI(self._http_client, self.config, self._rate_limiter)
|
|
@@ -200,6 +204,7 @@ class AsyncLixingerClient:
|
|
|
200
204
|
candlestick=cn_index_candlestick,
|
|
201
205
|
drawdown=cn_index_drawdown,
|
|
202
206
|
tracking_fund=cn_index_tracking_fund,
|
|
207
|
+
margin_trading=cn_index_margin_trading,
|
|
203
208
|
fs_non_financial=cn_index_fs_non_financial,
|
|
204
209
|
fs_bank=cn_index_fs_bank,
|
|
205
210
|
fs_security=cn_index_fs_security,
|
|
@@ -213,6 +218,7 @@ class AsyncLixingerClient:
|
|
|
213
218
|
self.cn_index_drawdown = cn_index_drawdown
|
|
214
219
|
self.cn_index_fundamental = cn_index_fundamental
|
|
215
220
|
self.cn_index_tracking_fund = cn_index_tracking_fund
|
|
221
|
+
self.cn_index_margin_trading = cn_index_margin_trading
|
|
216
222
|
self.cn_index_fs_non_financial = cn_index_fs_non_financial
|
|
217
223
|
self.cn_index_fs_bank = cn_index_fs_bank
|
|
218
224
|
self.cn_index_fs_security = cn_index_fs_security
|
|
@@ -229,13 +235,18 @@ class AsyncLixingerClient:
|
|
|
229
235
|
)
|
|
230
236
|
self.cn_fund_announcement = FundAnnouncementAPI(self._http_client, self.config, self._rate_limiter)
|
|
231
237
|
|
|
232
|
-
async def __aenter__(self):
|
|
238
|
+
async def __aenter__(self) -> "AsyncLixingerClient":
|
|
233
239
|
return self
|
|
234
240
|
|
|
235
|
-
async def __aexit__(
|
|
241
|
+
async def __aexit__(
|
|
242
|
+
self,
|
|
243
|
+
exc_type: type[BaseException] | None,
|
|
244
|
+
exc_val: BaseException | None,
|
|
245
|
+
exc_tb: TracebackType | None,
|
|
246
|
+
) -> None:
|
|
236
247
|
await self.close()
|
|
237
248
|
|
|
238
|
-
async def close(self):
|
|
249
|
+
async def close(self) -> None:
|
|
239
250
|
"""Close the underlying HTTP client."""
|
|
240
251
|
await self._http_client.aclose()
|
|
241
252
|
|
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
|
|
|
@@ -12,6 +12,7 @@ from lixinger.models.cn.index.fs import (
|
|
|
12
12
|
)
|
|
13
13
|
from lixinger.models.cn.index.fundamental import IndexFundamentalData
|
|
14
14
|
from lixinger.models.cn.index.index import Index
|
|
15
|
+
from lixinger.models.cn.index.margin_trading import IndexMarginTrading
|
|
15
16
|
from lixinger.models.cn.index.tracking_fund import TrackingFund
|
|
16
17
|
|
|
17
18
|
__all__ = [
|
|
@@ -21,6 +22,7 @@ __all__ = [
|
|
|
21
22
|
"IndexCandlestick",
|
|
22
23
|
"IndexDrawdown",
|
|
23
24
|
"IndexFundamentalData",
|
|
25
|
+
"IndexMarginTrading",
|
|
24
26
|
"TrackingFund",
|
|
25
27
|
# Index financial statements
|
|
26
28
|
"IndexBankStatementSchema",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Index margin trading and securities lending models."""
|
|
2
|
+
|
|
3
|
+
import pandera.pandas as pa
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class IndexMarginTrading(pa.DataFrameModel):
|
|
7
|
+
"""Index margin trading and securities lending model.
|
|
8
|
+
|
|
9
|
+
Represents the daily margin trading (融资) and securities lending (融券)
|
|
10
|
+
metrics for an index.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
class Config:
|
|
14
|
+
"""Pandera configuration."""
|
|
15
|
+
|
|
16
|
+
coerce = True
|
|
17
|
+
strict = False
|
|
18
|
+
|
|
19
|
+
date: pa.typing.Series[pa.typing.DateTime]
|
|
20
|
+
stock_code: pa.typing.Series[str]
|
|
21
|
+
financing_purchase_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
22
|
+
financing_repayment_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
23
|
+
financing_net_purchase_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
24
|
+
financing_balance: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
25
|
+
securities_sell_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
26
|
+
securities_repayment_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
27
|
+
securities_net_sell_amount: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
28
|
+
securities_balance: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
29
|
+
financing_balance_to_market_cap: pa.typing.Series[float] | None = pa.Field(nullable=True)
|
|
30
|
+
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=q-HBT1HyVJ6NKlsP_T6T5WCq_bYn330wAo9bsfD-lNQ,2750
|
|
2
|
+
lixinger/client.py,sha256=_oj9vlfMTWDbbn89A3DCZ0epBY2nMs1iQKBIrLO4vQA,12905
|
|
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
|
|
@@ -35,14 +35,15 @@ lixinger/api/cn/fund/candlestick.py,sha256=XdkxjtjIT1ixNzOArJRKBvlabTHz3PA9w2zsG
|
|
|
35
35
|
lixinger/api/cn/fund/fund.py,sha256=Y1ysdyl1zpu71iiFR4G6ixqBT4Kb9PxSWk_oFpFVeMI,1624
|
|
36
36
|
lixinger/api/cn/fund/profile.py,sha256=kTbqmz3obYRNjFjkD74I-R3x0SBsZCqI0KPjiWe84QI,1347
|
|
37
37
|
lixinger/api/cn/fund/shareholdings.py,sha256=aGFsyBiIW-wsbpAnwnAnRY6duiBKeYbQVKfpdQXs3tY,2358
|
|
38
|
-
lixinger/api/cn/index/__init__.py,sha256=
|
|
38
|
+
lixinger/api/cn/index/__init__.py,sha256=WH01vjbnqWE5gAxU7R8l8NQmfjGacmWgbFiVSBCF7-8,1765
|
|
39
39
|
lixinger/api/cn/index/candlestick.py,sha256=MdFGWf3pSoqPtzkCQJbSY1b6vw1nmZ6lKmgxdFMIMlo,2356
|
|
40
40
|
lixinger/api/cn/index/constituent_weightings.py,sha256=UuAmqhgapMAMW6qZge3yKb9E9h7WNuZZ83sLkZIq-rA,3352
|
|
41
41
|
lixinger/api/cn/index/constituents.py,sha256=8kQjTJER8PqpZMTQWusDK9mbQ27YLYgYxw8u_vHqsy4,3372
|
|
42
42
|
lixinger/api/cn/index/drawdown.py,sha256=D-fhA-Sv2-gf6VzX0zG1dm7Tn5Wy7NK1IB-f5kFXi7w,2450
|
|
43
43
|
lixinger/api/cn/index/fundamental.py,sha256=MyhGmMk7GkOZflpT0JMoiLsCs3DLMLLkopyUsD94Y4Q,2474
|
|
44
44
|
lixinger/api/cn/index/index.py,sha256=5gDwE5K3tYNlCrV-EsSC4HXhfIi58uqWpHQxTt9LJMk,4177
|
|
45
|
-
lixinger/api/cn/index/
|
|
45
|
+
lixinger/api/cn/index/margin_trading.py,sha256=Tr5nXXC5H38FoAB5RoiTysr2wQEB0K4i4eKcEZnV4dw,4161
|
|
46
|
+
lixinger/api/cn/index/namespace.py,sha256=GQrvboQiqXOpY7KULhIt-BwOqYktpelHp-fSQUSq120,6413
|
|
46
47
|
lixinger/api/cn/index/tracking_fund.py,sha256=su0zJRROKuTZlHe0XkIQz8kJOyPZmyg7HxZIbmpM_YM,1960
|
|
47
48
|
lixinger/api/cn/index/fs/__init__.py,sha256=eQTxjzZfiqxDU8WdLA-deAtus-nYEiO2mLq2gOkFTts,1060
|
|
48
49
|
lixinger/api/cn/index/fs/bank.py,sha256=zjDB_d06E_gxAvVNyk9Byoa5ShlevNoc75z5gVBH6aY,4416
|
|
@@ -78,13 +79,14 @@ lixinger/models/cn/fund/candlestick.py,sha256=JSmEPTIB992Mujb6qBBX3NUTq9tafoJdNh
|
|
|
78
79
|
lixinger/models/cn/fund/fund.py,sha256=IQQJic7dL58eM00E6DDY9beePpqJSqxu6E1DW0-X3iY,762
|
|
79
80
|
lixinger/models/cn/fund/profile.py,sha256=j02zgDXdFC9zLPcEgNKpoxIeHLac27ySngU6Vikh_V4,1202
|
|
80
81
|
lixinger/models/cn/fund/shareholdings.py,sha256=67cJfRGBjMRwI6f1RQbg-Hnb-SK620gKIphvCdjNzOk,611
|
|
81
|
-
lixinger/models/cn/index/__init__.py,sha256=
|
|
82
|
+
lixinger/models/cn/index/__init__.py,sha256=Q2dtEiJmZzPt7w47nxIXmfm_A_87OPM0IT-IbadD02k,1099
|
|
82
83
|
lixinger/models/cn/index/candlestick.py,sha256=So3ArqKge-reoeAn5E26I1fQusPks6jtvfHVNKF_yY0,560
|
|
83
84
|
lixinger/models/cn/index/constituent_weightings.py,sha256=Vr68TyJ6mjXtKMUD-d_daG2CR1GJ60ipAfK-HhdXZVo,370
|
|
84
85
|
lixinger/models/cn/index/constituents.py,sha256=UDVCoQsKahMhlF9Os-Xgo0XRg6dfH5WBBiOuQMlPqz8,371
|
|
85
86
|
lixinger/models/cn/index/drawdown.py,sha256=kvrhy7_fIjvUHXFTUn3TXqSNip7vZXpfWjlypmXxvLw,332
|
|
86
87
|
lixinger/models/cn/index/fundamental.py,sha256=4gBOFADCq1C0pcSa9JfxDkH-3spRErkg3LwVJyYrGvU,374
|
|
87
88
|
lixinger/models/cn/index/index.py,sha256=M_ZYGGfcpWXrmwhz58HfojInsmAUQeZSNJ74sAqTbqA,842
|
|
89
|
+
lixinger/models/cn/index/margin_trading.py,sha256=NLPZ0BrPLNyaSunw0LiCKKd5Ys-DMLHMhw3ezS_40rM,1379
|
|
88
90
|
lixinger/models/cn/index/tracking_fund.py,sha256=qbsdMlD0FBpWDBWS8smOeqK_hJOp8OzkT2NA0Zn_k-s,424
|
|
89
91
|
lixinger/models/cn/index/fs/__init__.py,sha256=CMHJ7UaslJYuUkynpd_yADsP8gsNFEOS67kng5Ryvok,507
|
|
90
92
|
lixinger/models/cn/index/fs/bank.py,sha256=DA_sRFSsK5IE0JQtp3pHdvPJQxbipHsSyKahcBbaZ-U,559
|
|
@@ -95,9 +97,9 @@ lixinger/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
95
97
|
lixinger/utils/api.py,sha256=BktR40JtKCMe9excFWo4ujsq3GiQK4ypJLG3MpJgo2s,402
|
|
96
98
|
lixinger/utils/dataframe.py,sha256=tYBrNdmJ4poyuwD-9XgzHt3A_A8bBo0cdHiu8Yy9e9A,2208
|
|
97
99
|
lixinger/utils/dict.py,sha256=yvbUtv8QpRmy0d_o_7gCuEwwiEfBji5_xB490ANxilw,589
|
|
98
|
-
lixinger/utils/rate_limiter.py,sha256=
|
|
100
|
+
lixinger/utils/rate_limiter.py,sha256=ZHlRTTL60L62uRA_f--LD26qkAfk-pHBllRqPapAXQM,1141
|
|
99
101
|
lixinger/utils/retry.py,sha256=sXtb0ESp12_JedjzDxoeIH48TlOrbxtIA0j1V33DW7M,1026
|
|
100
|
-
lixinger_python-0.3.
|
|
101
|
-
lixinger_python-0.3.
|
|
102
|
-
lixinger_python-0.3.
|
|
103
|
-
lixinger_python-0.3.
|
|
102
|
+
lixinger_python-0.3.10.dist-info/METADATA,sha256=dSxFGEZE6ajZsnOnLeMc4dKYCyXK2-ZYlTLGsrEhYJI,9207
|
|
103
|
+
lixinger_python-0.3.10.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
104
|
+
lixinger_python-0.3.10.dist-info/licenses/LICENSE,sha256=5oOwRq1lHSOScbNGCHr2feuNnhNYdGcArj6fSUfsC5U,1064
|
|
105
|
+
lixinger_python-0.3.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|