主要统计当日市场指数基本情况、涨停板的情况,空间板数,个股所属行业情况,当前市场的主线,市场成交的基本情况等等,一目了然,看完之后对当前市场有个基本的把控,非常有利于复盘。欢迎高手批评指正,有啥好的建议或者意见可以提出来,我再加进去
#分析指数近期走势
import pandas as pd
zhishu_list=['000001.XSHG','000016.XSHG','000300.XSHG','000905.XSHG','399001.XSHE','399005.XSHE','399006.XSHE','399678.XSHE']
zhishu_close=[]
zhishu_pct=[]
zhishu_pct5=[]
zhishu_pct3=[]
zhishu_money=[]
zhishu_money3=[]
zhishu_money5=[]
zhishu_volume=[]
zhishu_volume3=[]
zhishu_volume5=[]
for zhishu in zhishu_list:
zhishu_price=get_price(zhishu,end_date='2019-01-08',count=6,fields=['close','volume','money'])
#指数值
zhishu_close.append(zhishu_price['close'][-1])
#涨跌幅度%
zhishu_pct.append(round((zhishu_price['close'][-1]/zhishu_price['close'][-2]-1)*100,2))
zhishu_pct3.append(round((zhishu_price['close'][-1]/zhishu_price['close'][-3]-1)*100,2))
zhishu_pct5.append(round((zhishu_price['close'][-1]/zhishu_price['close'][-6]-1)*100,2))
#成交量(亿)
zhishu_volume.append(round(zhishu_price['volume'][-1]/(10**8),4))
zhishu_volume3.append(round((zhishu_price['volume'][-3:].mean())/(10**8),4))
zhishu_volume5.append(round((zhishu_price['volume'][-5:].mean())/(10**8),4))
#成交额
zhishu_money.append(round(zhishu_price['money'][-1]/(10**8),2))
zhishu_money3.append(round(zhishu_price['money'][-3:].mean()/(10**8),2))
zhishu_money5.append(round(zhishu_price['money'][-5:].mean()/(10**8),2))
df_zhishu=pd.DataFrame(index=['上证指数','上证50','沪深300','中证500','深成指','中小板指','创业板指','深次新股'],\
columns=['指数值','涨跌幅%','3日涨跌幅%','5日涨跌幅%','成交量(亿)','3日成交均量(亿)',\
'5日成交均量(亿)','成交额(亿)','3日成交均额(亿)','5日成交均额(亿)'])
df_zhishu['指数值']=zhishu_close
df_zhishu['涨跌幅%']=zhishu_pct
df_zhishu['3日涨跌幅%']=zhishu_pct3
df_zhishu['5日涨跌幅%']=zhishu_pct5
df_zhishu['成交量(亿)']=zhishu_volume
df_zhishu['3日成交均量(亿)']=zhishu_volume3
df_zhishu['5日成交均量(亿)']=zhishu_volume5
df_zhishu['成交额(亿)']=zhishu_money
df_zhishu['3日成交均额(亿)']=zhishu_money3
df_zhishu['5日成交均额(亿)']=zhishu_money5
df_zhishu
指数值 | 涨跌幅% | 3日涨跌幅% | 5日涨跌幅% | 成交量(亿) | 3日成交均量(亿) | 5日成交均量(亿) | 成交额(亿) | 3日成交均额(亿) | 5日成交均额(亿) | |
---|---|---|---|---|---|---|---|---|---|---|
上证指数 | 2526.46 | -0.26 | 0.46 | 1.31 | 158.0992 | 168.0940 | 147.7223 | 1233.79 | 1360.64 | 1225.41 |
上证50 | 2305.17 | -0.40 | -0.41 | 0.53 | 18.1312 | 23.1036 | 21.8173 | 223.29 | 295.34 | 282.52 |
沪深300 | 3047.70 | -0.22 | 0.39 | 1.23 | 86.1706 | 96.8846 | 86.0368 | 796.29 | 974.91 | 890.49 |
中证500 | 4277.30 | -0.26 | 1.58 | 2.62 | 69.5569 | 74.7197 | 65.4290 | 497.00 | 537.21 | 475.68 |
深成指 | 7391.65 | -0.12 | 1.47 | 2.10 | 92.4488 | 100.7327 | 87.4080 | 804.72 | 912.41 | 814.75 |
中小板指 | 4813.60 | -0.01 | 2.06 | 2.35 | 22.6168 | 24.4821 | 21.8523 | 243.22 | 266.88 | 238.57 |
创业板指 | 1263.51 | -0.36 | 1.47 | 1.04 | 12.7616 | 14.7083 | 13.5662 | 162.41 | 187.66 | 173.55 |
深次新股 | 709.36 | -0.14 | 1.68 | 0.95 | 4.4667 | 5.1428 | 4.5069 | 105.73 | 108.09 | 99.47 |
import pandas as pd
pd.set_option('precision', 8)
pd.set_option('display.width',1000)
import matplotlib.pyplot as plt
plt.style.use('ggplot')
df=get_all_securities(types=['stock'],date='2019-01-08')
#df=get_fundamentals(query(valuation.code))
#print (len(df['code'])) #两市股票数量
u10=[]
u7=[]
u5=[]
u3=[]
u0=[]
u_0=[]
u_3=[]
u_5=[]
u_7=[]
u_10=[]
uuv=[]
uus=[]
uust=[]
uuzhang=[]
uuzhang2=[]
uunost=[]
uu_5=[]
for stock in list(df.index):
df2=get_price(stock,end_date='2019-01-08',count=6,frequency='daily',\
fields=['open','close','volume','high','low','money','high_limit','low_limit'],\
fq='pre')
if df2['close'][-1]==df2['high_limit'][-1]: #没有排除掉当前已经停牌的票,包含ST个股
u10.append(stock)
elif df2['close'][-1]>=1.07*df2['close'][-2] and df2['close'][-1]<df2['high_limit'][-1]:
u7.append(stock) #7个点以上涨幅个股
elif df2['close'][-1]>=1.05*df2['close'][-2] and df2['close'][-1]<1.07*df2['close'][-2]:
u5.append(stock) #5个点以上涨幅个股
elif df2['close'][-1]>=1.03*df2['close'][-2] and df2['close'][-1]<1.05*df2['close'][-2]:
u3.append(stock) #3个点以上涨幅个股
elif df2['close'][-1]>=df2['close'][-2] and df2['close'][-1]<1.03*df2['close'][-2]:
u0.append(stock) #0个点以上涨幅个股数
elif df2['close'][-1]==df2['low_limit'][-1]:
u_10.append(stock) #跌停个股数
elif df2['close'][-1]>df2['low_limit'][-1] and df2['close'][-1]<=0.93*df2['close'][-2]:
u_7.append(stock) #7个点以上跌幅个股数
elif df2['close'][-1]>0.93*df2['close'][-2] and df2['close'][-1]<=0.95*df2['close'][-2]:
u_5.append(stock) #5个点以上跌幅个股数
elif df2['close'][-1]>0.95*df2['close'][-2] and df2['close'][-1]<=0.97*df2['close'][-2]:
u_3.append(stock) #3个点以上跌幅个股数
elif df2['close'][-1]>0.97*df2['close'][-2] and df2['close'][-1]<df2['close'][-2]:
u_0.append(stock) #0个点以上跌幅个股数
if df2['close'][-1]<df2['high_limit'][-1] and df2['high'][-1]==df2['high_limit'][-1]: #当日炸板股票
uuv.append(stock)
if df2['volume'][-1]==df2['money'][-1]==0: #当日停盘股票
uus.append(stock)
#涨停票和停牌票合在一起处理
if df2['close'][-1]==df2['high_limit'][-1] and df2['volume'][-1]>0 and df2['money'][-1]>0:
uuzhang.append(stock) #得到今日涨停个股
if df2['close'][-1]==df2['high_limit'][-1] and df2['close'][-1]<1.07*df2['close'][-2]:
uust.append(stock) #st涨停个股
if df2['close'][-2]==df2['high_limit'][-2] and df2['volume'][-2]>0 and df2['money'][-2]>0 \
and df2['close'][-2]>1.06*df2['close'][-3]:
uuzhang2.append(stock) #昨日涨停个股
if df2['close'][-1]==df2['high_limit'][-1] and df2['volume'][-1]>0 and df2['money'][-1]>0 \
and df2['close'][-1]>1.07*df2['close'][-2]: #得到涨停且非st个股
uunost.append(stock)
#5个点以上个股,用于分析5个点以上个股所属行业
if df2['close'][-1]>=1.05*df2['close'][-2] and df2['volume'][-1]>0 and df2['money'][-1]>0:
uu_5.append(stock)
#print (len(uunost))
#当日涨停个股数(包含st)
uuust=len(u10)-len(uus)
#当日涨停个股(不包含st)
uuu=len(u10)-len(uus)-len(uust)
#当日触板个股总数
uuc=len(uuzhang)+len(uuv)
#当日炸板率
uuz=round((len(uuv)/uuc*100),2)
df_zhangfu=pd.DataFrame(index=['涨停个股(包含ST)','炸板个股','7个点以上涨幅','5-7个点涨幅','3-5个点涨幅','0-3个点涨幅','跌停个股数(包含ST)','0-3个点跌幅','3-5个点跌幅','5-7个点跌幅','7个点以上跌幅'],\
columns=['个数统计'])
df_zhangfu['个数统计']=[len(uuzhang),len(uuv),len(u7),len(u5),len(u3),len(u0),len(u_10),len(u_0),len(u_3),len(u_5),len(u_7)]
df_zhangfu
个数统计 | |
---|---|
涨停个股(包含ST) | 55 |
炸板个股 | 44 |
7个点以上涨幅 | 12 |
5-7个点涨幅 | 42 |
3-5个点涨幅 | 99 |
0-3个点涨幅 | 1338 |
跌停个股数(包含ST) | 2 |
0-3个点跌幅 | 1866 |
3-5个点跌幅 | 121 |
5-7个点跌幅 | 15 |
7个点以上跌幅 | 5 |
#今日涨停个股板数统计
uuu1=[]
uuu2=[]
uuu3=[]
uuu4=[]
uuu5=[]
uuu6=[]
uuu7=[]
uuu8=[]
uuu9=[]
uuu10=[]
for stock in uunost:
df2_1=get_price(stock,end_date='2019-01-08',count=10,frequency='daily',\
fields=['open','close','volume','high','low','money','high_limit','low_limit'],\
fq='pre')
if df2_1['close'][-2]<df2_1['high_limit'][-2]:
uuu1.append(stock)
if df2_1['close'][-2]==df2_1['high_limit'][-2] and df2_1['close'][-3]<df2_1['high_limit'][-3]:
uuu2.append(stock)
if df2_1['close'][-2]==df2_1['high_limit'][-2] and df2_1['close'][-3]==df2_1['high_limit'][-3] \
and df2_1['close'][-4]<df2_1['high_limit'][-4]:
uuu3.append(stock)
if df2_1['close'][-2]==df2_1['high_limit'][-2] and df2_1['close'][-3]==df2_1['high_limit'][-3] and \
df2_1['close'][-4]==df2_1['high_limit'][-4] and df2_1['close'][-5]<df2_1['high_limit'][-5]:
uuu4.append(stock)
if df2_1['close'][-2]==df2_1['high_limit'][-2] and df2_1['close'][-3]==df2_1['high_limit'][-3] and \
df2_1['close'][-4]==df2_1['high_limit'][-4] and df2_1['close'][-5]==df2_1['high_limit'][-5] and \
df2_1['close'][-6]<df2_1['high_limit'][-6]:
uuu5.append(stock)
if df2_1['close'][-2]==df2_1['high_limit'][-2] and df2_1['close'][-3]==df2_1['high_limit'][-3] and \
df2_1['close'][-4]==df2_1['high_limit'][-4] and df2_1['close'][-5]==df2_1['high_limit'][-5] and \
df2_1['close'][-6]==df2_1['high_limit'][-6] and df2_1['close'][-7]<df2_1['high_limit'][-7]:
uuu6.append(stock)
if df2_1['close'][-2]==df2_1['high_limit'][-2] and df2_1['close'][-3]==df2_1['high_limit'][-3] and \
df2_1['close'][-4]==df2_1['high_limit'][-4] and df2_1['close'][-5]==df2_1['high_limit'][-5] and \
df2_1['close'][-6]==df2_1['high_limit'][-6] and df2_1['close'][-7]==df2_1['high_limit'][-7] and \
df2_1['close'][-8]<df2_1['high_limit'][-8]:
uuu7.append(stock)
if df2_1['close'][-2]==df2_1['high_limit'][-2] and df2_1['close'][-3]==df2_1['high_limit'][-3] and \
df2_1['close'][-4]==df2_1['high_limit'][-4] and df2_1['close'][-5]==df2_1['high_limit'][-5] and \
df2_1['close'][-6]==df2_1['high_limit'][-6] and df2_1['close'][-7]==df2_1['high_limit'][-7] and \
df2_1['close'][-8]==df2_1['high_limit'][-8] and df2_1['close'][-9]<df2_1['high_limit'][-9]:
uuu8.append(stock)
if df2_1['close'][-2]==df2_1['high_limit'][-2] and df2_1['close'][-3]==df2_1['high_limit'][-3] and \
df2_1['close'][-4]==df2_1['high_limit'][-4] and df2_1['close'][-5]==df2_1['high_limit'][-5] and \
df2_1['close'][-6]==df2_1['high_limit'][-6] and df2_1['close'][-7]==df2_1['high_limit'][-7] and \
df2_1['close'][-8]==df2_1['high_limit'][-8] and df2_1['close'][-9]==df2_1['high_limit'][-9] and \
df2_1['close'][-10]<df2_1['high_limit'][-10]:
uuu9.append(stock)
if df2_1['close'][-2]==df2_1['high_limit'][-2] and df2_1['close'][-3]==df2_1['high_limit'][-3] and \
df2_1['close'][-4]==df2_1['high_limit'][-4] and df2_1['close'][-5]==df2_1['high_limit'][-5] and \
df2_1['close'][-6]==df2_1['high_limit'][-6] and df2_1['close'][-7]==df2_1['high_limit'][-7] and \
df2_1['close'][-8]==df2_1['high_limit'][-8] and df2_1['close'][-9]==df2_1['high_limit'][-9] and \
df2_1['close'][-10]==df2_1['high_limit'][-10] and df2_1['close'][-11]<df2_1['high_limit'][-11]:
uuu10.append(stock)
df_zhangtingtongji=pd.DataFrame(index=['今日涨停个股数','首板个股数','二板个股数','三板个股数','四板个股数','五板个股数',\
'六板个股数','七板个股数','八板个股数',\
'九板个股数','十板个股数'],columns=['个数统计'])
df_zhangtingtongji['个数统计']=[len(uunost),len(uuu1),len(uuu2),len(uuu3),len(uuu4),\
len(uuu5),len(uuu6),len(uuu7),len(uuu8),\
len(uuu9),len(uuu10)]
df_zhangtingtongji
个数统计 | |
---|---|
今日涨停个股数 | 46 |
首板个股数 | 27 |
二板个股数 | 10 |
三板个股数 | 3 |
四板个股数 | 1 |
五板个股数 | 2 |
六板个股数 | 1 |
七板个股数 | 0 |
八板个股数 | 1 |
九板个股数 | 0 |
十板个股数 | 0 |
#涨停个股行业统计,扣除掉刚上市的新股吧,不然拉不出来新股的行业
import pandas as pd
industry_name=[]
code=[]
#print (uunost)
#uunost=uunost.remove('600310.XSHG')
#print (uunost)
for stock in uunost:
df3=get_industry(stock,date='2019-01-08')
code.append(stock)
industry_name.append(df3[stock]['zjw']['industry_name'])
#print (df3[stock])
#print (df3[stock]['sw_l2']['industry_name'],stock)
#print (pd.Series(code))
#print (pd.Series(industry_name))
#加一列,便于个数统计
df_1=[]
for i in range(len(uunost)):
df_1.append(1)
#print (df_1)
df_industry=pd.DataFrame({'股票代码':pd.Series(code),'涨停个股所属行业':pd.Series(industry_name),'计数器':pd.Series(df_1)}) #顺利合成两列数据,便于分析涨停板所属行业
#print (df_industry)
df_industry_name=df_industry.groupby(df_industry['涨停个股所属行业']).sum().sort_values('计数器',ascending=False).head(10) #可以直接看出那个行业比较强势
df_industry_name #用软件来分类和处理数据吧
计数器 | |
---|---|
涨停个股所属行业 | |
计算机、通信和其他电子设备制造业 | 6 |
电气机械和器材制造业 | 5 |
金属制品业 | 4 |
专用设备制造业 | 4 |
商务服务业 | 3 |
燃气生产和供应业 | 2 |
化学原料和化学制品制造业 | 2 |
软件和信息技术服务业 | 2 |
橡胶和塑料制品业 | 2 |
电力、热力生产和供应业 | 2 |
#昨日涨停个股今日表现统计
gaokai=[]
dikai=[]
jinrilianban=[]
shangzhang=[]
xiadie=[]
jinridieting=[]
jinrizhaban=[]
for stock in uuzhang2:
df2_2=get_price(stock,end_date='2019-01-08',count=6,frequency='daily',\
fields=['open','close','volume','high','low','money','high_limit','low_limit'],\
fq='pre')
if df2_2['open'][-1]>df2_2['close'][-2]:
gaokai.append(stock)
elif df2_2['open'][-1]<=df2_2['close'][-2]:
dikai.append(stock)
if df2_2['close'][-1]==df2_2['high_limit'][-1] and df2_2['volume'][-1]>0 and df2_2['money'][-1]>0:
jinrilianban.append(stock)
if df2_2['high'][-1]==df2_2['high_limit'][-1] and df2_2['close'][-1]<df2_2['high_limit'][-1]:
jinrizhaban.append(stock)
if df2_2['close'][-1]>df2_2['close'][-2]:
shangzhang.append(stock)
elif df2_2['close'][-1]<=df2_2['close'][-2]:
xiadie.append(stock)
if df2_2['close'][-1]==df2_2['low_limit'][-1]:
jinridieting.append(stock)
df_zhangting=pd.DataFrame(index=['昨日涨停个股数','高开率','低开率','连板个股','炸板个股','上涨','下跌','跌停',\
'上涨概率','下跌概率'],columns=['个数统计'])
df_zhangting['个数统计']=[len(uuzhang2),round(len(gaokai)/len(uuzhang2),2),round(len(dikai)/len(uuzhang2),2),len(jinrilianban),\
len(jinrizhaban),len(shangzhang),len(xiadie),len(jinridieting),round(len(shangzhang)/len(uuzhang2),2),\
round(len(xiadie)/len(uuzhang2),2)]
df_zhangting
个数统计 | |
---|---|
昨日涨停个股数 | 89.00 |
高开率 | 0.80 |
低开率 | 0.20 |
连板个股 | 19.00 |
炸板个股 | 16.00 |
上涨 | 44.00 |
下跌 | 45.00 |
跌停 | 1.00 |
上涨概率 | 0.49 |
下跌概率 | 0.51 |
#昨日涨停个股今日收盘表现
uuz10=[]
uuz7=[]
uuz5=[]
uuz3=[]
uuz0=[]
uuz_0=[]
uuz_3=[]
uuz_5=[]
uuz_7=[]
uuz_10=[]
for stock in uuzhang2:
df2_3=get_price(stock,end_date='2019-01-08',count=6,frequency='daily',\
fields=['open','close','volume','high','low','money','high_limit','low_limit'],\
fq='pre')
if df2_3['close'][-1]==df2_3['high_limit'][-1]:
uuz10.append(stock)
if df2_3['close'][-1]<df2_3['high_limit'][-1] and df2_3['close'][-1]>=1.07*df2_3['close'][-2]:
uuz7.append(stock)
if df2_3['close'][-1]<1.07*df2_3['close'][-2] and df2_3['close'][-1]>=1.05*df2_3['close'][-2]:
uuz5.append(stock)
if df2_3['close'][-1]<1.05*df2_3['close'][-2] and df2_3['close'][-1]>=1.03*df2_3['close'][-2]:
uuz3.append(stock)
if df2_3['close'][-1]<1.03*df2_3['close'][-2] and df2_3['close'][-1]>=1.00*df2_3['close'][-2]:
uuz0.append(stock)
if df2_3['close'][-1]<df2_3['close'][-2] and df2_3['close'][-1]>=0.97*df2_3['close'][-2]:
uuz_0.append(stock)
if df2_3['close'][-1]<0.97*df2_3['close'][-2] and df2_3['close'][-1]>=0.95*df2_3['close'][-2]:
uuz_3.append(stock)
if df2_3['close'][-1]<0.95*df2_3['close'][-2] and df2_3['close'][-1]>=0.93*df2_3['close'][-2]:
uuz_5.append(stock)
if df2_3['close'][-1]<0.93*df2_3['close'][-2] and df2_3['close'][-1]>df2_3['low_limit'][-1]:
uuz_7.append(stock)
if df2_3['close'][-1]==df2_3['low_limit'][-1]:
uuz_10.append(stock)
df_zuorizhangting=pd.DataFrame(index=['昨日涨停个股数','今日连板','7个点以上涨幅','5-7个点涨幅','3-5个点涨幅','0-3个点涨幅',\
'0-3个点跌幅','3-5个点跌幅','5-7个点跌幅','7个点以上跌幅','今日跌停'],columns=['个数统计'])
df_zuorizhangting['个数统计']=[len(uuzhang2),len(uuz10),len(uuz7),len(uuz5),len(uuz3),len(uuz0),len(uuz_0),len(uuz_3),len(uuz_5),\
len(uuz_7),len(uuz_10)]
df_zuorizhangting
个数统计 | |
---|---|
昨日涨停个股数 | 89 |
今日连板 | 19 |
7个点以上涨幅 | 1 |
5-7个点涨幅 | 4 |
3-5个点涨幅 | 6 |
0-3个点涨幅 | 16 |
0-3个点跌幅 | 17 |
3-5个点跌幅 | 21 |
5-7个点跌幅 | 4 |
7个点以上跌幅 | 0 |
今日跌停 | 1 |
#寻找5个点以上涨幅个股所属行业
import pandas as pd
industry_name=[]
code=[]
for stock in uu_5:
df3=get_industry(stock,date='2019-01-08')
code.append(stock)
industry_name.append(df3[stock]['zjw']['industry_name'])
#print (df3[stock]['zjw']['industry_name'])
#print (pd.Series(code))
#print (pd.Series(industry_name))
#加一列,便于个数统计
df_1=[]
for i in range(len(uu_5)):
df_1.append(1)
#print (df_1)
df_industry=pd.DataFrame({'股票代码':pd.Series(code),'5个点以上涨幅个股所属行业':pd.Series(industry_name),'计数器':pd.Series(df_1)}) #顺利合成两列数据,便于分析个股所属行业
#print (df_industry)
df_industry_name=df_industry.groupby(df_industry['5个点以上涨幅个股所属行业']).sum().sort_values('计数器',ascending=False).head(10) #可以直接看出那个行业比较强势
df_industry_name #用软件来分类和处理数据吧
计数器 | |
---|---|
5个点以上涨幅个股所属行业 | |
计算机、通信和其他电子设备制造业 | 19 |
电气机械和器材制造业 | 16 |
专用设备制造业 | 10 |
燃气生产和供应业 | 6 |
金属制品业 | 4 |
化学原料和化学制品制造业 | 4 |
橡胶和塑料制品业 | 3 |
商务服务业 | 3 |
软件和信息技术服务业 | 3 |
汽车制造业 | 3 |
import pandas as pd
import numpy as np
df=get_all_securities(types=['stock'],date='2019-01-08')
#df['code']
newhigh_20=[] #20日新高
newhigh_60=[] #60日新高
newhigh_250=[] #250日新高,也就是一年新高
newhigh_10years=[] #10年新高,一般也就意味着是历史新高了
for stock in list(df.index):
df4=get_price(stock,end_date='2019-01-07',count=3000,frequency='daily',fields=['close','money'],fq='pre')
if df4['close'].max()==df4['close'][-1] and df4['money'][-1]>0: #10年新高个股,扣除停牌股
newhigh_10years.append(stock)
if df4['close'][-20:].max()==df4['close'][-1] and df4['money'][-1]>0:
newhigh_20.append(stock)
if df4['close'][-60:].max()==df4['close'][-1] and df4['money'][-1]>0:
newhigh_60.append(stock)
if df4['close'][-250:].max()==df4['close'][-1] and df4['money'][-1]>0:
newhigh_250.append(stock)
df_newhigh_20=pd.DataFrame({'20日新高':newhigh_20})
df_xingao=pd.DataFrame(index=['20日新高','60日新高','一年新高','历史新高'],columns=['个数统计'])
df_xingao['个数统计']=[len(newhigh_20),len(newhigh_60),len(newhigh_250),len(newhigh_10years)]
df_xingao
个数统计 | |
---|---|
20日新高 | 511 |
60日新高 | 234 |
一年新高 | 21 |
历史新高 | 4 |
df_newhigh_250=pd.DataFrame({'一年新高':newhigh_250})
df_newhigh_250
一年新高 | |
---|---|
0 | 000429.XSHE |
1 | 000750.XSHE |
2 | 002017.XSHE |
3 | 002115.XSHE |
4 | 002124.XSHE |
5 | 002414.XSHE |
6 | 002776.XSHE |
7 | 002811.XSHE |
8 | 002941.XSHE |
9 | 300087.XSHE |
10 | 300265.XSHE |
11 | 300498.XSHE |
12 | 300615.XSHE |
13 | 300628.XSHE |
14 | 300751.XSHE |
15 | 600242.XSHG |
16 | 600406.XSHG |
17 | 600548.XSHG |
18 | 600677.XSHG |
19 | 600776.XSHG |
20 | 601860.XSHG |
df_newhigh_20=pd.DataFrame({'20日新高':newhigh_20})
df_newhigh_20
20日新高 | |
---|---|
0 | 000026.XSHE |
1 | 000043.XSHE |
2 | 000070.XSHE |
3 | 000099.XSHE |
4 | 000100.XSHE |
5 | 000400.XSHE |
6 | 000426.XSHE |
7 | 000429.XSHE |
8 | 000519.XSHE |
9 | 000520.XSHE |
10 | 000537.XSHE |
11 | 000543.XSHE |
12 | 000547.XSHE |
13 | 000550.XSHE |
14 | 000551.XSHE |
15 | 000561.XSHE |
16 | 000563.XSHE |
17 | 000587.XSHE |
18 | 000590.XSHE |
19 | 000600.XSHE |
20 | 000608.XSHE |
21 | 000625.XSHE |
22 | 000633.XSHE |
23 | 000655.XSHE |
24 | 000682.XSHE |
25 | 000685.XSHE |
26 | 000712.XSHE |
27 | 000718.XSHE |
28 | 000719.XSHE |
29 | 000720.XSHE |
... | ... |
481 | 603200.XSHG |
482 | 603238.XSHG |
483 | 603278.XSHG |
484 | 603298.XSHG |
485 | 603303.XSHG |
486 | 603313.XSHG |
487 | 603319.XSHG |
488 | 603326.XSHG |
489 | 603380.XSHG |
490 | 603383.XSHG |
491 | 603500.XSHG |
492 | 603556.XSHG |
493 | 603567.XSHG |
494 | 603577.XSHG |
495 | 603606.XSHG |
496 | 603609.XSHG |
497 | 603618.XSHG |
498 | 603636.XSHG |
499 | 603663.XSHG |
500 | 603665.XSHG |
501 | 603688.XSHG |
502 | 603698.XSHG |
503 | 603709.XSHG |
504 | 603712.XSHG |
505 | 603738.XSHG |
506 | 603823.XSHG |
507 | 603855.XSHG |
508 | 603879.XSHG |
509 | 603900.XSHG |
510 | 603920.XSHG |
511 rows × 1 columns
df_newhigh_60=pd.DataFrame({'60日新高':newhigh_60})
df_newhigh_60
60日新高 | |
---|---|
0 | 000070.XSHE |
1 | 000100.XSHE |
2 | 000400.XSHE |
3 | 000426.XSHE |
4 | 000429.XSHE |
5 | 000519.XSHE |
6 | 000543.XSHE |
7 | 000547.XSHE |
8 | 000550.XSHE |
9 | 000561.XSHE |
10 | 000625.XSHE |
11 | 000682.XSHE |
12 | 000719.XSHE |
13 | 000735.XSHE |
14 | 000738.XSHE |
15 | 000750.XSHE |
16 | 000777.XSHE |
17 | 000797.XSHE |
18 | 000823.XSHE |
19 | 000851.XSHE |
20 | 000876.XSHE |
21 | 000890.XSHE |
22 | 000895.XSHE |
23 | 000899.XSHE |
24 | 000901.XSHE |
25 | 002017.XSHE |
26 | 002023.XSHE |
27 | 002039.XSHE |
28 | 002064.XSHE |
29 | 002091.XSHE |
... | ... |
204 | 601700.XSHG |
205 | 601860.XSHG |
206 | 601890.XSHG |
207 | 601900.XSHG |
208 | 601901.XSHG |
209 | 601919.XSHG |
210 | 601965.XSHG |
211 | 601989.XSHG |
212 | 603005.XSHG |
213 | 603016.XSHG |
214 | 603017.XSHG |
215 | 603043.XSHG |
216 | 603050.XSHG |
217 | 603118.XSHG |
218 | 603200.XSHG |
219 | 603238.XSHG |
220 | 603313.XSHG |
221 | 603326.XSHG |
222 | 603500.XSHG |
223 | 603567.XSHG |
224 | 603577.XSHG |
225 | 603606.XSHG |
226 | 603618.XSHG |
227 | 603636.XSHG |
228 | 603663.XSHG |
229 | 603665.XSHG |
230 | 603688.XSHG |
231 | 603709.XSHG |
232 | 603712.XSHG |
233 | 603823.XSHG |
234 rows × 1 columns
#统计出今日市场成交情况所占比例
import pandas as pd
def get_money_statistics(date):
money_500=[]
money_1000=[]
money_3000=[]
money_5000=[]
money_10000=[]
money_50000=[]
money_5up=[]
money_10up=[]
df=get_all_securities(types=['stock'],date=date)
for stock in list(df.index):
df5=get_price(stock,end_date=date,count=2,frequency='daily',fields=['money'],fq='pre')
if df5['money'][-1]<5*10**6:
money_500.append(stock)
if df5['money'][-1]<10**7 and df5['money'][-1]>=5*10**6:
money_1000.append(stock)
if df5['money'][-1]<3*10**7 and df5['money'][-1]>=10**7:
money_3000.append(stock)
if df5['money'][-1]<5*10**7 and df5['money'][-1]>=3*10**7:
money_5000.append(stock)
if df5['money'][-1]<10**8 and df5['money'][-1]>=5*10**7:
money_10000.append(stock)
if df5['money'][-1]<5*10**8 and df5['money'][-1]>=10**8:
money_50000.append(stock)
if df5['money'][-1]<10**9 and df5['money'][-1]>=5*10**8:
money_5up.append(stock)
if df5['money'][-1]>=10**9:
money_10up.append(stock)
df_money=pd.DataFrame(index=['500万以下','500-1000万','1000万-3000万','3000万-5000万','5000万-1亿','1亿-5亿','5亿-10亿','10亿以上'],\
columns=['成交额个股数','个股所占比例'])
df_money['成交额个股数']=[len(money_500),len(money_1000),len(money_3000),len(money_5000),len(money_10000),len(money_50000),len(money_5up),len(money_10up)]
df_money['个股所占比例']=round(df_money['成交额个股数']/len(df.index),4)
return df_money
get_money_statistics('2019-01-08')
成交额个股数 | 个股所占比例 | |
---|---|---|
500万以下 | 100 | 0.0280 |
500-1000万 | 341 | 0.0955 |
1000万-3000万 | 1160 | 0.3249 |
3000万-5000万 | 567 | 0.1588 |
5000万-1亿 | 680 | 0.1905 |
1亿-5亿 | 635 | 0.1779 |
5亿-10亿 | 69 | 0.0193 |
10亿以上 | 18 | 0.0050 |
#今日涨停个股价位区间分布
import pandas as pd
uz10=[]
uz20=[]
uz30=[]
uz40=[]
for stock in uunost:
df2_3=get_price(stock,end_date='2019-01-08',count=10,frequency='daily',\
fields=['open','close'],\
fq='pre')
if df2_3['close'][-1]<=10:
uz10.append(stock)
if df2_3['close'][-1]<=20 and df2_3['close'][-1]>10:
uz20.append(stock)
if df2_3['close'][-1]<=30 and df2_3['close'][-1]>20:
uz30.append(stock)
if df2_3['close'][-1]>30:
uz40.append(stock)
df_closefenbu=pd.DataFrame(index=['10元以内','20元以内','30元以内','30元以上'],columns=['涨停个股数','个股所占总涨停数的比例'])
df_closefenbu['涨停个股数']=[len(uz10),len(uz20),len(uz30),len(uz40)]
df_closefenbu['个股所占总涨停数的比例']=round(df_closefenbu['涨停个股数']/len(uunost),4)
df_closefenbu
涨停个股数 | 个股所占总涨停数的比例 | |
---|---|---|
10元以内 | 31 | 0.6739 |
20元以内 | 10 | 0.2174 |
30元以内 | 4 | 0.0870 |
30元以上 | 1 | 0.0217 |
#截止到当前日期的交易日列表,涨停个股数,反应的是当前市场的情绪
def get_trade_days(date):
df=get_price('000001.XSHG',end_date=date,count=30,frequency='daily',fields=['close'],fq='pre')
return df['close'].index
#截止到当前日期的涨停个股走势图,看出市场的情绪
import pandas as pd
def get_zhangting(date):
uuzzz=[]
for i in get_trade_days(date):
df2=get_all_securities(types=['stock'],date=i)
uuzz=[]
for stock in list(df2.index):
df3=get_price(stock,end_date=i,count=1,frequency='daily',fields=['close','high_limit','money'],fq='pre')
if df3['close'][-1]==df3['high_limit'][-1] and df3['money'][-1]>0:
uuzz.append(stock)
uuzzz.append(len(uuzz))
df_uuzz=pd.DataFrame(index=get_trade_days(date),columns=['涨停个股数'])
df_uuzz['涨停个股数']=uuzzz
return df_uuzz.plot()
get_zhangting('2019-01-08') #市场情绪指标走势图
本社区仅针对特定人员开放
查看需注册登录并通过风险意识测评
5秒后跳转登录页面...
移动端课程