A simple tool to simulate stock market returns using S&P 500 data from January 1871 through today
- Load libraries:
$LOAD_PATH << File.join(File.dirname(__FILE__), "..", "lib")
$LOAD_PATH << File.join(File.dirname(__FILE__), "..", "data")
require 'investsim'
- Parse data from Robert Shiller's S&P 500 spreadsheet:
data_table = ShillerParser.new.data_table
- Create an investment account; optionally load with an initial investment:
account = InvestmentAccount.new(data_table, {amount: 100})
- Manipulate the account through investment, withdrawal, or no action through each month
account.invest_and_advance 10
account.withdraw_and_advance 10
account.advance
account.advance_to account.last_date
- Check account balance at any point
puts account.balance
scripts/trinity_extended
analyzes stock market portfolio success probabilities for different drawdown terms and withdrawal rates. The script also provides for optional adjustable expense ratio and toggling between monthly and annual withdrawals
This tool was scraped together by @chrisdurheim and could use some TLC. I may do some updates on my own, but if you'd like to get involved, let me know.