Adding shares outstanding and aligning things
This commit is contained in:
parent
afcf7d4ab9
commit
b8b0710b96
32
app/stock.py
32
app/stock.py
@ -16,28 +16,30 @@ def parse_message(msg):
|
||||
|
||||
def get_stock(share_name):
|
||||
share_name = share_name.upper()
|
||||
token = os.getenv('stock_api_key')
|
||||
request_string = "https://fmpcloud.io/api/v3/quote/%s?apikey=%s" % (share_name, token)
|
||||
request = requests.get(request_string).json()[0]
|
||||
request_string = "https://query1.finance.yahoo.com/v7/finance/quote?lang=en-US®ion=US&corsDomain=finance.yahoo.com&symbols=%s" % share_name
|
||||
request = requests.get(request_string).json()['quoteResponse']['result'][0]
|
||||
|
||||
change_symbol = '+'
|
||||
embed_color = 2067276
|
||||
meme_url = 'https://i.ytimg.com/vi/if-2M3K1tqk/hqdefault.jpg'
|
||||
if float(request['price']) < float(request['open']):
|
||||
if float(request['bid']) < float(request['regularMarketOpen']):
|
||||
change_symbol = '-'
|
||||
embed_color = 15158332
|
||||
meme_url = 'https://i.ytimg.com/vi/E_XlA_IEzwM/hqdefault.jpg'
|
||||
|
||||
embed = discord.Embed(description='Stock info', color=embed_color, type="rich")
|
||||
embed = discord.Embed(description='-------', color=embed_color, type="rich")
|
||||
embed.set_thumbnail(url=meme_url)
|
||||
embed.set_author(name=request['name'])
|
||||
embed.add_field(name='Current Price', value=request['price'], inline=False)
|
||||
embed.add_field(name='Previous Close', value=request['previousClose'], inline=False)
|
||||
embed.add_field(name='Opening price', value=request['open'], inline=False)
|
||||
embed.add_field(name='Change', value=request['change'], inline=False)
|
||||
embed.add_field(name='Change percent', value="%s%%" % request['changesPercentage'], inline=False)
|
||||
embed.add_field(name='Day Low', value=request['dayLow'], inline=False)
|
||||
embed.add_field(name='Day High', value=request['dayHigh'], inline=False)
|
||||
embed.set_footer(text="Pulled from https://fmpcloud.io", icon_url='https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/emojidex/112/chart-with-downwards-trend_1f4c9.png')
|
||||
|
||||
embed.set_author(name=request['longName'])
|
||||
embed.add_field(name='Current Price', value="$%s" % request['bid'], inline=False)
|
||||
embed.add_field(name='Previous Close', value="$%s" % request['regularMarketPreviousClose'], inline=False)
|
||||
embed.add_field(name='Opening price', value="$%s" % request['regularMarketOpen'], inline=False)
|
||||
embed.add_field(name='Change', value="$%s" % request['regularMarketChange'], inline=False)
|
||||
embed.add_field(name='Change percent', value="%s%%" % request['regularMarketChangePercent'], inline=False)
|
||||
embed.add_field(name='Day Low', value="$%s" % request['regularMarketDayLow'], inline=False)
|
||||
embed.add_field(name='Day High', value="$%s" % request['regularMarketDayHigh'], inline=False)
|
||||
embed.add_field(name='Day\'s Range', value=request['regularMarketDayRange'], inline=False)
|
||||
embed.add_field(name='Market Cap', value=request['marketCap'], inline=False)
|
||||
embed.add_field(name='Shares Outstanding', value=request['sharesOutstanding'], inline=False)
|
||||
embed.set_footer(text="Pulled from https://finance.yahoo.com", icon_url='https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/emojidex/112/chart-with-downwards-trend_1f4c9.png')
|
||||
|
||||
return embed
|
Loading…
x
Reference in New Issue
Block a user