mirror of
https://gitlab.com/simple-stock-bots/simple-stock-bot.git
synced 2025-06-16 15:17:28 +00:00
fix for marketdata after hours
This commit is contained in:
parent
f364a82aad
commit
8cb7bce34c
@ -131,7 +131,11 @@ class MarketData:
|
|||||||
|
|
||||||
if quoteResp := self.get(f"stocks/quotes/{symbol}/"):
|
if quoteResp := self.get(f"stocks/quotes/{symbol}/"):
|
||||||
price = round(quoteResp["last"][0], 2)
|
price = round(quoteResp["last"][0], 2)
|
||||||
changePercent = round(quoteResp["changepct"][0], 2)
|
|
||||||
|
try:
|
||||||
|
changePercent = round(quoteResp["changepct"][0], 2)
|
||||||
|
except TypeError:
|
||||||
|
return f"The price of {symbol} is {price}"
|
||||||
|
|
||||||
message = f"The current price of {symbol.name} is ${price} and "
|
message = f"The current price of {symbol.name} is ${price} and "
|
||||||
|
|
||||||
@ -148,11 +152,13 @@ class MarketData:
|
|||||||
|
|
||||||
def spark_reply(self, symbol: Stock) -> str:
|
def spark_reply(self, symbol: Stock) -> str:
|
||||||
if quoteResp := self.get(f"stocks/quotes/{symbol}/"):
|
if quoteResp := self.get(f"stocks/quotes/{symbol}/"):
|
||||||
changePercent = round(quoteResp["changepct"][0], 2)
|
try:
|
||||||
return f"`{symbol.tag}`: {changePercent}%"
|
changePercent = round(quoteResp["changepct"][0], 2)
|
||||||
else:
|
return f"`{symbol.tag}`: {changePercent}%"
|
||||||
logging.warning(f"{symbol} did not have 'changepct' field.")
|
except TypeError:
|
||||||
return f"`{symbol.tag}`"
|
pass
|
||||||
|
|
||||||
|
return f"`{symbol.tag}`"
|
||||||
|
|
||||||
def intra_reply(self, symbol: Stock) -> pd.DataFrame:
|
def intra_reply(self, symbol: Stock) -> pd.DataFrame:
|
||||||
"""Returns price data for a symbol of the past month up until the previous trading days close.
|
"""Returns price data for a symbol of the past month up until the previous trading days close.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user