Skip to content

Commit

Permalink
Dev (#4869)
Browse files Browse the repository at this point in the history
* docs: update date

* fix: fix stock_info_cjzc_em

* fix(futures_contract_info_shfe): 修复由于上海期货交易所网站改版导致的`futures_contract_info_shfe`获取错误的问题 (#4867)

- 更新url到旧版上期所地址`tsite.shfe.com.cn`

* fix: fix futures_contract_info_shfe

* feat: add version 1.13.72

---------

Co-authored-by: JiangJam <[email protected]>
  • Loading branch information
albertandking and JiangJamm committed May 13, 2024
1 parent 84ca36b commit 4227706
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
3 changes: 2 additions & 1 deletion akshare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2783,9 +2783,10 @@
1.13.69 fix: fix get_shfe_rank_table interface
1.13.70 fix: fix stock_irm_cninfo interface
1.13.71 fix: fix stock_fhps_detail_ths interface
1.13.72 fix: fix futures_contract_info_shfe interface
"""

__version__ = "1.13.71"
__version__ = "1.13.72"
__author__ = "AKFamily"

import sys
Expand Down
12 changes: 6 additions & 6 deletions akshare/futures_derivative/futures_contract_info_shfe.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Date: 2024/4/8 17:30
Date: 2024/5/13 17:45
Desc: 上海期货交易所-交易所服务-业务数据-交易参数汇总查询
https://www.shfe.com.cn/bourseService/businessdata/summaryinquiry/
https://tsite.shfe.com.cn/bourseService/businessdata/summaryinquiry/
"""

import pandas as pd
import requests


def futures_contract_info_shfe(date: str = "20240227") -> pd.DataFrame:
def futures_contract_info_shfe(date: str = "20240513") -> pd.DataFrame:
"""
上海期货交易所-交易所服务-业务数据-交易参数汇总查询
https://www.shfe.com.cn/bourseService/businessdata/summaryinquiry/
https://tsite.shfe.com.cn/bourseService/businessdata/summaryinquiry/
:param date: 查询日期; 交易日
:type date: str
:return: 交易参数汇总查询
:rtype: pandas.DataFrame
"""
url = f"https://www.shfe.com.cn/data/instrument/ContractBaseInfo{date}.dat"
url = f"https://tsite.shfe.com.cn/data/instrument/ContractBaseInfo{date}.dat"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/119.0.0.0 Safari/537.36"
Expand Down Expand Up @@ -66,5 +66,5 @@ def futures_contract_info_shfe(date: str = "20240227") -> pd.DataFrame:


if __name__ == "__main__":
futures_contract_info_shfe_df = futures_contract_info_shfe(date="20240422")
futures_contract_info_shfe_df = futures_contract_info_shfe(date="20240513")
print(futures_contract_info_shfe_df)
2 changes: 1 addition & 1 deletion akshare/stock_feature/stock_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def stock_info_cjzc_em() -> pd.DataFrame:
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["list"])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)

big_df = big_df[["title", "summary", "showTime", "uniqueUrl"]]
big_df.rename(
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@

## 更新说明详情

1.13.72 fix: fix futures_contract_info_shfe interface

1. 修复 futures_contract_info_shfe 接口

1.13.71 fix: fix stock_fhps_detail_ths interface

1. 修复 stock_fhps_detail_ths 接口
Expand Down Expand Up @@ -4077,6 +4081,8 @@

## 版本更新说明

1.13.72 fix: fix futures_contract_info_shfe interface

1.13.71 fix: fix stock_fhps_detail_ths interface

1.13.70 fix: fix stock_irm_cninfo interface
Expand Down
28 changes: 14 additions & 14 deletions docs/data/futures/futures.md
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,7 @@ print(futures_spot_sys_df)

接口: futures_contract_info_shfe

目标地址: https://www.shfe.com.cn/bourseService/businessdata/summaryinquiry/
目标地址: https://tsite.shfe.com.cn/bourseService/businessdata/summaryinquiry/

描述: 上海期货交易所-交易所服务-业务数据-交易参数汇总查询

Expand All @@ -2394,7 +2394,7 @@ print(futures_spot_sys_df)

| 名称 | 类型 | 描述 |
|------|-----|----------------------|
| date | str | date="20240227"; 交易日 |
| date | str | date="20240513"; 交易日 |

输出参数

Expand All @@ -2414,25 +2414,25 @@ print(futures_spot_sys_df)
```python
import akshare as ak

futures_contract_info_shfe_df = ak.futures_contract_info_shfe(date="20240227")
futures_contract_info_shfe_df = ak.futures_contract_info_shfe(date="20240513")
print(futures_contract_info_shfe_df)
```

数据示例

```
合约代码 上市日 到期日 ... 挂牌基准价 交易日 更新时间
0 cu2403 2023-03-16 2024-03-15 ... 67870.0 2024-02-27 2024-02-27 17:21:10
1 cu2404 2023-04-18 2024-04-15 ... 69110.0 2024-02-27 2024-02-27 17:21:10
2 cu2405 2023-05-16 2024-05-15 ... 64490.0 2024-02-27 2024-02-27 17:21:10
3 cu2406 2023-06-16 2024-06-17 ... 66930.0 2024-02-27 2024-02-27 17:21:10
4 cu2407 2023-07-18 2024-07-15 ... 68220.0 2024-02-27 2024-02-27 17:21:10
合约代码 上市日 到期日 ... 挂牌基准价 交易日 更新时间
0 cu2405 2023-05-16 2024-05-15 ... 64490.0 2024-05-13 2024-05-13 18:21:10
1 cu2406 2023-06-16 2024-06-17 ... 66930.0 2024-05-13 2024-05-13 18:21:10
2 cu2407 2023-07-18 2024-07-15 ... 68220.0 2024-05-13 2024-05-13 18:21:10
3 cu2408 2023-08-16 2024-08-15 ... 67270.0 2024-05-13 2024-05-13 18:21:10
4 cu2409 2023-09-18 2024-09-18 ... 68900.0 2024-05-13 2024-05-13 18:21:10
.. ... ... ... ... ... ... ...
271 ec2406 2023-08-18 2024-06-24 ... 780.0 2024-02-27 2024-02-27 17:21:10
272 ec2408 2023-08-18 2024-08-26 ... 780.0 2024-02-27 2024-02-27 17:21:10
273 ec2410 2023-08-18 2024-10-28 ... 780.0 2024-02-27 2024-02-27 17:21:10
274 ec2412 2023-08-18 2024-12-30 ... 780.0 2024-02-27 2024-02-27 17:21:10
275 ec2502 2024-02-27 2025-02-24 ... 1359.8 2024-02-27 2024-02-27 17:21:10
271 ec2408 2023-08-18 2024-08-26 ... 780.0 2024-05-13 2024-05-13 18:21:10
272 ec2410 2023-08-18 2024-10-28 ... 780.0 2024-05-13 2024-05-13 18:21:10
273 ec2412 2023-08-18 2024-12-30 ... 780.0 2024-05-13 2024-05-13 18:21:10
274 ec2502 2024-02-27 2025-02-24 ... 1359.8 2024-05-13 2024-05-13 18:21:10
275 ec2504 2024-04-30 2025-04-28 ... 2158.3 2024-05-13 2024-05-13 18:21:10
[276 rows x 8 columns]
```

Expand Down

0 comments on commit 4227706

Please sign in to comment.