Skip to content

Commit

Permalink
update version 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
lit26 committed Oct 15, 2021
1 parent fc0d59a commit ee89528
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Tianning Li'

# The full version, including alpha/beta/rc tags
release = '0.9.10'
release = '0.10'


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion finvizfinance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
.. moduleauthor:: Tianning Li <[email protected]>
"""

__version__ = "0.9.9"
__version__ = "0.10"
__author__ = "Tianning Li"
98 changes: 98 additions & 0 deletions finvizfinance/group/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import pandas as pd
from finvizfinance.util import webScrap, numberCovert
from finvizfinance.group.overview import Overview
"""
.. module:: group.custom
:synopsis: group custom table.
.. moduleauthor:: Tianning Li <[email protected]>
"""


COLUMNS = {
0: 'No.',
1: 'Name',
2: 'Market Cap.',
3: 'P/E',
4: 'Forward P/E',
5: 'PEG',
6: 'P/S',
7: 'P/B',
8: 'P/Cash',
9: 'P/Free Cash Flow',
10: 'Dividend Yield',
11: 'EPS growth past 5 years',
12: 'EPS growth next 5 years',
13: 'Sales growth past 5 years',
14: 'Shares Float',
15: 'Performance (Week)',
16: 'Performance (Month)',
17: 'Performance (Quarter)',
18: 'Performance (Half Year)',
19: 'Performance (Year)',
20: 'Performance (YearToDate)',
21: 'Analyst Recom.',
22: 'Average Volume',
23: 'Relative Volume',
24: 'Change',
25: 'Volume',
26: 'Number of Stocks'
}


class Custom(Overview):
"""Custom inherit from overview module.
Getting information from the finviz group custom page.
"""
def __init__(self):
"""initiate module
"""
self.BASE_URL = 'https://finviz.com/groups.ashx?{group}&v=152'
self.url = self.BASE_URL.format(group='g=sector')
Overview._loadSetting(self)

def getColumns(self):
"""Get information about the columns
Returns:
columns(dict): return the index and column name.
"""
return COLUMNS

def ScreenerView(self, group='Sector', order='Name', columns=[0, 1, 2, 3, 10, 22, 24, 25, 26]):
"""Get screener table.
Args:
group(str): choice of group option.
order(str): sort the table by the choice of order.
columns(list): columns of your choice. Default index: 0, 1, 2, 3, 10, 22, 24, 25, 26.
Returns:
df(pandas.DataFrame): group information table.
"""
if group not in self.group_dict:
raise ValueError()
if order not in self.order_dict:
raise ValueError()
self.url = self.BASE_URL.format(group=self.group_dict[group])+'&'+self.order_dict[order]
columns = [str(i) for i in columns]
self.url += '&c=' + ','.join(columns)

soup = webScrap(self.url)
table = soup.findAll('table')[6]
rows = table.findAll('tr')
table_header = [i.text for i in rows[0].findAll('td')][1:]
df = pd.DataFrame([], columns=table_header)
rows = rows[1:]
num_col_index = [i for i in range(2, len(table_header))]
for row in rows:
cols = row.findAll('td')[1:]
info_dict = {}
for i, col in enumerate(cols):
# check if the col is number
if i not in num_col_index:
info_dict[table_header[i]] = col.text
else:
info_dict[table_header[i]] = numberCovert(col.text)

df = df.append(info_dict, ignore_index=True)
return df
4 changes: 2 additions & 2 deletions finvizfinance/screener/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.. moduleauthor:: Tianning Li <[email protected]>
"""

columns = {
COLUMNS = {
0: 'No.',
1: 'Ticker',
2: 'Company',
Expand Down Expand Up @@ -100,7 +100,7 @@ def getColumns(self):
Returns:
columns(dict): return the index and column name.
"""
return columns
return COLUMNS

def _screener_helper(self, i, page, rows, df, num_col_index, table_header, limit):
"""Get screener table helper function.
Expand Down
1 change: 1 addition & 0 deletions release.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
| Date | Version | Comment |
| ------------- | ------------- | ------------- |
| 2021/10/14 | 0.10 | Add group group |
| 2021/07/03 | 0.9.10 | Add sec doc link https://github.com/lit26/finvizfinance/issues/26 |
| 2021/07/03 | 0.9.9 | Add calendar module. Fixing import package order. Add package version https://github.com/lit26/finvizfinance/issues/25.|
| 2021/05/08 | 0.9.8 | Adding data type in Quote file.|
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

HERE = pathlib.Path(__file__).parent

VERSION = '0.9.10'
VERSION = '0.10'
PACKAGE_NAME = 'finvizfinance'
AUTHOR = 'Tianning Li'
AUTHOR_EMAIL = '[email protected]'
Expand Down

0 comments on commit ee89528

Please sign in to comment.