示例#1
0
  def makeMonthlyTables(ticker_symbol, year):
     """Provide monthly (12 months) for a particular year for a particular
        ticker symbol.

     Ex: GOOG, 2012 -> tables for Jan 2012, Feb 2012, ..., Dec 2012     
     """
     months = [month for month in range(1, 13)]
     monthly_tables = []
     for month in months:
       # Assume we go from the 1st of the month, and then 30 days later.
       start_date = DateUtils.getDateStr(year, month, 1)
       end_date = DateUtils.getEndDate(start_date, 30)
       tbl = YahooStockTable.make_data_table(ticker_symbol, start_date, end_date)
       monthly_tables.append(tbl)
     return monthly_tables  
示例#2
0
 def runTests():
     Tests.assertEquals([1.0, 0.5], StockUtils.getPercentChanges([5, 10, 15]))
     Tests.assertEquals([0.75], [StockUtils.getAverageReturn([5, 10, 15])])
     Tests.assertEquals([-0.67], [StockUtils.getTotalReturn([15, 10, 5])])
     Tests.assertStrEquals(["20120220"], [DateUtils.getEndDate("20120215", 5)])
     Tests.assertStrEquals(["20121231"], [DateUtils.getDateStr(2012, 12, 31)])