今天盘后消息,多只权重股尾盘买盘压单,秀肌肉,摆明要把指数压住。

比如招商银行的委卖一档上压着160万手的卖单。哪位勇士敢去接。

然后我们读取全市场的收盘最后一刻的盘口数据,压着万手卖单以上的不就是国家队的股票池了么?
要么以后大跌的时候买入,等国家队托底;要么上涨的时候远离它们,毕竟是潜在控盘股票池。
利用ptrade获取盘口十档数据
ptrade内置了十档委卖买数据。
接口文档:https://ptradeapi.com/#get_gear_price

只要遍历全部股票,把十档数据取出来,做运算即可。
这里我们计算委托卖与委托买的差,排除部分做市商股票的委卖和委买量级相当的股票,排除掉一字板跌停。
主要核心代码:(让AI写的)
def execution(context):
a_share_code_list = get_Ashares()
stock_code_to_name = display_name_func(a_share_code_list)
order_book_info_dict = get_gear_price(a_share_code_list)
target_list = []
for code, info in order_book_info_dict.items():
offer_groups = info['offer_grp'] # 委卖盘各档位信息
bid_groups = info['bid_grp'] # 委买盘各档位信息
total_bid_volume = 0 # 委买前十档总手数
total_offer_volume = 0# 委卖前十档总手数
# 遍历前十档(1-10)
for level in range(1, ORDER_BOOK_LEVELS + 1):
offer_volume_per_level = int(offer_groups[level][1]/100)
bid_volume_per_level = int(bid_groups[level][1]/100)
total_bid_volume += bid_volume_per_level
total_offer_volume += offer_volume_per_level
# 条件:卖盘总手数 - 买盘总手数 ≥ 10万手 且 买盘总手数 > 0
if (total_offer_volume - total_bid_volume >= MIN_ORDER_VOLUME_DIFF) and (total_bid_volume > 0):
converted_code = post_fix_convert(code)
target_stock_info = {
'code': converted_code,
'name': stock_code_to_name.get(converted_code, ''),
'offer_sum_amount': total_offer_volume, # 保留原key名,避免影响后续使用
'bid_sum_amount': total_bid_volume # 保留原key名,避免影响后续使用
}
target_list.append(target_stock_info)
volume_diff = total_offer_volume - total_bid_volume
log.info(f"股票代码:{converted_code},{stock_code_to_name.get(converted_code, '')} "
f"前十档卖盘-买盘总手数差:{volume_diff}")
部署到ptrade上立即执行。上面笔者设定的数据 委卖总和 - 委买总和 大于 10万手的股。

导出到excel可做进一步分析。PS:里面数据单位是手。


随便找了几个,对比同花顺盘口,确认都是满足条件的就OK啦。
收藏好啦。