-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,8 @@ | |
.. moduleauthor:: Tianning Li <[email protected]> | ||
""" | ||
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. | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = '[email protected]' | ||
|