Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions isthisstockgood/Active/Zacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,13 @@ def get_growth_rate(self, text):
if "Next 5 Years" in line:
result = lines[i+1]

if "NA" not in result:
estimate = re.sub(r"[^\d\.]", "", result)
return float(estimate)

for i, line in enumerate(lines):
if "Next Year (" in line:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The opening bracket is important. Earlier on the page, "Next Year" appears in another context, and there it lacks the parentheses.

result = lines[i+1]

estimate = re.sub(r"[^\d\.]", "", result)
return float(estimate)
10 changes: 8 additions & 2 deletions isthisstockgood/DataFetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ def fetchDataForTickerSymbol(ticker):
zacks_analysis = data_fetcher.zacks_analysis
# NOTE: Some stocks won't have analyst growth rates, such as newly listed stocks or some foreign stocks.
five_year_growth_rate = \
yahoo_finance_analysis.five_year_growth_rate if yahoo_finance_analysis \
else zacks_analysis.five_year_growth_rate if zacks_analysis \
yahoo_finance_analysis.five_year_growth_rate if (
yahoo_finance_analysis
and yahoo_finance_analysis.five_year_growth_rate
) \
else zacks_analysis.five_year_growth_rate if (
zacks_analysis
and zacks_analysis.five_year_growth_rate
) \
else 0
margin_of_safety_price, sticker_price = _calculateMarginOfSafetyPrice(
msn_money.equity_growth_rates[-1],
Expand Down
6 changes: 3 additions & 3 deletions isthisstockgood/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def get_logger():
def create_app(fetchDataForTickerSymbol):
app = Flask(__name__)

@app.route('/api/ticker/nvda')
def api_ticker():
template_values = fetchDataForTickerSymbol("NVDA")
@app.route('/api/ticker/<ticker>')
def api_ticker(ticker):
template_values = fetchDataForTickerSymbol(ticker)

if not template_values:
data = render_template('json/error.json', **{'error' : 'Invalid ticker symbol'})
Expand Down
2 changes: 1 addition & 1 deletion tests/test_DataSources.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def test_msn_money():
test_ticker = 'MSFT'
test_name = 'Microsoft Corp'
test_name = 'Microsoft Corporation'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data returned from the source changed.


data = get_msn_money_data(test_ticker)

Expand Down
4 changes: 4 additions & 0 deletions tests/test_Zacks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from isthisstockgood.Active.Zacks import Zacks

def test_zacks():
zacks = Zacks("TSLA")
Loading