top of page
  • Writer's pictureNicholas Masagao

Automatic Valuation Python –– Wacc


This is the second post in the series on automatic valuation. The first post was on the code for calculating the actual DCF valuation. Here we have the code for calculating the weighted cost of capital for the company in question. The first required inputs for all the calculations are the market value of equity and debt, as well as the effective tax rate.

class Rates:
	def __init__(self,D,E,t):
		self.D = D
		self.E = E
		self.t = t
		
	def wacc(self,rd,re):
		return (self.D/(self.E+self.D))*(1-self.t)*(rd) + (self.E/(self.E+self.D))*cost_of_equity
	
	def debt_beta(self,credit_spread,erp):
		return credit_spread/erp
	
	def unleverd_beta(self,regression_beta):
		return regression_beta/(1+(1-self.t)*(self.D/self.E))
	
	def cost_of_equity(self,reg_beta,rf,erp,credit_spread):
		bl = self.unleverd_beta(reg_beta)*(1+(1-self.t)*(self.D/self.E)) - self.debt_beta(credit_spread, erp) *(1-self.t)*(self.D/self.E)
		return rf+bl*erp
		

The process for finding the WACC starts with the calculation of the debt beta and the un-levered beta, which requires one to supply the credit spread and regression beta respectively. The second step is the calculation of the cost of equity. Finally one can calculate the WACC.




43 views0 comments

Recent Posts

See All

Comentários


bottom of page