1
0
mirror of https://gitlab.com/simple-stock-bots/simple-stock-bot.git synced 2025-09-12 16:54:59 +00:00

Mostly wrapped up #75

This commit is contained in:
2021-08-31 20:03:59 -07:00
parent dcce2cb95a
commit a583cad741
3 changed files with 56 additions and 2 deletions

View File

@@ -36,7 +36,7 @@ class IEX_Symbol:
IEX API Token
"""
try:
self.IEX_TOKEN = os.environ["IEX"]
self.IEX_TOKEN = "pk_3c39d940736e47dabfdd47eb689a65be"
except KeyError:
self.IEX_TOKEN = ""
warning(
@@ -485,6 +485,23 @@ class IEX_Symbol:
return pd.DataFrame()
def spark_reply(self, symbol: Stock) -> str:
quote = self.get(f"/stock/{symbol.id}/quote")
open_change = quote.get("changePercent", 0)
after_change = quote.get("extendedChangePercent", 0)
change = 0
if open_change:
change = change + open_change
if after_change:
change = change + after_change
change = change * 100
return f"`{symbol.tag}`: {quote['companyName']}, {change:.2f}%"
def trending(self) -> list[str]:
"""Gets current coins trending on IEX. Only returns when market is open.