Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not show 0 prices #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 33 additions & 10 deletions finviz/main_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def get_analyst_price_targets(ticker, last_ratings=5):
if count == last_ratings:
break
# defalut values for len(row) == 4 , that is there is NO price information
price_from, price_to = 0, 0
price_from, price_to = "Unknown", "Unknown"
if len(row) == 5:

strings = row[4].split('→')
Expand All @@ -161,15 +161,38 @@ def get_analyst_price_targets(ticker, last_ratings=5):
elements.append(price_from)
elements.append(price_to)

data = {
'date': elements[0],
'category':elements[1],
'analyst': elements[2],
'rating':elements[3],
'price_from':float(price_from),
'price_to':float(price_to)
}

if price_from == "Unknown" and price_to == "Unknown":
data = {
'date': elements[0],
'category':elements[1],
'analyst': elements[2],
'rating':elements[3]
}
elif price_to == "Unknown":
data = {
'date': elements[0],
'category': elements[1],
'analyst': elements[2],
'rating': elements[3],
'price_from': price_from
}
elif price_from == "Unknown":
data = {
'date': elements[0],
'category': elements[1],
'analyst': elements[2],
'rating': elements[3],
'price_to': price_to
}
else:
data = {
'date': elements[0],
'category':elements[1],
'analyst': elements[2],
'rating':elements[3],
'price_from':price_from,
'price_to':price_to
}
analyst_price_targets.append(data)
count += 1
except Exception as e:
Expand Down