diff --git a/docs/conf.py b/docs/conf.py index 3dea84f..15990cb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,7 @@ author = 'Tianning Li' # The full version, including alpha/beta/rc tags -release = '0.9.7' +release = '0.9.8' # -- General configuration --------------------------------------------------- diff --git a/finvizfinance/quote.py b/finvizfinance/quote.py index 83a853b..40d38e9 100644 --- a/finvizfinance/quote.py +++ b/finvizfinance/quote.py @@ -10,7 +10,8 @@ .. moduleauthor:: Tianning Li """ QUOTE_URL = 'https://finviz.com/quote.ashx?t={ticker}' - +NUM_COL = ['P/E', 'EPS (ttm)', 'Insider Own', 'Shs Outstand', 'Market Cap', 'Forward P/E', + 'EPS nest Y', 'Insider '] class Quote: """quote @@ -90,9 +91,12 @@ def TickerCharts(self, timeframe='daily', charttype='advanced', out_dir='', urlo imageScrap(chart_url, self.ticker, out_dir) return chart_url - def TickerFundament(self): + def TickerFundament(self, raw=True): """Get ticker fundament. + Args: + raw(boolean): if True, the data is raw. + Returns: fundament(dict): ticker fundament. """ @@ -115,10 +119,53 @@ def TickerFundament(self): if i % 2 == 0: header = value else: - fundament_info[header] = value + if header == 'Volatility': + fundament_info = self._parse_volatility(header, fundament_info, value, raw) + elif header == '52W Range': + fundament_info = self._parse_52w_range(header, fundament_info, value, raw) + elif header == 'Optionable' or header == 'Shortable': + if raw: + fundament_info[header] = value + elif value == 'Yes': + fundament_info[header] = True + else: + fundament_info[header] = False + else: + if raw: + fundament_info[header] = value + else: + try: + fundament_info[header] = numberCovert(value) + except ValueError: + fundament_info[header] = value self.info['fundament'] = fundament_info return fundament_info + def _parse_52w_range(self, header, fundament_info, value, raw): + info_header = ['52W Range From', '52W Range To'] + info_value = [0, 2] + self._parse_value(header, fundament_info, value, raw, info_header, info_value) + return fundament_info + + def _parse_volatility(self, header, fundament_info, value, raw): + info_header = ['Volatility W', 'Volatility M'] + info_value = [0, 1] + self._parse_value(header, fundament_info, value, raw, info_header, info_value) + return fundament_info + + def _parse_value(self, header, fundament_info, value, raw, info_header, info_value): + try: + value = value.split() + if raw: + for i, value_index in enumerate(info_value): + fundament_info[info_header[i]] = value[value_index] + else: + for i, value_index in enumerate(info_value): + fundament_info[info_header[i]] = numberCovert(value[value_index]) + except: + fundament_info[header] = value + return fundament_info + def TickerDescription(self): """Get ticker description. diff --git a/release.md b/release.md index 4141f63..15277d1 100644 --- a/release.md +++ b/release.md @@ -1,5 +1,6 @@ | Date | Version | Comment | | ------------- | ------------- | ------------- | +| 2021/05/08 | 0.9.8 | Adding data type in Quote file.| | 2021/04/27 | 0.9.7 | Update Value Error message https://github.com/lit26/finvizfinance/issues/23. Adding insider options https://github.com/lit26/finvizfinance/pull/22 | | 2021/04/18 | 0.9.6 | Increase performance and add timeout https://github.com/lit26/finvizfinance/issues/21.| | 2021/04/14 | 0.9.5 | Add quarterly statements https://github.com/lit26/finvizfinance/issues/19.| diff --git a/setup.py b/setup.py index 8928226..d82494b 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ HERE = pathlib.Path(__file__).parent -VERSION = '0.9.7' +VERSION = '0.9.8' PACKAGE_NAME = 'finvizfinance' AUTHOR = 'Tianning Li' AUTHOR_EMAIL = 'ltianningli@gmail.com'