Skip to content

Instantly share code, notes, and snippets.

@gregturn
Created April 6, 2012 00:41
Show Gist options
  • Save gregturn/2315532 to your computer and use it in GitHub Desktop.
Save gregturn/2315532 to your computer and use it in GitHub Desktop.
Finance app with scala part 2
$ scalac finance.scala && scala Main
S&P 500 performance = List((1951,16.3), (1952,11.8), (1953,-6.6), (1954,26.4), (1955,26.4), (1956,2.6), (1957,-14.3), (1958,38.1), (1959,8.5), (1960,-3.0), (1961,23.1), (1962,-11.8), (1963,18.9), (1964,13.0), (1965,9.1), (1966,-13.1), (1967,20.1), (1968,7.7), (1969,-11.4), (1970,0.1), (1971,10.8), (1972,15.6), (1973,-17.4), (1974,-29.7), (1975,31.5), (1976,19.1), (1977,-11.5), (1978,1.1), (1979,12.3), (1980,25.8), (1981,-9.7), (1982,14.8), (1983,17.3), (1984,1.4), (1985,26.3), (1986,14.6), (1987,2.0), (1988,12.4), (1989,27.3), (1990,-6.6), (1991,26.3), (1992,4.5), (1993,7.1), (1994,-1.5), (1995,34.1), (1996,20.3), (1997,31.0), (1998,26.7), (1999,19.5), (2000,-10.1), (2001,-13.0), (2002,-23.4), (2003,26.4), (2004,9.0), (2005,3.0), (2006,13.6), (2007,3.5), (2008,-38.5), (2009,23.5), (2010,12.8))
Arithmetic mean = 8.235000000000001%
Geometric mean = 6.866554380824419%
Actual total growth factor = 53.766085563840456
EIUL performance = List((1951,15.0), (1952,11.8), (1953,0.0), (1954,15.0), (1955,15.0), (1956,2.6), (1957,0.0), (1958,15.0), (1959,8.5), (1960,0.0), (1961,15.0), (1962,0.0), (1963,15.0), (1964,13.0), (1965,9.1), (1966,0.0), (1967,15.0), (1968,7.7), (1969,0.0), (1970,0.1), (1971,10.8), (1972,15.0), (1973,0.0), (1974,0.0), (1975,15.0), (1976,15.0), (1977,0.0), (1978,1.1), (1979,12.3), (1980,15.0), (1981,0.0), (1982,14.8), (1983,15.0), (1984,1.4), (1985,15.0), (1986,14.6), (1987,2.0), (1988,12.4), (1989,15.0), (1990,0.0), (1991,15.0), (1992,4.5), (1993,7.1), (1994,0.0), (1995,15.0), (1996,15.0), (1997,15.0), (1998,15.0), (1999,15.0), (2000,0.0), (2001,0.0), (2002,0.0), (2003,15.0), (2004,9.0), (2005,3.0), (2006,13.6), (2007,3.5), (2008,0.0), (2009,15.0), (2010,12.8))
EIUL arithmetic performance = 8.428333333333335%
EIUL geometric performance = 8.226111328758012%
Actual EIUL total growth factor = 114.79507227304792
This is where every 10, 15, 20, etc. year interval in all the data is evaluated and then averaged together.
The min and max performance of each interval is displayed, and the 1st stddev is shown. There is a 68%
that actual performance is within 1 stddev of the average.
10-year stats
==========================
S&P 500 stats: Avg geom mean = 7.08 (-3.04..16.06) 68% chance between 2.22 and 11.94
EIUL stats: Avg geom mean = 8.08 (5.48..10.34) 68% chance between 6.83 and 9.33
15-year stats
==========================
S&P 500 stats: Avg geom mean = 7.30 (0.90..15.59) 68% chance between 3.58 and 11.02
EIUL stats: Avg geom mean = 8.18 (6.51..10.54) 68% chance between 7.22 and 9.14
20-year stats
==========================
S&P 500 stats: Avg geom mean = 7.16 (2.73..13.95) 68% chance between 4.07 and 10.25
EIUL stats: Avg geom mean = 8.13 (6.81..10.16) 68% chance between 7.32 and 8.94
25-year stats
==========================
S&P 500 stats: Avg geom mean = 7.15 (3.94..13.05) 68% chance between 4.77 and 9.53
EIUL stats: Avg geom mean = 8.18 (7.10..9.82) 68% chance between 7.52 and 8.84
30-year stats
==========================
S&P 500 stats: Avg geom mean = 7.17 (5.14..10.05) 68% chance between 5.66 and 8.68
EIUL stats: Avg geom mean = 8.20 (7.36..9.00) 68% chance between 7.74 and 8.66
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment