def getyahoojpan(self, ticker, startdate, enddate = date.today()): self.bars = yahoojap.get_historical(ticker, startdate, enddate, filename = None) self.bars.reverse()
tickers = map(lambda x: str(x), tickers) tot_pnl = 0 for ticker in tickers: bt = Strat2(store = store) print "ticker = " + str(ticker) try: open(ticker + ".quotes", "rb") except: print "downloading quotes ..." yahoojap.get_historical(ticker, date(2010,1,1), filename = ticker + ".quotes") bt.load(ticker + ".quotes") print "running backtest ..." bt.run() #bt.store.save(open(ticker + ".log", "wb")) pnl = bt.store[bt.name]["final pnl"] tot_pnl += pnl[3] print "pnl = " + str(pnl[0]) + ", unrealized pnl = " + str(pnl[2]) + ", total pnl = " + str(pnl[3]) + "\n" fig = bt.draw()