# 实时计算涨停板股票的封单资金与总流通市值的比例

``````# 常量准备
import pandas as pd
from datetime import datetime as dt
from pandas import DataFrame, Series
today = dt.today().strftime('%Y%m%d')   # 获得今天的日期

# DataAPI取所有A股
stocks = DataAPI.EquGet(equTypeCD='A',listStatusCD='L',field='secID,nonrestfloatA',pandas="1")
universe = stocks['secID'].tolist()    # 转变为list格式，以便和DataAPI中的格式符合

# 取所有A股的最新行情
data = DataFrame()
for i in range(0,len(universe),300):   # 原则上可以性取完的，但是试验中作者发现会报错，估计是运算量太大，所以这里分批次取，每次300个
t = DataAPI.MktTickRTSnapshotGet(securityID=universe[i:min(i+300,len(universe))],field=fields,pandas="1")
tmp = DataFrame()
tmp['secID'] = t['ticker']+'.'+t['exchangeCD']
data = pd.concat([data,tmp],axis=0)   # 数据拼接

# 去掉当日停牌的股票
data['nonrestfloatA'] = stocks['nonrestfloatA']
data = data[data['suspension']==0]

# 去掉没有涨停板的股票
data['suspension'][(data['bidBook_volume1']>0).values & (data['askBook_volume1']==0).values] = 1  # 若涨停盘，suspension则赋值1
data = data[data['suspension']==1]

# 计算封停板资金量、流通市值、两者比值
data['stop_money'] = data['bidBook_price1'].values * data['bidBook_volume1'].values
data['float_value'] = data['bidBook_price1'].values * data['nonrestfloatA'].values
data['rate'] = data['stop_money']/data['float_value']*100   #百分之几
data = data.sort(columns='rate',ascending=False).reset_index()
data.drop('index',axis=1,inplace=True)

# 重命名
data.columns = ['代码','简称','最新成交价','买一价','买一量','非受限流通股','封停板资金','流通市值','封停资金流通市值比（百分之几）']
``````

0 600127.XSHG 金健米业 8.64 8.64 31034932 138756240 2.681418e+08 1.198854e+09 22.366513
1 002465.XSHE 海格通信 26.49 26.49 48681212 232841128 1.289565e+09 6.167961e+09 20.907480
2 002451.XSHE 摩恩电气 10.15 10.15 20255795 99720453 2.055963e+08 1.012163e+09 20.312578
3 600307.XSHG 酒钢宏兴 4.97 4.97 41841200 223174819 2.079508e+08 1.109179e+09 18.748172
4 601216.XSHG 内蒙君正 10.97 10.97 47936330 256155318 5.258615e+08 2.810024e+09 18.713775
5 002220.XSHE 天宝股份 9.53 9.53 36358180 203638446 3.464935e+08 1.940674e+09 17.854281
6 000153.XSHE 丰原药业 8.91 8.91 43825338 296645200 3.904838e+08 2.643109e+09 14.773655
7 600363.XSHG 联创光电 11.98 11.98 39827219 287985798 4.771301e+08 3.450070e+09 13.829577
8 600881.XSHG 亚泰集团 10.32 10.32 39219948 324000000 4.047499e+08 3.343680e+09 12.104922
9 601989.XSHG 中国重工 12.90 12.90 35504690 309043600 4.580105e+08 3.986662e+09 11.488570
10 002578.XSHE 闽发铝业 8.61 8.61 18732903 169374479 1.612903e+08 1.458314e+09 11.060051
11 002314.XSHE 雅致股份 8.51 8.51 29786294 331060900 2.534814e+08 2.817328e+09 8.997225
12 002596.XSHE 海南瑞泽 19.77 19.77 13188288 150360840 2.607325e+08 2.972634e+09 8.771092
13 300245.XSHE 天玑科技 14.99 14.99 30609263 358143846 4.588329e+08 5.368576e+09 8.546639
14 600725.XSHG 云维股份 7.21 7.21 10355583 131323745 7.466375e+07 9.468442e+08 7.885537
15 600635.XSHG 大众公用 8.45 8.45 15693824 203285722 1.326128e+08 1.717764e+09 7.720082
16 000005.XSHE 世纪星源 5.96 5.96 65653281 913743007 3.912936e+08 5.445908e+09 7.185093
17 000908.XSHE 景峰医药 13.72 13.72 22259100 318306848 3.053949e+08 4.367170e+09 6.992969
18 002392.XSHE 北京利尔 6.60 6.60 18238316 272720782 1.203729e+08 1.799957e+09 6.687542
19 300315.XSHE 掌趣科技 15.47 15.47 8467640 143055590 1.309944e+08 2.213070e+09 5.919126
20 000733.XSHE 振华科技 17.52 17.52 25394193 429158874 4.449063e+08 7.518863e+09 5.917201
21 002492.XSHE 恒基达鑫 10.15 10.15 15039065 258580938 1.526465e+08 2.624597e+09 5.815999
22 000662.XSHE 索芙特 13.52 13.52 16284361 287985798 2.201646e+08 3.893568e+09 5.654571
23 002070.XSHE 众和股份 9.57 9.57 16355886 301076280 1.565258e+08 2.881300e+09 5.432472
24 002582.XSHE 好想你 18.94 18.94 19100773 400080405 3.617686e+08 7.577523e+09 4.774234
25 600818.XSHG 中路股份 67.12 67.12 9203792 213594042 6.177585e+08 1.433643e+10 4.309012
26 600439.XSHG 瑞贝卡 6.90 6.90 17411170 429158874 1.201371e+08 2.961196e+09 4.057045
27 002385.XSHE 大北农 16.10 16.10 8450558 221721339 1.360540e+08 3.569714e+09 3.811342
28 600839.XSHG 四川长虹 8.07 8.07 21128839 560561743 1.705097e+08 4.523733e+09 3.769226
29 002176.XSHE 江特电机 18.48 18.48 13745498 387357522 2.540168e+08 7.158367e+09 3.548530