tushare ID: 419258
打新肯定是股市中赚钱最稳当,而且很多的了,所以新手跟着新股买基本上是稳赚,只是你基本上买不进去而已。
再一个就是买基本面很好,或者是趋势很好,但是突然一下跌了5个点以上这种的股票,这种一般第二天都会弹回来,我是经常用这种方法,感觉挺好用的。
# 找到某段时间内的上网发行的股票
def find_all_new_stock_during_date(start_date, end_date):
df = pro.new_share(start_date=start_date, end_date=end_date)
return df
# print(find_all_new_stock_during_date('20200327','20200410'))
# 找到某天之后上市的新股
def find_all_new_stock_on_market_after_the_date(date, industry):
"""
:param date:
:param industry:
:return:
"""
data = pro.query('stock_basic', fields='ts_code,symbol,name,area,industry,market,list_date')
for i in range(len(data)):
# 如果上市日期在date之前,就删去这一行
if industry != '':
if datetime.datetime.strptime(date, "%Y%m%d") > datetime.datetime.strptime(data['list_date'][i], "%Y%m%d") \
or industry != data['industry'][i]:
data = data.drop(index=i)
else:
if datetime.datetime.strptime(date, "%Y%m%d") > datetime.datetime.strptime(data['list_date'][i], "%Y%m%d"):
data = data.drop(index=i)
# data['list_date'][i]=datetime.datetime.strptime(data['list_date'][i],"%Y%m%d")
data.set_index('list_date', inplace=True)
return data
# print(find_all_new_stock_on_market_after_the_date('20210322',''))
def get_last_on_market_date(date):
date_ = datetime.datetime.strptime(date, "%Y%m%d")
date = (date_ + datetime.timedelta(days=-1)).strftime("%Y%m%d")
while pro.query('trade_cal', start_date=date, end_date=date)['is_open'][0] == 0:
date_ += datetime.timedelta(days=-1)
date = date_.strftime("%Y%m%d")
return date
def get_ke_neng_ming_tian_zhang_stock_data_by_codes(codes, zhang_die_fu_limit, price_limit):
"""
找到猛跌的股票
:param codes: list
:param zhang_die_fu_limit: 2 items tuple
:param price_limit: 2 items tuple
:return:'name', 'open':今日开盘价, 'pre_close'昨日收盘价, 'price':当前价格, 'high':今日最高价, 'low':今日最低价,
'bid',竞买价,即“买一”报价, 'ask',竞卖价,即“卖一”报价, 'volume'成交量 ,maybe you need do volumn/100, 'amount',成交金额(元 CNY),
'b1_v',委买一(笔数 bid volume), 'b1_p', 'b2_v', 'b2_p', 'b3_v', 'b3_p', 'b4_v', 'b4_p', 'b5_v', 'b5_p',
'a1_v',委卖一(笔数 ask volume), 'a1_p', 'a2_v', 'a2_p', 'a3_v', 'a3_p', 'a4_v', 'a4_p', 'a5_v', 'a5_p',
'date',日期, 'time',时间, 'code'
"""
today = datetime.datetime.now().strftime("%Y%m%d")
out_list = [['code', 'price', '涨跌幅', '换手率', '量比', 'date', 'time']]
df = pro.query('daily_basic',
ts_code='',
trade_date=get_last_on_market_date(today),
fields='ts_code,trade_date,turnover_rate,volume_ratio,pe,pb')
df = df.where(df.notnull(), -1)
for i in range(len(codes)):
data = ts.get_realtime_quotes(codes[i])
if float(data['pre_close']) != 0:
dang_qian_zhang_die_fu = (float(data['price'][0]) - float(data['pre_close'][0])) / float(
data['pre_close'][0]) * 100
else:
return None
if zhang_die_fu_limit[0] < dang_qian_zhang_die_fu < zhang_die_fu_limit[1]:
if float(data['price'][0]) < price_limit:
turnover_rate = int([df['turnover_rate'][x] for x in range(len(df)) if
df['ts_code'][x].split('.')[0] == data['code'][0]][0])
if turnover_rate > 3:
volume_ratio = int([df['volume_ratio'][x] for x in range(len(df)) if
df['ts_code'][x].split('.')[0] == data['code'][0]][0])
if volume_ratio > 1:
out_list.append([data['code'][0],
float(data['price'][0]),
dang_qian_zhang_die_fu,
turnover_rate,
volume_ratio,
data['date'][0],
data['time'][0]])
else:
continue
else:
continue
else:
continue
else:
continue
out_list = pd.DataFrame(out_list)
return out_list