两个问题,我这种方式筛选出来的交易日期是否合理
第二个问题,我这个日波动率就百分之十几是不是有误
附上代码
merge m:1 id_stock using f_Conver_id_stock.dta
gen var3=date(发行公告日,"DMY")
format var3 %td
gen var5=date(TradingDate, "YMD") //jiaoyiri
format var5 %td
gen var4=var3-2 //t-2
format var4 %td
gen day1 = var4-var5
replace earliest_date = v4_t2 - 350
keep if v5_trade >= earliest_date & v5_trade < v4_t2
dataex id Cnvtprc ClosePrice sigema csd in 5/15
dataex id_stock v5_trade v4_t2 day1 earliest cp_lnst csd in 1/10
----------------------- copy starting from the next line -----------------------
- * Example generated by -dataex-. For more info, type help dataex
- clear
- input str12 id_stock float(v5_trade v4_t2 day1 earliest_date cp_lnst csd)
- "300723" 22259 22304 45 21954 .009554235 .12835492
- "300723" 22001 22304 303 21954 -.26990408 .12835492
- "300723" 22004 22304 300 21954 -.26745802 .12835492
- "300723" 22005 22304 299 21954 -.21316914 .12835492
- "300723" 22006 22304 298 21954 -.23263843 .12835492
- "300723" 22007 22304 297 21954 -.2163464 .12835492
- "300723" 22008 22304 296 21954 -.209431 .12835492
- "300723" 22011 22304 293 21954 -.24645425 .12835492
- "300723" 22012 22304 292 21954 -.201436 .12835492
- "300723" 22013 22304 291 21954 -.1669583 .12835492
- end
------------------ copy up to and including the previous line ------------------
bys 证券简称 :gen cp_st_ = ClosePrice
bys 证券简称 :gen cp_st_1 = 0
replace cp_st_1=0 if n == 1
bys 证券简称 : replace cp_st_1 = ClosePrice[n-1] if n != 1
bys 证券简称 :gen cp_lnst = log(cp_st_ )-log(cp_st_1)
replace cp_lnst=ClosePrice if n == 1
replace cp_lnst=0 if n == 1
bys 证券简称 :replace cp_lnst = log(cp_st_ )-log(cp_st_1)
egen cpstmean =mean(cp_lnst),by(证券简称)
egen csd= sd(cp_lnst),by(证券简称)
bys id: egen sum = nvals(n)
gen day_2 = sqrt(sum)//根号天数
gen sigma = csd * day_2
----------------------- copy starting from the next line -----------------------
- * Example generated by -dataex-. For more info, type help dataex
- clear
- input str6 id double(Cnvtprc ClosePrice) float(sigema2 csd)
- "110048" 8.69 21.093 .005923446 .10884343
- "110052" 8.13 8.528 .0121633 .15596987
- "110053" 7.9 7.454 .0007878512 .03969512
- "110055" 17.6 60.715 .064305335 .3586233
- "110057" 10.09 92.68 .004099632 .0905498
- "110058" 6.5 65.732 .005691642 .10669248
- "110059" 15.05 164.25 .003549309 .0842533
- "110060" 7.24 55.875 .008393915 .12956786
- "110061" 9.92 189.026 .005772712 .10744964
- "110062" 25.99 88.207 .00362888 .08519249
- "110067" 8.77 8.962 .008355752 .12927298
- end
------------------ copy up to and including the previous line ------------------
第一次发帖,本科水平。求助各位老师大神