数据采集20200618(可转债逐周信息)

#可转债逐周信息

BDate=’20200101′

EDate=’20200630′

TickerBond=”113581″

calendar=DataAPI.TradeCalGet(exchangeCD=u”XSHG”,beginDate=BDate,endDate=EDate,field=u””,pandas=”1″)

calendar=calendar[calendar.isOpen==1][calendar.isWeekEnd==1]#只取周末日期

factor_list=[]

for tdate in calendar.calendarDate.values:#拿到因子数据,遍历每一天

kzzyj=DataAPI.MktConsBondPremiumGet(SecID=u””,tickerBond=u””,beginDate=tdate,endDate=tdate,

field=u”tickerBond,tradeDate,bondPremDisc”,pandas=”1″)

table={‘tradeDate’:([tdate]),’MBPD’:([np.median(kzzyj.bondPremDisc)])}

DF=pd.DataFrame(table)

factor_list.append(DF)

MBPD=pd.concat(factor_list)

kzz=DataAPI.MktConsBondPremiumGet(SecID=u””,tickerBond=TickerBond,beginDate=BDate,endDate=EDate,

field=u”tickerEqu,secShortNameEqu,closePriceEqu,secShortNameBond,closePriceBond,convPrice,tradeDate”,pandas=”1″)

kzz[‘zp’]=(100/kzz.convPrice)*kzz.closePriceEqu-kzz.closePriceBond

calendar[‘tradeDate’]=calendar.calendarDate

kzz=kzz.merge(calendar)

kzz=kzz.merge(MBPD)

kzz[‘cl’]=kzz.zp*kzz.MBPD/kzz.closePriceBond

kzz.head(60)

 

tickerEqu secShortNameEqu closePriceEqu secShortNameBond     closePriceBond     convPrice       tradeDate      zp       exchangeCD  calendarDate isOpen   prevTradeDate      isWeekEnd     isMonthEnd   isQuarterEnd isYearEnd       MBPD     cl

0     603906    龙蟠科技       9.04 龙蟠转债       107.57     9.61 2020-05-22    -13.501322     XSHG     2020-05-22    1       2020-05-21    1     0     0     0     22.63020 -2.840361

1     603906    龙蟠科技       9.33 龙蟠转债       109.06     9.61 2020-05-29    -11.973632     XSHG     2020-05-29    1       2020-05-28    1     1     0     0     21.49560 -2.359989

2     603906    龙蟠科技       11.92      龙蟠转债       137.34     9.48 2020-06-05    -11.601603     XSHG     2020-06-05    1       2020-06-04    1     0     0     0     20.35490 -1.719452

3     603906    龙蟠科技       15.38      龙蟠转债       137.82     9.48 2020-06-12    24.416287      XSHG     2020-06-12    1       2020-06-11    1     0     0     0     19.69165 3.488586

Leave a Reply

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