Created
August 2, 2020 15:46
-
-
Save shashankvemuri/d9653da78945ff585e09c2f2ff554dfc to your computer and use it in GitHub Desktop.
Python Code
This file contains hidden or 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
import requests | |
import yahoo_fin.stock_info as si | |
from flask import render_template | |
def get_balance_sheet(ticker): | |
try: | |
def get_symbol(symbol): | |
url = "http://d.yimg.com/autoc.finance.yahoo.com/autoc?query={}®ion=1&lang=en".format(symbol) | |
result = requests.get(url).json() | |
for x in result['ResultSet']['Result']: | |
if x['symbol'] == symbol: | |
return x['name'] | |
company_name = get_symbol(ticker.upper()) | |
df = si.get_balance_sheet(ticker) | |
return render_template('balanceSheetOutput.html', company_name=company_name, tables=[df.to_html(classes='data center table-sortable', index=False)], titles=df.columns.values) | |
except Exception as e: | |
return render_template('error.html', e = e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment