lixinger-python 0.3.26__py3-none-any.whl → 0.3.28__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/models/cn/index/tracking_fund.py +1 -1
- lixinger/models/macro/domestic_debt_securities.py +3 -2
- lixinger/models/macro/official_reserve_assets.py +3 -2
- lixinger/models/macro/rmb_deposits.py +3 -2
- lixinger/models/macro/rmb_loans.py +3 -2
- lixinger/models/macro/social_financing.py +3 -2
- lixinger/utils/dataframe.py +23 -8
- {lixinger_python-0.3.26.dist-info → lixinger_python-0.3.28.dist-info}/METADATA +2 -2
- {lixinger_python-0.3.26.dist-info → lixinger_python-0.3.28.dist-info}/RECORD +11 -11
- {lixinger_python-0.3.26.dist-info → lixinger_python-0.3.28.dist-info}/WHEEL +1 -1
- {lixinger_python-0.3.26.dist-info → lixinger_python-0.3.28.dist-info}/licenses/LICENSE +0 -0
|
@@ -12,7 +12,7 @@ class TrackingFund(pa.DataFrameModel):
|
|
|
12
12
|
coerce = True
|
|
13
13
|
|
|
14
14
|
stock_code: pa.typing.Series[str]
|
|
15
|
-
name: pa.typing.Series[str]
|
|
15
|
+
name: pa.typing.Series[str] | None = pa.Field(nullable=True)
|
|
16
16
|
short_name: pa.typing.Series[str]
|
|
17
17
|
area_code: pa.typing.Series[str]
|
|
18
18
|
market: pa.typing.Series[str]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""国内各类债券数据模型."""
|
|
2
2
|
|
|
3
|
+
from pandera.engines.pandas_engine import DateTime
|
|
3
4
|
import pandera.pandas as pa
|
|
4
5
|
|
|
5
6
|
|
|
@@ -14,7 +15,7 @@ class DomesticDebtSecurities(pa.DataFrameModel):
|
|
|
14
15
|
class Config:
|
|
15
16
|
"""Pandera configuration."""
|
|
16
17
|
|
|
17
|
-
coerce =
|
|
18
|
+
coerce = False
|
|
18
19
|
strict = False # Allow extra metrics columns like y.gs_i.t
|
|
19
20
|
|
|
20
|
-
date: pa.typing.Series[pa.
|
|
21
|
+
date: pa.typing.Series[DateTime] = pa.Field(dtype_kwargs={"time_zone_agnostic": True})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""官方储备资产数据模型."""
|
|
2
2
|
|
|
3
|
+
from pandera.engines.pandas_engine import DateTime
|
|
3
4
|
import pandera.pandas as pa
|
|
4
5
|
|
|
5
6
|
|
|
@@ -14,7 +15,7 @@ class OfficialReserveAssets(pa.DataFrameModel):
|
|
|
14
15
|
class Config:
|
|
15
16
|
"""Pandera configuration."""
|
|
16
17
|
|
|
17
|
-
coerce =
|
|
18
|
+
coerce = False
|
|
18
19
|
strict = False # Allow extra metrics columns like y.ora.t
|
|
19
20
|
|
|
20
|
-
date: pa.typing.Series[pa.
|
|
21
|
+
date: pa.typing.Series[DateTime] = pa.Field(dtype_kwargs={"time_zone_agnostic": True})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""人民币存款数据模型."""
|
|
2
2
|
|
|
3
|
+
from pandera.engines.pandas_engine import DateTime
|
|
3
4
|
import pandera.pandas as pa
|
|
4
5
|
|
|
5
6
|
|
|
@@ -14,7 +15,7 @@ class RmbDeposits(pa.DataFrameModel):
|
|
|
14
15
|
class Config:
|
|
15
16
|
"""Pandera configuration."""
|
|
16
17
|
|
|
17
|
-
coerce =
|
|
18
|
+
coerce = False
|
|
18
19
|
strict = False # Allow extra metrics columns like y.rmb_d.t
|
|
19
20
|
|
|
20
|
-
date: pa.typing.Series[pa.
|
|
21
|
+
date: pa.typing.Series[DateTime] = pa.Field(dtype_kwargs={"time_zone_agnostic": True})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""人民币贷款数据模型."""
|
|
2
2
|
|
|
3
|
+
from pandera.engines.pandas_engine import DateTime
|
|
3
4
|
import pandera.pandas as pa
|
|
4
5
|
|
|
5
6
|
|
|
@@ -14,7 +15,7 @@ class RmbLoans(pa.DataFrameModel):
|
|
|
14
15
|
class Config:
|
|
15
16
|
"""Pandera configuration."""
|
|
16
17
|
|
|
17
|
-
coerce =
|
|
18
|
+
coerce = False
|
|
18
19
|
strict = False # Allow extra metrics columns like y.rmb_l.t
|
|
19
20
|
|
|
20
|
-
date: pa.typing.Series[pa.
|
|
21
|
+
date: pa.typing.Series[DateTime] = pa.Field(dtype_kwargs={"time_zone_agnostic": True})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""社会融资规模数据模型."""
|
|
2
2
|
|
|
3
|
+
from pandera.engines.pandas_engine import DateTime
|
|
3
4
|
import pandera.pandas as pa
|
|
4
5
|
|
|
5
6
|
|
|
@@ -14,7 +15,7 @@ class SocialFinancing(pa.DataFrameModel):
|
|
|
14
15
|
class Config:
|
|
15
16
|
"""Pandera configuration."""
|
|
16
17
|
|
|
17
|
-
coerce =
|
|
18
|
+
coerce = False
|
|
18
19
|
strict = False # Allow extra metrics columns like y.sf.t
|
|
19
20
|
|
|
20
|
-
date: pa.typing.Series[pa.
|
|
21
|
+
date: pa.typing.Series[DateTime] = pa.Field(dtype_kwargs={"time_zone_agnostic": True})
|
lixinger/utils/dataframe.py
CHANGED
|
@@ -11,7 +11,11 @@ def camel_to_snake(name: str) -> str:
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def get_response_df(data: Any, model: type[pa.DataFrameModel]) -> pd.DataFrame:
|
|
14
|
-
"""Convert API
|
|
14
|
+
"""Convert API data to a validated DataFrame.
|
|
15
|
+
|
|
16
|
+
Timezone-agnostic schema fields preserve input offsets. Their date-only and
|
|
17
|
+
naive values are localized to Asia/Shanghai. Mixed offsets use object dtype.
|
|
18
|
+
"""
|
|
15
19
|
if not data:
|
|
16
20
|
return pd.DataFrame()
|
|
17
21
|
|
|
@@ -42,16 +46,27 @@ def get_response_df(data: Any, model: type[pa.DataFrameModel]) -> pd.DataFrame:
|
|
|
42
46
|
if "p_c_benchmark" in df.columns:
|
|
43
47
|
df["p_c_benchmark"] = df["p_c_benchmark"].apply(lambda x: ",".join(x) if isinstance(x, list) else x)
|
|
44
48
|
|
|
45
|
-
#
|
|
49
|
+
# Timezone-aware parsing is enabled only by the response field's schema.
|
|
46
50
|
schema = model.to_schema()
|
|
47
51
|
for col_name, col in schema.columns.items():
|
|
48
52
|
if (
|
|
49
|
-
"datetime" in str(col.dtype).lower()
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
"datetime" in str(col.dtype).lower() or getattr(col.dtype, "time_zone_agnostic", False)
|
|
54
|
+
) and col_name in df.columns:
|
|
55
|
+
if getattr(col.dtype, "time_zone_agnostic", False):
|
|
56
|
+
df[col_name] = df[col_name].map(_with_timezone)
|
|
57
|
+
elif not pd.api.types.is_datetime64_any_dtype(df[col_name]):
|
|
58
|
+
# Legacy schemas retain their existing face-time behavior.
|
|
59
|
+
df[col_name] = pd.to_datetime(df[col_name].astype(str).str.slice(0, 19), errors="coerce")
|
|
55
60
|
|
|
56
61
|
# Validate the DataFrame using the pandera model
|
|
57
62
|
return model.validate(df)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _with_timezone(value: Any) -> Any:
|
|
66
|
+
"""Preserve explicit offsets; interpret naive values as Beijing time."""
|
|
67
|
+
timestamp = pd.to_datetime(value, errors="coerce")
|
|
68
|
+
if pd.isna(timestamp):
|
|
69
|
+
return pd.NaT
|
|
70
|
+
if timestamp.tzinfo is None:
|
|
71
|
+
timestamp = timestamp.tz_localize("Asia/Shanghai")
|
|
72
|
+
return timestamp
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: lixinger-python
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.28
|
|
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
|
|
@@ -121,7 +121,7 @@ lixinger/models/cn/index/drawdown.py,sha256=kvrhy7_fIjvUHXFTUn3TXqSNip7vZXpfWjly
|
|
|
121
121
|
lixinger/models/cn/index/fundamental.py,sha256=4gBOFADCq1C0pcSa9JfxDkH-3spRErkg3LwVJyYrGvU,374
|
|
122
122
|
lixinger/models/cn/index/index.py,sha256=M_ZYGGfcpWXrmwhz58HfojInsmAUQeZSNJ74sAqTbqA,842
|
|
123
123
|
lixinger/models/cn/index/margin_trading.py,sha256=NLPZ0BrPLNyaSunw0LiCKKd5Ys-DMLHMhw3ezS_40rM,1379
|
|
124
|
-
lixinger/models/cn/index/tracking_fund.py,sha256
|
|
124
|
+
lixinger/models/cn/index/tracking_fund.py,sha256=-TNvxF8vHR3CU_P3wOzcw9bHtTiYGy_lih5VuX2WkKY,457
|
|
125
125
|
lixinger/models/cn/index/fs/__init__.py,sha256=CMHJ7UaslJYuUkynpd_yADsP8gsNFEOS67kng5Ryvok,507
|
|
126
126
|
lixinger/models/cn/index/fs/bank.py,sha256=DA_sRFSsK5IE0JQtp3pHdvPJQxbipHsSyKahcBbaZ-U,559
|
|
127
127
|
lixinger/models/cn/index/fs/hybrid.py,sha256=AlCoEfkkPdWGxE_K71rBKgwWpR4iWTaMJ8bc56YxYrk,565
|
|
@@ -146,24 +146,24 @@ lixinger/models/cn/industry/margin_trading/sw.py,sha256=GyBhpZxSm1aoQHdzJvjb5INp
|
|
|
146
146
|
lixinger/models/cn/industry/margin_trading/sw_2021.py,sha256=JWdEVXarlKso3JOpMJ7zvkw-I5tsLlXagJFXEJxYC3s,1399
|
|
147
147
|
lixinger/models/macro/__init__.py,sha256=2JzNqBA9489NH8kQn33o7vcVkW4p12BbggZT215P89Y,826
|
|
148
148
|
lixinger/models/macro/crude_oil.py,sha256=hvve8HL3FF3V1iOIE5shH7SUHyssj3f-vjIsZAY-KoQ,574
|
|
149
|
-
lixinger/models/macro/domestic_debt_securities.py,sha256=
|
|
149
|
+
lixinger/models/macro/domestic_debt_securities.py,sha256=ch_TvQpWgUZ4jpgxrQE6EvsbNa8d9hXmAMjz8pgN_k8,697
|
|
150
150
|
lixinger/models/macro/gold_price.py,sha256=nqsfQWG2zH6dZ7LIu616dZI4xmEKzkHCrTv0hTgLmk0,571
|
|
151
151
|
lixinger/models/macro/national_debt.py,sha256=EVOCgzoahjKW0YMq-08ICw17GpOmhJdBWQGqmO0oqQc,581
|
|
152
152
|
lixinger/models/macro/natural_gas.py,sha256=kAGDY9ZqRrm96azBvjLmk8IyZz5_DhEHfUWR1HrXeM0,554
|
|
153
153
|
lixinger/models/macro/non_ferrous_metals.py,sha256=8fuOfmR7So1mWZtUuOBO9UiQEN58u1qrEbh6exJ5Vq0,636
|
|
154
|
-
lixinger/models/macro/official_reserve_assets.py,sha256=
|
|
154
|
+
lixinger/models/macro/official_reserve_assets.py,sha256=Zk_0D6jrLU4erV5-OzgICg8e34AdC80mcJPhisi1LMc,694
|
|
155
155
|
lixinger/models/macro/platinum_price.py,sha256=4nh11VoHfnL_cUGUeNr0I1njaF4ovmISnKE9_Az16RA,538
|
|
156
|
-
lixinger/models/macro/rmb_deposits.py,sha256=
|
|
157
|
-
lixinger/models/macro/rmb_loans.py,sha256=
|
|
156
|
+
lixinger/models/macro/rmb_deposits.py,sha256=KzvkxIDzZPNAHXKWSCDc9-GvZfXL-9mZQONnaVWx338,679
|
|
157
|
+
lixinger/models/macro/rmb_loans.py,sha256=36CHRPt8QRvkadxAa0VlqKCYo9i8jMdUTGFWaf_sBfg,676
|
|
158
158
|
lixinger/models/macro/silver_price.py,sha256=8OPmXoA_aK-J6VkZpDI9qsH19gbZrzpnMi68afqRFeI,536
|
|
159
|
-
lixinger/models/macro/social_financing.py,sha256=
|
|
159
|
+
lixinger/models/macro/social_financing.py,sha256=07O1cTuuj7RoV8aY0ja-Pb2yVW-mIehujlkvkssH3C4,686
|
|
160
160
|
lixinger/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
161
161
|
lixinger/utils/api.py,sha256=BktR40JtKCMe9excFWo4ujsq3GiQK4ypJLG3MpJgo2s,402
|
|
162
|
-
lixinger/utils/dataframe.py,sha256=
|
|
162
|
+
lixinger/utils/dataframe.py,sha256=9i9J_hWQoUqAczsbEC7T5iZOdZmZddkKqrbBuRc19UM,2853
|
|
163
163
|
lixinger/utils/dict.py,sha256=yvbUtv8QpRmy0d_o_7gCuEwwiEfBji5_xB490ANxilw,589
|
|
164
164
|
lixinger/utils/rate_limiter.py,sha256=ZHlRTTL60L62uRA_f--LD26qkAfk-pHBllRqPapAXQM,1141
|
|
165
165
|
lixinger/utils/retry.py,sha256=C9QBcrpD7WYAuT8R4SJfWNUZFj1mZsv-qyTRIFQDmwc,2862
|
|
166
|
-
lixinger_python-0.3.
|
|
167
|
-
lixinger_python-0.3.
|
|
168
|
-
lixinger_python-0.3.
|
|
169
|
-
lixinger_python-0.3.
|
|
166
|
+
lixinger_python-0.3.28.dist-info/METADATA,sha256=RzzrcEO9_bi69d0C6gNiZzE8R4tAc1QB7ybS_mPkUD8,9207
|
|
167
|
+
lixinger_python-0.3.28.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
168
|
+
lixinger_python-0.3.28.dist-info/licenses/LICENSE,sha256=5oOwRq1lHSOScbNGCHr2feuNnhNYdGcArj6fSUfsC5U,1064
|
|
169
|
+
lixinger_python-0.3.28.dist-info/RECORD,,
|
|
File without changes
|