Skip to content

Commit

Permalink
feat(stock_hot_rank_detail_realtime_em): add stock_hot_rank_detail_re…
Browse files Browse the repository at this point in the history
…altime_em interface

add stock_hot_rank_detail_realtime_em interface
  • Loading branch information
ak-quant committed Feb 11, 2022
1 parent 049fe93 commit 6cf8ce8
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 7 deletions.
12 changes: 10 additions & 2 deletions akshare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,9 +1835,10 @@
1.4.12 add: add stock_hot_rank_em interface
1.4.13 add: add stock_hot_rank_detail_em interface
1.4.14 add: add index_bi_cx interface
1.4.15 add: add stock_hot_rank_detail_realtime_em interface
"""

__version__ = "1.4.14"
__version__ = "1.4.15"
__author__ = "Albert King"

import sys
Expand All @@ -1850,7 +1851,14 @@

"""
"""
from akshare.stock.stock_hot_rank_em import stock_hot_rank_detail_em, stock_hot_rank_em
from akshare.stock.stock_hot_rank_em import (
stock_hot_rank_detail_em,
stock_hot_rank_em,
stock_hot_rank_detail_realtime_em,
stock_hot_rank_relate_em,
stock_hot_keyword_em,
stock_hot_rank_latest_em,
)

"""
冬奥会历届奖牌榜
Expand Down
111 changes: 106 additions & 5 deletions akshare/stock/stock_hot_rank_em.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding:utf-8 -*-
# !/usr/bin/env python
"""
Date: 2022/2/10 21:30
Date: 2022/2/11 14:15
Desc: 东方财富个股人气榜-人气榜
http://guba.eastmoney.com/rank/
"""
Expand Down Expand Up @@ -99,13 +99,114 @@ def stock_hot_rank_detail_em(symbol: str = "SH603123") -> pd.DataFrame:
return temp_df


def stock_hot_rank_detail_realtime_em(symbol: str = "SZ000665") -> pd.DataFrame:
"""
东方财富个股人气榜-实时变动
http://guba.eastmoney.com/rank/stock?code=000665
:param symbol: 带市场表示的证券代码
:type symbol: str
:return: 实时变动
:rtype: pandas.DataFrame
"""
url = "https://emappdata.eastmoney.com/stockrank/getCurrentList"
payload = {
"appId": "appId01",
"globalId": "786e4c21-70dc-435a-93bb-38",
"marketType": "",
"srcSecurityCode": symbol,
}
r = requests.post(url, json=payload)
data_json = r.json()
temp_df = pd.DataFrame(data_json['data'])
temp_df.columns = ['时间', '排名']
return temp_df


def stock_hot_keyword_em(symbol: str = "SZ000665") -> pd.DataFrame:
"""
东方财富个股人气榜-关键词
http://guba.eastmoney.com/rank/stock?code=000665
:param symbol: 带市场表示的证券代码
:type symbol: str
:return: 关键词
:rtype: pandas.DataFrame
"""
url = "https://emappdata.eastmoney.com/stockrank/getHotStockRankList"
payload = {
"appId": "appId01",
"globalId": "786e4c21-70dc-435a-93bb-38",
"srcSecurityCode": symbol,
}
r = requests.post(url, json=payload)
data_json = r.json()
temp_df = pd.DataFrame(data_json['data'])
del temp_df['flag']
temp_df.columns = ['时间', '股票代码', '概念名称', '概念代码', '热度']
return temp_df


def stock_hot_rank_latest_em(symbol: str = "SZ000665") -> pd.DataFrame:
"""
东方财富个股人气榜-最新排名
http://guba.eastmoney.com/rank/stock?code=000665
:param symbol: 带市场表示的证券代码
:type symbol: str
:return: 最新排名
:rtype: pandas.DataFrame
"""
url = "https://emappdata.eastmoney.com/stockrank/getCurrentLatest"
payload = {
"appId": "appId01",
"globalId": "786e4c21-70dc-435a-93bb-38",
'marketType': "",
"srcSecurityCode": symbol,
}
r = requests.post(url, json=payload)
data_json = r.json()
temp_df = pd.DataFrame.from_dict(data_json['data'], orient="index")
temp_df.reset_index(inplace=True)
temp_df.columns = ['item', 'value']
return temp_df


def stock_hot_rank_relate_em(symbol: str = "SZ000665") -> pd.DataFrame:
"""
东方财富个股人气榜-相关股票
http://guba.eastmoney.com/rank/stock?code=000665
:param symbol: 带市场表示的证券代码
:type symbol: str
:return: 相关股票
:rtype: pandas.DataFrame
"""
url = "https://emappdata.eastmoney.com/stockrank/getFollowStockRankList"
payload = {
"appId": "appId01",
"globalId": "786e4c21-70dc-435a-93bb-38",
"srcSecurityCode": symbol,
}
r = requests.post(url, json=payload)
data_json = r.json()
temp_df = pd.DataFrame.from_dict(data_json['data'])
temp_df.columns = ['时间', '-', '股票代码', '-', '相关股票代码', '涨跌幅', '-']
temp_df = temp_df[['时间', '股票代码', '相关股票代码', '涨跌幅']]
return temp_df


if __name__ == "__main__":
stock_hot_rank_em_df = stock_hot_rank_em()
print(stock_hot_rank_em_df)

stock_hot_rank_detail_em_df = stock_hot_rank_detail_em()
stock_hot_rank_detail_em_df = stock_hot_rank_detail_em(symbol="SZ000665")
print(stock_hot_rank_detail_em_df)

for stock in stock_hot_rank_em_df["代码"]:
stock_hot_rank_detail_em_df = stock_hot_rank_detail_em(stock)
print(stock_hot_rank_detail_em_df)
stock_hot_rank_detail_realtime_em_df = stock_hot_rank_detail_realtime_em(symbol="SZ000665")
print(stock_hot_rank_detail_realtime_em_df)

stock_hot_keyword_em_df = stock_hot_keyword_em(symbol="SZ000665")
print(stock_hot_keyword_em_df)

stock_hot_rank_latest_em_df = stock_hot_rank_latest_em(symbol="SZ000665")
print(stock_hot_rank_latest_em_df)

stock_hot_rank_relate_em_df = stock_hot_rank_relate_em(symbol="SZ000665")
print(stock_hot_rank_relate_em_df)
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3083,4 +3083,6 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
1.4.13 add: add stock_hot_rank_detail_em interface
1.4.14 add: add index_bi_cx interface
1.4.15 add: add stock_hot_rank_detail_realtime_em interface
```

0 comments on commit 6cf8ce8

Please sign in to comment.