from jqdata import jyimport pandas as pd
def getDvDJY(stockPool,date):indexStockFormat=[]for i in stockPool:indexStockFormat.append(i[:6])trade_list = indexStockFormat # 股票列表secu_category = [1] # 证券类别:1-A股,SecuMain表中的字段incode = jy.run_query(query(jy.SecuMain.SecuCode,jy.SecuMain.InnerCode,).filter(jy.SecuMain.SecuCategory.in_(secu_category),jy.SecuMain.SecuCode.in_(trade_list),))# incodeq = query(jy.LC_DIndicesForValuation.InnerCode, # 证券内部编码jy.LC_DIndicesForValuation.TradingDay,jy.LC_DIndicesForValuation.DividendRatio, # 股息率).filter(jy.LC_DIndicesForValuation.TradingDay ==date, # 股息率日期jy.LC_DIndicesForValuation.InnerCode.in_(incode['InnerCode']) # 股票代码)df = jy.run_query(q).fillna(value=0, method=None, axis=0) df2 = pd.merge(incode, df, on='InnerCode')secuCodeList=df2["SecuCode"].tolist()JQList=[]for i in secuCodeList:JQList.append(normalize_code(i))dvdSeries=pd.Series(df2["DividendRatio"].tolist(),index=JQList)return dvdSeries
indexStock=get_index_stocks("000300.XSHG") #获得股票列表getDvDJY(indexStock,"2019-08-23")
000001.XSHE 0.009897
000002.XSHE 0.038765
000063.XSHE 0.000000
000069.XSHE 0.043174
000100.XSHE 0.029457
000157.XSHE 0.078579
000402.XSHE 0.039474
000408.XSHE 0.000000
000413.XSHE 0.014614
000415.XSHE 0.000000
000423.XSHE 0.030864
000425.XSHE 0.013483
000538.XSHE 0.020941
000553.XSHE 0.010509
000568.XSHE 0.017477
000596.XSHE 0.012715
000625.XSHE 0.002187
000627.XSHE 0.004202
000629.XSHE 0.000000
000630.XSHE 0.013333
000651.XSHE 0.038258
000656.XSHE 0.050992
000661.XSHE 0.002310
000671.XSHE 0.009135
000703.XSHE 0.026224
000709.XSHE 0.038610
000725.XSHE 0.007557
000728.XSHE 0.017123
000768.XSHE 0.006464
000776.XSHE 0.000000
...
603858.XSHG 0.063746
002736.XSHE 0.008639
300413.XSHE 0.000000
300408.XSHE 0.012255
601229.XSHG 0.038590
600919.XSHG 0.051282
601997.XSHG 0.034758
600926.XSHG 0.030979
601838.XSHG 0.042787
601881.XSHG 0.008364
603833.XSHG 0.006710
601228.XSHG 0.009067
000166.XSHE 0.009240
300498.XSHE 0.012633
601108.XSHG 0.007099
601155.XSHG 0.057906
601162.XSHG 0.000780
001979.XSHE 0.037890
603260.XSHG 0.019714
600025.XSHG 0.003771
002939.XSHE 0.012796
002925.XSHE 0.025450
002945.XSHE 0.002282
601066.XSHG 0.019313
603259.XSHG 0.005018
601319.XSHG 0.005333
601298.XSHG 0.048369
002938.XSHE 0.013116
601577.XSHG 0.032370
601138.XSHG 0.008629
Length: 300, dtype: float64