diff --git a/README.md b/README.md index 7a401b7..bf35397 100644 --- a/README.md +++ b/README.md @@ -65,14 +65,14 @@ To configure the application, update the `config.py` file in the `src/config` di TOP_COMPANIES_COUNT = 10000 TIMESTAMP_FORMAT = "%Y-%m-%dT%H:%M:%SZ" UTC_DIFFERENCE = 8 -NEWS_LOOKBACK_DAYS = 1 +MAX_NEWS_LOOKBACK_DAYS = 60 CPU_COUNT = 2 ``` - `TOP_COMPANIES_COUNT`: The number of top companies ranked by market cap to search. - `TIMESTAMP_FORMAT`: The format for timestamps used in the application, especially for the news API. - `UTC_DIFFERENCE`: The difference in hours between local time and UTC. -- `NEWS_LOOKBACK_DAYS`: The number of days to look back when fetching news articles. +- `MAX_NEWS_LOOKBACK_DAYS`: The max number of days to look back when fetching news articles. - `CPU_COUNT`: The number of CPUs to be used for multiprocessing. ## LICENSE diff --git a/src/app/flask_app.py b/src/app/flask_app.py index 458ecb6..1142634 100644 --- a/src/app/flask_app.py +++ b/src/app/flask_app.py @@ -3,7 +3,7 @@ from flask import Flask, render_template, request -from config.config import CPU_COUNT, NEWS_LOOKBACK_DAYS, TIMESTAMP_FORMAT +from config.config import CPU_COUNT, MAX_NEWS_LOOKBACK_DAYS, TIMESTAMP_FORMAT from scrapers import yahoo_news_scraper from utils import action, data, sentiment_analyzer, time @@ -74,15 +74,20 @@ def home(): @app.route("/", methods=["POST"]) def search(): input_company = request.form["company"] + start_day = int(request.form["start"]) + end_day = int(request.form["end"]) company_exists, [company_name, ticker_symbol] = ( data.check_company_exists(input_company) ) if company_exists: - current_timestamp = datetime.now().strftime(TIMESTAMP_FORMAT) + current_timestamp = ( + datetime.now() - timedelta(days=start_day) + ).strftime(TIMESTAMP_FORMAT) start_timestamp = ( - datetime.now() - timedelta(days=NEWS_LOOKBACK_DAYS) + datetime.now() - timedelta(days=end_day) ).strftime(TIMESTAMP_FORMAT) + news = yahoo_news_scraper.get_news_URLs( ticker_symbol, start_timestamp=start_timestamp, @@ -119,6 +124,7 @@ def search(): news=news, recommended_action=recommended_action, confidence_index=f"{confidence_index: .3f}", + max_news_lookback_days=MAX_NEWS_LOOKBACK_DAYS, ) else: return render_template( diff --git a/src/app/templates/index.html b/src/app/templates/index.html index 611dff2..7177d77 100644 --- a/src/app/templates/index.html +++ b/src/app/templates/index.html @@ -8,6 +8,45 @@ integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> + + +
@@ -17,9 +56,16 @@