首页 > 其他分享 >(26-5-03)基于OpenAI和LangChain的上市公司估值系统:定量分析(Quantitative Analysis)(3)计算估值

(26-5-03)基于OpenAI和LangChain的上市公司估值系统:定量分析(Quantitative Analysis)(3)计算估值

时间:2024-06-21 21:28:09浏览次数:24  
标签:03 26 5y value growth values LangChain ttm mr

10.5.4  计算估值

(1)在本项目中,分别使用了基于股息和自由现金流的方法计算股票的估值。针对不同情景(正常和经济衰退),分别进行了计算。通过这些计算,可以帮助投资者评估股票的合理价格,并制定相应的投资策略。

    dict_values_for_bi = {}

    stock_value_div_ttm_fixed = dividends_valuation(EARNINGS_TTM, GROWTH_FIXED, cagr, growth_eps_5y, growth_5y,
                                                    riskfree, industry_payout, cost_of_equity,
                                                    target_cost_of_equity, growth_eps_last, eps_5y, payout_5y, ttm_eps_adj,
                                                    reinvestment_eps_last, fx_rate, survival_prob, liquidation_per_share, debug=debug, dict_values_for_bi=dict_values_for_bi)
    stock_value_div_norm_fixed = dividends_valuation(EARNINGS_NORM, GROWTH_FIXED, cagr, growth_eps_5y, growth_5y,
                                                     riskfree, industry_payout, cost_of_equity,
                                                     target_cost_of_equity, growth_eps_last, eps_5y, payout_5y, ttm_eps_adj,
                                                    reinvestment_eps_last, fx_rate, survival_prob, liquidation_per_share, debug=debug, dict_values_for_bi=dict_values_for_bi)
    stock_value_div_ttm_ttm = dividends_valuation(EARNINGS_TTM, GROWTH_TTM, cagr, growth_eps_5y, growth_5y, riskfree,
                                                  industry_payout, cost_of_equity, target_cost_of_equity,
                                                  growth_eps_last, eps_5y, payout_5y, ttm_eps_adj,
                                                    reinvestment_eps_last, fx_rate, survival_prob, liquidation_per_share, debug=debug, dict_values_for_bi=dict_values_for_bi)
    stock_value_div_norm_norm = dividends_valuation(EARNINGS_NORM, GROWTH_NORM, cagr, growth_eps_5y, growth_5y, riskfree,
                                                    industry_payout, cost_of_equity,
                                                    target_cost_of_equity, growth_eps_last, eps_5y, payout_5y, ttm_eps_adj,
                                                    reinvestment_eps_last, fx_rate, survival_prob, liquidation_per_share, debug=debug, dict_values_for_bi=dict_values_for_bi)
    stock_value_div_ttm_fixed_recession = dividends_valuation(EARNINGS_TTM, GROWTH_FIXED, cagr, growth_eps_5y, growth_5y,
                                                    riskfree, industry_payout, cost_of_equity,
                                                    target_cost_of_equity, growth_eps_last, eps_5y, payout_5y, ttm_eps_adj,
                                                    reinvestment_eps_last, fx_rate, survival_prob, liquidation_per_share, debug=debug, recession=True, dict_values_for_bi=dict_values_for_bi)
    stock_value_div_norm_fixed_recession = dividends_valuation(EARNINGS_NORM, GROWTH_FIXED, cagr, growth_eps_5y, growth_5y,
                                                     riskfree, industry_payout, cost_of_equity,
                                                     target_cost_of_equity, growth_eps_last, eps_5y, payout_5y, ttm_eps_adj,
                                                    reinvestment_eps_last, fx_rate, survival_prob, liquidation_per_share, debug=debug, recession=True, dict_values_for_bi=dict_values_for_bi)
    stock_value_div_ttm_ttm_recession = dividends_valuation(EARNINGS_TTM, GROWTH_TTM, cagr, growth_eps_5y, growth_5y, riskfree,
                                                  industry_payout, cost_of_equity, target_cost_of_equity,
                                                  growth_eps_last, eps_5y, payout_5y, ttm_eps_adj,
                                                    reinvestment_eps_last, fx_rate, survival_prob, liquidation_per_share, debug=debug, recession=True, dict_values_for_bi=dict_values_for_bi)
    stock_value_div_norm_norm_recession = dividends_valuation(EARNINGS_NORM, GROWTH_NORM, cagr, growth_eps_5y, growth_5y, riskfree,
                                                    industry_payout, cost_of_equity,
                                                    target_cost_of_equity, growth_eps_last, eps_5y, payout_5y, ttm_eps_adj,
                                                    reinvestment_eps_last, fx_rate, survival_prob, liquidation_per_share, debug=debug, recession=True, dict_values_for_bi=dict_values_for_bi)

    stock_value_fcff_ttm_fixed = fcff_valuation(EARNINGS_TTM, GROWTH_FIXED, cagr, riskfree, ttm_revenue, ttm_ebit_adj,
                                                target_operating_margin, mr_tax_benefits, tax_rate, sales_capital_5y, target_sales_capital,
                                                debt_equity, target_debt_equity, unlevered_beta, final_erp, cost_of_debt,
                                                target_cost_of_debt, mr_cash, mr_securities, debt_mkt, mr_minority_interest, survival_prob, mr_shares,
                                                liquidation_value, growth_last, growth_5y, revenue_5y, ebit_5y, fx_rate, mr_property, mr_sbc, debug=debug, dict_values_for_bi=dict_values_for_bi)
    stock_value_fcff_norm_fixed = fcff_valuation(EARNINGS_NORM, GROWTH_FIXED, cagr, riskfree, ttm_revenue, ttm_ebit_adj,
                                                 target_operating_margin, mr_tax_benefits, tax_rate, sales_capital_5y, target_sales_capital,
                                                 debt_equity, target_debt_equity, unlevered_beta, final_erp, cost_of_debt,
                                                 target_cost_of_debt, mr_cash, mr_securities, debt_mkt, mr_minority_interest, survival_prob, mr_shares,
                                                 liquidation_value, growth_last, growth_5y, revenue_5y, ebit_5y, fx_rate, mr_property, mr_sbc, debug=debug, dict_values_for_bi=dict_values_for_bi)
    stock_value_fcff_ttm_ttm = fcff_valuation(EARNINGS_TTM, GROWTH_TTM, cagr, riskfree, ttm_revenue, ttm_ebit_adj,
                                              target_operating_margin, mr_tax_benefits, tax_rate, sales_capital_5y, target_sales_capital,
                                              debt_equity, target_debt_equity, unlevered_beta, final_erp, cost_of_debt,
                                              target_cost_of_debt, mr_cash, mr_securities, debt_mkt, mr_minority_interest, survival_prob, mr_shares,
                                              liquidation_value, growth_last, growth_5y, revenue_5y, ebit_5y, fx_rate, mr_property, mr_sbc, debug=debug, dict_values_for_bi=dict_values_for_bi)
    stock_value_fcff_norm_norm = fcff_valuation(EARNINGS_NORM, GROWTH_NORM, cagr, riskfree, ttm_revenue, ttm_ebit_adj,
                                                target_operating_margin, mr_tax_benefits, tax_rate, sales_capital_5y, target_sales_capital,
                                                debt_equity, target_debt_equity, unlevered_beta, final_erp, cost_of_debt,
                                                target_cost_of_debt, mr_cash, mr_securities, debt_mkt, mr_minority_interest, survival_prob, mr_shares,
                                                liquidation_value, growth_last, growth_5y, revenue_5y, ebit_5y, fx_rate, mr_property, mr_sbc, debug=debug, dict_values_for_bi=dict_values_for_bi)
    stock_value_fcff_ttm_fixed_recession = fcff_valuation(EARNINGS_TTM, GROWTH_FIXED, cagr, riskfree, ttm_revenue, ttm_ebit_adj,
                                                          target_operating_margin, mr_tax_benefits, tax_rate, sales_capital_5y, target_sales_capital,
                                                          debt_equity, target_debt_equity, unlevered_beta, final_erp, cost_of_debt,
                                                          target_cost_of_debt, mr_cash, mr_securities, debt_mkt, mr_minority_interest, survival_prob, mr_shares,
                                                          liquidation_value, growth_last, growth_5y, revenue_5y, ebit_5y, fx_rate, mr_property, mr_sbc, debug=debug, recession=True, dict_values_for_bi=dict_values_for_bi)
    stock_value_fcff_norm_fixed_recession = fcff_valuation(EARNINGS_NORM, GROWTH_FIXED, cagr, riskfree, ttm_revenue, ttm_ebit_adj,
                                                           target_operating_margin, mr_tax_benefits, tax_rate, sales_capital_5y, target_sales_capital,
                                                           debt_equity, target_debt_equity, unlevered_beta, final_erp, cost_of_debt,
                                                           target_cost_of_debt, mr_cash, mr_securities, debt_mkt, mr_minority_interest, survival_prob, mr_shares,
                                                           liquidation_value, growth_last, growth_5y, revenue_5y, ebit_5y, fx_rate, mr_property, mr_sbc, debug=debug, recession=True, dict_values_for_bi=dict_values_for_bi)
    stock_value_fcff_ttm_ttm_recession = fcff_valuation(EARNINGS_TTM, GROWTH_TTM, cagr, riskfree, ttm_revenue, ttm_ebit_adj,
                                                        target_operating_margin, mr_tax_benefits, tax_rate, sales_capital_5y, target_sales_capital,
                                                        debt_equity, target_debt_equity, unlevered_beta, final_erp, cost_of_debt,
                                                        target_cost_of_debt, mr_cash, mr_securities, debt_mkt, mr_minority_interest, survival_prob, mr_shares,
                                                        liquidation_value, growth_last, growth_5y, revenue_5y, ebit_5y, fx_rate, mr_property, mr_sbc, debug=debug, recession=True, dict_values_for_bi=dict_values_for_bi)
    stock_value_fcff_norm_norm_recession = fcff_valuation(EARNINGS_NORM, GROWTH_NORM, cagr, riskfree, ttm_revenue, ttm_ebit_adj,
                                                          target_operating_margin, mr_tax_benefits, tax_rate, sales_capital_5y, target_sales_capital,
                                                          debt_equity, target_debt_equity, unlevered_beta, final_erp, cost_of_debt,
                                                          target_cost_of_debt, mr_cash, mr_securities, debt_mkt, mr_minority_interest, survival_prob, mr_shares,
                                                          liquidation_value, growth_last, growth_5y, revenue_5y, ebit_5y, fx_rate, mr_property, mr_sbc, debug=debug, recession=True, dict_values_for_bi=dict_values_for_bi)

执行后会会输出:

===== Dividends Valuation - EARNINGS_TTM + GROWTH_FIXED + recession:False =====
expected_growth [0.1074 0.101  0.0946 0.0881 0.0817 0.0753 0.0689 0.0625 0.0561 0.0497

 0.0433]

earnings_per_share [6.0673, 6.6799, 7.3116, 7.9561, 8.6064, 9.2546, 9.8924, 10.5106, 11.1, 11.6513, 12.1552]

payout_ratio [0.0867 0.1734 0.2601 0.3468 0.4335 0.5202 0.6069 0.6935 0.7802 0.8669

 0.9536]
###省略部分输出结果
cost_of_capital [0.13007303944488582, 0.1300431538207438, 0.13001336342016462, 0.1299836677887606, 0.1299540664750306, 0.12992455903033706, 0.12989514500888305, 0.12986582396769025, 0.12983659546657647, 0.12980745906813357, 0.12977841433770582]

cumulative WACC [1.130073039444886, 1.2770313015420927, 1.4430624362484106, 1.6306369845601636, 1.8425448916483385, 2.081936724189349, 2.3523701968772435, 2.6578626907717444, 3.002950533759182, 3.3927559122537567, 3.833062394780926]

present value [25761416.44331457, 24895720.67192729, 30371497.058220774, -5626645.969449993, -19044099.093171094, -20582665.42125352, 31225188.95732479, 32235887.09764502, 32526419.718413804, 32117106.30522833, 31061573.360930156]

terminal value 1317943752.34

PV of FCFF during growth 163879825.76819995

PV of terminal value 343835715.83

Value of operating assets 507715541.60016966

Value of cash and property 110880000.0
firm value 618595541.6

debt outstanding 23519939.49

equity value 592937602.12

stock value (price curr) 43.88

stock value (fin curr) 43.88

上面的输出结果展示了股息估值模型的计算结果,其中包括了预期增长率、每股收益、股息支付比率等参数。通过计算成本资本、现金流量贴现值、终端价值等指标,最终得出了公司的股票价值。在当前和财务调整后的情况下,计算结果显示了股票的合理价格为43.88美元。

(2)下面的这段代码计算了自由现金流(FCFF)和股利的估值期望值。首先,将不同情景下的FCFF和股利估值值组成列表,并设定了衰退概率。然后,通过对不同情景下的估值值进行加权平均,得到了FCFF和股利的估值期望值,从而更全面地考虑了衰退风险。

fcff_values_list = [stock_value_fcff_ttm_fixed, stock_value_fcff_norm_fixed, stock_value_fcff_ttm_ttm,
                       stock_value_fcff_norm_norm]
fcff_recession_values_list = [stock_value_fcff_ttm_fixed_recession, stock_value_fcff_norm_fixed_recession,
                                          stock_value_fcff_ttm_ttm_recession, stock_value_fcff_norm_norm_recession]
div_values_list = [stock_value_div_ttm_fixed, stock_value_div_norm_fixed, stock_value_div_ttm_ttm,
                   stock_value_div_norm_norm]
div_recession_values_list = [stock_value_div_ttm_fixed_recession, stock_value_div_norm_fixed_recession,
                                         stock_value_div_ttm_ttm_recession, stock_value_div_norm_norm_recession]

recession_probability = 0.5
fcff_value = summary_valuation(fcff_values_list)
fcff_recession_value = summary_valuation(fcff_recession_values_list)
ev_fcff = fcff_value * (1 - recession_probability) + fcff_recession_value * recession_probability
div_value = summary_valuation(div_values_list)
div_recession_value = summary_valuation(div_recession_values_list)
ev_dividends = div_value * (1 - recession_probability) + div_recession_value * recession_probability

(3)计算自由现金流(FCFF)和股利的估值差异,以及股票的清算价值与当前价格之间的差异。根据不同的情况进行了条件判断,如果估值值大于0,则计算出价格与估值之间的百分比差异;如果估值值小于等于0,则将差异值设置为10,这可能表示着一种异常情况。

fcff_delta = price_per_share / ev_fcff - 1 if fcff_value > 0 else 10
div_delta = price_per_share / ev_dividends - 1 if div_value > 0 else 10
liquidation_delta = price_per_share / liquidation_per_share - 1 if liquidation_per_share > 0 else 10

(4)请看下面的的代码,用于打印输出计算的估值数据,主要包括:

  1. FCFF值列表,包括四个不同情景下的FCFF值。
  2. 带有经济衰退情景的FCFF值列表。
  3. 股利值列表,包括四个不同情景下的股利值。
  4. 带有经济衰退情景的股利值列表。
  5. 每股价格。
  6. FCFF估值结果。
  7. FCFF偏差。
  8. 股利估值结果。
  9. 股利偏差。
print("FCFF values")
print([round(x, 2) for x in fcff_values_list])
print("\nFCFF values w/ Recession")
print([round(x, 2) for x in fcff_recession_values_list])
print("\n\nDiv values")
print([round(x, 2) for x in div_values_list])
print("\nDiv values w/ Recession")
print([round(x, 2) for x in div_recession_values_list])

print("\n\n\n")

print("Price per Share", price_per_share)
print("FCFF Result", ev_fcff)
print("FCFF Deviation", fcff_delta)
print("Dividends Result", ev_dividends)
print("Dividends Deviation", div_delta)

执行后会输出:

FCFF values
[59.31, 54.0, 75.09, 71.83]

FCFF values w/ Recession

[42.92, 39.34, 46.93, 43.88]

Div values

[49.63, 48.94, 79.39, 82.64]

Div values w/ Recession

[35.41, 34.92, 48.82, 49.95]

Price per Share 120.97

FCFF Result 54.48574881278017

FCFF Deviation 1.2202135904503764

Dividends Result 53.31465660538761

Dividends Deviation 1.2689820717662768

通过打印这些数值,可以更好地了解不同情景下的估值结果,并评估市场价格与估值之间的差异。

标签:03,26,5y,value,growth,values,LangChain,ttm,mr
From: https://blog.csdn.net/asd343442/article/details/139865871

相关文章

  • 【MindSpore学习打卡】初学教程-03张量Tensor-理解MindSpore中的张量(Tensor)操作
    03张量Tensor-理解MindSpore中的张量(Tensor)操作在深度学习领域,张量(Tensor)是最基本的数据结构之一。它不仅可以表示标量、向量和矩阵,还可以表示更高维度的数据。张量在神经网络的构建和训练中扮演着至关重要的角色。在MindSpore中,张量是网络运算的基本单位。本篇博客将详......
  • 汽车功能安全(ISO 26262)系列_ 系统阶段开发 - 技术安全需求(TSR)及安全机制
    汽车功能安全(ISO 26262)系列: 系统阶段开发 - 技术安全需求(TSR)及安全机制01. 什么是TSR附赠自动驾驶最全的学习资料和量产经验:链接总体而言,技术安全需求(TSR: Technical Safety Requirement)是为满足安全目标SG或功能安全需求(FSR),由功能安全需求(FSR)在技......
  • 0基础学C++ | 第03天 | 基础知识 |算术运算符 | 赋值运算符 | 比较运算符 | 逻辑运算
    前言前面已经讲了,数据类型以及求数据类型所占的空间0基础学C++|第02天|基础知识|sizeof关键字|浮点型|字符型|转义字符|字符串|布尔类型|数据的输入-CSDN博客,现在讲运算符算术运算符 作用:用于处理四则运算#include<iostream>usingnamespacestd;in......
  • Weaver E-Office v9.5 文件上传漏洞(CVE-2023-2648)
    前言CVE-2023-2648是一个在WeaverE-Office9.5版本中发现的严重漏洞。此漏洞位于文件/inc/jquery/uploadify/uploadify.php中,通过操控Filedata参数,可以进行不受限制的文件上传。这一漏洞允许攻击者上传可能包含危险类型的文件,并在应用程序环境中执行。该漏洞可以通过......
  • 定位接口 MissingServletRequestParameterException: Required String parameter '' i
    @RequestParam与实际传参对不上导致,会抛出异常 可以定义一个MissingServletRequestParameterException的异常处理,获取、打印出要的接口信息importcn.hutool.core.util.ObjectUtil;importcom.byd.common.api.vo.Result;importlombok.extern.slf4j.Slf4j;importorg.sp......
  • 基于大语言模型LangChain框架:知识库问答系统实践
    ChatGPT所取得的巨大成功,使得越来越多的开发者希望利用OpenAI提供的API或私有化模型开发基于大语言模型的应用程序。然而,即使大语言模型的调用相对简单,仍需要完成大量的定制开发工作,包括API集成、交互逻辑、数据存储等。为了解决这个问题,从2022年开始,多家机构和......
  • LangChain:如何高效管理 LLM 聊天历史记录?
    LangChain团队发布了一篇关于使用DragonflyDB来有效管理LangChain应用程序聊天历史记录的教程。该教程旨在解决用户在使用LangChain应用程序时普遍遇到的一个问题:如何高效地管理聊天历史记录。LangChain团队在推文中强调了DragonflyDB在管理聊天历史记录中的......
  • #26. 2024.6.21
    929.qoj1961Postman930.loj3085「GXOI/GZOI2019」特技飞行931.loj3086「GXOI/GZOI2019」逼死强迫症932.loj3087「GXOI/GZOI2019」旅行者933.loj3088「GXOI/GZOI2019」旧词934.The3rdUniversalCup.Stage0:TrialContestL又名:hos_lyric代码......
  • 【漏洞挖掘】——103、Blind注入类型深入刨析(中)
    时间盲注使用场景没有True/False,也没有任何错误提示类信息,在这种情况下可以考虑通过时间线的长短来判断是否存在SQL注入,即基于时间的盲注!函数简介sleep():用于延迟IF(Condition,A,B):当Condition为TRUE时,返回A;当Condition为FALSE时,返回BBENCHMARK(count,expr):重复count......
  • LPD6803是专为LED(LED)灯光系统设计的驱动芯片
    一般简介:    LPD6803是专为LED(LED)灯光系统设计的驱动芯片,它采用先进的高压CMOS芯片工艺,提供三路恒流驱动和灰度调制输出,特别适合离散的多灰度全彩色灯光系统。    LPD6803芯片包括串行移位寄存器和级联驱动电路,灰度数据在时钟上沿移入串行移位寄存器,转储后......