fix stock
All checks were successful
Build and push / changes (push) Successful in 4s
Build and push / Lint-Python (push) Successful in 2s
Build and push / Build-and-Push-Docker (push) Successful in 1m3s
Build and push / sync-argocd-app (push) Successful in 3s
Build and push / post-status-to-discord (push) Successful in 2s
All checks were successful
Build and push / changes (push) Successful in 4s
Build and push / Lint-Python (push) Successful in 2s
Build and push / Build-and-Push-Docker (push) Successful in 1m3s
Build and push / sync-argocd-app (push) Successful in 3s
Build and push / post-status-to-discord (push) Successful in 2s
This commit is contained in:
parent
cd324a4be7
commit
02ab5fa300
10
app/stock.py
10
app/stock.py
@ -2,6 +2,8 @@ import discord
|
|||||||
import yfinance as yf
|
import yfinance as yf
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import pprint
|
||||||
|
|
||||||
|
|
||||||
def parse_message(symbols, verbose):
|
def parse_message(symbols, verbose):
|
||||||
embeds = []
|
embeds = []
|
||||||
@ -99,9 +101,11 @@ def get_stock(share_name, verbose=False, fast=False):
|
|||||||
current_price = request["lastPrice"]
|
current_price = request["lastPrice"]
|
||||||
else:
|
else:
|
||||||
request = yf.Ticker(share_name).info
|
request = yf.Ticker(share_name).info
|
||||||
current_change = request["currentPrice"] - request["open"]
|
# pprint.pprint(request)
|
||||||
current_price = request["currentPrice"]
|
current_change = request["ask"] - request["open"]
|
||||||
except Exception:
|
current_price = request["ask"]
|
||||||
|
except Exception as e:
|
||||||
|
# print(e)
|
||||||
raise ValueError("Invalid symbol %s: empty response from Yahoo" % share_name)
|
raise ValueError("Invalid symbol %s: empty response from Yahoo" % share_name)
|
||||||
|
|
||||||
# If stock price has gone down since open, use red and a sad stonk meme
|
# If stock price has gone down since open, use red and a sad stonk meme
|
||||||
|
Loading…
x
Reference in New Issue
Block a user