cron job bug fixing
This commit is contained in:
parent
4491fc836f
commit
e591fd2bd3
@ -5,19 +5,14 @@ import os
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
from datetime import datetime
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
# Load environment variables
|
# Load environment variables
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
'''
|
today = datetime.today().date()
|
||||||
benzinga_api_key = os.getenv('benzinga_api_key')
|
|
||||||
|
|
||||||
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')
|
api_key = os.getenv('UNUSUAL_WHALES_API_KEY')
|
||||||
|
|
||||||
url = "https://api.unusualwhales.com/api/market/fda-calendar"
|
url = "https://api.unusualwhales.com/api/market/fda-calendar"
|
||||||
@ -45,6 +40,11 @@ async def get_data():
|
|||||||
try:
|
try:
|
||||||
response = requests.get(url, headers=headers)
|
response = requests.get(url, headers=headers)
|
||||||
data = response.json()['data']
|
data = response.json()['data']
|
||||||
|
data = [
|
||||||
|
entry for entry in data
|
||||||
|
if datetime.strptime(entry['start_date'], '%Y-%m-%d').date() >= today
|
||||||
|
]
|
||||||
|
|
||||||
res_list = []
|
res_list = []
|
||||||
for item in data:
|
for item in data:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -99,6 +99,8 @@ def run_options_jobs():
|
|||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
run_command(["python3", "cron_options_historical_volume.py"])
|
run_command(["python3", "cron_options_historical_volume.py"])
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
|
run_command(["python3", "cron_implied_volatility.py"])
|
||||||
|
time.sleep(60)
|
||||||
run_command(["python3", "cron_options_hottest_contracts.py"])
|
run_command(["python3", "cron_options_hottest_contracts.py"])
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
run_command(["python3", "cron_options_single_contract.py"])
|
run_command(["python3", "cron_options_single_contract.py"])
|
||||||
@ -353,7 +355,7 @@ def run_threaded(job_func):
|
|||||||
|
|
||||||
# Schedule the job to run
|
# 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("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')
|
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