## akshare文档涨跌板
https://akshare.akfamily.xyz/data/stock/stock.html#id374资金流向
https://akshare.akfamily.xyz/data/stock/stock.html#id154
涨跌板:https://quote.eastmoney.com/ztb/detail#type=ztgc
资金流向:https://data.eastmoney.com/zjlx/detail.html
代码
import akshare as ak
import pandas as pd# 指定日期
trade_date = '20241031'# 获取涨停股票
limit_up_stocks = ak.stock_zt_pool_em(date=trade_date)# 获取资金流向排名(以3日为例)
fund_flow_rank = ak.stock_individual_fund_flow_rank(indicator="3日")# 筛选出涨停股票与资金流向股票都有的
common_stocks = pd.merge(limit_up_stocks, fund_flow_rank, left_on='代码', right_on='代码', how='inner')# 按3日主力净流入-净额列倒序排序
sorted_common_stocks = common_stocks.sort_values(by='3日主力净流入-净额', ascending=False)
sorted_common_stocks
获取涨停股票
limit_up_stocks
获取资金流向排名(以3日为例)
fund_flow_rank
按3日主力净流入-净额列倒序排序
sorted_common_stocks
连板数与资金流入关系
import akshare as ak
import pandas as pd# 指定日期
trade_date = '20241031'# 获取涨停股票
limit_up_stocks = ak.stock_zt_pool_em(date=trade_date)# 获取资金流向排名(以3日为例)
fund_flow_rank = ak.stock_individual_fund_flow_rank(indicator="3日")# 筛选出涨停股票与资金流向股票都有的
common_stocks = pd.merge(limit_up_stocks, fund_flow_rank, left_on='代码', right_on='代码', how='inner')# 检查数据类型
common_stocks['连板数'] = pd.to_numeric(common_stocks['连板数'], errors='coerce')# 处理缺失值
common_stocks['连板数'].fillna(0, inplace=True)# 按3日主力净流入-净额列和连板数列倒序排序
sorted_common_stocks = common_stocks.sort_values(by=[ '连板数','3日主力净流入-净额'], ascending=[False, False])
# 显示结果,重置索引
result = sorted_common_stocks.reset_index(drop=True)
result[['代码', '名称_x', '最新价_x', '涨跌幅', '3日主力净流入-净额', '连板数']].to_csv('sorted_common_stocks.csv', index=False)
保存csv查看