cron job bug fixing
This commit is contained in:
parent
4491fc836f
commit
e591fd2bd3
@ -5,19 +5,14 @@ import os
|
||||
import sqlite3
|
||||
from tqdm import tqdm
|
||||
from dotenv import load_dotenv
|
||||
from datetime import datetime
|
||||
import requests
|
||||
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
|
||||
'''
|
||||
benzinga_api_key = os.getenv('benzinga_api_key')
|
||||
today = datetime.today().date()
|
||||
|
||||
url = "https://api.benzinga.com/api/v2.1/calendar/fda"
|
||||
querystring = {"token":benzinga_api_key}
|
||||
headers = {"accept": "application/json"}
|
||||
|
||||
'''
|
||||
api_key = os.getenv('UNUSUAL_WHALES_API_KEY')
|
||||
|
||||
url = "https://api.unusualwhales.com/api/market/fda-calendar"
|
||||
@ -45,6 +40,11 @@ async def get_data():
|
||||
try:
|
||||
response = requests.get(url, headers=headers)
|
||||
data = response.json()['data']
|
||||
data = [
|
||||
entry for entry in data
|
||||
if datetime.strptime(entry['start_date'], '%Y-%m-%d').date() >= today
|
||||
]
|
||||
|
||||
res_list = []
|
||||
for item in data:
|
||||
try:
|
||||
|
||||
@ -99,6 +99,8 @@ def run_options_jobs():
|
||||
time.sleep(60)
|
||||
run_command(["python3", "cron_options_historical_volume.py"])
|
||||
time.sleep(60)
|
||||
run_command(["python3", "cron_implied_volatility.py"])
|
||||
time.sleep(60)
|
||||
run_command(["python3", "cron_options_hottest_contracts.py"])
|
||||
time.sleep(60)
|
||||
run_command(["python3", "cron_options_single_contract.py"])
|
||||
@ -353,7 +355,7 @@ def run_threaded(job_func):
|
||||
|
||||
# Schedule the job to run
|
||||
|
||||
schedule.every().day.at("00:00").do(run_threaded, run_options_jobs).tag('options_job')
|
||||
schedule.every().day.at("22:00").do(run_threaded, run_options_jobs).tag('options_job')
|
||||
schedule.every().day.at("02:00").do(run_threaded, run_db_schedule_job)
|
||||
schedule.every().day.at("05:00").do(run_threaded, run_options_historical_flow).tag('options_historical_flow_job')
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user