1
0
mirror of https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git synced 2025-08-02 11:31:29 +00:00

Fix logging

This commit is contained in:
2023-04-09 12:32:12 -06:00
parent bf4b3032f1
commit 45a590a4a9
6 changed files with 40 additions and 40 deletions

View File

@@ -1,7 +1,6 @@
import logging
import os
import datetime as dt
from logging import warning
from typing import Dict
import pandas as pd
@@ -10,6 +9,8 @@ import schedule
from Symbol import Stock
log = logging.getLogger(__name__)
class MarketData:
"""
@@ -35,7 +36,7 @@ class MarketData:
self.MARKETDATA_TOKEN = ""
except KeyError:
self.MARKETDATA_TOKEN = ""
warning("Starting without an MarketData.app Token will not allow you to get market data!")
log.warning("Starting without an MarketData.app Token will not allow you to get market data!")
if self.MARKETDATA_TOKEN != "":
schedule.every().day.do(self.clear_charts)
@@ -134,6 +135,14 @@ class MarketData:
else:
return f"Getting a quote for {symbol} encountered an error."
def spark_reply(self, symbol: Stock) -> str:
if quoteResp := self.get(f"stocks/quotes/{symbol}/"):
changePercent = round(quoteResp["changepct"][0], 2)
return f"`{symbol.tag}`: {changePercent}%"
else:
logging.warning(f"{symbol} did not have 'changepct' field.")
return f"`{symbol.tag}`"
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.
Also caches multiple requests made in the same day.