Giter Club home page Giter Club logo

finvizfinance's Introduction

Hi 👋 I am Tianning Li

I am a developer who is passionate about stuff like data science, machine learning, web programming and financial analysis. Few tech that I enjoy working in are Python, React.js, React Native, Typescript.

  • 😊 Willing to contribute in opensource development projects.
  • 🌐 Visit my porfolio website for complete background and contact.
  • 👍 View my project list.
😇 My Github Stats:

finvizfinance's People

Contributors

adammuzz avatar aliziauddin avatar faultfactory avatar fyzyx avatar huzaifazahoor avatar lit26 avatar seekerc137 avatar the-praxs avatar vikyw89 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

finvizfinance's Issues

JSONDecodeError("Expecting value", s, err.value)

I am getting this error when I try to execute the performance function of the Future class

from finvizfinance import future

def perform():

    fut = future.Future()
    fut.performance(timeframe="W")

perform()

this is what i get

Traceback (most recent call last): File "/home/TBot/table.py", line 9, in <module> perform() File "/home/TBot/table.py", line 7, in perform fut.performance(timeframe="W") File "/home/TBot/env/lib/python3.7/site-packages/finvizfinance/future.py", line 49, in performance data = json.loads(data.strip()[:-1]) File "/usr/lib/python3.7/json/__init__.py", line 348, in loads return _default_decoder.decode(s) File "/usr/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I would also like to add that it would be convenient to have a quote function for each of the indices. I've been looking a bit and I think it's not implemented.

ENH: Handle Finviz night mode

Is your feature request related to a problem?

Failed to get stock fundamental data due to DOM change when Finviz automaticaly chalange UI with night mode

Describe the solution you'd like

Externally no changes should be observed

API breaking implications

No API change is required

Describe alternatives you've considered

Force day mode of handle night mode

Additional context

Night mode representation:

MSFT | Microsoft Corporation | [NASD] Technology | Software - Infrastructure | USA There is only 2 table rows (code calls for 3rd one)
# Your code here, if applicable

BUG: If finviz doesnt have ratings table ticker_full_info() fails

finvizfinance version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the master branch of finvizfinance.

Reproducible Example

x = finvizfinance('acon')
x.ticker_full_info()

Issue Description

Traceback (most recent call last):

File "C:\Users\chris\AppData\Local\Temp\ipykernel_20800\477896250.py", line 1, in
x2 = x.ticker_full_info()

File "C:\Users\chris\anaconda3\lib\site-packages\finvizfinance\quote.py", line 377, in ticker_full_info
self.ticker_outer_ratings()

File "C:\Users\chris\anaconda3\lib\site-packages\finvizfinance\quote.py", line 233, in ticker_outer_ratings
rows = fullview_ratings_outer.findAll("td", class_="fullview-ratings-inner")

AttributeError: 'NoneType' object has no attribute 'findAll'

Expected Behavior

I think you should have the results return with the ratings with an empty dataframe or a nonetype

Installed Versions

(base) C:\Users\chris>pip show finvizfinance
Name: finvizfinance
Version: 0.14.4
Summary: Finviz Finance. Information downloader.
Home-page: https://github.com/lit26/finvizfinance
Author: Tianning Li
Author-email: [email protected]
License: The MIT License (MIT)
Location: c:\users\chris\anaconda3\lib\site-packages
Requires: bs4, datetime, lxml, pandas, requests
Required-by:

Multiple exchange option

Hi,

How I can choose to download info only on two exchanges? i.e. NYSE and NASDAQ?

I tried something like:

[foverview = Overview()
filters_dict = {'Exchange': 'NYSE', 'Exchange': 'NASDAQ'}
foverview.set_filter(filters_dict=filters_dict)
df = foverview.ScreenerView()](url)

But it looks that it downloads info based only on the second filter.

FINVIZFINANCE ISSUE WHEN GETTING TICKER INFO

When I use:

from finvizfinance.quote import finvizfinance

stock = finvizfinance('tsla')
stock.ticker_fundament()

I get:

IndexError Traceback (most recent call last)
stock = finvizfinance('tsla')
stock.ticker_fundament()

in finvizfinance.ticker_fundament(self, raw, output_format)
134 rows = table.findAll("tr")
136 fundament_info["Company"] = rows[1].text
137 (
138 fundament_info["Sector"],
139 fundament_info["Industry"],
140 fundament_info["Country"],
--> 141 ) = rows[2].text.split(" | ")
143 fundament_table = self.soup.find("table", class_="snapshot-table2")
144 rows = fundament_table.findAll("tr")

IndexError: list index out of range

Any clue???

screener_view List index out of range

Right now when I call valuation.Valuation().screener_view(), and using the default value, an error is thrown:

  File "/Users/minh/Desktop/DareData/GameStonk/GamestonkTerminal/openbb_terminal/economy/finviz_model.py", line 34, in get_valuation_performance_data
    return valuation.Valuation().screener_view(group=group)
  File "/Users/minh/.virtualenvs/gst/lib/python3.9/site-packages/finvizfinance/group/overview.py", line 97, in screener_view
    info_dict[table_header[i]] = col.text

'Overview' object has no attribute 'ScreenerView'

Hi I am running the example in the documentation and I am getting this error

from finvizfinance.screener.overview import Overview

foverview = Overview()
filters_dict = {'Index': 'S&P 500'}
foverview.set_filter(filters_dict=filters_dict)
df = foverview.ScreenerView()


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/var/folders/7g/gr9fl0cx43g5f42xf78n_str0000gn/T/ipykernel_59856/4129785455.py in <module>
      2 filters_dict = {'Index': 'S&P 500'}
      3 foverview.set_filter(filters_dict=filters_dict)
----> 4 df = foverview.ScreenerView()

AttributeError: 'Overview' object has no attribute 'ScreenerView'

I cannot understand the reason.

BUG: screener_view not retrieving any results

finvizfinance version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the master branch of finvizfinance.

Reproducible Example

overview = Overview()
    filters_dict = {'Index':'S&P 500','Sector':'Basic Materials'}
    overview.set_filter(filters_dict=filters_dict)
    df = overview.screener_view()
    df.head()

Issue Description

Hi,

unfortunately somehow I am not getting any results any more using the Screener.
Strangely it is still downloading something but the response is only a empty Dataframe with defined Columns regarding the different views.

See the example here:

grafik

Expected Behavior

Expected Result is a DataFrame with the content of finviz pages (Overview / Custom / Performance) etc.

Installed Versions

'0.12.2'

BUG: missing Ticker: X when filters_dict = {'Sector':'Basic Materials','Market Cap.':'Mid ($2bln to $10bln)'}

finvizfinance version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the master branch of finvizfinance.

Reproducible Example

from finvizfinance.screener.overview import Overview

filters_dict = {'Sector':'Basic Materials','Market Cap.':'Mid ($2bln to $10bln)'}
foverview.set_filter(filters_dict=filters_dict)
df = foverview.screener_view()
df

Issue Description

The last row is missing "Ticker: X", when compare finviz website

Expected Behavior

include "Ticker:X" in last row.

Installed Versions

finvizfinance in /jupyter/notebookenv/lib/python3.10/site-packages (0.14.3)

Persistant bug related to night mode

The fix for issue #73 is apparently not complete

pip list|grep finvizfinance
finvizfinance       0.14.6rc1

and when calling the finvizfinance(ticker=ticker).ticker_fundament() function, I get an error in the exception handler:

  File "/home/eric/.local/lib/python3.11/site-packages/finvizfinance/quote.py", line 142, in ticker_fundament
    ) = rows[2].text.split(" | ")
        ~~~~^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/eric/dev/polygon/yahoo.py", line 95, in <module>
    analyzeStock("MRVL")
  File "/home/eric/dev/polygon/yahoo.py", line 65, in analyzeStock
    quote=finvizfinance(ticker=ticker).ticker_fundament()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/eric/.local/lib/python3.11/site-packages/finvizfinance/quote.py", line 145, in ticker_fundament
    (_, fundament_info["Company"], _) = rows[0].text.split(' | ')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 3, got 2)

Adding a trace on print (rows[1].text) and print (rows[2].text) prints this:

Technology | Semiconductors | USA | NASD
Cannot parse Company, Sector, Industry and Country

BUG: News Feed Date Issue (text being returned with 'today' rather than date etc)

finvizfinance version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the master branch of finvizfinance.

Reproducible Example

from finvizfinance.quote import finvizfinance

stock = finvizfinance('tsla')
news_df = stock.ticker_news()
print(news_df)

Issue Description

Presents error - ValueError: time data 'Today 07:10AM' does not match format '%b-%d-%y %I:%M%p'

Expected Behavior

Should construct datafame with Date Column

Installed Versions

finvizfinance 0.14.5

QST: How to fetch historical futures data?

Question about finvizfinance

Hi,
I have to fetch futures ( SP 500) data for 20 years with 1h tick?

Alternatively, do you know from where I can fetch historical data?

New "Maps" feature in screener view is messing up the columns that are pulled when using finviz screener

Code has been working for months. However, now that the new maps feature was added, the screener_view functionality is no longer working.

This is the code I am using:
foverview = Custom()
cols = list(range(0, 68))
filters_dict = {'Market Cap.':'+Mid (over $2bln)','RSI (14)':'Oversold (40)'}
#filters_dict = {'Market Cap.':'+Mid (over $2bln)'}
foverview.set_filter(filters_dict=filters_dict)
df = foverview.screener_view(order='LT Debt/Equity', columns=cols)

And it is pulling these columns, instead of the correct ones:
Valuation | Financial | Ownership | Performance | Technical | Custom | Charts | Tickers | Basic | TA | News | Snapshot | \n\n\nMaps\r\n | Stats

Suggestion - timeout for scrapoing

Hi thanks for the time here, im thinking of using your library, one suggestion:
In the Util.py - webscrap
website = requests.get(url, headers=headers)
You may want to setup a timeout, as this helps handle different use cases.
better if its handled from the Object constructor as an optional parameter.

Thanks again.

Issue with screener

I tried the same code as in the README file and I got this on Google Colab:
Screenshot_2021-01-10_16-02-28

FinViz Fundamentals

Hello,
It seems as if the FinViz fundamentals endpoint has lost functionality, and I can't seem to get the new code to work correctly

Here is the code:

from finvizfinance.quote import finvizfinance
stock = finvizfinance(ticker)
stock_fundamentals = stock.ticker_fundament()
print(stock_fundamentals)

Here is the error:
AttributeError: 'finvizfinance' object has no attribute 'ticker_fundament

Thank you!

Weekly chart not downloading

When I write stock.TickerCharts('weekly'), it is only downloading the daily timeframe chart and not the weekly chart

Change% bad interpretation

I ran into the following error. in the column of Change% does not interpret the amount well.
This error occurs in both the overview and Custom modules. I have not tried the others.

Screenshot 2021-02-26 at 15

Screenshot 2021-02-26 at 15 (1)

Remove systemexit

Problem:

I would like to iterate over the finvizfinance(ticker) but since the SystemExit is present in the webScrap function, when there is an exception I cannot capture it, and the program simply exits:

    try:
        website = requests.get(url, headers=headers)
        website.raise_for_status()
        soup = BeautifulSoup(website.text, 'lxml')
    except requests.exceptions.HTTPError as err:
        raise SystemExit(err)
    return soup

Solution:

  • Change the exception type (e.g. LookupError, NameError,...)

screener - list index out of range

File "market_alerts.py", line 71, in getAlerts
df = foverview.ScreenerView(verbose=False)
File "/home/wallace/.local/lib/python3.8/site-packages/finvizfinance/screener/overview.py", line 232, in ScreenerView
page = self._get_page(soup)
File "/home/wallace/.local/lib/python3.8/site-packages/finvizfinance/screener/overview.py", line 178, in _get_page
options = soup.findAll('table')[17].findAll('option')
IndexError: list index out of range

I'm receiving index out of range errors seemingly at random. Any idea if this is FinViz not returning expected results or if this is something that can be solved for?

ENH: Extra Columns Available for Custom Table

Some columns are not available in the 'Custom' table.
finvizfinance provides columns 0 to 70

But finviz has a few more columns:
https://finviz.com/screener.ashx?v=152&c=73,%2075,%2076,%2077,%2078,%2079,%2080,%2081,%2082,%2083,%2084,%2085,%2086,%2087,%2088

non_implemented_col_ids = [73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88]

EXTRA_COLUMNS = {
 73 : 'Book Value per Share',
 75 : 'Dividend',
 76 : 'Employees',
 ...
 86 : 'Open'
 87 : 'High',
 88 : 'Low',
}

For the sake of cleanness, completeness and because this is an easy fix,
I was going to fiddle with the base code.
But after seeing that the Sept 28 issue got fixed very quickly (big up @lit26 !), it may be better to implement this properly in the original code?

Any chance to see this implemented soon?

BUG: screener limit is not working

finvizfinance version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the master branch of finvizfinance.

Reproducible Example

from finvizfinance.screener.overview import Overview

foverview = Overview()
filters_dict = {'Index':'S&P 500'}
foverview.set_filter(filters_dict=filters_dict)
df = foverview.screener_view(order="ticker",ascend=False, limit=41)

Issue Description

Screener limit parameter is not working

Expected Behavior

Screener limit parameter should limit the rows.

Installed Versions

0.14.3

BUG: Insider Page is not giving the error.

finvizfinance version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the master branch of finvizfinance.

Reproducible Example

from finvizfinance.insider import Insider
finsider = Insider()
insider_trader_df = finsider.get_insider()

Issue Description

Whenever we call the Insider() class. It throws a below error:

AttributeError: 'NoneType' object has no attribute 'findAll'

I think it is throwing the error because of Finviz Restrictions to get only the insider data from the insider page. You should use different user agents to see, how we can make this work.

Expected Behavior

It should get the Data Frame, like how you have used it. Please work on it.

Installed Versions

finvizfinance.0.14.1

How do you get Industry filter?

Hello, thanks for the package!

I am wondering how do you get Industries?

in code:

filters_dict = {'Industry': "Silver"}
    performance = Performance()
    performance.set_filter(filters_dict=filters_dict)
    df = performance.ScreenerView()
    return df

Where do you get the proper filter for that industry? ind_silver

I want to make list of all filters, but I can't find them in your code. How do you generate filters?

Thanks

scanner method

Hi Is there a way to add a reply to line 192 of overview.py

            raise ValueError("Invalid order {} .Possible values are {}".format (order,  self.getOrders()))

Please excuse the syntax error.

The same for line 73

And line 41.

Screneer pagination

Hi!

Is it possible to provide pagination to the screener?
I'm using the Custom class in this way:

from finvizfinance.screener.custom import Custom

filters = {...something here}

foverwiew = Custom()
foverwiew.set_filter(filters_dict=filters)
df = foverwiew.ScreenerView(limit=20, order='Change',ascend=False, columns[0,1,2,3,4,5,6,7,16,17,22,23,33,36,37,38,65,66,67,68])

The problem is that I have to set a limit, otherwise the request could take too much time to be executed.
Is there a way to add pagination?

Thank you so much.

BUG: failed to generate ticker outer ratings

finvizfinance version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the master branch of finvizfinance.

Reproducible Example

>>> ticker = 'PLTR'
>>> stock = finvizfinance(ticker)
>>> outer_ratings_df = stock.ticker_outer_ratings()
>>> print (outer_ratings_df)
None

Issue Description

its 'None' irrespective of ticker

Expected Behavior

dataframe of analyst ratings

Installed Versions

Replace this line with the output of finvizfinance.version

BUG: Insider SEC Form 4 Link 'NoneType' object has no attribute 'attrs’

finvizfinance version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the master branch of finvizfinance.

Reproducible Example

from finvizfinance.insider import Insider

finsider = Insider(option='latest')
insider_trader = finsider.get_insider()

Issue Description

Whenever we call the get_insider(). It throws a below error:

File “finvizfinance/insider.py”, line 81, in get_insider
info_dict[“SEC Form 4 Link”] = col.find(“a”).attrs[“href”]
AttributeError: 'NoneType' object has no attribute 'attrs’

Expected Behavior

Get the Insider data

Installed Versions

finvizfinance 0.14.3

Options in the arguments of the function

Hi, thanks for the very useful library.

But something that is missing in the documentation is that is not clear what are the options

In this example

from finvizfinance.screener.overview import Overview

foverview = Overview()
filters_dict = {'Index':'S&P 500','Sector':'Basic Materials'}
foverview.set_filter(filters_dict=filters_dict)
df = foverview.ScreenerView()
df.head()

Cannot understand where I can find the number of different indices and the related information that can be filtered or passed as arguments.

ENH: Screener Feature Request: url converter instead of manually filter list.

Is your feature request related to a problem?

For the overview feature, won't it be better if you just take the given link and obtain stocks list from the link ? Is kind of taking much more works to copy each filter criterial and put them into a dict by clients.

Describe the solution you'd like

Accpet clients url , and crawl the filtered list given by the url.

API breaking implications

for instance, Overview (url = 'https://finviz.com/screener.ashx?v=111&f=idx_sp500,sh_avgvol_u500') , you write the class method "_convert_url_dict" that turn the specific argument from the link into a filter dict internally, and then set it as the filter dict to Overview().

User Code Example :

foverview = Overview(url = 'https://finviz.com/screener.ashx?v=111&f=idx_sp500,sh_avgvol_u500')
df = foverview.screener_view()
df.head()

Screeners not pulling any data

Hi,

I am trying to import technical data from finviz using the following piece of code:

from finvizfinance.screener.technical import Technical

finviz_scan_technical = Technical()
technical_df = finviz_scan_technical.screener_view()

But the output says 'No Tickers found.'. As you can see, I have not set any filters but still the function is not retrieving any data.
Did some setting change on finviz's side to cause this failure?

Btw, I am using version "0.11.0"

Thanks

table change for overview

Hey @lit26, within group.overview the table value on line 85 needs to be changed. Currently this is set to table = soup.findAll("table")[5] but should be table = soup.findAll("table")[7]. Could you fix this minor detail please?

Asc and Desc sort options

Hello, is it currently possible to use Asc or Desc for sorting?
The default is Asc, would it be possible to change it to Desc if needed?
I've attempted order=ticker asc & order=ticker desc but no luck there. seems only the criteria order is respected not the sort

Current

foverview.ScreenerView(order='Analyst Recommendation', limit=limit)

Want?

foverview.ScreenerView(order='Analyst Recommendation', sort='asc', limit=limit)

(Willing to make a PR if I could get some direction 😅 )

BUG: Use of deprecated pandas function

finvizfinance version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the master branch of finvizfinance.

Reproducible Example

def scan():
    overview = Overview()
    overview.set_filter(filters_dict={
        'Price': 'Over $15',
        'Average Volume': 'Over 2M',
        'Average True Range': 'Over 1.5',
    })
    return overview.screener_view()

Issue Description

This spits out warnings about using append() as it has been deprecated in favor of concat()

frame.append method is deprecated and will be removed from pandas in a future version.

Expected Behavior

Should not use deprecated method.

Installed Versions

0.14.1

error message

Every polling leads to this response from finvizfinance:
\nsave as portfolio | \ncreate alert \nRefresh: 3min | off \n\nPage 1/2Page 2/2\n

BUG:

finvizfinance version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the master branch of finvizfinance.

Reproducible Example

stock_fundament = stock.ticker_fundament()

#Currently produces a index error: list index out of range

Issue Description

stock_fundament = stock.ticker_fundament() does not currently function. Index error: list index out of range. I believe this is due to Finviz updating their website.

Expected Behavior

The expexted behavior is that the finviz fundementals for a give stock ticker would be added to stock_funament.

Installed Versions

Replace this line with the output of finvizfinance.__version__4.5.0

ImportError: cannot import name 'finviznews' from 'finvizfinance.news'

Following along with the README.md. Importing and calling anything from finvizfinance.quote work perfectly, but importing finvizfinance.news give me:
ImportError: cannot import name 'finviznews' from 'finvizfinance.news'

The issue is that the News class in finvizfinance.news has been renamed. The fix is either to update the README.md file to alias the news module: from finvizfinance.news import News as finviznews, or to otherwise account for the re-name.

BUG: ticker news 'NoneType' object has no attribute 'text'

finvizfinance version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the master branch of finvizfinance.

Reproducible Example

from finvizfinance.news import News
fnews = News()
all_news = fnews.get_news()

Issue Description

ticker news 'NoneType' object has no attribute 'text'

Expected Behavior

Return news df

Installed Versions

Replace this line with the output of finvizfinance.version

table change for ticker_fundament

for the function ticker_fundament, please change the following line :

original:
table = self.soup.findAll("table")[4]

new:
table = self.soup.findAll("table")[6]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.