Пример #1
0
    def test_get_all_tickers_should_return_list_of_strs(self):
        tickers = YubbExtractor.get_all_tickers()
        # There are at least 300 tickers in the Yubb website
        assert len(tickers) > 300
        assert type(tickers[0]) == str

        # Also saving to not need to retrieve them all again
        YubbExtractor.save_list_to_file(tickers, 'yubb_tickers.txt')
Пример #2
0
    def test_should_save_list_to_file(self, tickers_list):
        import os.path

        filename = 'tickers.txt'
        try:
            os.remove(filename)
        except Exception:
            pass

        YubbExtractor.save_list_to_file(tickers_list, filename)
        assert os.path.exists(filename)
    def get_dataframe_indicators_for_stocks(cls,
                                            stocks: List[str]) -> pd.DataFrame:
        indicators_dict = YubbExtractor.get_indicators_from_stocks(stocks)

        data_frame = cls.create_dataframe_dict_from_indicators_dict(
            indicators_dict)
        df = pd.DataFrame(data_frame)
        # df.to_csv('dataframe.csv', index=False)
        return df
Пример #4
0
def indicators_dict(stocks_list):
    from extractor import YubbExtractor
    indicators_dict = YubbExtractor.get_indicators_from_stocks(stocks_list)
    return indicators_dict
Пример #5
0
 def test_should_get_tickers_list_from_file(self, tickers_list):
     returned_tickers_list = YubbExtractor.get_tickers_list_from_file(
         'tickers.txt')
     assert returned_tickers_list == tickers_list
Пример #6
0
 def test_get_tickers_from_page_should_return_list_of_strs(self):
     tickers = YubbExtractor.get_tickers_from_page(1)
     assert len(tickers) > 0
     assert type(tickers[0]) == str
Пример #7
0
 def test_get_indicators_from_stocks_should_return_dict_with_stocks_as_keys(
         self, tickers_list):
     indicators_dict = YubbExtractor.get_indicators_from_stocks(
         tickers_list)
     assert type(indicators_dict) == dict
     assert list(indicators_dict.keys()) == tickers_list
Пример #8
0
 def test_get_stock_indicators_should_return_list_of_tuples(self):
     indicators = YubbExtractor.get_stock_indicators('SEER3')
     assert type(indicators) == list
     assert type(indicators[0]) == tuple