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 1, 2024
2 parents be8fe1b + 7fa5afa commit 50fc087
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion akshare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2691,9 +2691,10 @@
1.12.76 fix: fix bond_zh_hs_spot interface
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
"""

__version__ = "1.12.78"
__version__ = "1.12.79"
__author__ = "AKFamily"

import sys
Expand Down
9 changes: 5 additions & 4 deletions akshare/futures_derivative/futures_index_sina.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Date: 2023/11/5 20:00
Date: 2024/3/1 23:00
Desc: 新浪财经-期货的主力合约数据
https://finance.sina.com.cn/futuremarket/index.shtml
"""
Expand Down Expand Up @@ -29,7 +29,8 @@ def zh_subscribe_exchange_symbol(symbol: str = "dce") -> pd.DataFrame:
"""
r = requests.get(zh_subscribe_exchange_symbol_url)
r.encoding = "gb2312"
data_json = demjson.decode(r.text[r.text.find("{"): r.text.find("};") + 1])
data_text = r.text
data_json = demjson.decode(data_text[data_text.find("{"): data_text.find("};") + 1])
if symbol == "czce":
data_json["czce"].remove("郑州商品交易所")
return pd.DataFrame(data_json["czce"])
Expand Down Expand Up @@ -121,7 +122,7 @@ def futures_main_sina(
data_json = data_text[data_text.find("([") + 1: data_text.rfind("])") + 1]
temp_df = pd.read_json(StringIO(data_json))
temp_df.columns = ["日期", "开盘价", "最高价", "最低价", "收盘价", "成交量", "持仓量", "动态结算价"]
temp_df["日期"] = pd.to_datetime(temp_df["日期"]).dt.date
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
temp_df.set_index(keys=["日期"], inplace=True)
temp_df.index = pd.to_datetime(temp_df.index)
temp_df = temp_df[start_date:end_date]
Expand All @@ -142,6 +143,6 @@ def futures_main_sina(
print(futures_display_main_sina_df)

futures_main_sina_hist = futures_main_sina(
symbol="CF0", start_date="20240124", end_date="20240131"
symbol="CF0", start_date="20240124", end_date="20240301"
)
print(futures_main_sina_hist)
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@

## 更新说明详情

1.12.79 fix: fix futures_main_sina interface

1. 修复 futures_main_sina 接口

1.12.78 fix: fix stock_info_sh_delist interface

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

## 版本更新说明

1.12.79 fix: fix futures_main_sina interface

1.12.78 fix: fix stock_info_sh_delist interface

1.12.77 fix: fix futures_contract_info_shfe interface
Expand Down

0 comments on commit 50fc087

Please sign in to comment.