停牌期间前复权价格波动检查

#iterrows练习
#纪念lambda鲜有的顺手写出来,难得这么pythonic...
#最后的最后,挑出连续停牌的方式,值得黄鱼脑袋留念...


for stock in stock_list:
    re_ordered = []
    res_of_lists = []
    list_contig = []
    
    listed_date = instruments(stock).listed_date
    status_str = instruments(stock).status
    if (listed_date != '2999-12-31' and (listed_date != '0000-00-00') and (status_str=='Active')) :   #处理有效股票(具备上市日期)
        try:
            suspension_true_df = is_suspended(stock)  #得到公司上市每个日期的停牌情况
        except:
            continue
        
        for index,row in suspension_true_df.iterrows():
            if row[0] == True:
                list_contig.append(index)  #放到临时list里面
            else:
                if len(list_contig) > 1: 
                    res_of_lists.append(list_contig) #放到大的list里面
                    list_contig = []  #清空临时
                list_contig = []
                    
        re_ordered = list(filter(lambda x : len(x) > 1 ,res_of_lists)) #再次确保得到了连续的停牌
        res_of_lists = []
        total_consequent = 0
        
        total_consequent = len(re_ordered)
        for k in range(total_consequent):
            df_close = get_price(stock,start_date=re_ordered[k][0],end_date=re_ordered[k][-1])
            if not df_close is None:
                list_close = list(df_close.close)
                verifying = list(set(list_close))
                if len(verifying) == 2 and (round(verifying[0],2) != round(verifying[1],2)):
                    print(stock,re_ordered[k][0],re_ordered[k][-1])
                elif len(verifying) > 2:
                    print(stock,"more than 2",re_ordered[k][0],re_ordered[k][-1])
    else:
        
        continue

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

取啥都被占用

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值