Python - Calculate the Annualized Holding Period Return
by matt392 in Circuits > Software
98 Views, 1 Favorites, 0 Comments
Python - Calculate the Annualized Holding Period Return
print ("Calculating the Annualized Holding Period Return") import math print ("The formula is: ") print ("AnnualizedHoldingPeriodReturn = (((((EndOfPeriodValue + IntermediateGains - InitialValue)/InitialValue)+1)**(1/NumberOfYears))-1)") # Input the data EnteredEndOfPeriodValue = input ("Enter the End of Period Value: ") EnteredIntermediateGains = input ("Enter the Intermediate Gains: ") EnteredInitialValue = input ("Enter the Initial Value: ") EnteredNumberOfYears = input ("Enter the Number Of Years: ") # Convert entered numbers to float EndOfPeriodValue = float(EnteredEndOfPeriodValue) IntermediateGains = float(EnteredIntermediateGains) InitialValue = float(EnteredInitialValue) NumberOfYears = float(EnteredNumberOfYears) AnnualizedHoldingPeriodReturn = (((((EndOfPeriodValue + IntermediateGains - InitialValue)/InitialValue)+1)**(1/NumberOfYears))-1) print ("The Annualized Holding Period Return is: ", AnnualizedHoldingPeriodReturn) print ("Thank you to fxsolver.com for assistance with this equation.")