Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
albertandking committed Mar 2, 2024
2 parents 50fc087 + 74e3878 commit 018cbcc
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
3 changes: 2 additions & 1 deletion akshare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2692,9 +2692,10 @@
1.12.77 fix: fix futures_contract_info_shfe interface
1.12.78 fix: fix stock_info_sh_delist interface
1.12.79 fix: fix futures_main_sina interface
1.12.80 fix: fix get_czce_daily interface
"""

__version__ = "1.12.79"
__version__ = "1.12.80"
__author__ = "AKFamily"

import sys
Expand Down
5 changes: 4 additions & 1 deletion akshare/futures/cot.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ def get_czce_rank_table(
date 日期 string YYYYMMDD
"""
date = cons.convert_date(date) if date is not None else datetime.date.today()
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
}
if date < datetime.date(2015, 10, 8):
print("CZCE可获取的数据源开始日期为 20151008, 请输入合适的日期参数")
return {}
Expand All @@ -427,7 +430,7 @@ def get_czce_rank_table(
return {}
if date >= datetime.date(2015, 10, 8):
url = f"http://www.czce.com.cn/cn/DFSStaticFiles/Future/{date.year}/{date.isoformat().replace('-', '')}/FutureDataHolding.xls"
r = requests.get(url)
r = requests.get(url, headers=headers)
temp_df = pd.read_excel(BytesIO(r.content))

temp_pinzhong_index = [
Expand Down
39 changes: 21 additions & 18 deletions akshare/futures/futures_daily_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


def _futures_daily_czce(
date: str = "20100824", dataset: str = "datahistory2010"
date: str = "20100824", dataset: str = "datahistory2010"
) -> pd.DataFrame:
"""
郑州商品交易所-交易数据-历史行情下载
Expand Down Expand Up @@ -294,17 +294,17 @@ def get_ine_daily(date: str = "20220208") -> pd.DataFrame:
temp_df = temp_df[~temp_df["PRODUCTNAME"].str.contains("总计")]
try:
result_df["symbol"] = (
temp_df["PRODUCTGROUPID"].str.upper().str.strip()
+ temp_df["DELIVERYMONTH"]
temp_df["PRODUCTGROUPID"].str.upper().str.strip()
+ temp_df["DELIVERYMONTH"]
)
except:
result_df["symbol"] = (
temp_df["PRODUCTID"]
.str.upper()
.str.strip()
.str.split("_", expand=True)
.iloc[:, 0]
+ temp_df["DELIVERYMONTH"]
temp_df["PRODUCTID"]
.str.upper()
.str.strip()
.str.split("_", expand=True)
.iloc[:, 0]
+ temp_df["DELIVERYMONTH"]
)
result_df["date"] = day.strftime("%Y%m%d")
result_df["open"] = temp_df["OPENPRICE"]
Expand Down Expand Up @@ -348,9 +348,12 @@ def get_czce_daily(date: str = "20050525") -> pd.DataFrame:
day = (
cons.convert_date(date) if date is not None else datetime.date.today()
)
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
}
if day.strftime("%Y%m%d") not in calendar:
# warnings.warn(f"{day.strftime('%Y%m%d')}非交易日")
return
return pd.DataFrame()
if day > datetime.date(2010, 8, 24):
if day > datetime.date(2015, 11, 11):
u = cons.CZCE_DAILY_URL_3
Expand All @@ -361,11 +364,11 @@ def get_czce_daily(date: str = "20050525") -> pd.DataFrame:
listed_columns = cons.CZCE_COLUMNS
output_columns = cons.OUTPUT_COLUMNS
try:
r = requests.get(url)
r = requests.get(url, headers=headers)
if (
datetime.date(2015, 11, 12)
<= day
<= datetime.date(2017, 12, 27)
datetime.date(2015, 11, 12)
<= day
<= datetime.date(2017, 12, 27)
):
html = str(r.content, encoding="gbk")
else:
Expand Down Expand Up @@ -544,7 +547,7 @@ def get_shfe_daily(date: str = "20220415") -> pd.DataFrame:
row
for row in json_data["o_curinstrument"]
if row["DELIVERYMONTH"] not in ["小计", "合计"]
and row["DELIVERYMONTH"] != ""
and row["DELIVERYMONTH"] != ""
]
)
try:
Expand Down Expand Up @@ -683,9 +686,9 @@ def get_dce_daily(date: str = "20220308") -> pd.DataFrame:


def get_futures_daily(
start_date: str = "20220208",
end_date: str = "20220208",
market: str = "CFFEX",
start_date: str = "20220208",
end_date: str = "20220208",
market: str = "CFFEX",
) -> pd.DataFrame:
"""
交易所日交易数据
Expand Down
7 changes: 7 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@

## 更新说明详情

1.12.80 fix: fix get_czce_daily interface

1. 修复 get_czce_daily 接口
2. 修复 get_czce_rank_table 接口

1.12.79 fix: fix futures_main_sina interface

1. 修复 futures_main_sina 接口
Expand Down Expand Up @@ -3644,6 +3649,8 @@

## 版本更新说明

1.12.80 fix: fix get_czce_daily interface

1.12.79 fix: fix futures_main_sina interface

1.12.78 fix: fix stock_info_sh_delist interface
Expand Down
2 changes: 1 addition & 1 deletion docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
**风险提示:[AKShare](https://github.com/akfamily/akshare) 开源财经数据接口库所采集的数据皆来自公开的数据源,不涉及任何个人隐私数据和非公开数据。
同时本项目提供的数据接口及相关数据仅用于学术研究,任何个人、机构及团体使用本项目的数据接口及相关数据请注意商业风险。**

1. 本文档更新时间:**2024-03-01**
1. 本文档更新时间:**2024-03-02**
2. 如有 [AKShare](https://github.com/akfamily/akshare) 库、文档及数据的相关问题,请在 [AKShare Issues](https://github.com/akfamily/akshare/issues) 中提 Issues;
3. 欢迎关注 **数据科学实战** 微信公众号:<div><img src="https://jfds-1252952517.cos.ap-chengdu.myqcloud.com/akshare/readme/qrcode/ds.png"></div>;
4. 如果您的问题未能在文档中找到答案,您也可以加入 **AKShare-VIP QQ 群**: 为了提高问答质量,此群为收费群(一杯咖啡钱即可入群,赠送[《AKShare-初阶-使用教学》](https://zmj.xet.tech/s/wck86)视频课),可以添加 **AKShare-小助手** QQ:1254836886,由小助手邀请入群! ![](https://jfds-1252952517.cos.ap-chengdu.myqcloud.com/akshare/readme/qrcode/qr_code_1254836886.jpg)
Expand Down

0 comments on commit 018cbcc

Please sign in to comment.