lixinger-python 0.3.24__py3-none-any.whl → 0.3.25__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lixinger/__init__.py CHANGED
@@ -61,6 +61,7 @@ from lixinger.api.macro import (
61
61
  get_national_debt,
62
62
  get_natural_gas,
63
63
  get_non_ferrous_metals,
64
+ get_official_reserve_assets,
64
65
  get_platinum_price,
65
66
  get_rmb_deposits,
66
67
  get_rmb_loans,
@@ -147,4 +148,5 @@ __all__ = [
147
148
  "get_crude_oil",
148
149
  "get_natural_gas",
149
150
  "get_non_ferrous_metals",
151
+ "get_official_reserve_assets",
150
152
  ]
@@ -3,6 +3,7 @@
3
3
  This module provides access to macroeconomic data APIs:
4
4
 
5
5
  - national_debt: 国债收益率 (/macro/national-debt)
6
+ - official_reserve_assets: 官方储备资产 (/macro/official-reserve-assets)
6
7
  - rmb_deposits: 人民币存款 (/macro/rmb-deposits)
7
8
  - rmb_loans: 人民币贷款 (/macro/rmb-loans)
8
9
  - social_financing: 社会融资规模 (/macro/social-financing)
@@ -22,6 +23,10 @@ from lixinger.api.macro.non_ferrous_metals import (
22
23
  NonFerrousMetalsAPI,
23
24
  get_non_ferrous_metals,
24
25
  )
26
+ from lixinger.api.macro.official_reserve_assets import (
27
+ OfficialReserveAssetsAPI,
28
+ get_official_reserve_assets,
29
+ )
25
30
  from lixinger.api.macro.platinum_price import PlatinumPriceAPI, get_platinum_price
26
31
  from lixinger.api.macro.rmb_deposits import RmbDepositsAPI, get_rmb_deposits
27
32
  from lixinger.api.macro.rmb_loans import RmbLoansAPI, get_rmb_loans
@@ -38,6 +43,7 @@ __all__ = [
38
43
  "NationalDebtAPI",
39
44
  "NaturalGasAPI",
40
45
  "NonFerrousMetalsAPI",
46
+ "OfficialReserveAssetsAPI",
41
47
  "PlatinumPriceAPI",
42
48
  "RmbDepositsAPI",
43
49
  "RmbLoansAPI",
@@ -49,6 +55,7 @@ __all__ = [
49
55
  "get_national_debt",
50
56
  "get_natural_gas",
51
57
  "get_non_ferrous_metals",
58
+ "get_official_reserve_assets",
52
59
  "get_platinum_price",
53
60
  "get_rmb_deposits",
54
61
  "get_rmb_loans",
@@ -9,6 +9,7 @@ from lixinger.api.macro.gold_price import GoldPriceAPI
9
9
  from lixinger.api.macro.national_debt import NationalDebtAPI
10
10
  from lixinger.api.macro.natural_gas import NaturalGasAPI
11
11
  from lixinger.api.macro.non_ferrous_metals import NonFerrousMetalsAPI
12
+ from lixinger.api.macro.official_reserve_assets import OfficialReserveAssetsAPI
12
13
  from lixinger.api.macro.platinum_price import PlatinumPriceAPI
13
14
  from lixinger.api.macro.rmb_deposits import RmbDepositsAPI
14
15
  from lixinger.api.macro.rmb_loans import RmbLoansAPI
@@ -32,6 +33,7 @@ class MacroNamespace:
32
33
  - crude_oil: 原油 API
33
34
  - natural_gas: 天然气 API
34
35
  - non_ferrous_metals: 有色金属 API
36
+ - official_reserve_assets: 官方储备资产 API
35
37
 
36
38
  """
37
39
 
@@ -47,6 +49,7 @@ class MacroNamespace:
47
49
  crude_oil: CrudeOilAPI,
48
50
  natural_gas: NaturalGasAPI,
49
51
  non_ferrous_metals: NonFerrousMetalsAPI,
52
+ official_reserve_assets: OfficialReserveAssetsAPI,
50
53
  ) -> None:
51
54
  """Initialize the macro namespace.
52
55
 
@@ -61,6 +64,7 @@ class MacroNamespace:
61
64
  crude_oil: 原油 API
62
65
  natural_gas: 天然气 API
63
66
  non_ferrous_metals: 有色金属 API
67
+ official_reserve_assets: 官方储备资产 API
64
68
 
65
69
  """
66
70
  self.national_debt = national_debt
@@ -73,6 +77,7 @@ class MacroNamespace:
73
77
  self.crude_oil = crude_oil
74
78
  self.natural_gas = natural_gas
75
79
  self.non_ferrous_metals = non_ferrous_metals
80
+ self.official_reserve_assets = official_reserve_assets
76
81
 
77
82
  # Convenience aliases for shorter access
78
83
  async def get_national_debt(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
@@ -114,3 +119,7 @@ class MacroNamespace:
114
119
  async def get_non_ferrous_metals(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
115
120
  """Alias for non_ferrous_metals.get_non_ferrous_metals."""
116
121
  return await self.non_ferrous_metals.get_non_ferrous_metals(*args, **kwargs)
122
+
123
+ async def get_official_reserve_assets(self, *args: Any, **kwargs: Any) -> pd.DataFrame:
124
+ """Alias for official_reserve_assets.get_official_reserve_assets."""
125
+ return await self.official_reserve_assets.get_official_reserve_assets(*args, **kwargs)
@@ -0,0 +1,132 @@
1
+ """官方储备资产 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.macro.official_reserve_assets import OfficialReserveAssets
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 OfficialReserveAssetsAPI(BaseAPI):
15
+ """官方储备资产 API."""
16
+
17
+ async def get_official_reserve_assets(
18
+ self,
19
+ area_code: str,
20
+ start_date: str,
21
+ end_date: str,
22
+ metrics_list: list[str],
23
+ limit: int | None = None,
24
+ ) -> pd.DataFrame:
25
+ """获取官方储备资产数据.
26
+
27
+ 获取官方储备资产数据. 可按时间范围获取大陆官方储备总计、外汇储备、
28
+ 黄金储备、基金组织储备头寸、特别提款权、其他储备资产数据, 包括存量及
29
+ 月度新增数据, 以及同比环比等数据. 当用户想了解国际收支状况或汇率支撑
30
+ 能力时, 调用此接口.
31
+
32
+ API Endpoint: /macro/official-reserve-assets
33
+ API Method: POST
34
+ API Doc: https://www.lixinger.com/open/api/doc?api-key=macro/official-reserve-assets
35
+
36
+ Args:
37
+ area_code: 地区代码, 目前仅支持 ``cn``.
38
+ start_date: 信息起始时间 (YYYY-MM-DD, 北京时间), 开始和结束的时间间隔不超过10年.
39
+ end_date: 信息结束时间 (YYYY-MM-DD, 北京时间).
40
+ metrics_list: 指标列表, 格式为
41
+ ``[granularity].[metricsName].[expressionCalculateType]``,
42
+ 例如 ``["y.ora.t", "m.ora.c_y2y"]``.
43
+ 支持的指标: ``ora`` (官方储备资产总计), ``ora_fc`` (外汇储备),
44
+ ``ora_g_usd`` (黄金储量资产), ``ora_g_o`` (黄金储量),
45
+ ``ora_imf_rp`` (基金组织储备头寸), ``ora_sdr_s`` (特别提款权),
46
+ ``ora_o`` (其他储备资产).
47
+ 粒度 ``y`` (年) 支持 ``t``, ``t_y2y``;
48
+ 粒度 ``m`` (月) 支持 ``t``, ``t_y2y``, ``c``, ``c_y2y``,
49
+ ``c_c2c``, ``c_2y``, ``ttm``, ``ttm_y2y``, ``ttm_c2c``.
50
+ limit: 返回最近数据的数量.
51
+
52
+ Returns:
53
+ DataFrame 包含以下列:
54
+
55
+ - date: 数据时间
56
+ - 各请求指标 (点号分隔, 例如 ``y.ora.t``)
57
+
58
+ Example:
59
+ 获取大陆官方储备资产总计年度累积值::
60
+
61
+ from lixinger import AsyncLixingerClient
62
+
63
+ async with AsyncLixingerClient() as client:
64
+ df = await client.macro.official_reserve_assets.get_official_reserve_assets(
65
+ area_code="cn",
66
+ start_date="2023-06-13",
67
+ end_date="2026-06-13",
68
+ metrics_list=["y.ora.t"],
69
+ )
70
+ print(df)
71
+
72
+ """
73
+ payload: dict[str, Any] = {
74
+ "areaCode": area_code,
75
+ "startDate": start_date,
76
+ "endDate": end_date,
77
+ "metricsList": metrics_list,
78
+ }
79
+ if limit is not None:
80
+ payload["limit"] = limit
81
+
82
+ data = await self._request("POST", "/macro/official-reserve-assets", json=payload)
83
+ # Flatten nested metrics (e.g. {"y": {"ora": {"t": ...}}})
84
+ flattened_data = [flatten_dict(item) for item in data]
85
+ return get_response_df(flattened_data, OfficialReserveAssets)
86
+
87
+
88
+ # Functional API instance
89
+ _api_instance = OfficialReserveAssetsAPI()
90
+
91
+
92
+ @api
93
+ async def get_official_reserve_assets(
94
+ area_code: str,
95
+ start_date: str,
96
+ end_date: str,
97
+ metrics_list: list[str],
98
+ limit: int | None = None,
99
+ ) -> pd.DataFrame:
100
+ """获取官方储备资产数据.
101
+
102
+ Args:
103
+ area_code: 地区代码, 目前仅支持 ``cn``.
104
+ start_date: 信息起始时间 (YYYY-MM-DD).
105
+ end_date: 信息结束时间 (YYYY-MM-DD).
106
+ metrics_list: 指标列表, 例如 ``["y.ora.t"]``.
107
+ limit: 返回最近数据的数量.
108
+
109
+ Returns:
110
+ DataFrame 包含官方储备资产数据.
111
+
112
+ Example:
113
+ 获取大陆官方储备资产总计年度累积值::
114
+
115
+ from lixinger import get_official_reserve_assets
116
+
117
+ df = await get_official_reserve_assets(
118
+ area_code="cn",
119
+ start_date="2023-06-13",
120
+ end_date="2026-06-13",
121
+ metrics_list=["y.ora.t"],
122
+ )
123
+ print(df)
124
+
125
+ """
126
+ return await _api_instance.get_official_reserve_assets(
127
+ area_code=area_code,
128
+ start_date=start_date,
129
+ end_date=end_date,
130
+ metrics_list=metrics_list,
131
+ limit=limit,
132
+ )
lixinger/client.py CHANGED
@@ -65,6 +65,7 @@ from lixinger.api.macro import (
65
65
  NationalDebtAPI,
66
66
  NaturalGasAPI,
67
67
  NonFerrousMetalsAPI,
68
+ OfficialReserveAssetsAPI,
68
69
  PlatinumPriceAPI,
69
70
  RmbDepositsAPI,
70
71
  RmbLoansAPI,
@@ -321,6 +322,7 @@ class AsyncLixingerClient:
321
322
  macro_crude_oil = CrudeOilAPI(self._http_client, self.config, self._rate_limiter)
322
323
  macro_natural_gas = NaturalGasAPI(self._http_client, self.config, self._rate_limiter)
323
324
  macro_non_ferrous_metals = NonFerrousMetalsAPI(self._http_client, self.config, self._rate_limiter)
325
+ macro_official_reserve_assets = OfficialReserveAssetsAPI(self._http_client, self.config, self._rate_limiter)
324
326
 
325
327
  # Macro namespace (groups all macro APIs)
326
328
  self.macro = MacroNamespace(
@@ -334,6 +336,7 @@ class AsyncLixingerClient:
334
336
  crude_oil=macro_crude_oil,
335
337
  natural_gas=macro_natural_gas,
336
338
  non_ferrous_metals=macro_non_ferrous_metals,
339
+ official_reserve_assets=macro_official_reserve_assets,
337
340
  )
338
341
 
339
342
  # Legacy flat access for macro APIs (deprecated, for backward compatibility)
@@ -347,6 +350,7 @@ class AsyncLixingerClient:
347
350
  self.macro_crude_oil = macro_crude_oil
348
351
  self.macro_natural_gas = macro_natural_gas
349
352
  self.macro_non_ferrous_metals = macro_non_ferrous_metals
353
+ self.macro_official_reserve_assets = macro_official_reserve_assets
350
354
 
351
355
  # Fund APIs
352
356
  self.cn_fund = FundAPI(self._http_client, self.config, self._rate_limiter)
@@ -0,0 +1,20 @@
1
+ """官方储备资产数据模型."""
2
+
3
+ import pandera.pandas as pa
4
+
5
+
6
+ class OfficialReserveAssets(pa.DataFrameModel):
7
+ """官方储备资产数据模型.
8
+
9
+ 表示某个地区某个时点的官方储备资产数据. 指标以 flatten 后的
10
+ ``granularity.metricsName.expressionCalculateType`` (例如 ``y.ora.t``)
11
+ 形式出现在 extra columns 中, 由请求 ``metrics_list`` 决定.
12
+ """
13
+
14
+ class Config:
15
+ """Pandera configuration."""
16
+
17
+ coerce = True
18
+ strict = False # Allow extra metrics columns like y.ora.t
19
+
20
+ date: pa.typing.Series[pa.typing.DateTime]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lixinger-python
3
- Version: 0.3.24
3
+ Version: 0.3.25
4
4
  Summary: Python SDK for Lixinger Financial Data API
5
5
  Project-URL: Homepage, https://www.lixinger.com
6
6
  Project-URL: Documentation, https://www.lixinger.com/open/api/doc
@@ -1,5 +1,5 @@
1
- lixinger/__init__.py,sha256=csqVki6-8KnIb_6YcNXITUvJw8eyn3NPrr1Ns75yzng,4400
2
- lixinger/client.py,sha256=QvcWB3ZqUue1vX2HbfwMbAyMEdsgaEquI0TX5FgOl_4,19556
1
+ lixinger/__init__.py,sha256=mq4EYODZfr8DbwgyR7XYcikieJLGDiN2Iyjh53m7TYY,4468
2
+ lixinger/client.py,sha256=VcLUyBXk14mLjVtBa2qBFClIPFB0ZTXst1BSW2bOhWc,19845
3
3
  lixinger/config.py,sha256=JPz8EOrf1kP4Do-Z5-MsnOM0pMrNE1ZsP-Qoarh9y4c,2008
4
4
  lixinger/exceptions.py,sha256=Gkv1z-LC09paYGVs430-gDgDs43dLyRHbglB3Frehd4,1069
5
5
  lixinger/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -69,13 +69,14 @@ lixinger/api/cn/industry/margin_trading/__init__.py,sha256=4JZDCF6v2TPg9uyBLKXAf
69
69
  lixinger/api/cn/industry/margin_trading/cni.py,sha256=7IqidE2N2_INiVybeiTt5qFRUY4PJsY6nUPEGtdWJlM,4600
70
70
  lixinger/api/cn/industry/margin_trading/sw.py,sha256=hjC5Uf7XXSwiiqoloIWFx5nDzbxd_D5bB1QPQCEjUjg,4591
71
71
  lixinger/api/cn/industry/margin_trading/sw_2021.py,sha256=uZWAiIdPPLWnvYduAULPythgzgNzLFeVkqP5OEMq_vw,4706
72
- lixinger/api/macro/__init__.py,sha256=MXZEpK6xG6wnBE1IlFlkcJI9BArzc49T0s3tim_1q08,1913
72
+ lixinger/api/macro/__init__.py,sha256=9ocvA6H751nxNRb2O-FLHNorrv2L9LMkTCKJcGwfqGI,2181
73
73
  lixinger/api/macro/crude_oil.py,sha256=9S_7toaelhbiia6qC6YQMEB2Qh39WsXHrLhE0WoeIBY,3486
74
74
  lixinger/api/macro/gold_price.py,sha256=-_seADto-qA5HR_aVMOZKX_JbFYC-W0bQnbIJ6lI_0o,3478
75
- lixinger/api/macro/namespace.py,sha256=O6YjF7KE6pc45s-idwo6DuHUgnH-9Lhdeh7v3NpnuY4,4747
75
+ lixinger/api/macro/namespace.py,sha256=m8nUVA_7iaz5wi_gVuxbmaHA2qeoYUNr0AFCINGtKio,5328
76
76
  lixinger/api/macro/national_debt.py,sha256=Nt7EnJ6Mks2oQbpDznr3ejLl4zg-INRhuDoKsDvuY2A,3834
77
77
  lixinger/api/macro/natural_gas.py,sha256=FyDeaCYqD3Q-AyKZVTqVYK3xavM_ycJo4q33srtdIJY,3486
78
78
  lixinger/api/macro/non_ferrous_metals.py,sha256=WUmzFmAfWL4cZ_1kXUOjA0KNNomawH50G_5fO5zYO34,3756
79
+ lixinger/api/macro/official_reserve_assets.py,sha256=zPz9glis8WLYEj2MteCQOk5BGQh8S64A5utmMbeeIt8,4709
79
80
  lixinger/api/macro/platinum_price.py,sha256=R_wrMrgEb20ktnVBcNxkgNGw9eip1LGmETwoBh3uhAQ,3462
80
81
  lixinger/api/macro/rmb_deposits.py,sha256=BOfQhSi9qPZy1qhVNDanasuwwD2Gz3GsU8RZuoGbIx4,4134
81
82
  lixinger/api/macro/rmb_loans.py,sha256=ne1gmtxqR6jF0qI4W0U99NPf0ds3-O7DBzfo9Vf2grE,4152
@@ -148,6 +149,7 @@ lixinger/models/macro/gold_price.py,sha256=nqsfQWG2zH6dZ7LIu616dZI4xmEKzkHCrTv0h
148
149
  lixinger/models/macro/national_debt.py,sha256=EVOCgzoahjKW0YMq-08ICw17GpOmhJdBWQGqmO0oqQc,581
149
150
  lixinger/models/macro/natural_gas.py,sha256=kAGDY9ZqRrm96azBvjLmk8IyZz5_DhEHfUWR1HrXeM0,554
150
151
  lixinger/models/macro/non_ferrous_metals.py,sha256=8fuOfmR7So1mWZtUuOBO9UiQEN58u1qrEbh6exJ5Vq0,636
152
+ lixinger/models/macro/official_reserve_assets.py,sha256=eDaifzFKo4CKZxel6yIfvE6jdYGRBNiIB51b7fLCC2A,598
151
153
  lixinger/models/macro/platinum_price.py,sha256=4nh11VoHfnL_cUGUeNr0I1njaF4ovmISnKE9_Az16RA,538
152
154
  lixinger/models/macro/rmb_deposits.py,sha256=SeJoD0t3xHjNuSUX6BCUi343wQCnRgOs93BIW9bE9ss,583
153
155
  lixinger/models/macro/rmb_loans.py,sha256=Mptmogd_R2e8TGYkJ36QMtIyLzxmJJdKxt7eJryX3nQ,580
@@ -159,7 +161,7 @@ lixinger/utils/dataframe.py,sha256=tYBrNdmJ4poyuwD-9XgzHt3A_A8bBo0cdHiu8Yy9e9A,2
159
161
  lixinger/utils/dict.py,sha256=yvbUtv8QpRmy0d_o_7gCuEwwiEfBji5_xB490ANxilw,589
160
162
  lixinger/utils/rate_limiter.py,sha256=ZHlRTTL60L62uRA_f--LD26qkAfk-pHBllRqPapAXQM,1141
161
163
  lixinger/utils/retry.py,sha256=C9QBcrpD7WYAuT8R4SJfWNUZFj1mZsv-qyTRIFQDmwc,2862
162
- lixinger_python-0.3.24.dist-info/METADATA,sha256=gucxlsblsko2ji12SqoXT8hdA-x4mGkNa6rwBPuVRY8,9207
163
- lixinger_python-0.3.24.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
164
- lixinger_python-0.3.24.dist-info/licenses/LICENSE,sha256=5oOwRq1lHSOScbNGCHr2feuNnhNYdGcArj6fSUfsC5U,1064
165
- lixinger_python-0.3.24.dist-info/RECORD,,
164
+ lixinger_python-0.3.25.dist-info/METADATA,sha256=ApPLhk8QBSnLps0-HckignTJQEYKx3jHiR5f1G_5xKg,9207
165
+ lixinger_python-0.3.25.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
166
+ lixinger_python-0.3.25.dist-info/licenses/LICENSE,sha256=5oOwRq1lHSOScbNGCHr2feuNnhNYdGcArj6fSUfsC5U,1064
167
+ lixinger_python-0.3.25.dist-info/RECORD,,