Skip to content

Commit

Permalink
fix: psycopg dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowtham1729 committed Dec 10, 2023
1 parent 5c03426 commit f4acfa0
Show file tree
Hide file tree
Showing 3 changed files with 448 additions and 47 deletions.
8 changes: 7 additions & 1 deletion applications/data_fetcher/fetcher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
from dataclasses import dataclass
from datetime import datetime
Expand Down Expand Up @@ -99,11 +100,14 @@ def to_news(self, items: Dict, tickers_list: List[str]) -> List[News]:
def fetch_news(self):
tickers = self.get_tickers()
tickers_list = [ticker.ticker for ticker in tickers]
logging.log(f"Ticker List: {tickers_list}")

ticker_symbols = ",".join(tickers_list)
today_date = datetime.today().strftime("%Y-%m-%d")
page = 1
news_url = f"{self.marketaux_news_url}&symbols={ticker_symbols}&published_on={today_date}"

logging.log(f"Fetching News...")
response = requests.get(f"{news_url}&page={page}")
news = []
if response.status_code == 200:
Expand All @@ -120,10 +124,12 @@ def fetch_news(self):
news += self.to_news(response_json["data"], tickers_list)
else:
break

logging.log(f"Finished fetching News: {news}")
logging.log(f"Inserting News...")
self.insert_news(news)


if __name__ == "__main__":
fetcher = Fetcher()
print("Hello")
fetcher.fetch_news()
Loading

0 comments on commit f4acfa0

Please sign in to comment.