盘中打开涨停板

xuan=[]
#构建自已的股票池
def build_my_stock():
    #获取股票列表
    df = pro.stock_basic(exchange='', list_status='L', fields='ts_code,symbol,name,area,industry,list_date')
    #剔除ST股票 
    df = df[~df['name'].str.contains('ST')]
    #上市时间
    now = datetime.datetime.now()
    df['list_date'] = pd.to_datetime(df['list_date'])
    df['ssdays'] = (now - df['list_date']).dt.days
    df = df[df['ssdays']>2000]
    #流通盘太大不做
    df2 = pro.daily_basic(ts_code='', trade_date='20200507', fields='ts_code,float_share')
    df2 = df2[df2['float_share']<100000]
    df = pd.merge(df,df2,on=['ts_code'])
    return df
df2 = pro.stk_limit(trade_date='20200612')

for code in build_my_stock()['ts_code'].values:
    data = ts.get_realtime_quotes(code[0:6])
    pre_close = data.loc[data[data['code']==code[0:6]].index[0],'pre_close']    #昨日收盘价
    price = data.loc[data[data['code']==code[0:6]].index[0],'price']
    high = data.loc[data[data['code']==code[0:6]].index[0],'high']              #今日最高价
    limit = df2.loc[df2[df2['ts_code']==code].index[0],'up_limit']              #今日涨停价
    if float(high) ==limit:#: float(pre_close)*1.095:
        if float(price) < limit:#float(high):
            print(code)
            xuan.append(code)
        

print(xuan)

  

上一篇:Datawhale-Pandas-Task02-索引【更新中】


下一篇:Python基础 | pandas中dataframe的整合与形变(merge & reshape)