コード例 #1
0
def get_date():
    return randomDate("2010-9-1 00:00+0300", "2013-10-26 23:50+0300", random.random())
コード例 #2
0
	print ""
	print "You have chosen to backtest stocks that UCM picks. We'll compare the average return of each"
	print "portfolio and subtract from that the average return of the index to identify how much you beat"
	print "the market by with the given method and signal over the course of a year"
	print ""
	print "++++++++++++++++++++++++++++++%s++++++++++++++++++++++++++++++" % method.__name__

	backtest_avg = []
	for n in range(0, ITERATIONS):
		print ""
		print "++++++++++++++++++++++++++++++ITERATION %s++++++++++++++++++++++++++++++" % n

		now = datetime.datetime.now()
		start = now - datetime.timedelta(days=1) - dateutil.relativedelta.relativedelta(years=2)
		end = now - datetime.timedelta(days=1) - dateutil.relativedelta.relativedelta(years=1)
		date = randomDate(start, end)

		print "Selecting Stocks from Date: %s" % date.strftime(DATE_FORMAT)
		print "Searching for investing ideas on Seeking Alpha..."

		stocks = seeking_alpha.get(date, SIGNAL_DAYS)
		
		print "The UCM identified %s stocks to backtest." % len(stocks)
		print "\n".join(stocks)

		if len(stocks) == 0: continue

		start_date = date - dateutil.relativedelta.relativedelta(years=1)
		end_date = date
		start = start_date.strftime(YAHOO_DATE_FORMAT)
		end = end_date.strftime(YAHOO_DATE_FORMAT)