add cron job for retail volume && add timer for share statistics

This commit is contained in:
MuslemRahimi 2024-06-16 14:59:10 +02:00
parent 9a4865d228
commit d016fc8dda
2 changed files with 20 additions and 1 deletions

View File

@ -84,11 +84,18 @@ async def run():
cursor.execute("SELECT DISTINCT symbol FROM stocks") cursor.execute("SELECT DISTINCT symbol FROM stocks")
stock_symbols = [row[0] for row in cursor.fetchall()] stock_symbols = [row[0] for row in cursor.fetchall()]
counter = 0
for ticker in tqdm(stock_symbols): for ticker in tqdm(stock_symbols):
data_dict = await get_data(ticker, con) data_dict = await get_data(ticker, con)
if data_dict.keys(): if data_dict.keys():
await save_as_json(ticker, data_dict) await save_as_json(ticker, data_dict)
counter += 1
if counter % 100 == 0:
print(f"Processed {counter} tickers, waiting for 10 seconds...")
await asyncio.sleep(10)
con.close() con.close()
try: try:

View File

@ -99,6 +99,17 @@ def run_share_statistics():
] ]
subprocess.run(command) subprocess.run(command)
def run_retail_volume():
week = datetime.today().weekday()
if week <= 5:
subprocess.run(["python3", "cron_retail_volume.py"])
command = [
"sudo", "rsync", "-avz", "-e", "ssh",
"/root/backend/app/json/retail-volume",
f"root@{useast_ip_address}:/root/backend/app/json"
]
subprocess.run(command)
def run_cron_market_movers(): def run_cron_market_movers():
week = datetime.today().weekday() week = datetime.today().weekday()
if week <= 4: if week <= 4:
@ -300,6 +311,7 @@ schedule.every().day.at("10:00").do(run_threaded, run_shareholders).tag('shareho
schedule.every().day.at("10:15").do(run_threaded, run_share_statistics).tag('share_statistics_job') schedule.every().day.at("10:15").do(run_threaded, run_share_statistics).tag('share_statistics_job')
schedule.every().day.at("10:30").do(run_threaded, run_sec_filings).tag('sec_filings_job') schedule.every().day.at("10:30").do(run_threaded, run_sec_filings).tag('sec_filings_job')
schedule.every().day.at("11:00").do(run_threaded, run_executive).tag('executive_job') schedule.every().day.at("11:00").do(run_threaded, run_executive).tag('executive_job')
schedule.every().day.at("11:30").do(run_threaded, run_retail_volume).tag('retail_volume_job')
schedule.every().day.at("13:30").do(run_threaded, run_stockdeck).tag('stockdeck_job') schedule.every().day.at("13:30").do(run_threaded, run_stockdeck).tag('stockdeck_job')