自学内容网 自学内容网

获取首日涨停封盘后第二次交易日上涨/下跌的概率

有许多投资者喜欢在股票涨停封盘后,跟进买入。普通股民会认为一个能在今日涨停封盘的股票,证明其上市公司正有十分重大的利好信息,只需要跟进购买便可以获取短期利益。

我们用数据来看一下在当日涨停封盘后,第二次交易日是上涨还是下跌?

import efinance as ef
import numpy as np
import pandas as pd
from tqdm import tqdm

all_stocks = ef.stock.get_realtime_quotes()
stock_codes= np.array(all_stocks["股票代码"])

stock_rise_fall_arr = []

for stock_code in tqdm(stock_codes):
    # 获取股票历史行情数据
    df = ef.stock.get_quote_history(stock_code)
    if len(df) == 0:
        continue
    stock_rise_fall = {}
    stock_rise_fall["股票代码"] = stock_code
    stock_rise_fall["股票名称"] = df["股票名称"].loc[0]
    stock_rise_fall["涨停天数"] = 0
    stock_rise_fall["涨停后涨"] = 0
    stock_rise_fall["涨停后跌"] = 0
    stock_rise_fall["涨停后开盘涨"] = 0
    stock_rise_fall["涨停后开盘跌"] = 0
    stock_rise_fall["涨停后最高涨"] = 0
    stock_rise_fall["涨停后最高跌"] = 0
    is_limit_up = False
    is_first = False
    last_price = 0
    for i in df.index[:]:
        line = df.loc[i]
        # 如果昨日涨停
        if is_limit_up and is_first:
            if line["涨跌幅"] > 0:
                stock_rise_fall["涨停后涨"] += 1
            else:
                stock_rise_fall["涨停后跌"] += 1
            if line["开盘"]> last_price:
                stock_rise_fall["涨停后开盘涨"] += 1
            else:
                stock_rise_fall["涨停后开盘跌"] += 1
            if line["最高"]> last_price:
                stock_rise_fall["涨停后最高涨"] += 1
            else:
                stock_rise_fall["涨停后最高跌"] += 1
        # 如果当日涨停
        if line["涨跌幅"]>9.9:
            # 如果昨天也涨停
            if is_limit_up:
                is_first = False
            else:
                last_price = line["收盘"]
                is_first = True
            is_limit_up = True
            stock_rise_fall["涨停天数"] += 1
        else:
            is_limit_up = False
    if stock_rise_fall["涨停后涨"] + stock_rise_fall["涨停后跌"] > 0:
        stock_rise_fall["涨停后涨概率"] = stock_rise_fall["涨停后涨"] / (stock_rise_fall["涨停后涨"]+stock_rise_fall["涨停后跌"])
    if stock_rise_fall["涨停后开盘涨"] + stock_rise_fall["涨停后开盘跌"] > 0:
        stock_rise_fall["涨停后开盘涨概率"] = stock_rise_fall["涨停后开盘涨"] / (stock_rise_fall["涨停后开盘涨"]+stock_rise_fall["涨停后开盘跌"])
    if stock_rise_fall["涨停后最高涨"] + stock_rise_fall["涨停后最高跌"] > 0:
        stock_rise_fall["涨停后最高涨概率"] = stock_rise_fall["涨停后最高涨"] / (stock_rise_fall["涨停后最高涨"]+stock_rise_fall["涨停后最高跌"])
    stock_rise_fall_arr.append(stock_rise_fall)
stock_rise_fall_df = pd.DataFrame(stock_rise_fall_arr)
stock_rise_fall_df.to_excel('output.xlsx', index = False)
stock_rise_fall_df
100%|██████████| 5649/5649 [43:02<00:00,  2.19it/s]  
股票代码股票名称涨停天数涨停后涨涨停后跌涨停后开盘涨涨停后开盘跌涨停后最高涨涨停后最高跌涨停后涨概率涨停后开盘涨概率涨停后最高涨概率
0300120经纬辉开72321836144280.6400000.7200000.840000
1300284苏交科58311125173840.7380950.5952380.904762
2300052中青宝914625442758130.6478870.6197180.816901
3300045华力创通65332139154950.6111110.7222220.907407
4300865大宏立21891071520.4705880.5882350.882353
.......................................
5637300047天源迪科49242128174230.5333330.6222220.933333
5638872953国子软件123618630.3333330.1111110.666667
5639300598诚迈科技104372435265470.6065570.5737700.885246
5640001279C强邦10101010.0000000.0000000.000000
5641837592华信永道601738144125300.3090910.2545450.454545

5642 rows × 12 columns

将导出excel文件下载到本地,并对数据进行统计整理到最后一行,计算各个概率,可以得到如图所示:
在这里插入图片描述
可以看出,涨停后收盘涨和涨停后开盘涨的概率均在0.5左右,可以认为首日涨停与第二日是否涨停无关。故某只股在今日涨停,并不意味着,该股公司有什么重大利好信息,也无法作为买进的支撑。


原文地址:https://blog.csdn.net/weixin_44345870/article/details/142964328

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!