boknows/cFIREsim-open — pull request #3 by pmallory (2014-12-19 04:27:57+00:00)
Title: JSONify historical market data

Hi, I made some changes in order to get familiar with the code. I think it's tidier now, if you agree feel free to accept the pull request :) If not that's fine too.

Summary of changes:
* changed the marketData data structure to nested objects. This makes all the accessor functions unnecessary and is cleaner imho. You can get a year's data with by name, eg `var cpi = Market[1942].cpi`.
* changed all of the data accesses to accommodate the new data structure
* moved the cumulative inflation calculation into its own function for readability and testability
* reworked the iteration variables in the for loops to be in terms of years, that way we don't have to add 1871 to everything. In the process I think I found an of-by-one error, Market.getLength was returning a number one smaller than the actual length of the data.
* Renamed some variables to make things more clear (imho)