股利贴现模型 - 年化复合增长率(CAGR)#

又是一个“爷青回”的话题。 对上一次讨论股利贴现模型是19年的事情:股利贴现模型 - 戈登模型(Gordon Growth Model), 距离现在差不多两年半的时间。

pic

Fig. 11 股利贴现模型#

在DCF模型中, 为了得到股票的内在价值,我们需要预判目标企业未来的增长率 g, 这个 g 往往对股票的内在价值起了重要作用。

那么这个增长率我们不能随便拍拍脑袋就定下来。 一般我们可以有几种方法去预判这个增长率 g

  • 第一,看行业增速;

  • 第二,看历史增速。

行业增速#

看行业增速算是比较简单, 一般情况下我们可以找到一些行业协会写的行业报告,里面一般会提及过往或者对未来增速的预估。 还有一个就是,挑选多家同行业的上市公司,然后将这些企业的历年增速叠加再平均一下作为增长率 g

历史增速#

在这里我主要是讨论如何利用python量化获得多个股票的历年增速。

因为我个人重仓了隆基股份,因此这里我挑选了光伏行业作为例子, 其中股票池包括'爱旭股份', '晶澳科技', '协鑫集成', '中环股份', '东方日升', '中来股份', '亿晶光电', '天合光能', '向日葵', '隆基股份', '通威股份', '正泰电器', '航天机电', '拓日新能'

实现代码#

设置tushare的token和引入相关的库

import tushare as ts
import pandas as pd

#设置完整显示数据
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
pd.set_option('display.float_format', '{:,.2f}'.format)

#注册tushare后获得token
pro = ts.pro_api('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')

def cagr(start_value, end_value, num_periods):
    return (end_value / start_value) ** (1 / (num_periods - 1)) - 1

设置年化复合增长率(CAGR)的时间跨度,这里我选取5年期,因此时间段为2015年-2020年.

#时间段
start_date = '20150101'
end_date = '20201231'

#股票池
stock_list = ['爱旭股份', '晶澳科技', '协鑫集成', '中环股份', '东方日升', '中来股份', '亿晶光电', '天合光能', '向日葵', '隆基股份', '通威股份', '正泰电器', '航天机电', '拓日新能']

下面为主要的实现代码

result_list = []

#主要用于将上述的股票中文名称转换为tushare能识别的`ts_code`
stock_basic = pro.stock_basic(exchange='', list_status='L', fields='ts_code,symbol,name')
stock_selections = stock_basic[stock_basic['name'].isin(stock_list)]

for ticker, name in zip(stock_selections['ts_code'], stock_selections['name']):
    result_dict = {}
    #获取股票历年的营收
    total_revenue = pro.income(ts_code=ticker, start_date=start_date, end_date=end_date,fields='ts_code,end_date,total_revenue')
    total_revenue.drop_duplicates(subset=['ts_code','end_date'],keep='first',inplace=True)
    total_revenue.set_index('end_date', inplace=True)
    total_revenue_yrs = total_revenue.filter(like='1231', axis=0)

    #计算CAGR
    start_value = float(total_revenue_yrs.iloc[-1]['total_revenue'])
    end_value = float(total_revenue_yrs.iloc[0]['total_revenue'])
    num_periods = len(total_revenue_yrs['total_revenue'])
    cagr_y = cagr(start_value, end_value, num_periods)

    result_dict['代码'] = ticker
    result_dict['股票名称'] = name
    result_dict['年复合增长率'] = cagr_y * 100
    result_dict['周期'] = num_periods - 1
    result_list.append(result_dict)

df = pd.DataFrame(result_list)
df.sort_values(by='年复合增长率', ascending=False)

结果#

pic

Fig. 12 年复合增长率输出结果#