💵 Invest check
This commit is contained in:
26
funcs/games/invest.py
Normal file
26
funcs/games/invest.py
Normal file
@ -0,0 +1,26 @@
|
||||
import finnhub
|
||||
|
||||
finnhubClient = finnhub.Client(api_key = "bsm16nvrh5rdb4ara3j0")
|
||||
|
||||
def getPrice(symbol : str):
|
||||
res = finnhubClient.quote(symbol.upper())
|
||||
if res == {}:
|
||||
return 0
|
||||
else:
|
||||
print(res)
|
||||
return int(res["c"] * 100)
|
||||
|
||||
def getPortfolio(user : str):
|
||||
return None
|
||||
|
||||
def parseInvest(content: str, user : str):
|
||||
if content.startswith("check"):
|
||||
commands = content.split(" ")
|
||||
if len(commands) == 1:
|
||||
return getPortfolio(user)
|
||||
else:
|
||||
price = getPrice(commands[1])
|
||||
if price == 0:
|
||||
return f"{commands[1].upper()} is not traded on the american market."
|
||||
else:
|
||||
return "The current "+commands[1].upper()+" stock is valued at **"+str(price)+"** GwendoBucks"
|
Reference in New Issue
Block a user