From 38623f9b1487536b760b84beb3cf86a14b57147b Mon Sep 17 00:00:00 2001 From: Bill Chan Date: Tue, 20 Feb 2024 00:08:29 +0800 Subject: [PATCH] [Main] Update YahooQuery --- engines/data_engine.py | 2 +- main_backend.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/data_engine.py b/engines/data_engine.py index 963d8b1e..19de1f9a 100644 --- a/engines/data_engine.py +++ b/engines/data_engine.py @@ -465,7 +465,7 @@ def get_stocks_email(stock_list: list) -> dict: 'Last Close': f"{stock_ticker.summary_detail[stock_code].get('currency', 'N/A')} {stock_ticker.summary_detail[stock_code].get('previousClose', 0):.3f}", 'Open': f"{stock_ticker.summary_detail[stock_code].get('currency', 'N/A')} {stock_ticker.price[stock_code].get('regularMarketDayHigh', 0):.3f}", 'Close': f"{stock_ticker.summary_detail[stock_code].get('currency', 'N/A')} {stock_ticker.price[stock_code].get('regularMarketPrice', 0):.3f}", - '% Change': f"{stock_ticker.price[stock_code].get('regularMarketChange', 0):.2f}%", + '% Change': f"{stock_ticker.price[stock_code].get('regularMarketChangePercent', 0):.2f}%", 'Volume': f"{stock_ticker.summary_detail[stock_code].get('currency', 'N/A')} {humanize.intword(stock_ticker.summary_detail[stock_code].get('volume', 'N/A'))}", '52 Week Range': f"{stock_ticker.summary_detail[stock_code].get('currency', 'N/A')} {stock_ticker.summary_detail[stock_code].get('fiftyTwoWeekLow', 'N/A')}-{stock_ticker.summary_detail[stock_code].get('fiftyTwoWeekHigh', 'N/A')}", 'PE(Trailing/Forward)': f"{stock_ticker.summary_detail[stock_code].get('trailingPE', 'N/A')} / {stock_ticker.summary_detail[stock_code].get('forwardPE', 'N/A')}", diff --git a/main_backend.py b/main_backend.py index 590195cf..784ca2ef 100644 --- a/main_backend.py +++ b/main_backend.py @@ -189,6 +189,7 @@ def main(): subscription_list = json.loads(config.get('Email', 'SubscriptionList')) for market in args.market: filtered_stock_list = [] + filtered_stock_dict = {} if 'HK' in args.market or 'US' in args.market: # HK Market Stock Filter full_equity_list = [] @@ -207,6 +208,7 @@ def main(): filtered_stock_list = init_stock_filter(args.filter, china_equity_list) filtered_stock_dict = TuShareInterface.get_stocks_email(filtered_stock_list) + # DO NOT send email if no stock gets selected if len(filtered_stock_list) == 0: continue for subscriber in subscription_list: