Skip to content

Commit

Permalink
Trying to fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackal08 committed Apr 16, 2024
1 parent 949f5f6 commit aaa8279
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 8 additions & 5 deletions arbitragelab/util/data_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_ticker_sector_info(self, tickers: list, yf_call_chunk: int = 20) -> pd.D
# Set end as the limit value equals to the chunk size.
# If we hit the last chunk, set the end value as the
# full length of the ticker list.
end = i+yf_call_chunk if i <= len(tickers) else len(tickers)
end = i + yf_call_chunk if i <= len(tickers) else len(tickers)

ticker_sector_queue.append(self._sector_info_helper(tickers[i: end]))

Expand All @@ -132,13 +132,16 @@ def _sector_info_helper(tickers: list) -> pd.DataFrame:
and industry information.
"""

tckrs = yf.Tickers(' '.join(tickers))
tickers_obj = yf.Tickers(' '.join(tickers))

tckr_info = []
for name in tickers:

for tckr in tickers:
ticker_info = tckrs.tickers[tckr].info
tckr_tuple = (tckr, ticker_info['industry'], ticker_info['sector'])
sector = tickers_obj.tickers[name].info.get('sector', 'NA')
industry = tickers_obj.tickers[name].info.get('industry', 'NA')

# Append to list storage
tckr_tuple = (name, industry, sector)
tckr_info.append(tckr_tuple)

return pd.DataFrame(data=tckr_info, columns=['ticker', 'industry', 'sector'])
1 change: 1 addition & 0 deletions tests/test_data_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy as np
from arbitragelab.util import DataImporter


class TestDataImporter(unittest.TestCase):
"""
Tests Data Importer class.
Expand Down

0 comments on commit aaa8279

Please sign in to comment.