分析上证指数,涨跌概率

分析上证指数从20180605以来,上涨超过某个比例,上涨回落,下跌超过比例,下跌回升的概率

#统计所有K线,当天上涨0.1%,0.15%,0.2%。。之后,收盘价又低于该值的概率
def find_out_close_price_change_rate(df):
    open=list(df['open'])
    close=list(df['close'])
    high=list(df["high"])
    low=list(df["low"])
    trade_date=list(df["trade_date"])
    pre_close=list(df['pre_close'])
    #将每个比例的数据放入列表中
    tg_list=[]
    for i in range(10,305,5):
        rate=i/10000
        #上涨超过比例的个数
        count_high_than_rate=0
        #收盘回落的个数
        count_high_huiluo=0
        #下跌超过比例的个数
        count_low_than_rate=0
        #收盘回升的个数
        count_low_huisheng=0
        #k线总个数
        count_total_k=len(open)
        for j in range(len(open)):
            today_open=open[j]
            today_close=close[j]
            today_high=high[j]
            today_low=low[j]
            today_date=trade_date[j]
            pre_close_price=pre_close[j]
            #统计上涨超过比例
            if today_high>=pre_close_price*(1+rate):
                count_high_than_rate+=1
            #统计回落个数
            if today_high>=pre_close_price*(1+rate) and today_close<=pre_close_price*(1+rate):
                count_high_huiluo+=1
            #统计下跌超过比例
            if today_low<=pre_close_price*(1-rate):
                count_low_than_rate+=1
            #统计下落又回升
            if today_low<=pre_close_price*(1-rate) and today_close>=pre_close_price*(1-rate):
                count_low_huisheng+=1
        #分别计算比例
        rate1=count_high_than_rate*100//count_total_k
        rate2=count_high_huiluo*100//count_total_k
        rate3=count_low_than_rate*100//count_total_k
        rate4=count_low_huisheng*100//count_total_k
        tg_list.append([rate,rate1,rate2,rate3,rate4])
    [print(i) for i in tg_list]

执行结果

[0.001, 79, 34, 84, 40]
[0.0015, 76, 33, 80, 39]
[0.002, 71, 30, 77, 38]
[0.0025, 67, 29, 74, 37]
[0.003, 63, 27, 69, 35]
[0.0035, 59, 24, 66, 33]
[0.004, 55, 22, 62, 30]
[0.0045, 50, 20, 57, 28]
[0.005, 46, 18, 54, 27]
[0.0055, 43, 17, 50, 25]
[0.006, 40, 15, 46, 23]
[0.0065, 37, 13, 43, 21]
[0.007, 34, 12, 39, 18]
[0.0075, 31, 11, 36, 17]
[0.008, 29, 10, 33, 15]
[0.0085, 26, 9, 31, 14]
[0.009, 24, 8, 28, 12]
[0.0095, 22, 7, 26, 11]
[0.01, 21, 7, 25, 11]
[0.0105, 19, 6, 23, 10]
[0.011, 18, 6, 22, 10]
[0.0115, 17, 6, 20, 9]
[0.012, 15, 5, 18, 8]
[0.0125, 14, 4, 17, 8]
[0.013, 13, 4, 16, 7]
[0.0135, 12, 4, 14, 6]
[0.014, 11, 3, 14, 6]
[0.0145, 10, 3, 13, 6]
[0.015, 10, 3, 11, 5]
[0.0155, 9, 3, 10, 5]
[0.016, 9, 2, 10, 4]
[0.0165, 8, 2, 9, 4]
[0.017, 7, 2, 8, 3]
[0.0175, 7, 2, 8, 3]
[0.018, 7, 2, 7, 3]
[0.0185, 6, 2, 7, 3]
[0.019, 6, 2, 7, 3]
[0.0195, 5, 1, 6, 3]
[0.02, 5, 1, 6, 2]
[0.0205, 5, 1, 5, 2]
[0.021, 4, 1, 5, 2]
[0.0215, 3, 1, 4, 2]
[0.022, 3, 0, 4, 2]
[0.0225, 3, 0, 4, 2]
[0.023, 2, 0, 4, 2]
[0.0235, 2, 0, 3, 1]
[0.024, 2, 0, 3, 1]
[0.0245, 2, 0, 3, 1]
[0.025, 1, 0, 3, 1]
[0.0255, 1, 0, 2, 1]
[0.026, 1, 0, 2, 1]
[0.0265, 1, 0, 2, 1]
[0.027, 1, 0, 2, 1]
[0.0275, 1, 0, 2, 1]
[0.028, 0, 0, 2, 1]
[0.0285, 0, 0, 2, 1]
[0.029, 0, 0, 2, 0]
[0.0295, 0, 0, 1, 0]
[0.03, 0, 0, 1, 0]

分析以上数据

1、50%的概率,当天上涨幅度不会超过0.45%,50%的概率,当天下跌幅度不会超过0.55%

2、涨幅和跌幅较低时,大约有一半的概率,会回落和拉升。随着涨跌幅扩大,大约有33%的概率会回落(当天涨幅较大时,会回落的概率变小了)。而下跌基本上还有一半的概率会拉升。

即:应当在相对较高的涨幅时买入,此时会回调的概率较小。后续继续上涨的概率更大。而卖出时应当选择跌幅较小的位置卖出,如果后续拉升,可以在比卖出点更低的位置买回。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值