def test_get_expected_sharpe_ratio(self):
     tickers = ['AAPL', 'GLD', 'GOOG', 'XOM']
     startDate = dt.datetime(2011, 1, 1)
     endDate = dt.datetime(2011, 12, 31)
     allocations = [0.4, 0.4, 0.0, 0.2]
     vol, daily_ret, sharpe, cum_ret = homework1.simulate(startDate, endDate, tickers, allocations)  
     
     self.assertAlmostEqual(sharpe, 1.02828403099)
    def test_get_expected_daily_return(self):
        tickers = ['AAPL', 'GLD', 'GOOG', 'XOM']
        startDate = dt.datetime(2011, 1, 1)
        endDate = dt.datetime(2011, 12, 31)
        allocations = [0.4, 0.4, 0.0, 0.2]
        vol, daily_ret, sharpe, cum_ret = homework1.simulate(startDate, endDate, tickers, allocations)  

        self.assertAlmostEqual(daily_ret, 0.000657261102001)
 def test_get_expected_volatility(self):
     tickers = ['AAPL', 'GLD', 'GOOG', 'XOM']
     startDate = dt.datetime(2011, 1, 1)
     endDate = dt.datetime(2011, 12, 31)
     allocations = [0.4, 0.4, 0.0, 0.2]
     vol, daily_ret, sharpe, cum_ret = homework1.simulate(startDate, endDate, tickers, allocations)  
     
     self.assertAlmostEqual(vol, 0.0101467067654)
    def test_sending_real_data_into_simulate_does_not_cause_exception(self):
        tickers = ["AAPL", "GLD", "GOOG", "$SPX"]
        startDate = dt.datetime(2011, 1, 1)
        endDate = dt.datetime(2011, 12, 31)
        allocations = [0.4, 0.4, 0.0, 0.2]
        vol, daily_ret, sharpe, cum_ret = homework1.simulate(startDate, endDate, tickers, allocations)        

        self.assertEquals(1, 1)
 def test_full_simulate(self):
     tickers = ['AXP', 'HPQ', 'IBM', 'HNZ']
     startDate = dt.datetime(2010, 1, 1)
     endDate = dt.datetime(2010, 12, 31)
     allocations = [0.0, 0.0, 0.0, 1.0]
     vol, daily_ret, sharpe, cum_ret = homework1.simulate(startDate, endDate, tickers, allocations)  
     
     self.assertAlmostEqual(sharpe, 1.29889334008)
     self.assertAlmostEqual(vol, 0.00924299255937)
     self.assertAlmostEqual(daily_ret, 0.000756285585593)
     self.assertAlmostEqual(cum_ret, 1.1960583568)