aayush9 commited on
Commit
3e6ef05
·
verified ·
1 Parent(s): 4b2f91d

Update CurrentDB.py

Browse files
Files changed (1) hide show
  1. CurrentDB.py +5 -3
CurrentDB.py CHANGED
@@ -9,8 +9,8 @@ import time
9
  load_dotenv()
10
 
11
  # Define your Aylien credentials
12
- AppID = os.getenv('AYLIEN_APP_ID')
13
- APIKey = os.getenv('AYLIEN_API_KEY')
14
  PolygonAPIKey = os.getenv('POLYGON_API_KEY')
15
 
16
  # Function to get authentication header
@@ -90,6 +90,7 @@ def save_data_to_csv(ticker, all_stories, stock_data):
90
  print(sentiment_polarity)
91
  publication_date = datetime.strptime(story.get('published_at', 'N/A'), '%Y-%m-%dT%H:%M:%SZ').strftime('%Y-%m-%d')
92
  stock_date = (datetime.strptime(publication_date, '%Y-%m-%d') + timedelta(days=1)).strftime('%Y-%m-%d')
 
93
 
94
  if stock_data.get(stock_date) == None:
95
  stock_price = 'N/A'
@@ -152,12 +153,13 @@ def main():
152
  # Define the date range (last 3 days)
153
  end_date = datetime.now() # Current date
154
  #end_date = datetime.strptime(end_date, '%Y-%m-%d')
155
- start_date = datetime.now() - timedelta(days=7) # Three days ago
156
 
157
  # Fetch all stock data for each ticker in the date range
158
  for ticker in tickers:
159
  stock_data = get_stock_data(PolygonAPIKey, ticker, start_date.strftime("%Y-%m-%d"), end_date.strftime("%Y-%m-%d"))
160
  print(stock_data)
 
161
  if stock_data:
162
  all_stories = []
163
  current_date = start_date
 
9
  load_dotenv()
10
 
11
  # Define your Aylien credentials
12
+ AppID = os.getenv('APP_ID')
13
+ APIKey = os.getenv('API_KEY')
14
  PolygonAPIKey = os.getenv('POLYGON_API_KEY')
15
 
16
  # Function to get authentication header
 
90
  print(sentiment_polarity)
91
  publication_date = datetime.strptime(story.get('published_at', 'N/A'), '%Y-%m-%dT%H:%M:%SZ').strftime('%Y-%m-%d')
92
  stock_date = (datetime.strptime(publication_date, '%Y-%m-%d') + timedelta(days=1)).strftime('%Y-%m-%d')
93
+
94
 
95
  if stock_data.get(stock_date) == None:
96
  stock_price = 'N/A'
 
153
  # Define the date range (last 3 days)
154
  end_date = datetime.now() # Current date
155
  #end_date = datetime.strptime(end_date, '%Y-%m-%d')
156
+ start_date = datetime.now() - timedelta(days=7) # 7 days ago
157
 
158
  # Fetch all stock data for each ticker in the date range
159
  for ticker in tickers:
160
  stock_data = get_stock_data(PolygonAPIKey, ticker, start_date.strftime("%Y-%m-%d"), end_date.strftime("%Y-%m-%d"))
161
  print(stock_data)
162
+ print(end_date)
163
  if stock_data:
164
  all_stories = []
165
  current_date = start_date