数据采集之指数估值三:市场平均PE方法二

#市场平均PE方法二
data=DataAPI.MktStockFactorsOneDayGet(secID=u””,tradeDate=u”20181225″,field=u”ticker,tradeDate,PE,PB”,pandas=”1″)
data=data.set_index(‘ticker’)#将ticker作为索引
after_winsorizepe=winsorize(data[‘PE’].to_dict())#PE值dict化,并去极值
after_winsorizepb=winsorize(data[‘PB’].to_dict())
data[‘winsorized_PE’]=np.nan
data[‘winsorized_PB’]=np.nan
data.loc[after_winsorizepe.keys(),’winsorized_PE’]=after_winsorizepe.values()#新建winsorized PE列,赋值after_winsorize
data.loc[after_winsorizepb.keys(),’winsorized_PB’]=after_winsorizepb.values()
#data.plot(figsize=(14,5)).legend(fontsize=14)#画图
table={‘APB’:([np.mean(data.PB)]),’APB+’:([np.mean(data.winsorized_PB)]),’APE(TTM)’:([np.mean(data.PE)]),’APE(TTM)+’:([np.mean(data.winsorized_PE)]),’MPE(TTM)’:([np.median(data.PE)])}
APE=pd.DataFrame(table)
APE

APB APB+ APE(TTM) APE(TTM)+ MPE(TTM)
0 1.692978 2.533131 24.427032 29.76065 23.729

数据采集自网络

Leave a Reply

邮箱地址不会被公开。 必填项已用*标注