diff --git a/tests/test_ticker.py b/tests/test_ticker.py index 257e3ed0..d8cd0fa2 100644 --- a/tests/test_ticker.py +++ b/tests/test_ticker.py @@ -216,11 +216,24 @@ def test_history(self): self.assertFalse(data.empty, "data is empty") def test_download(self): + tomorrow = pd.Timestamp.now().date() + pd.Timedelta(days=1) # helps with caching for t in [False, True]: for i in [False, True]: - data = yf.download(self.symbols, threads=t, ignore_tz=i) - self.assertIsInstance(data, pd.DataFrame, "data has wrong type") - self.assertFalse(data.empty, "data is empty") + for m in [False, True]: + for n in [1, 'all']: + symbols = self.symbols[0] if n == 1 else self.symbols + data = yf.download(symbols, end=tomorrow, session=self.session, + threads=t, ignore_tz=i, multi_level_index=m) + self.assertIsInstance(data, pd.DataFrame, "data has wrong type") + self.assertFalse(data.empty, "data is empty") + if i: + self.assertIsNone(data.index.tz) + else: + self.assertIsNotNone(data.index.tz) + if (not m) and n == 1: + self.assertFalse(isinstance(data.columns, pd.MultiIndex)) + else: + self.assertIsInstance(data.columns, pd.MultiIndex) def test_no_expensive_calls_introduced(self): """ diff --git a/yfinance/multi.py b/yfinance/multi.py index 5a063050..9e399813 100644 --- a/yfinance/multi.py +++ b/yfinance/multi.py @@ -210,7 +210,7 @@ def download(tickers, start=None, end=None, actions=False, threads=True, _realign_dfs() data = _pd.concat(shared._DFS.values(), axis=1, sort=True, keys=shared._DFS.keys(), names=['Ticker', 'Price']) - data.index = _pd.to_datetime(data.index, utc=True) + data.index = _pd.to_datetime(data.index, utc=not ignore_tz) # switch names back to isins if applicable data.rename(columns=shared._ISINS, inplace=True)