美文网首页
无标题文章

无标题文章

作者: 午后慵 | 来源:发表于2018-11-13 00:10 被阅读0次

  global path "C:\Users\Echo\Desktop\公司金融\作业\HW04"

  cap mkdir data

  cap mkdir refs

  cap mkdir out

  cap mkdir adofiles 

  global D    "$path\data"      //范例数据

  global R    "$path\refs"      //参考文献

  global out  "$path\out"      //图形和表格结果

  adopath +  "$path\adofiles"  //添加外部命令所在路径 

  cd $D

  set scheme s2color

*---------------------

*- 1 下载个股交易资料

*---------------------

global id="000541" //000541 佛山照明

cntrade $id

    global nn = stknme[1]  //股票简称

    use "$id.dta", clear

    tsset date  //设定为时间序列变量

    *-股价时序图

    tsline clsprc , xlabel(,angle(60)) subtitle("$nn $id")

    graph export "$out\price_$id.png", replace

*------------------

*- 2 下载指数数据

*------------------

  *  -Index Codes and Index Names:

  *  000001  The Shanghai Composite Index (上证综合指数).

  *  000300  CSI 300 Index (沪深 300).

  *  399001  Shenzhen Component Index (深成指).

cntrade 399001, index

use "399001.dta", clear

describe

foreach i in "399001" "000001" "000300" {

cntrade `i', index

rename rmt retmkt_`i'

save index_`i'.dta, replace

erase `i'.dta

    }

* 调用其中一个指数数据:

    use index_000300.dta, clear // 沪深300指数

    tsset date

    tsline clsprc , xlabel(,angle(60)) subtitle("沪深300指数")

*-----------------------

*- 3 合并个股和指数数据

*-----------------------

  use "index_399001.dta", clear

  merge 1:1 date using "$id.dta", nogen

  gen year = year(date)

  order date year index* stk* ret*

  save "merge_$id.dta", replace

*---------------------------------

*- 4 估计CAPM模型并分析 Beta 系数

*---------------------------------

*-估计CAPM模型

  use "merge_$id.dta", clear

  *winsor2 reti, replace  // winsor 处理

  reg rit retmkt

  #delimit ;

  twoway

    (scatter rit retmkt if year<2008&abs(retmkt)<0.4, 

      xline(0,lp(dash) lc(red))

      yline(0,lp(dash) lc(red)) msize(*0.2))

    (lfit rit retmkt);

  #d cr

  // 图示拟合情况 2015年 

    reg rit retmkt if 2015<year<2016 //&abs(retmkt)<0.4  // OLS

    aaplot rit retmkt if e(sample), xline(0,lp(dash) lc(red)) ///

            yline(0,lp(dash) lc(red)) msize(*0.6) /// 

            title("$nn ($id) 的 Beta 系数, 2015") ///

            xtitle("市场指数收益率(深成指)")

    graph export "$out\aaplot_$id_b$yr.png", replace    

    regfit, f(%4.2f) tvalue  //呈现拟合方程

// 图示拟合情况 2016年

    reg rit retmkt if 2016<year<2017 //&abs(retmkt)<0.4  // OLS

    aaplot rit retmkt if e(sample), xline(0,lp(dash) lc(red)) ///

            yline(0,lp(dash) lc(red)) msize(*0.6)    ///

            title("$nn ($id) 的 Beta 系数, 2016") ///

            xtitle("市场指数收益率(深成指)")

    graph export "$out\aaplot_$id_a$yr.png", replace

    regfit, f(%4.2f) tvalue  //呈现拟合方程

// 图示拟合情况 2017年

    reg rit retmkt if 2017<year<2018 //&abs(retmkt)<0.4  // OLS

    aaplot rit retmkt if e(sample), xline(0,lp(dash) lc(red)) ///

            yline(0,lp(dash) lc(red)) msize(*0.6) /// 

            title("$nn ($id) 的 Beta 系数, 2017") ///

            xtitle("市场指数收益率(深成指)")

    graph export "$out\aaplot_$id_b$yr.png", replace   

    regfit, f(%4.2f) tvalue  //呈现拟合方程

*-逐年回归

    bysort year: reg rit retmkt, noheader

    *-逐年统计

    statsby _b[retmkt], by(year) saving("beta_data.dta", replace): ///

          reg rit retmkt

    *-变化趋势   

    preserve

      use "beta_data.dta", clear

      keep if _stat!=.

      qui sum year

      local byr = r(min)

      local eyr = r(max)

      list

      #d ;

      twoway connect _stat year, 

            yline(1, lpattern(dash) lcolor(red*0.3))

            xlabel(`byr'(2)`eyr')

            ylabel(,angle(0) format(%2.1f))

            subtitle("$nn ($id) 的Beta系数")

            ytitle("beta") xtitle("");

      #d cr

      graph export "beta $nn $id.wmf", replace

    restore   

  *--------------------------over------------------------

佛山照明的β系数在2015年间总体高于1,2016-2017年间呈下滑趋势,且低于1,表明佛山照明未来回报率趋于与市场同向变动,但其变动幅度较小,对于市场风险的敏感度较低。且敏感度将越变越低。

相关文章

  • 无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章 无标题文章无标题文章无标题文章无...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • fasfsdfdf

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章

  • 无标题文章

    无标题文章 无标题文章 无标题文章无标题文章 无标题文章 无标题文章

网友评论

      本文标题:无标题文章

      本文链接:https://www.haomeiwen.com/subject/zpwhfqtx.html