Skip to content

Commit

Permalink
Merge pull request akfamily#1828 from akfamily/develop
Browse files Browse the repository at this point in the history
feat(stock_rank_lxxd_ths): add stock_rank_lxxd_ths interface
  • Loading branch information
albertandking authored Nov 3, 2021
2 parents c047a69 + ebf8da7 commit eba97e9
Show file tree
Hide file tree
Showing 4 changed files with 260 additions and 27 deletions.
5 changes: 4 additions & 1 deletion akshare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1620,9 +1620,10 @@
1.1.95 fix: fix stock_board_concept_hist_ths interface
1.1.96 add: add bond_zh_hs_cov_min interface
1.1.97 add: add stock_rank_lxsz_ths interface
1.1.98 add: add stock_rank_lxxd_ths interface
"""

__version__ = "1.1.97"
__version__ = "1.1.98"
__author__ = "Albert King"

import sys
Expand All @@ -1641,6 +1642,8 @@
stock_rank_cxd_ths,
stock_rank_lxsz_ths,
stock_rank_lxxd_ths,
stock_rank_cxfl_ths,
stock_rank_cxsl_ths,
)

"""
Expand Down
166 changes: 141 additions & 25 deletions akshare/stock_feature/stock_technology_ths.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,33 +262,149 @@ def stock_rank_lxxd_ths() -> pd.DataFrame:
return big_df


if __name__ == "__main__":
stock_rank_cxg_ths_df = stock_rank_cxg_ths(symbol="创月新高")
print(stock_rank_cxg_ths_df)

stock_rank_cxg_ths_df = stock_rank_cxg_ths(symbol="半年新高")
print(stock_rank_cxg_ths_df)

stock_rank_cxg_ths_df = stock_rank_cxg_ths(symbol="一年新高")
print(stock_rank_cxg_ths_df)

stock_rank_cxg_ths_df = stock_rank_cxg_ths(symbol="历史新高")
print(stock_rank_cxg_ths_df)

stock_rank_cxd_ths_df = stock_rank_cxd_ths(symbol="创月新低")
print(stock_rank_cxd_ths_df)
def stock_rank_cxfl_ths() -> pd.DataFrame:
"""
同花顺-数据中心-技术选股-持续放量
http://data.10jqka.com.cn/rank/cxfl/
:return: 持续放量
:rtype: pandas.DataFrame
"""
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
"Cookie": f"v={v_code}",
}
url = f"http://data.10jqka.com.cn/rank/cxfl/field/count/order/desc/ajax/1/free/1/page/1/free/1/"
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
try:
total_page = soup.find("span", attrs={"class": "page_info"}).text.split("/")[1]
except AttributeError as e:
total_page = 1
big_df = pd.DataFrame()
for page in tqdm(range(1, int(total_page) + 1), leave=False):
v_code = js_code.call("v")
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
"Cookie": f"v={v_code}",
}
url = f"http://data.10jqka.com.cn/rank/cxfl/field/count/order/desc/ajax/1/free/1/page/{page}/free/1/"
r = requests.get(url, headers=headers)
temp_df = pd.read_html(r.text, converters={"股票代码": str})[0]
big_df = big_df.append(temp_df, ignore_index=True)
big_df.columns = [
'序号',
'股票代码',
'股票简称',
'涨跌幅',
'最新价',
'成交量',
'基准日成交量',
'放量天数',
'阶段涨跌幅',
'所属行业',
]
big_df['股票代码'] = big_df['股票代码'].astype(str).str.zfill(6)
big_df["涨跌幅"] = big_df["涨跌幅"].astype(str).str.strip("%")
big_df["阶段涨跌幅"] = big_df["阶段涨跌幅"].astype(str).str.strip("%")
big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"])
big_df["阶段涨跌幅"] = pd.to_numeric(big_df["阶段涨跌幅"])
big_df["最新价"] = pd.to_numeric(big_df["最新价"])
big_df["放量天数"] = pd.to_numeric(big_df["放量天数"])
return big_df

stock_rank_cxd_ths_df = stock_rank_cxd_ths(symbol="半年新低")
print(stock_rank_cxd_ths_df)

stock_rank_cxd_ths_df = stock_rank_cxd_ths(symbol="一年新低")
print(stock_rank_cxd_ths_df)
def stock_rank_cxsl_ths() -> pd.DataFrame:
"""
同花顺-数据中心-技术选股-持续缩量
http://data.10jqka.com.cn/rank/cxsl/
:return: 持续缩量
:rtype: pandas.DataFrame
"""
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
"Cookie": f"v={v_code}",
}
url = f"http://data.10jqka.com.cn/rank/cxsl/field/count/order/desc/ajax/1/free/1/page/1/free/1/"
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
try:
total_page = soup.find("span", attrs={"class": "page_info"}).text.split("/")[1]
except AttributeError as e:
total_page = 1
big_df = pd.DataFrame()
for page in tqdm(range(1, int(total_page) + 1), leave=False):
v_code = js_code.call("v")
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
"Cookie": f"v={v_code}",
}
url = f"http://data.10jqka.com.cn/rank/cxsl/field/count/order/desc/ajax/1/free/1/page/{page}/free/1/"
r = requests.get(url, headers=headers)
temp_df = pd.read_html(r.text, converters={"股票代码": str})[0]
big_df = big_df.append(temp_df, ignore_index=True)
big_df.columns = [
'序号',
'股票代码',
'股票简称',
'涨跌幅',
'最新价',
'成交量',
'基准日成交量',
'缩量天数',
'阶段涨跌幅',
'所属行业',
]
big_df['股票代码'] = big_df['股票代码'].astype(str).str.zfill(6)
big_df["涨跌幅"] = big_df["涨跌幅"].astype(str).str.strip("%")
big_df["阶段涨跌幅"] = big_df["阶段涨跌幅"].astype(str).str.strip("%")
big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"])
big_df["阶段涨跌幅"] = pd.to_numeric(big_df["阶段涨跌幅"])
big_df["最新价"] = pd.to_numeric(big_df["最新价"])
big_df["缩量天数"] = pd.to_numeric(big_df["缩量天数"])
return big_df

stock_rank_cxd_ths_df = stock_rank_cxd_ths(symbol="历史新低")
print(stock_rank_cxd_ths_df)

stock_rank_lxsz_ths_df = stock_rank_lxsz_ths()
print(stock_rank_lxsz_ths_df)
if __name__ == "__main__":
# stock_rank_cxg_ths_df = stock_rank_cxg_ths(symbol="创月新高")
# print(stock_rank_cxg_ths_df)
#
# stock_rank_cxg_ths_df = stock_rank_cxg_ths(symbol="半年新高")
# print(stock_rank_cxg_ths_df)
#
# stock_rank_cxg_ths_df = stock_rank_cxg_ths(symbol="一年新高")
# print(stock_rank_cxg_ths_df)
#
# stock_rank_cxg_ths_df = stock_rank_cxg_ths(symbol="历史新高")
# print(stock_rank_cxg_ths_df)
#
# stock_rank_cxd_ths_df = stock_rank_cxd_ths(symbol="创月新低")
# print(stock_rank_cxd_ths_df)
#
# stock_rank_cxd_ths_df = stock_rank_cxd_ths(symbol="半年新低")
# print(stock_rank_cxd_ths_df)
#
# stock_rank_cxd_ths_df = stock_rank_cxd_ths(symbol="一年新低")
# print(stock_rank_cxd_ths_df)
#
# stock_rank_cxd_ths_df = stock_rank_cxd_ths(symbol="历史新低")
# print(stock_rank_cxd_ths_df)
#
# stock_rank_lxsz_ths_df = stock_rank_lxsz_ths()
# print(stock_rank_lxsz_ths_df)
#
# stock_rank_lxxd_ths_df = stock_rank_lxxd_ths()
# print(stock_rank_lxxd_ths_df)
#
# stock_rank_cxfl_ths_df = stock_rank_cxfl_ths()
# print(stock_rank_cxfl_ths_df)

stock_rank_lxxd_ths_df = stock_rank_lxxd_ths()
print(stock_rank_lxxd_ths_df)
stock_rank_cxsl_ths_df = stock_rank_cxsl_ths()
print(stock_rank_cxsl_ths_df)
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2654,4 +2654,6 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
1.1.96 add: add bond_zh_hs_cov_min interface
1.1.97 add: add stock_rank_lxsz_ths interface
1.1.98 add: add stock_rank_lxxd_ths interface
```
114 changes: 113 additions & 1 deletion docs/data/stock/stock.md
Original file line number Diff line number Diff line change
Expand Up @@ -13322,7 +13322,7 @@ print(stock_rank_cxd_ths_df)
| 累计换手率 | float64 | 注意单位: % |
| 所属行业 | object | - |

接口示例
接口示例

```python
import akshare as ak
Expand Down Expand Up @@ -13402,3 +13402,115 @@ print(stock_rank_lxxd_ths_df)
254 255 688389 普门科技 21.75 23.75 21.51 3 -4.61 6.50 医疗器械
255 256 688677 海泰新光 86.47 98.88 86.33 3 -12.03 4.74 医疗器械
```

#### 持续放量

接口: stock_rank_cxfl_ths

目标地址: http://data.10jqka.com.cn/rank/cxfl/

描述: 同花顺-数据中心-技术选股-持续放量

限量: 单次返回所有数据

输入参数

| 名称 | 类型 | 描述 |
| ---- | ---- | ---- |
| - | - | - |

输出参数

| 名称 | 类型 | 描述 |
| -------- | -------- | ---- |
| 序号 | int64 | - |
| 股票代码 | object | - |
| 股票简称 | object | - |
| 涨跌幅 | float64 | 注意单位: % |
| 最新价 | float64 | 注意单位: 元 |
| 成交量 | object | 注意单位: 股 |
| 基准日成交量 | object | 注意单位: 股 |
| 放量天数 | int64 | - |
| 阶段涨跌幅 | float64 | 注意单位: % |
| 所属行业 | object | - |

接口示例

```python
import akshare as ak
stock_rank_cxfl_ths_df = ak.stock_rank_cxfl_ths()
print(stock_rank_cxfl_ths_df)
```

数据示例

```
序号 股票代码 股票简称 涨跌幅 ... 基准日成交量 放量天数 阶段涨跌幅 所属行业
0 1 000892 欢瑞世纪 5.33 ... 430.18万(10月26日) 6 13.26 传媒
1 2 002180 纳思达 0.91 ... 279.60万(10月27日) 5 7.06 计算机设备
2 3 300511 雪榕生物 4.77 ... 1313.76万(10月27日) 5 11.57 种植业与林业
3 4 600105 永鼎股份 2.15 ... 3576.74万(10月27日) 5 15.05 通信设备
4 5 600305 恒顺醋业 2.98 ... 1115.00万(10月27日) 5 9.30 食品加工制造
.. ... ... ... ... ... ... ... ... ...
132 133 688196 卓越新能 4.22 ... 73.76万(10月29日) 3 4.10 化学制品
133 134 688305 科德数控 2.28 ... 57.36万(10月29日) 3 5.31 通用设备
134 135 688456 有研粉材 -1.27 ... 53.42万(10月29日) 3 -0.80 工业金属
135 136 688597 煜邦电力 2.71 ... 126.71万(10月29日) 3 1.79 电力设备
136 137 688660 电气风电 1.00 ... 3588.18万(10月29日) 3 2.82 电力设备
```

#### 持续缩量

接口: stock_rank_cxsl_ths

目标地址: http://data.10jqka.com.cn/rank/cxsl/

描述: 同花顺-数据中心-技术选股-持续缩量

限量: 单次返回所有数据

输入参数

| 名称 | 类型 | 描述 |
| ---- | ---- | ---- |
| - | - | - |

输出参数

| 名称 | 类型 | 描述 |
| -------- | -------- | ---- |
| 序号 | int64 | - |
| 股票代码 | object | - |
| 股票简称 | object | - |
| 涨跌幅 | float64 | 注意单位: % |
| 最新价 | float64 | 注意单位: 元 |
| 成交量 | object | 注意单位: 股 |
| 基准日成交量 | object | 注意单位: 股 |
| 缩量天数 | int64 | - |
| 阶段涨跌幅 | float64 | 注意单位: % |
| 所属行业 | object | - |

接口示例

```python
import akshare as ak
stock_rank_cxsl_ths_df = ak.stock_rank_cxsl_ths()
print(stock_rank_cxsl_ths_df)
```

数据示例

```
序号 股票代码 股票简称 涨跌幅 ... 基准日成交量 缩量天数 阶段涨跌幅 所属行业
0 1 002118 紫鑫药业 0.78 ... 1.22亿(10月21日) 9 -10.96 中药
1 2 605077 华康股份 0.48 ... 51.42万(10月22日) 8 -2.83 化学制品
2 3 600322 天房发展 -0.57 ... 990.03万(10月25日) 7 -5.91 房地产开发
3 4 688255 凯尔达 3.18 ... 1211.44万(10月25日) 7 -24.07 自动化设备
4 5 000700 模塑科技 -0.67 ... 2037.27万(10月26日) 6 -5.35 汽车零部件
.. ... ... ... ... ... ... ... ... ...
408 409 688536 思瑞浦 -0.25 ... 152.89万(10月29日) 3 2.46 半导体及元件
409 410 688550 瑞联新材 0.79 ... 92.52万(10月29日) 3 0.89 电子化学品
410 411 688561 奇安信 0.21 ... 328.65万(10月29日) 3 -3.08 计算机应用
411 412 688626 翔宇医疗 0.61 ... 224.52万(10月29日) 3 -0.02 医疗器械
412 413 688682 霍莱沃 -2.05 ... 110.75万(10月29日) 3 2.24 国防军工
```

0 comments on commit eba97e9

Please sign in to comment.