def test_fetch_realtime_multiple_quotes(self): test_date = dates.get_database_timestamp().date() quotes = stocks.fetch_realtime(["SPX", "VIX", "AAPL"], TEST_DB_NAME) self.assertGreater(quotes["SPX"].close, 0) self.assertGreater(quotes["VIX"].close, 0) self.assertGreater(quotes["AAPL"].close, 0) self._check_database_quotes("SPX", 1, test_date, None) self._check_database_quotes("VIX", 1, test_date, None) self._check_database_quotes("AAPL", 1, test_date, None)
def update_stocks(): if request.args["date"] == "": stocks.fetch_realtime(["VIX", "VXST", "VXV", "VXMT", "VVIX", "SPX", "XIV", "VXX", "TLT"]) structures.update_stocks_vol_last("SPX") return jsonify()
def test_fetch_realtime_non_existing_quote(self): test_date = dates.get_database_timestamp().date() quotes = stocks.fetch_realtime([NON_EXISTING_SYMBOL], TEST_DB_NAME) self.assertIsNone(quotes[NON_EXISTING_SYMBOL].close) self._check_database_quotes(NON_EXISTING_SYMBOL, 0, test_date, None)
def test_fetch_realtime_single_quote(self): test_date = dates.get_database_timestamp().date() quotes = stocks.fetch_realtime(["SPX"], TEST_DB_NAME) self._check_quotes(quotes, "SPX", test_date, None) self._check_database_quotes("SPX", 1, test_date, None)
def test_fetch_realtime_no_quote(self): self.assertEqual(stocks.fetch_realtime([], TEST_DB_NAME), {})