Esempio n. 1
0
import sys
sys.path.insert(0, '..')

# Import stocker:
import stocker

# Main:
if __name__ == "__main__":

    # Let's save in a combination of stocks and bonds for retirement. Weight the
    # initial portfolio towards 100% stocks for 15 years, weighted 70% US and
    # 30% international. We will contribute 15000 annually with a 2% increase
    # in that contribution annually. Assume the default inflation rate of 3.5%.
    all_stocks_portfolio = stocker.Portfolio(
      name="Stocks", \
      value=0.0, \
      positions=[stocker.US_Stocks(), stocker.International_Stocks()], \
      weights=[7, 3]
    )
    all_stocks_phase = stocker.Scenario(
      name="Initial Accumulation", \
      portfolio=all_stocks_portfolio, \
      num_years=15, \
      annual_contribution=16000, \
      annual_contribution_increase_perc=2.0
    )

    # The next phase of our retirement accumulation will start at 100% stocks
    # but gradually transition to a 50/50 stocks/bonds portfolio by retirement.
    # This phase consists of 20 years more accumulation, with an annual contribution
    # of 20k, increasing 2% each year.
    end_weights = [7, 3, 7, 3]
Esempio n. 2
0
# Include the directory up in the path:
import sys
sys.path.insert(0, '..')

# Import stocker:
import stocker

# Main:
if __name__ == "__main__":

    # Define a retirement portfolio with a 60/40 split between US stocks and US
    # bonds.
    stocks_and_bonds_portfolio = stocker.Portfolio(
      name="Retirement Savings", \
      value=250000, \
      positions=[stocker.US_Stocks(), stocker.US_Bonds()], \
      weights=[6, 4]
    )
    print(str(stocks_and_bonds_portfolio))

    # Define a retirement savings scenario that lasts for 30 years. We will
    # contribute 10K annually, increasing our svings amount by 2% every year.
    retirement_scenario = stocker.Scenario(
      name="Retirement Accumulation", \
      portfolio=stocks_and_bonds_portfolio, \
      num_years=30, \
      annual_contribution=20000, \
      annual_contribution_increase_perc=2.0, \
    )

    # Run the savings scenario once and print and plot the results:
Esempio n. 3
0
#!/usr/bin/env python3

# Include the directory up in the path:
import sys
sys.path.insert(0, '..')

# Import stocker:
import stocker

# Main:
if __name__ == "__main__":

    # Define a portfolio that contains a mixed variety of stocks, bonds, alternatives, and cash with a value of 10k:
    sample_portfolio = stocker.Portfolio(
      name="Sample", \
      value=10000.0, \
      positions=[stocker.US_Stocks(), stocker.International_Stocks(), stocker.US_Bonds(), stocker.International_Bonds(), stocker.Alternatives(), stocker.Cash()], \
      weights=[30, 15, 20, 10, 5, 1] \
    )

    # Create a savings scenario where we compound the interest on this portfolio for 15 years, with no annual additions:
    savings = stocker.Scenario(name="Savings",
                               portfolio=sample_portfolio,
                               num_years=15)

    # Run the savings scenario once and print and plot the results:
    savings.run()
    print(savings.results())
    savings.plot(smooth=False)

    # Run a monte carlo simulation of this scenario with 400 iterations:
    mc = stocker.Monte_Carlo(savings)
Esempio n. 4
0
sys.path.insert(0, '..')

# Import stocker:
import stocker

# Main:
if __name__ == "__main__":

    # Let's save in a combination of US stocks and US bonds for college. Weight the
    # initial portfolio towards 100% stocks, but gradually transition to 100% bonds
    # over the coarse of the savings period. We can seed the portfolio with $5000.
    positions = [stocker.US_Stocks(), stocker.US_Bonds()]
    start_weights = [1, 0]
    end_weights = [0, 1]
    college_529_portfolio = stocker.Portfolio(name="529",
                                              value=5000.0,
                                              positions=positions,
                                              weights=start_weights)

    # Create the college savings scenario where we compound the interest on this portfolio
    # for 18 years, adding $2500 annually. Assume an inflation rate of 2.5%
    college_savings = stocker.Scenario(name="College",
                                       portfolio=college_529_portfolio,
                                       num_years=18,
                                       annual_contribution=2500,
                                       inflation_rate_perc=2.5,
                                       end_weights=end_weights)

    # Run the savings scenario once and print and plot the results:
    college_savings.run()
    print(college_savings.results())
    college_savings.plot(smooth=False)