Ejemplo n.º 1
0
 def testDownloadAndParseWeekly(self):
     with common.TmpDir() as tmpPath:
         instrument = "AAPL"
         path = os.path.join(tmpPath, "quandl-aapl-weekly-2010.csv")
         quandl.download_weekly_bars("WIKI", instrument, 2010, path,
                                     auth_token)
         bf = quandlfeed.Feed(frequency=bar.Frequency.WEEK)
         bf.addBarsFromCSV(instrument, path)
         bf.loadAll()
         # Quandl used to report 2010-1-3 as the first week of 2010.
         self.assertTrue(bf[instrument][0].getDateTime() in [
             datetime.datetime(2010, 1, 3),
             datetime.datetime(2010, 1, 10)
         ])
         self.assertEquals(bf[instrument][-1].getDateTime(),
                           datetime.datetime(2010, 12, 26))
         self.assertEquals(bf[instrument][-1].getOpen(), 325.0)
         self.assertEquals(bf[instrument][-1].getHigh(), 325.15)
         self.assertEquals(bf[instrument][-1].getLow(), 323.17)
         self.assertEquals(bf[instrument][-1].getClose(), 323.6)
         self.assertEquals(bf[instrument][-1].getVolume(), 7969900)
         self.assertEquals(bf[instrument][-1].getPrice(), 323.6)
         # Not checking against a specific value since this is going to change
         # as time passes by.
         self.assertNotEquals(bf[instrument][-1].getAdjClose(), None)
Ejemplo n.º 2
0
 def testDownloadAndParseWeekly(self):
     with common.TmpDir() as tmpPath:
         instrument = "AAPL"
         path = os.path.join(tmpPath, "quandl-aapl-weekly-2010.csv")
         quandl.download_weekly_bars("WIKI", instrument, 2010, path, auth_token)
         bf = quandlfeed.Feed(frequency=bar.Frequency.WEEK)
         bf.addBarsFromCSV(instrument, path)
         bf.loadAll()
         self.assertEquals(bf[instrument][0].getDateTime(), datetime.datetime(2010, 1, 3))
         self.assertEquals(bf[instrument][-1].getDateTime(), datetime.datetime(2010, 12, 26))
         self.assertEquals(bf[instrument][-1].getOpen(), 325.0)
         self.assertEquals(bf[instrument][-1].getHigh(), 325.15)
         self.assertEquals(bf[instrument][-1].getLow(), 323.17)
         self.assertEquals(bf[instrument][-1].getClose(), 323.6)
         self.assertEquals(bf[instrument][-1].getVolume(), 7969900)
         self.assertEquals(bf[instrument][-1].getPrice(), 323.6)
         # Not checking against a specific value since this is going to change
         # as time passes by.
         self.assertNotEquals(bf[instrument][-1].getAdjClose(), None)