Created
November 3, 2021 20:48
-
-
Save techwithshadab/dd9c3b5e672ebadde266b181fa909077 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class EikonDataProvider(BaseDataProvider): | |
| """ | |
| The abstract base class for Eikon data_provider. | |
| """ | |
| def __init__(self, stocks_list, start_date, end_date): | |
| ''' | |
| stocks -> List of interested assets | |
| start -> start date to fetch historical data | |
| end -> end date to fetch historical data | |
| ''' | |
| super().__init__() | |
| self._stocks = stocks_list | |
| self._start = start_date | |
| self._end = end_date | |
| self._data = [] | |
| self.stock_data = pd.DataFrame() | |
| def run(self): | |
| self._data = [] | |
| stocks_notfound = [] | |
| stock_data = ek.get_timeseries(self._stocks, | |
| start_date=self._start, | |
| end_date=self._end, | |
| interval='daily', | |
| corax='adjusted') | |
| for ticker in self._stocks: | |
| stock_value = stock_data[ticker]['CLOSE'] | |
| self.stock_data[ticker] = stock_data[ticker]['CLOSE'] | |
| if stock_value.dropna().empty: | |
| stocks_notfound.append(ticker) | |
| self._data.append(stock_value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment