Skip to content

Commit

Permalink
Date (#4460)
Browse files Browse the repository at this point in the history
* add version 1.12.38

* fix futures_index_ccidx

* fix futures_to_spot_dce
  • Loading branch information
albertandking authored Jan 22, 2024
1 parent ead8da8 commit 0085764
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 150 deletions.
3 changes: 2 additions & 1 deletion akshare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2650,9 +2650,10 @@
1.12.35 fix: fix article_epu_index interface
1.12.36 fix: fix bond_china_close_return interface
1.12.37 fix: fix futures_delivery_shfe interface
1.12.38 fix: fix futures_to_spot_dce interface
"""

__version__ = "1.12.37"
__version__ = "1.12.38"
__author__ = "AKFamily"

import sys
Expand Down
1 change: 0 additions & 1 deletion akshare/futures/futures_index_ccidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def futures_index_ccidx(symbol: str = "中证商品期货指数") -> pd.DataFram
params = {"indexCode": futures_index_map[symbol]}
r = requests.get(url, params=params)
temp_df = pd.read_excel(BytesIO(r.content), header=1, engine="openpyxl")

temp_df.columns = [
"日期",
"指数代码",
Expand Down
14 changes: 11 additions & 3 deletions akshare/futures/futures_to_spot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import requests


def futures_to_spot_shfe(date: str = "202101") -> pd.DataFrame:
def futures_to_spot_shfe(date: str = "202312") -> pd.DataFrame:
"""
上海期货交易所-期转现
https://www.shfe.com.cn/statements/dataview.html?paramid=kx
Expand Down Expand Up @@ -46,10 +46,13 @@ def futures_to_spot_shfe(date: str = "202101") -> pd.DataFrame:
"期转现量",
]
]
temp_df['日期'] = pd.to_datetime(temp_df['日期'], errors="coerce").dt.date
temp_df['交割量'] = pd.to_numeric(temp_df['交割量'], errors="coerce")
temp_df['期转现量'] = pd.to_numeric(temp_df['期转现量'], errors="coerce")
return temp_df


def futures_delivery_dce(date: str = "202101") -> pd.DataFrame:
def futures_delivery_dce(date: str = "202312") -> pd.DataFrame:
"""
大连商品交易所-交割统计
http://www.dce.com.cn/dalianshangpin/xqsj/tjsj26/jgtj/jgsj/index.html
Expand Down Expand Up @@ -81,6 +84,11 @@ def futures_delivery_dce(date: str = "202101") -> pd.DataFrame:
temp_df["交割日期"] = (
temp_df["交割日期"].astype(str).str.split(".", expand=True).iloc[:, 0]
)
temp_df = temp_df[~temp_df['品种'].str.contains('小计|总计')]
temp_df.reset_index(inplace=True, drop=True)
temp_df['交割日期'] = pd.to_datetime(temp_df['交割日期'], errors="coerce").dt.date
temp_df['交割量'] = pd.to_numeric(temp_df['交割量'], errors="coerce")
temp_df['交割金额'] = pd.to_numeric(temp_df['交割金额'], errors="coerce")
return temp_df


Expand Down Expand Up @@ -298,7 +306,7 @@ def futures_delivery_shfe(date: str = "202312") -> pd.DataFrame:
futures_to_spot_dce_df = futures_to_spot_dce(date="202102")
print(futures_to_spot_dce_df)

futures_to_spot_shfe_df = futures_to_spot_shfe(date="202101")
futures_to_spot_shfe_df = futures_to_spot_shfe(date="202312")
print(futures_to_spot_shfe_df)

futures_to_spot_czce_df = futures_to_spot_czce(date="20210112")
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.38 fix: fix futures_to_spot_dce interface

1. 修复 futures_to_spot_dce 接口
2. 修复 futures_to_spot_shfe 接口

1.12.37 fix: fix futures_delivery_shfe interface

1. 修复 futures_delivery_shfe 接口
Expand Down Expand Up @@ -3440,6 +3445,8 @@

## 版本更新说明

1.12.38 fix: fix futures_to_spot_dce interface

1.12.37 fix: fix futures_delivery_shfe interface

1.12.36 fix: fix bond_china_close_return interface
Expand Down
Loading

0 comments on commit 0085764

Please sign in to comment.