Skip to content

Commit

Permalink
add cron job for retail volume && add timer for share statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
MuslemRahimi committed Jun 16, 2024
1 parent 9a4865d commit d016fc8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/cron_share_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,18 @@ async def run():
cursor.execute("SELECT DISTINCT symbol FROM stocks")
stock_symbols = [row[0] for row in cursor.fetchall()]

counter = 0

for ticker in tqdm(stock_symbols):
data_dict = await get_data(ticker, con)
if data_dict.keys():
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()

try:
Expand Down
12 changes: 12 additions & 0 deletions app/primary_cron_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ def run_share_statistics():
]
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():
week = datetime.today().weekday()
if week <= 4:
Expand Down Expand Up @@ -300,6 +311,7 @@ def run_threaded(job_func):
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("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')
Expand Down

0 comments on commit d016fc8

Please sign in to comment.