9090 monthly_r = fill (monthly_growth^ (1 / n) - 1 , n)
9191 # Direct formula
9292 expected = monthly_growth^ (1 / n_years) - 1
93- @test cagr (monthly_r; periods_per_year = periods_per_year) ≈ expected atol = 1e-12
93+ @test cagr (monthly_r, periods_per_year) ≈ expected atol = 1e-12
9494
9595 # Log returns variant
9696 log_r = log .(1 .+ monthly_r)
97- @test cagr (log_r; periods_per_year= periods_per_year, method= :log ) ≈ expected atol = 1e-12
97+ @test cagr (log_r, periods_per_year; method= :log ) ≈ expected atol = 1e-12
9898
9999 # Weekly example using simple returns
100100 weekly_growth = 2.0 # total double
@@ -103,16 +103,16 @@ end
103103 n2 = weeks_per_year * years
104104 weekly_r = fill (weekly_growth^ (1 / n2) - 1 , n2)
105105 expected2 = weekly_growth^ (1 / years) - 1
106- @test cagr (weekly_r; periods_per_year = weeks_per_year) ≈ expected2 atol = 1e-12
106+ @test cagr (weekly_r, weeks_per_year) ≈ expected2 atol = 1e-12
107107
108108 # Empty input
109- @test cagr (Float64[]; periods_per_year = 12 ) == 0.0
109+ @test cagr (Float64[], 12 ) == 0.0
110110
111111 # Invalid method
112- @test_throws ArgumentError cagr (monthly_r; periods_per_year = 12 , method= :foo )
112+ @test_throws ArgumentError cagr (monthly_r, 12 ; method= :foo )
113113
114114 # Invalid periods_per_year values
115- @test_throws ArgumentError cagr (monthly_r; periods_per_year = 0 )
116- @test_throws ArgumentError cagr (monthly_r; periods_per_year = - 12 )
117- @test_throws ArgumentError cagr (monthly_r; periods_per_year = Inf )
115+ @test_throws ArgumentError cagr (monthly_r, 0 )
116+ @test_throws ArgumentError cagr (monthly_r, - 12 )
117+ @test_throws ArgumentError cagr (monthly_r, Inf )
118118end
0 commit comments