Fixed slack notifications for aggregate task. Now sends one notification for the total number of symbols failed

This commit is contained in:
Juan Pablo Amoroso
2019-05-31 17:24:18 -03:00
parent e0194cb4db
commit 45eac371a8
3 changed files with 20 additions and 16 deletions
+9 -3
View File
@@ -76,6 +76,8 @@ def aggregate_monthly_data(symbols=None):
scraper_dir = os.path.join(save_data_path, "cboe")
symbols = [symbol.upper() for symbol in symbols]
done = 0
failed = []
for symbol in symbols:
daily_dir = os.path.join(scraper_dir, symbol + "_daily")
@@ -109,9 +111,10 @@ def aggregate_monthly_data(symbols=None):
today = pd.Timestamp.today()
first_date = date_range[0]
if first_date.year != today.year or first_date.month != today.month:
msg = "Some trading dates where missing for symbol {}".format(
symbol)
slack_notification(msg, __name__)
msg = "Some trading dates where missing for symbol {} in period {}".format(
symbol, month)
logger.error(msg)
failed.append(symbol)
continue
if not os.path.exists(monthly_dir):
@@ -132,10 +135,13 @@ def aggregate_monthly_data(symbols=None):
continue
logger.debug("Saved monthly data %s", monthly_file)
done += 1
for file in daily_files:
utils.remove_file(file, logger)
send_report(done, failed, __name__, op="aggregate")
def _get_all_listed_symbols():
"""Returns array of all listed symbols.