akshare 1.14.88__py3-none-any.whl → 1.14.90__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.
Potentially problematic release.
This version of akshare might be problematic. Click here for more details.
- akshare/__init__.py +3 -1
- akshare/bond/bond_china.py +38 -39
- akshare/fund/fund_em.py +181 -155
- akshare/stock_feature/stock_gdhs.py +73 -49
- akshare/stock_feature/stock_pankou_em.py +72 -34
- {akshare-1.14.88.dist-info → akshare-1.14.90.dist-info}/METADATA +1 -1
- {akshare-1.14.88.dist-info → akshare-1.14.90.dist-info}/RECORD +10 -10
- {akshare-1.14.88.dist-info → akshare-1.14.90.dist-info}/LICENSE +0 -0
- {akshare-1.14.88.dist-info → akshare-1.14.90.dist-info}/WHEEL +0 -0
- {akshare-1.14.88.dist-info → akshare-1.14.90.dist-info}/top_level.txt +0 -0
akshare/__init__.py
CHANGED
|
@@ -2899,9 +2899,11 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
|
|
|
2899
2899
|
1.14.86 fix: fix stock_comment_detail_scrd_focus_em interface
|
|
2900
2900
|
1.14.87 fix: fix stock_hot_search_baidu interface
|
|
2901
2901
|
1.14.88 fix: fix stock_hot_rank_relate_em interface
|
|
2902
|
+
1.14.89 fix: fix bond_spot_deal interface
|
|
2903
|
+
1.14.90 fix: fix stock_board_change_em interface
|
|
2902
2904
|
"""
|
|
2903
2905
|
|
|
2904
|
-
__version__ = "1.14.
|
|
2906
|
+
__version__ = "1.14.90"
|
|
2905
2907
|
__author__ = "AKFamily"
|
|
2906
2908
|
|
|
2907
2909
|
import sys
|
akshare/bond/bond_china.py
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date: 2024/
|
|
4
|
+
Date: 2024/10/1 17:00
|
|
5
5
|
Desc: 中国外汇交易中心暨全国银行间同业拆借中心
|
|
6
6
|
中国外汇交易中心暨全国银行间同业拆借中心-市场数据-债券市场行情-现券市场做市报价
|
|
7
7
|
中国外汇交易中心暨全国银行间同业拆借中心-市场数据-债券市场行情-现券市场成交行情
|
|
8
8
|
https://www.chinamoney.com.cn/chinese/mkdatabond/
|
|
9
9
|
"""
|
|
10
|
+
|
|
10
11
|
from io import StringIO
|
|
11
12
|
|
|
12
13
|
import pandas as pd
|
|
13
14
|
import requests
|
|
14
15
|
|
|
15
16
|
from akshare.bond.bond_china_money import bond_china_close_return_map
|
|
17
|
+
from akshare.utils.cons import headers
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
def bond_spot_quote() -> pd.DataFrame:
|
|
@@ -24,9 +26,6 @@ def bond_spot_quote() -> pd.DataFrame:
|
|
|
24
26
|
"""
|
|
25
27
|
bond_china_close_return_map()
|
|
26
28
|
url = "https://www.chinamoney.com.cn/ags/ms/cm-u-md-bond/CbMktMakQuot"
|
|
27
|
-
headers = {
|
|
28
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
|
|
29
|
-
}
|
|
30
29
|
payload = {
|
|
31
30
|
"flag": "1",
|
|
32
31
|
"lang": "cn",
|
|
@@ -61,16 +60,24 @@ def bond_spot_quote() -> pd.DataFrame:
|
|
|
61
60
|
"买入/卖出收益率",
|
|
62
61
|
]
|
|
63
62
|
]
|
|
64
|
-
temp_df["买入净价"] =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
temp_df["
|
|
63
|
+
temp_df["买入净价"] = (
|
|
64
|
+
temp_df["买入/卖出净价"].str.split("/", expand=True).iloc[:, 0]
|
|
65
|
+
)
|
|
66
|
+
temp_df["卖出净价"] = (
|
|
67
|
+
temp_df["买入/卖出净价"].str.split("/", expand=True).iloc[:, 1]
|
|
68
|
+
)
|
|
69
|
+
temp_df["买入收益率"] = (
|
|
70
|
+
temp_df["买入/卖出收益率"].str.split("/", expand=True).iloc[:, 0]
|
|
71
|
+
)
|
|
72
|
+
temp_df["卖出收益率"] = (
|
|
73
|
+
temp_df["买入/卖出收益率"].str.split("/", expand=True).iloc[:, 1]
|
|
74
|
+
)
|
|
68
75
|
del temp_df["买入/卖出净价"]
|
|
69
76
|
del temp_df["买入/卖出收益率"]
|
|
70
|
-
temp_df[
|
|
71
|
-
temp_df[
|
|
72
|
-
temp_df[
|
|
73
|
-
temp_df[
|
|
77
|
+
temp_df["买入净价"] = pd.to_numeric(temp_df["买入净价"], errors="coerce")
|
|
78
|
+
temp_df["卖出净价"] = pd.to_numeric(temp_df["卖出净价"], errors="coerce")
|
|
79
|
+
temp_df["买入收益率"] = pd.to_numeric(temp_df["买入收益率"], errors="coerce")
|
|
80
|
+
temp_df["卖出收益率"] = pd.to_numeric(temp_df["卖出收益率"], errors="coerce")
|
|
74
81
|
return temp_df
|
|
75
82
|
|
|
76
83
|
|
|
@@ -82,9 +89,6 @@ def bond_spot_deal() -> pd.DataFrame:
|
|
|
82
89
|
:rtype: pandas.DataFrame
|
|
83
90
|
"""
|
|
84
91
|
url = "https://www.chinamoney.com.cn/ags/ms/cm-u-md-bond/CbtPri"
|
|
85
|
-
headers = {
|
|
86
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
|
|
87
|
-
}
|
|
88
92
|
payload = {
|
|
89
93
|
"flag": "1",
|
|
90
94
|
"lang": "cn",
|
|
@@ -127,16 +131,16 @@ def bond_spot_deal() -> pd.DataFrame:
|
|
|
127
131
|
"交易量",
|
|
128
132
|
]
|
|
129
133
|
]
|
|
130
|
-
temp_df[
|
|
131
|
-
temp_df[
|
|
132
|
-
temp_df[
|
|
133
|
-
temp_df[
|
|
134
|
-
temp_df[
|
|
134
|
+
temp_df["成交净价"] = pd.to_numeric(temp_df["成交净价"], errors="coerce")
|
|
135
|
+
temp_df["最新收益率"] = pd.to_numeric(temp_df["最新收益率"], errors="coerce")
|
|
136
|
+
temp_df["涨跌"] = pd.to_numeric(temp_df["涨跌"], errors="coerce")
|
|
137
|
+
temp_df["加权收益率"] = pd.to_numeric(temp_df["加权收益率"], errors="coerce")
|
|
138
|
+
temp_df["交易量"] = pd.to_numeric(temp_df["交易量"], errors="coerce")
|
|
135
139
|
return temp_df
|
|
136
140
|
|
|
137
141
|
|
|
138
142
|
def bond_china_yield(
|
|
139
|
-
|
|
143
|
+
start_date: str = "20200204", end_date: str = "20210124"
|
|
140
144
|
) -> pd.DataFrame:
|
|
141
145
|
"""
|
|
142
146
|
中国债券信息网-国债及其他债券收益率曲线
|
|
@@ -152,28 +156,25 @@ def bond_china_yield(
|
|
|
152
156
|
"""
|
|
153
157
|
url = "https://yield.chinabond.com.cn/cbweb-pbc-web/pbc/historyQuery"
|
|
154
158
|
params = {
|
|
155
|
-
"startDate":
|
|
156
|
-
"endDate":
|
|
159
|
+
"startDate": "-".join([start_date[:4], start_date[4:6], start_date[6:]]),
|
|
160
|
+
"endDate": "-".join([end_date[:4], end_date[4:6], end_date[6:]]),
|
|
157
161
|
"gjqx": "0",
|
|
158
162
|
"qxId": "ycqx",
|
|
159
163
|
"locale": "cn_ZH",
|
|
160
164
|
}
|
|
161
|
-
headers = {
|
|
162
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
|
|
163
|
-
}
|
|
164
165
|
res = requests.get(url, params=params, headers=headers)
|
|
165
166
|
data_text = res.text.replace(" ", "")
|
|
166
167
|
data_df = pd.read_html(StringIO(data_text), header=0)[1]
|
|
167
|
-
data_df[
|
|
168
|
-
data_df[
|
|
169
|
-
data_df[
|
|
170
|
-
data_df[
|
|
171
|
-
data_df[
|
|
172
|
-
data_df[
|
|
173
|
-
data_df[
|
|
174
|
-
data_df[
|
|
175
|
-
data_df[
|
|
176
|
-
data_df.sort_values(by=
|
|
168
|
+
data_df["日期"] = pd.to_datetime(data_df["日期"], errors="coerce").dt.date
|
|
169
|
+
data_df["3月"] = pd.to_numeric(data_df["3月"], errors="coerce")
|
|
170
|
+
data_df["6月"] = pd.to_numeric(data_df["6月"], errors="coerce")
|
|
171
|
+
data_df["1年"] = pd.to_numeric(data_df["1年"], errors="coerce")
|
|
172
|
+
data_df["3年"] = pd.to_numeric(data_df["3年"], errors="coerce")
|
|
173
|
+
data_df["5年"] = pd.to_numeric(data_df["5年"], errors="coerce")
|
|
174
|
+
data_df["7年"] = pd.to_numeric(data_df["7年"], errors="coerce")
|
|
175
|
+
data_df["10年"] = pd.to_numeric(data_df["10年"], errors="coerce")
|
|
176
|
+
data_df["30年"] = pd.to_numeric(data_df["30年"], errors="coerce")
|
|
177
|
+
data_df.sort_values(by="日期", inplace=True)
|
|
177
178
|
data_df.reset_index(inplace=True, drop=True)
|
|
178
179
|
return data_df
|
|
179
180
|
|
|
@@ -185,7 +186,5 @@ if __name__ == "__main__":
|
|
|
185
186
|
bond_spot_deal_df = bond_spot_deal()
|
|
186
187
|
print(bond_spot_deal_df)
|
|
187
188
|
|
|
188
|
-
bond_china_yield_df = bond_china_yield(
|
|
189
|
-
start_date="20210201", end_date="20220201"
|
|
190
|
-
)
|
|
189
|
+
bond_china_yield_df = bond_china_yield(start_date="20210201", end_date="20220201")
|
|
191
190
|
print(bond_china_yield_df)
|