Example #1
0
def main():
  start_date = date(2002,1,1)
  end_date = date(2012, 5, 15)
  buy_hold_test = Backtest(start_date, end_date, commissions_class=WellsPMACommissions, 
                      taxes_class=CaliforniaTaxes, strategy_class=BuyHoldSPY, 
                      end_of_day_class=Yahoo)
  chart_backtest(buy_hold_test, title='Buy & Hold S&P 500 Index (SPY)')
Example #2
0
def main():
  start_date = date(2007,6,28)
  end_date = date(2012, 6, 28)
  buy_hold_test = Backtest(start_date, end_date, commissions_class=WellsPMACommissions, 
                      strategy_class=BuyHoldSPY, end_of_day_class=MongodbCache)
  biggest_loser_test = Backtest(start_date, end_date, commissions_class=WellsPMACommissions, 
                                 strategy_class=BiggestLoser,end_of_day_class=MongodbCache, cache=False)
  chart_backtest(buy_hold_test, biggest_loser_test, labels=['Buy & Hold', 'BiggestLoser.'], colors=['g', 'b'], title='Strategy Comparison')