update pathy to dale

This commit is contained in:
Luke Robles 2024-03-15 18:13:51 -07:00
parent 8a75d2736f
commit ff21f96352
2 changed files with 22 additions and 15 deletions

View File

@ -85,7 +85,7 @@ def _add_verbose_fields(embed, request):
return embed return embed
def get_stock(share_name, verbose=False): def get_stock(share_name, verbose=False, fast=False):
share_name = share_name.upper() share_name = share_name.upper()
try: try:
@ -93,29 +93,36 @@ def get_stock(share_name, verbose=False):
except OSError as error: except OSError as error:
pass pass
try:
request = yf.Ticker(share_name).fast_info
except Exception as e:
raise ValueError("Invalid symbol %s: empty response from Yahoo" % share_name)
change_symbol = "+" change_symbol = "+"
embed_color = 2067276 embed_color = 2067276
meme_url = "https://i.ytimg.com/vi/if-2M3K1tqk/hqdefault.jpg" meme_url = "https://i.ytimg.com/vi/if-2M3K1tqk/hqdefault.jpg"
# If stock price has gone down since open, use red and a sad stonk meme
current_change = request["lastPrice"] - request["open"]
if current_change < 0:
change_symbol = "-"
embed_color = 15158332
meme_url = "https://i.kym-cdn.com/photos/images/facebook/002/021/567/635.png"
embed = discord.Embed(description="-------", color=embed_color, type="rich") embed = discord.Embed(description="-------", color=embed_color, type="rich")
embed.set_thumbnail(url=meme_url) embed.set_thumbnail(url=meme_url)
embed.set_author(name=share_name) embed.set_author(name=share_name)
try:
if fast:
request = yf.Ticker(share_name).fast_info
current_change = request["lastPrice"] - request["open"]
current_price = request["lastPrice"]
else:
request = yf.Ticker(share_name).info
current_change = request["currentPrice"] - request["open"]
current_price = request["currentPrice"]
except Exception as e:
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
# current_change = request["lastPrice"] - request["open"]
if current_change < 0:
change_symbol = "-"
embed_color = 15158332
meme_url = "https://i.kym-cdn.com/photos/images/facebook/002/021/567/635.png"
embed.add_field( embed.add_field(
name="Current price", name="Current price",
value="$" + format(request["lastPrice"], ",.2f"), value="$" + format(current_price, ",.2f"),
inline=False, inline=False,
) )

View File

@ -75,7 +75,7 @@ volumes:
- name: dale-pics - name: dale-pics
type: nfs type: nfs
server: 192.168.1.119 server: 192.168.1.119
path: /volume1/nas/docker_storage/syncthing-syncthing-claim-pvc-93936d95-4c81-4b85-9f53-cecdd528e7e4/syncthing-configs/Dropbox-mirror/Photos/dale path: /volume1/nas/docker_storage/syncthing-syncthing-claim-pvc-c42f03ae-56f6-498a-9af7-2ee8de1fcdb7/syncthing-configs/Dropbox-mirror/Photos/dale
mountPath: /tmp/dale mountPath: /tmp/dale
env: env: