コード例 #1
0
 def test_wikipedia(self):
     """ wikipedia test """
     try:
         wiki = WikipediaDataProvider(token=self._quandl_token,
                                      tickers=["GOOG", "AAPL"],
                                      start=datetime.datetime(2016, 1, 1),
                                      end=datetime.datetime(2016, 1, 30))
         wiki.run()
         similarity = np.array([[1.00000000e+00, 8.44268222e-05],
                                [8.44268222e-05, 1.00000000e+00]])
         covariance = np.array([[269.60118129, 25.42252332],
                                [25.42252332, 7.86304499]])
         with self.subTest(
                 'test WikipediaDataProvider get_covariance_matrix'):
             np.testing.assert_array_almost_equal(
                 wiki.get_covariance_matrix(), covariance, decimal=3)
         with self.subTest(
                 'test WikipediaDataProvider get_similarity_matrix'):
             np.testing.assert_array_almost_equal(
                 wiki.get_similarity_matrix(), similarity, decimal=3)
     except MissingOptionalLibraryError as ex:
         self.skipTest(str(ex))
     except QiskitFinanceError as ex:
         self.skipTest("Test of WikipediaDataProvider skipped: {}".format(
             str(ex)))
コード例 #2
0
 def test_wikipedia(self):
     """ wikipedia test """
     wiki = WikipediaDataProvider(
         token="",
         tickers=["GOOG", "AAPL"],
         stockmarket=StockMarket.NASDAQ,
         start=datetime.datetime(2016, 1, 1),
         end=datetime.datetime(2016, 1, 30)
     )
     # can throw QiskitFinanceError
     try:
         wiki.run()
         similarity = np.array([
             [1.00000000e+00, 8.44268222e-05],
             [8.44268222e-05, 1.00000000e+00]
         ])
         covariance = np.array([
             [269.60118129, 25.42252332],
             [25.42252332, 7.86304499]
         ])
         np.testing.assert_array_almost_equal(wiki.get_covariance_matrix(),
                                              covariance, decimal=3)
         np.testing.assert_array_almost_equal(wiki.get_similarity_matrix(),
                                              similarity, decimal=3)
     except QiskitFinanceError:
         self.skipTest("Test of WikipediaDataProvider skipped due to the per-day usage limits.")