1 Star 1 Fork 11

连享会/Stata-Event_Study

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
fffactors.ado 2.09 KB
一键复制 编辑 原始数据 按行查看 历史
*! Date : 2017-09-14
*! version : 0.4
*! Author : Richard Herron
*! Email : richard.c.herron@gmail.com
*! get Fama-French factors from French Data Library
/*
2017-09-14 v0.4 added momentum factor, simplified code
2017-08-17 v0.3 more consistent date names
2017-08-04 v0.2 fixed date label, display summary statistics
2016-09-02 v0.1 first upload to GitHub
*/
program define fffactors
version 13.1
syntax , clear [ KEEPfiles ]
pwd
/* {{{ 3-factor file */
/* get 3-factor file */
local cloud "http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_CSV.zip"
copy "`cloud'" "F-F_Research_Data_Factors_CSV.zip", replace
unzipfile "F-F_Research_Data_Factors_CSV.zip", replace
/* read 3-factor file */
import delimited using "F-F_Research_Data_Factors.CSV" ///
, `clear' varnames(3) case(preserve) numericcols(_all)
drop if missing(v1) | (v1 < 190000)
/* }}} */
/* {{{ momentum file */
preserve
/* get momentum file */
local cloud "http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Momentum_Factor_CSV.zip"
copy "`cloud'" "F-F_Momentum_Factor_CSV.zip", replace
unzipfile "F-F_Momentum_Factor_CSV.zip", replace
/* read momentum file */
import delimited using "F-F_Momentum_Factor.CSV" ///
, `clear' varnames(13) case(preserve) numericcols(_all)
drop if missing(v1) | (v1 < 190000)
/* save momentum to tempfile */
tempfile Momentum
save "`Momentum'"
restore
/* }}} */
/* {{{ combine 3 and momentum factors and groom */
merge 1:1 v1 using "`Momentum'", nogenerate
/* fix date */
generate int Date = ym(floor(v1/100), mod(v1, 100))
format Date %tm
label variable Date "Date"
drop v1
order Date
/* fix labels */
quietly ds, not(varlabel)
foreach v in `r(varlist)' {
label variable `v' "`v'"
}
/* }}} */
/* {{{ by default, remove files */
if ("`keepfiles'" == "") {
rm "F-F_Research_Data_Factors_CSV.zip"
rm "F-F_Research_Data_Factors.CSV"
rm "F-F_Momentum_Factor_CSV.zip"
rm "F-F_Momentum_Factor.CSV"
}
/* }}} */
end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/arlionn/Stata-Event_Study.git
git@gitee.com:arlionn/Stata-Event_Study.git
arlionn
Stata-Event_Study
Stata-Event_Study
master

搜索帮助