It is a good application to estimate annualized return distribution and represent it as a graph. To make our exercise more meaningful, we download Microsoft's daily price data. Then, we estimate its daily returns and convert them into annual ones. Based on those annual returns, we generate its distribution by applying bootstrapping with replacements 5,000 times, as shown in the following code:
import numpy as np import scipy as sp import pandas as pd import matplotlib.pyplot as plt from matplotlib.finance import quotes_historical_yahoo_ochl as getData # Step 1: input area ticker='MSFT' # input value 1 begdate=(1926,1,1) # input value 2 enddate=(2013,12,31) # input value 3 n_simulation=5000 # input value 4 # Step 2: retrieve price data and estimate log returns x=getData(ticker,begdate,enddate,asobject=True) logret = sp.log(x.aclose[1:]/x.aclose[:-1]) # Step 3: estimate annual returns date=[] d0=x.date for i in range(0,sp.size(logret...