backend/app/ml_models/test2.py
2024-05-26 22:28:08 +02:00

518 lines
14 KiB
Python
Executable File

data = [
{
"year": "2028",
"symbol": "AMD",
"revenue": 114629191658,
"revenuePercentage": 38.27,
"ebitda": 17326854891,
"ebitdaPercentage": 15.12,
"ebit": 9902916035,
"ebitPercentage": 8.64,
"depreciation": 7423938855,
"depreciationPercentage": 6.48,
"totalCash": 27053022289,
"totalCashPercentage": 23.6,
"receivables": 24437715130,
"receivablesPercentage": 21.32,
"inventories": 17418440963,
"inventoriesPercentage": 15.2,
"payable": 10805895396,
"payablePercentage": 9.43,
"capitalExpenditure": -2838432889,
"capitalExpenditurePercentage": -2.48,
"price": 170.78,
"beta": 1.651,
"dilutedSharesOutstanding": 1625000000,
"costofDebt": 4.37,
"taxRate": -73.58,
"afterTaxCostOfDebt": 4.37,
"riskFreeRate": 4.37,
"marketRiskPremium": 4.72,
"costOfEquity": 12.16,
"totalDebt": 3003000000,
"totalEquity": 277517500000,
"totalCapital": 280520500000,
"debtWeighting": 1.07,
"equityWeighting": 98.93,
"wacc": 12.08,
"taxRateCash": 4430363,
"ebiat": 9464180956,
"ufcf": 5455551112,
"sumPvUfcf": 11958854466,
"longTermGrowthRate": 4,
"terminalValue": 70244084511,
"presentTerminalValue": 39721249234,
"enterpriseValue": 51680103700,
"netDebt": -930000000,
"equityValue": 52610103700,
"equityValuePerShare": 32.38,
"freeCashFlowT1": 5673773157
},
{
"year": "2027",
"symbol": "AMD",
"revenue": 82901959141,
"revenuePercentage": 38.27,
"ebitda": 12531103076,
"ebitdaPercentage": 15.12,
"ebit": 7161972693,
"ebitPercentage": 8.64,
"depreciation": 5369130382,
"depreciationPercentage": 6.48,
"totalCash": 19565247874,
"totalCashPercentage": 23.6,
"receivables": 17673809192,
"receivablesPercentage": 21.32,
"inventories": 12597339823,
"inventoriesPercentage": 15.2,
"payable": 7815024128,
"payablePercentage": 9.43,
"capitalExpenditure": -2052807352,
"capitalExpenditurePercentage": -2.48,
"price": 170.78,
"beta": 1.651,
"dilutedSharesOutstanding": 1625000000,
"costofDebt": 4.37,
"taxRate": -73.58,
"afterTaxCostOfDebt": 4.37,
"riskFreeRate": 4.37,
"marketRiskPremium": 4.72,
"costOfEquity": 12.16,
"totalDebt": 3003000000,
"totalEquity": 277517500000,
"totalCapital": 280520500000,
"debtWeighting": 1.07,
"equityWeighting": 98.93,
"wacc": 12.08,
"taxRateCash": 4430363,
"ebiat": 6844671340,
"ufcf": 3945555829,
"sumPvUfcf": 0,
"longTermGrowthRate": 4,
"terminalValue": 70244084511,
"presentTerminalValue": 39721249234,
"enterpriseValue": 51680103700,
"netDebt": -930000000,
"equityValue": 52610103700,
"equityValuePerShare": 32.38,
"freeCashFlowT1": 5673773157
},
{
"year": "2026",
"symbol": "AMD",
"revenue": 59956235668,
"revenuePercentage": 38.27,
"ebitda": 9062726345,
"ebitdaPercentage": 15.12,
"ebit": 5179671591,
"ebitPercentage": 8.64,
"depreciation": 3883054753,
"depreciationPercentage": 6.48,
"totalCash": 14149950430,
"totalCashPercentage": 23.6,
"receivables": 12782026867,
"receivablesPercentage": 21.32,
"inventories": 9110629990,
"inventoriesPercentage": 15.2,
"payable": 5651970511,
"payablePercentage": 9.43,
"capitalExpenditure": -1484628381,
"capitalExpenditurePercentage": -2.48,
"price": 170.78,
"beta": 1.651,
"dilutedSharesOutstanding": 1625000000,
"costofDebt": 4.37,
"taxRate": -73.58,
"afterTaxCostOfDebt": 4.37,
"riskFreeRate": 4.37,
"marketRiskPremium": 4.72,
"costOfEquity": 12.16,
"totalDebt": 3003000000,
"totalEquity": 277517500000,
"totalCapital": 280520500000,
"debtWeighting": 1.07,
"equityWeighting": 98.93,
"wacc": 12.08,
"taxRateCash": 4430363,
"ebiat": 4950193363,
"ufcf": 2853499211,
"sumPvUfcf": 0,
"longTermGrowthRate": 4,
"terminalValue": 70244084511,
"presentTerminalValue": 39721249234,
"enterpriseValue": 51680103700,
"netDebt": -930000000,
"equityValue": 52610103700,
"equityValuePerShare": 32.38,
"freeCashFlowT1": 5673773157
},
{
"year": "2025",
"symbol": "AMD",
"revenue": 43361462536,
"revenuePercentage": 38.27,
"ebitda": 6554331914,
"ebitdaPercentage": 15.12,
"ebit": 3746034639,
"ebitPercentage": 8.64,
"depreciation": 2808297274,
"depreciationPercentage": 6.48,
"totalCash": 10233506801,
"totalCashPercentage": 23.6,
"receivables": 9244199088,
"receivablesPercentage": 21.32,
"inventories": 6588976719,
"inventoriesPercentage": 15.2,
"payable": 4087609985,
"payablePercentage": 9.43,
"capitalExpenditure": -1073710802,
"capitalExpenditurePercentage": -2.48,
"price": 170.78,
"beta": 1.651,
"dilutedSharesOutstanding": 1625000000,
"costofDebt": 4.37,
"taxRate": -73.58,
"afterTaxCostOfDebt": 4.37,
"riskFreeRate": 4.37,
"marketRiskPremium": 4.72,
"costOfEquity": 12.16,
"totalDebt": 3003000000,
"totalEquity": 277517500000,
"totalCapital": 280520500000,
"debtWeighting": 1.07,
"equityWeighting": 98.93,
"wacc": 12.08,
"taxRateCash": 4430363,
"ebiat": 3580071725,
"ufcf": 2063703597,
"sumPvUfcf": 0,
"longTermGrowthRate": 4,
"terminalValue": 70244084511,
"presentTerminalValue": 39721249234,
"enterpriseValue": 51680103700,
"netDebt": -930000000,
"equityValue": 52610103700,
"equityValuePerShare": 32.38,
"freeCashFlowT1": 5673773157
},
{
"year": "2024",
"symbol": "AMD",
"revenue": 31359814577,
"revenuePercentage": 38.27,
"ebitda": 4740214501,
"ebitdaPercentage": 15.12,
"ebit": 2709201784,
"ebitPercentage": 8.64,
"depreciation": 2031012716,
"depreciationPercentage": 6.48,
"totalCash": 7401062072,
"totalCashPercentage": 23.6,
"receivables": 6685576370,
"receivablesPercentage": 21.32,
"inventories": 4765270267,
"inventoriesPercentage": 15.2,
"payable": 2956235415,
"payablePercentage": 9.43,
"capitalExpenditure": -776527582,
"capitalExpenditurePercentage": -2.48,
"price": 170.78,
"beta": 1.651,
"dilutedSharesOutstanding": 1625000000,
"costofDebt": 4.37,
"taxRate": -73.58,
"afterTaxCostOfDebt": 4.37,
"riskFreeRate": 4.37,
"marketRiskPremium": 4.72,
"costOfEquity": 12.16,
"totalDebt": 3003000000,
"totalEquity": 277517500000,
"totalCapital": 280520500000,
"debtWeighting": 1.07,
"equityWeighting": 98.93,
"wacc": 12.08,
"taxRateCash": 4430363,
"ebiat": 2589174324,
"ufcf": 3030048236,
"sumPvUfcf": 0,
"longTermGrowthRate": 4,
"terminalValue": 70244084511,
"presentTerminalValue": 39721249234,
"enterpriseValue": 51680103700,
"netDebt": -930000000,
"equityValue": 52610103700,
"equityValuePerShare": 32.38,
"freeCashFlowT1": 5673773157
},
{
"year": "2023",
"symbol": "AMD",
"revenue": 22680000000,
"revenuePercentage": -3.9,
"ebitda": 4149000000,
"ebitdaPercentage": 18.29,
"ebit": 598000000,
"ebitPercentage": 2.64,
"depreciation": 3551000000,
"depreciationPercentage": 15.66,
"totalCash": 5773000000,
"totalCashPercentage": 25.45,
"receivables": 5385000000,
"receivablesPercentage": 23.74,
"inventories": 4351000000,
"inventoriesPercentage": 19.18,
"payable": 2055000000,
"payablePercentage": 9.06,
"capitalExpenditure": -546000000,
"capitalExpenditurePercentage": -2.41,
"price": 170.78,
"beta": 1.651,
"dilutedSharesOutstanding": 1625000000,
"costofDebt": 4.37,
"taxRate": -73.58,
"afterTaxCostOfDebt": 4.37,
"riskFreeRate": 4.37,
"marketRiskPremium": 4.72,
"costOfEquity": 12.16,
"totalDebt": 3003000000,
"totalEquity": 277517500000,
"totalCapital": 280520500000,
"debtWeighting": 1.07,
"equityWeighting": 98.93,
"wacc": 12.08,
"taxRateCash": -73577235,
"ebiat": 1037991869,
"ufcf": 1767991869,
"sumPvUfcf": 0,
"longTermGrowthRate": 4,
"terminalValue": 70244084511,
"presentTerminalValue": 39717576725,
"enterpriseValue": 51676431191,
"netDebt": -930000000,
"equityValue": 52606431191,
"equityValuePerShare": 32.37,
"freeCashFlowT1": 5673773157
},
{
"year": "2022",
"symbol": "AMD",
"revenue": 23601000000,
"revenuePercentage": 43.61,
"ebitda": 3372000000,
"ebitdaPercentage": 14.29,
"ebit": 1264000000,
"ebitPercentage": 5.36,
"depreciation": 2108000000,
"depreciationPercentage": 8.93,
"totalCash": 5855000000,
"totalCashPercentage": 24.81,
"receivables": 4128000000,
"receivablesPercentage": 17.49,
"inventories": 3771000000,
"inventoriesPercentage": 15.98,
"payable": 2493000000,
"payablePercentage": 10.56,
"capitalExpenditure": -450000000,
"capitalExpenditurePercentage": -1.91,
"price": 170.78,
"beta": 1.651,
"dilutedSharesOutstanding": 1625000000,
"costofDebt": 4.37,
"taxRate": -73.58,
"afterTaxCostOfDebt": 4.37,
"riskFreeRate": 4.37,
"marketRiskPremium": 4.72,
"costOfEquity": 12.16,
"totalDebt": 3003000000,
"totalEquity": 277517500000,
"totalCapital": 280520500000,
"debtWeighting": 1.07,
"equityWeighting": 98.93,
"wacc": 12.08,
"taxRateCash": -11486486,
"ebiat": 1409189189,
"ufcf": 1003189189,
"sumPvUfcf": 0,
"longTermGrowthRate": 4,
"terminalValue": 70244084511,
"presentTerminalValue": 39717576725,
"enterpriseValue": 51676431191,
"netDebt": -930000000,
"equityValue": 52606431191,
"equityValuePerShare": 32.37,
"freeCashFlowT1": 5673773157
},
{
"year": "2021",
"symbol": "AMD",
"revenue": 16434000000,
"revenuePercentage": 68.33,
"ebitda": 3703000000,
"ebitdaPercentage": 22.53,
"ebit": 3648000000,
"ebitPercentage": 22.2,
"depreciation": 55000000,
"depreciationPercentage": 0.33467,
"totalCash": 3608000000,
"totalCashPercentage": 21.95,
"receivables": 2708000000,
"receivablesPercentage": 16.48,
"inventories": 1955000000,
"inventoriesPercentage": 11.9,
"payable": 1321000000,
"payablePercentage": 8.04,
"capitalExpenditure": -301000000,
"capitalExpenditurePercentage": -1.83,
"price": 170.78,
"beta": 1.651,
"dilutedSharesOutstanding": 1625000000,
"costofDebt": 4.37,
"taxRate": -73.58,
"afterTaxCostOfDebt": 4.37,
"riskFreeRate": 4.37,
"marketRiskPremium": 4.72,
"costOfEquity": 12.16,
"totalDebt": 3003000000,
"totalEquity": 277517500000,
"totalCapital": 280520500000,
"debtWeighting": 1.07,
"equityWeighting": 98.93,
"wacc": 12.07,
"taxRateCash": 13818480,
"ebiat": 3143901880,
"ufcf": 2562901880,
"sumPvUfcf": 0,
"longTermGrowthRate": 4,
"terminalValue": 70244084511,
"presentTerminalValue": 39729032775,
"enterpriseValue": 51687887242,
"netDebt": -930000000,
"equityValue": 52617887242,
"equityValuePerShare": 32.38,
"freeCashFlowT1": 5673773157
},
{
"year": "2020",
"symbol": "AMD",
"revenue": 9763000000,
"revenuePercentage": 45.05,
"ebitda": 1322000000,
"ebitdaPercentage": 13.54,
"ebit": 968000000,
"ebitPercentage": 9.91,
"depreciation": 354000000,
"depreciationPercentage": 3.63,
"totalCash": 2290000000,
"totalCashPercentage": 23.46,
"receivables": 2076000000,
"receivablesPercentage": 21.26,
"inventories": 1399000000,
"inventoriesPercentage": 14.33,
"payable": 468000000,
"payablePercentage": 4.79,
"capitalExpenditure": -294000000,
"capitalExpenditurePercentage": -3.01,
"price": 170.78,
"beta": 1.651,
"dilutedSharesOutstanding": 1625000000,
"costofDebt": 4.37,
"taxRate": -73.58,
"afterTaxCostOfDebt": 4.37,
"riskFreeRate": 4.37,
"marketRiskPremium": 4.72,
"costOfEquity": 12.16,
"totalDebt": 3003000000,
"totalEquity": 277517500000,
"totalCapital": 280520500000,
"debtWeighting": 1.07,
"equityWeighting": 98.93,
"wacc": 12.08,
"taxRateCash": -95294117,
"ebiat": 1890447058,
"ufcf": 796447058,
"sumPvUfcf": 0,
"longTermGrowthRate": 4,
"terminalValue": 70244084511,
"presentTerminalValue": 39717576725,
"enterpriseValue": 51676431191,
"netDebt": -930000000,
"equityValue": 52606431191,
"equityValuePerShare": 32.37,
"freeCashFlowT1": 5673773157
},
{
"year": "2019",
"symbol": "AMD",
"revenue": 6731000000,
"revenuePercentage": 0,
"ebitda": 466000000,
"ebitdaPercentage": 6.92,
"ebit": 208000000,
"ebitPercentage": 3.09,
"depreciation": 258000000,
"depreciationPercentage": 3.83,
"totalCash": 1503000000,
"totalCashPercentage": 22.33,
"receivables": 1859000000,
"receivablesPercentage": 27.62,
"inventories": 982000000,
"inventoriesPercentage": 14.59,
"payable": 988000000,
"payablePercentage": 14.68,
"capitalExpenditure": -217000000,
"capitalExpenditurePercentage": -3.22,
"price": 170.78,
"beta": 1.651,
"dilutedSharesOutstanding": 1625000000,
"costofDebt": 4.37,
"taxRate": -73.58,
"afterTaxCostOfDebt": 4.37,
"riskFreeRate": 4.37,
"marketRiskPremium": 4.72,
"costOfEquity": 12.16,
"totalDebt": 3003000000,
"totalEquity": 277517500000,
"totalCapital": 280520500000,
"debtWeighting": 1.07,
"equityWeighting": 98.93,
"wacc": 12.08,
"taxRateCash": 8333334,
"ebiat": 190666666,
"ufcf": -1621333333,
"sumPvUfcf": 0,
"longTermGrowthRate": 4,
"terminalValue": 70244084511,
"presentTerminalValue": 39724484904,
"enterpriseValue": 51683339370,
"netDebt": -930000000,
"equityValue": 52613339370,
"equityValuePerShare": 32.38,
"freeCashFlowT1": 5673773157
}
]
# Function to calculate present value
def present_value(cash_flow, discount_rate, time_period):
return cash_flow / ((1 + discount_rate) ** time_period)
# Initialize variables
total_present_value = 0
wacc_sum = 0
# Iterate over each year's data
for i, year_data in enumerate(data):
ufcf = year_data['ufcf']
wacc = year_data['wacc']
time_period = i + 1
# Discounting free cash flow to its present value
present_value_ufcf = present_value(ufcf, wacc, time_period)
total_present_value += present_value_ufcf
wacc_sum += wacc
# Calculate DCF
average_wacc = wacc_sum / len(data)
dcf = total_present_value + (data[-1]['presentTerminalValue'] / ((1 + average_wacc) ** len(data)))
print("Discounted Cash Flow (DCF) for AMD:", dcf)