Skip to content

Commit

Permalink
feat(stock_zh_tick_tx_js): add stock_zh_tick_tx_js to fetch current data
Browse files Browse the repository at this point in the history
add stock_zh_tick_tx_js to fetch current data
  • Loading branch information
albertandking committed Apr 9, 2020
1 parent f90ed41 commit c094883
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 28 deletions.
5 changes: 3 additions & 2 deletions akshare/__init__.py
Expand Up @@ -900,9 +900,10 @@
0.4.70: add: covid_19 CSSE 数据接口
0.4.71: add: argus
0.4.72: add: stock_zh_tick_163
0.4.73: add: stock_zh_tick_tx_js
"""

__version__ = "0.4.72"
__version__ = "0.4.73"
__author__ = "Albert King"

"""
Expand Down Expand Up @@ -1459,7 +1460,7 @@
"""
新浪-指数实时行情和历史行情
"""
from akshare.stock.zh_stock_a_tick_tx_163 import stock_zh_a_tick_tx, stock_zh_a_tick_163
from akshare.stock.zh_stock_a_tick_tx_163 import stock_zh_a_tick_tx, stock_zh_a_tick_163, stock_zh_a_tick_tx_js

"""
新浪-指数实时行情和历史行情
Expand Down
28 changes: 28 additions & 0 deletions akshare/stock/zh_stock_a_tick_tx_163.py
Expand Up @@ -14,6 +14,31 @@
import requests


def stock_zh_a_tick_tx_js(code: str = "sz000001"):
big_df = pd.DataFrame()
page = 0
while True:
try:
url = "http://stock.gtimg.cn/data/index.php"
params = {
"appn": "detail",
"action": "data",
"c": code,
"p": page,
}
r = requests.get(url, params=params)
text_data = r.text
temp_df = pd.DataFrame(eval(text_data[text_data.find("["):])[1].split("|")).iloc[:, 0].str.split("/", expand=True)
page += 1
big_df = big_df.append(temp_df)
except:
break
if not big_df.empty:
big_df = big_df.iloc[:, 1:]
big_df.columns = ["成交时间", "成交价", "价格变动", "成交量(手)", "成交额(元)", "性质"]
return big_df


def stock_zh_a_tick_tx(code: str = "sh600848", trade_date: str = "20191011") -> pd.DataFrame:
"""
http://gu.qq.com/sz000001/gp/detail
Expand Down Expand Up @@ -68,3 +93,6 @@ def stock_zh_a_tick_163(code: str = "sh600848", trade_date: str = "20200408") ->
print(data)
stock_zh_a_tick_163_df = stock_zh_a_tick_163(code="sh600848", trade_date="20200408")
print(stock_zh_a_tick_163_df)

stock_zh_a_tick_tx_js_df = stock_zh_a_tick_tx_js(code="sz000001")
print(stock_zh_a_tick_tx_js_df)
2 changes: 2 additions & 0 deletions docs/changelog.md
Expand Up @@ -1219,4 +1219,6 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
0.4.71: add: argus
0.4.72: add: stock_zh_tick_163
0.4.73: add: stock_zh_tick_tx_js
```
52 changes: 26 additions & 26 deletions docs/data/stock/stock.md
Expand Up @@ -171,29 +171,29 @@ print(stock_df)
数据示例-前复权因子

```
date qfq_factor
0 2019-06-11 1.0000000000000000
1 2018-07-13 1.0310834813499000
2 2017-05-25 1.0419713745004000
3 2016-06-23 1.3723042771825000
4 2015-06-23 1.5542777479525000
5 2014-06-24 1.6264035528443000
6 2013-06-03 1.7456731467196000
7 2012-06-26 1.8424594602978000
8 2011-06-03 1.9111225457747000
9 2010-06-10 2.5149201133019000
10 2009-06-09 3.2961214563983000
11 2008-04-24 4.6495289028892000
12 2007-07-18 6.0719168083645000
13 2006-05-25 6.0970905928105000
14 2006-05-12 6.1773967505679000
15 2005-05-12 8.0306157757383010
16 2004-05-20 8.1694736854052000
17 2003-06-23 8.2663101191762000
18 2002-08-22 8.3354264245204000
19 2000-07-06 12.6405367756464000
20 1999-11-10 12.7227249211316980
21 1900-01-01 12.7227249211316980
date qfq_factor
0 2019-06-11 1.0000000000000000
1 2018-07-13 1.0310834813499000
2 2017-05-25 1.0419713745004000
3 2016-06-23 1.3723042771825000
4 2015-06-23 1.5542777479525000
5 2014-06-24 1.6264035528443000
6 2013-06-03 1.7456731467196000
7 2012-06-26 1.8424594602978000
8 2011-06-03 1.9111225457747000
9 2010-06-10 2.5149201133019000
10 2009-06-09 3.2961214563983000
11 2008-04-24 4.6495289028892000
12 2007-07-18 6.0719168083645000
13 2006-05-25 6.0970905928105000
14 2006-05-12 6.1773967505679000
15 2005-05-12 8.0306157757383010
16 2004-05-20 8.1694736854052000
17 2003-06-23 8.2663101191762000
18 2002-08-22 8.3354264245204000
19 2000-07-06 12.6405367756464000
20 1999-11-10 12.7227249211316980
21 1900-01-01 12.7227249211316980
```

#### 历史分笔数据
Expand All @@ -208,7 +208,7 @@ print(stock_df)

限量: 单次返回具体某个 A 上市公司的近 2 年历史分笔行情数据

P.S. 每个交易日 16:00 提供当日数据, 如遇到数据缺失,请使用 **stock_zh_a_tick_163** 接口,注意数据会有一定差异
P.S. 每个交易日 16:00 提供当日数据, 如遇到数据缺失,请使用 **stock_zh_a_tick_163** 接口,注意数据会有一定差异, 或者使用 **stock_zh_a_tick_tx_js(code="sz000001")** 来获取当日腾讯分笔数据

输入参数

Expand All @@ -232,8 +232,8 @@ P.S. 每个交易日 16:00 提供当日数据, 如遇到数据缺失,请使用

```python
import akshare as ak
stock_df = ak.stock_zh_a_tick_tx(code="sh600848", trade_date="20191011")
print(stock_df)
stock_zh_a_tick_tx_df = ak.stock_zh_a_tick_tx(code="sh600848", trade_date="20191011")
print(stock_zh_a_tick_tx_df)
```

数据示例-历史行情数据
Expand Down
1 change: 1 addition & 0 deletions docs/tutorial.md
Expand Up @@ -114,6 +114,7 @@
"stock_zh_index_spot" # 股票指数实时行情数据
# 股票分笔数据
"stock_zh_a_tick_tx" # A 股票分笔行情数据(近2年)-腾讯
"stock_zh_a_tick_tx_js" # A 股票分笔行情数据(近2年)-腾讯-当日数据
"stock_zh_a_tick_163" # A 股票分笔行情数据(近5个交易日)-163
# Websocket 实时监控
"watch" # 监控外汇实时价格
Expand Down

0 comments on commit c094883

Please sign in to comment.