Exemplo n.º 1
0
    def testDownloadAndParseDailyNoAdjClose(self):
        with common.TmpDir() as tmpPath:
            symbol = "ADYEN"
            instrument = "%s/%s" % (symbol, PRICE_CURRENCY)
            year = 2018
            path = os.path.join(tmpPath,
                                "quandl-daily-%s-%s.csv" % (symbol, year))
            quandl.download_daily_bars("EURONEXT",
                                       symbol,
                                       year,
                                       path,
                                       authToken=QUANDL_API_KEY)
            bf = quandlfeed.Feed()
            bf.setNoAdjClose()
            bf.setColumnName("open", "Open")
            bf.setColumnName("high", "High")
            bf.setColumnName("low", "Low")
            bf.setColumnName("close", "Last")
            bf.setColumnName("volume", "Volume")
            bf.addBarsFromCSV(instrument, path, skipMalformedBars=True)
            bf.loadAll()
            ds = bf.getDataSeries(instrument)

            self.assertEqual(ds[0].getDateTime(),
                             datetime.datetime(year, 6, 13))
            self.assertEqual(ds[0].getOpen(), 400.00)
            self.assertEqual(ds[0].getHigh(), 503.90)
            self.assertEqual(ds[0].getLow(), 400.00)
            self.assertEqual(ds[0].getClose(), 455.00)
            self.assertEqual(ds[0].getVolume(), 1529232)
            self.assertEqual(ds[0].getAdjClose(), None)
            self.assertEqual(ds[0].getPrice(), 455.00)
Exemplo n.º 2
0
    def testDownloadAndParseDaily_UseAdjClose(self):
        with common.TmpDir() as tmpPath:
            symbol = "ORCL"
            instrument = "%s/%s" % (symbol, PRICE_CURRENCY)
            path = os.path.join(tmpPath, "quandl-daily-orcl-2010.csv")
            quandl.download_daily_bars("WIKI",
                                       symbol,
                                       2010,
                                       path,
                                       authToken=QUANDL_API_KEY)
            bf = quandlfeed.Feed()
            bf.addBarsFromCSV(instrument, path)
            # Need to setUseAdjustedValues(True) after loading the file because we
            # can't tell in advance if adjusted values are there or not.
            bf.setUseAdjustedValues(True)
            bf.loadAll()
            ds = bf.getDataSeries(instrument)

            self.assertEqual(ds[-1].getDateTime(),
                             datetime.datetime(2010, 12, 31))
            self.assertEqual(ds[-1].getOpen(), 31.22)
            self.assertEqual(ds[-1].getHigh(), 31.33)
            self.assertEqual(ds[-1].getLow(), 30.93)
            self.assertEqual(ds[-1].getClose(), 31.3)
            self.assertEqual(ds[-1].getVolume(), 11716300)
            self.assertEqual(ds[-1].getPrice(), ds[-1].getAdjClose())
            # Not checking against a specific value since this is going to change
            # as time passes by.
            self.assertNotEqual(ds[-1].getAdjClose(), None)
Exemplo n.º 3
0
 def testDownloadAndParseDailyNoAdjClose(self):
     with common.TmpDir() as tmpPath:
         instrument = "IWG"
         year = 2017
         path = os.path.join(tmpPath,
                             "quandl-daily-%s-%s.csv" % (instrument, year))
         quandl.download_daily_bars("LSE",
                                    instrument,
                                    year,
                                    path,
                                    authToken=QUANDL_API_KEY)
         bf = quandlfeed.Feed()
         bf.setNoAdjClose()
         bf.setColumnName("open", "Price")
         bf.setColumnName("close", "Price")
         bf.addBarsFromCSV(instrument, path, skipMalformedBars=True)
         bf.loadAll()
         self.assertEqual(bf[instrument][0].getDateTime(),
                          datetime.datetime(year, 1, 3))
         self.assertEqual(bf[instrument][0].getOpen(), 237.80)
         self.assertEqual(bf[instrument][0].getHigh(), 247.00)
         self.assertEqual(bf[instrument][0].getLow(), 236.30)
         self.assertEqual(bf[instrument][0].getClose(), 237.80)
         self.assertEqual(bf[instrument][0].getVolume(), 3494173)
         self.assertEqual(bf[instrument][0].getAdjClose(), None)
         self.assertEqual(bf[instrument][0].getPrice(), 237.80)
Exemplo n.º 4
0
    def testDownloadAndParseDaily(self):
        instrument = "ORCL"

        common.init_temp_path()
        path = os.path.join(common.get_temp_path(), "quandl-daily-orcl-2010.csv")
        quandl.download_daily_bars("WIKI", instrument, 2010, path, auth_token)
        bf = quandlfeed.Feed()
        bf.addBarsFromCSV(instrument, path)
        bf.loadAll()
        self.assertEquals(bf[instrument][-1].getDateTime(), datetime.datetime(2010, 12, 31))
        self.assertEquals(bf[instrument][-1].getOpen(), 31.22)
        self.assertEquals(bf[instrument][-1].getHigh(), 31.33)
        self.assertEquals(bf[instrument][-1].getLow(), 30.93)
        self.assertEquals(bf[instrument][-1].getClose(), 31.3)
        self.assertEquals(bf[instrument][-1].getVolume(), 11716300)
        self.assertEquals(bf[instrument][-1].getAdjClose(), 30.23179912467581)
Exemplo n.º 5
0
 def testDownloadAndParseDailyNoAdjClose(self):
     with common.TmpDir() as tmpPath:
         instrument = "ORCL"
         path = os.path.join(tmpPath, "quandl-daily-orcl-2013.csv")
         quandl.download_daily_bars("GOOG", "NASDAQ_ORCL", 2013, path, auth_token)
         bf = quandlfeed.Feed()
         bf.setNoAdjClose()
         bf.addBarsFromCSV(instrument, path)
         bf.loadAll()
         self.assertEquals(bf[instrument][-1].getDateTime(), datetime.datetime(2013, 12, 31))
         self.assertEquals(bf[instrument][-1].getOpen(), 37.94)
         self.assertEquals(bf[instrument][-1].getHigh(), 38.34)
         self.assertEquals(bf[instrument][-1].getLow(), 37.88)
         self.assertEquals(bf[instrument][-1].getClose(), 38.26)
         self.assertEquals(bf[instrument][-1].getVolume(), 11747517)
         self.assertEquals(bf[instrument][-1].getAdjClose(), None)
         self.assertEquals(bf[instrument][-1].getPrice(), 38.26)
Exemplo n.º 6
0
 def testDownloadAndParseDailyNoAdjClose(self):
     with common.TmpDir() as tmpPath:
         instrument = "ORCL"
         path = os.path.join(tmpPath, "quandl-daily-orcl-2013.csv")
         quandl.download_daily_bars("GOOG", "NASDAQ_ORCL", 2013, path, auth_token)
         bf = quandlfeed.Feed()
         bf.setNoAdjClose()
         bf.addBarsFromCSV(instrument, path)
         bf.loadAll()
         self.assertEquals(bf[instrument][-1].getDateTime(), datetime.datetime(2013, 12, 31))
         self.assertEquals(bf[instrument][-1].getOpen(), 37.94)
         self.assertEquals(bf[instrument][-1].getHigh(), 38.34)
         self.assertEquals(bf[instrument][-1].getLow(), 37.88)
         self.assertEquals(bf[instrument][-1].getClose(), 38.26)
         self.assertEquals(bf[instrument][-1].getVolume(), 11747517)
         self.assertEquals(bf[instrument][-1].getAdjClose(), None)
         self.assertEquals(bf[instrument][-1].getPrice(), 38.26)
Exemplo n.º 7
0
 def testDownloadAndParseDaily(self):
     with common.TmpDir() as tmpPath:
         instrument = "ORCL"
         path = os.path.join(tmpPath, "quandl-daily-orcl-2010.csv")
         quandl.download_daily_bars("WIKI", instrument, 2010, path, auth_token)
         bf = quandlfeed.Feed()
         bf.addBarsFromCSV(instrument, path)
         bf.loadAll()
         self.assertEquals(bf[instrument][-1].getDateTime(), datetime.datetime(2010, 12, 31))
         self.assertEquals(bf[instrument][-1].getOpen(), 31.22)
         self.assertEquals(bf[instrument][-1].getHigh(), 31.33)
         self.assertEquals(bf[instrument][-1].getLow(), 30.93)
         self.assertEquals(bf[instrument][-1].getClose(), 31.3)
         self.assertEquals(bf[instrument][-1].getVolume(), 11716300)
         self.assertEquals(bf[instrument][-1].getPrice(), 31.3)
         # Not checking against a specific value since this is going to change
         # as time passes by.
         self.assertNotEquals(bf[instrument][-1].getAdjClose(), None)
Exemplo n.º 8
0
 def testDownloadAndParseDaily(self):
     with common.TmpDir() as tmpPath:
         instrument = "ORCL"
         path = os.path.join(tmpPath, "quandl-daily-orcl-2010.csv")
         quandl.download_daily_bars("WIKI", instrument, 2010, path, auth_token)
         bf = quandlfeed.Feed()
         bf.addBarsFromCSV(instrument, path)
         bf.loadAll()
         self.assertEquals(bf[instrument][-1].getDateTime(), datetime.datetime(2010, 12, 31))
         self.assertEquals(bf[instrument][-1].getOpen(), 31.22)
         self.assertEquals(bf[instrument][-1].getHigh(), 31.33)
         self.assertEquals(bf[instrument][-1].getLow(), 30.93)
         self.assertEquals(bf[instrument][-1].getClose(), 31.3)
         self.assertEquals(bf[instrument][-1].getVolume(), 11716300)
         self.assertEquals(bf[instrument][-1].getPrice(), 31.3)
         # Not checking against a specific value since this is going to change
         # as time passes by.
         self.assertNotEquals(bf[instrument][-1].getAdjClose(), None)
Exemplo n.º 9
0
 def testDownloadAndParseDaily(self):
     with common.TmpDir() as tmpPath:
         instrument = "ORCL"
         path = os.path.join(tmpPath, "quandl-daily-orcl-2010.csv")
         quandl.download_daily_bars("WIKI", instrument, 2010, path,
                                    auth_token)
         bf = quandlfeed.Feed()
         bf.addBarsFromCSV(instrument, path)
         bf.loadAll()
         self.assertEquals(bf[instrument][-1].getDateTime(),
                           datetime.datetime(2010, 12, 31))
         self.assertEquals(bf[instrument][-1].getOpen(), 31.22)
         self.assertEquals(bf[instrument][-1].getHigh(), 31.33)
         self.assertEquals(bf[instrument][-1].getLow(), 30.93)
         self.assertEquals(bf[instrument][-1].getClose(), 31.3)
         self.assertEquals(bf[instrument][-1].getVolume(), 11716300)
         self.assertEquals(bf[instrument][-1].getAdjClose(),
                           30.23179912467581)
         self.assertEquals(bf[instrument][-1].getPrice(), 31.3)
Exemplo n.º 10
0
 def testDownloadAndParseDaily_UseAdjClose(self):
     with common.TmpDir() as tmpPath:
         instrument = "ORCL"
         path = os.path.join(tmpPath, "quandl-daily-orcl-2010.csv")
         quandl.download_daily_bars("WIKI", instrument, 2010, path, auth_token)
         bf = quandlfeed.Feed()
         bf.addBarsFromCSV(instrument, path)
         # Need to setUseAdjustedValues(True) after loading the file because we
         # can't tell in advance if adjusted values are there or not.
         bf.setUseAdjustedValues(True)
         bf.loadAll()
         self.assertEquals(bf[instrument][-1].getDateTime(), datetime.datetime(2010, 12, 31))
         self.assertEquals(bf[instrument][-1].getOpen(), 31.22)
         self.assertEquals(bf[instrument][-1].getHigh(), 31.33)
         self.assertEquals(bf[instrument][-1].getLow(), 30.93)
         self.assertEquals(bf[instrument][-1].getClose(), 31.3)
         self.assertEquals(bf[instrument][-1].getVolume(), 11716300)
         self.assertEquals(bf[instrument][-1].getAdjClose(), 30.23179912467581)
         self.assertEquals(bf[instrument][-1].getPrice(), 30.23179912467581)
Exemplo n.º 11
0
 def testDownloadAndParseDailyNoAdjClose(self):
     with common.TmpDir() as tmpPath:
         instrument = "IWG"
         year = 2017
         path = os.path.join(tmpPath, "quandl-daily-%s-%s.csv" % (instrument, year))
         quandl.download_daily_bars("LSE", instrument, year, path, authToken=QUANDL_API_KEY)
         bf = quandlfeed.Feed()
         bf.setNoAdjClose()
         bf.setColumnName("open", "Price")
         bf.setColumnName("close", "Price")
         bf.addBarsFromCSV(instrument, path, skipMalformedBars=True)
         bf.loadAll()
         self.assertEquals(bf[instrument][0].getDateTime(), datetime.datetime(year, 1, 3))
         self.assertEquals(bf[instrument][0].getOpen(), 237.80)
         self.assertEquals(bf[instrument][0].getHigh(), 247.00)
         self.assertEquals(bf[instrument][0].getLow(), 236.30)
         self.assertEquals(bf[instrument][0].getClose(), 237.80)
         self.assertEquals(bf[instrument][0].getVolume(), 3494173)
         self.assertEquals(bf[instrument][0].getAdjClose(), None)
         self.assertEquals(bf[instrument][0].getPrice(), 237.80)
Exemplo n.º 12
0
 def testDownloadAndParseDaily_UseAdjClose(self):
     with common.TmpDir() as tmpPath:
         instrument = "ORCL"
         path = os.path.join(tmpPath, "quandl-daily-orcl-2010.csv")
         quandl.download_daily_bars("WIKI", instrument, 2010, path, authToken=QUANDL_API_KEY)
         bf = quandlfeed.Feed()
         bf.addBarsFromCSV(instrument, path)
         # Need to setUseAdjustedValues(True) after loading the file because we
         # can't tell in advance if adjusted values are there or not.
         bf.setUseAdjustedValues(True)
         bf.loadAll()
         self.assertEquals(bf[instrument][-1].getDateTime(), datetime.datetime(2010, 12, 31))
         self.assertEquals(bf[instrument][-1].getOpen(), 31.22)
         self.assertEquals(bf[instrument][-1].getHigh(), 31.33)
         self.assertEquals(bf[instrument][-1].getLow(), 30.93)
         self.assertEquals(bf[instrument][-1].getClose(), 31.3)
         self.assertEquals(bf[instrument][-1].getVolume(), 11716300)
         self.assertEquals(bf[instrument][-1].getPrice(), bf[instrument][-1].getAdjClose())
         # Not checking against a specific value since this is going to change
         # as time passes by.
         self.assertNotEquals(bf[instrument][-1].getAdjClose(), None)
Exemplo n.º 13
0
 def testDownloadAndParseDaily_UseAdjClose(self):
     with common.TmpDir() as tmpPath:
         instrument = "ORCL"
         path = os.path.join(tmpPath, "quandl-daily-orcl-2010.csv")
         quandl.download_daily_bars("WIKI", instrument, 2010, path,
                                    auth_token)
         bf = quandlfeed.Feed()
         bf.addBarsFromCSV(instrument, path)
         # Need to setUseAdjustedValues(True) after loading the file because we
         # can't tell in advance if adjusted values are there or not.
         bf.setUseAdjustedValues(True)
         bf.loadAll()
         self.assertEquals(bf[instrument][-1].getDateTime(),
                           datetime.datetime(2010, 12, 31))
         self.assertEquals(bf[instrument][-1].getOpen(), 31.22)
         self.assertEquals(bf[instrument][-1].getHigh(), 31.33)
         self.assertEquals(bf[instrument][-1].getLow(), 30.93)
         self.assertEquals(bf[instrument][-1].getClose(), 31.3)
         self.assertEquals(bf[instrument][-1].getVolume(), 11716300)
         self.assertEquals(bf[instrument][-1].getAdjClose(),
                           30.23179912467581)
         self.assertEquals(bf[instrument][-1].getPrice(), 30.23179912467581)