Skip to content

Commit

Permalink
bugfixing cron job
Browse files Browse the repository at this point in the history
  • Loading branch information
MuslemRahimi committed Feb 18, 2025
1 parent 0a8bbcb commit 52420a6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/cron_dark_pool_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_data():
sources = ['utp_delayed', 'cta_a_delayed', 'cta_b_delayed']
page_size = 50000
min_size = 2000
threshold = 1E6 # Define threshold
threshold = 1E5 # Define threshold

for source in tqdm(sources):
try:
Expand Down
13 changes: 3 additions & 10 deletions app/cron_dark_pool_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,11 @@ def run():
etf_con.close()

total_symbols = stocks_symbols+ etf_symbols
data = []
weekdays = get_last_N_weekdays()
for date in weekdays:
try:
with open(f"json/dark-pool/historical-flow/{date}.json", "r") as file:
raw_data = orjson.loads(file.read())
data +=raw_data
except:
pass
with open(f"json/dark-pool/feed/data.json", "r") as file:
raw_data = orjson.loads(file.read())
for symbol in tqdm(total_symbols):
try:
res_list = [item for item in data if isinstance(item, dict) and item['ticker'] == symbol]
res_list = [item for item in raw_data if isinstance(item, dict) and item['ticker'] == symbol]
dark_pool_levels = analyze_dark_pool_levels(
trades=res_list,
size_threshold=0.8, # Look for levels with volume in top 20%
Expand Down
2 changes: 2 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3022,6 +3022,8 @@ async def get_dark_pool_feed(api_key: str = Security(get_api_key)):
with open(f"json/dark-pool/feed/data.json", "r") as file:
res_list = orjson.loads(file.read())

res_list = [item for item in res_list if float(item['premium']) >= 1E6]

except:
res_list = []

Expand Down
6 changes: 3 additions & 3 deletions app/primary_cron_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def run_dark_pool_level():
now = datetime.now(ny_tz)
week = now.weekday()
hour = now.hour
if week <= 4 and 8 <= hour < 20:
if week <= 4 and 8 <= hour <= 22:
run_command(["python3", "cron_dark_pool_level.py"])

def run_dark_pool_ticker():
Expand Down Expand Up @@ -421,8 +421,8 @@ def run_threaded(job_func):



#schedule.every(30).minutes.do(run_threaded, run_dark_pool_level).tag('dark_pool_level_job')
schedule.every(5).minutes.do(run_threaded, run_dark_pool_flow).tag('dark_pool_flow_job')
schedule.every(30).minutes.do(run_threaded, run_dark_pool_level).tag('dark_pool_level_job')
schedule.every(10).minutes.do(run_threaded, run_dark_pool_flow).tag('dark_pool_flow_job')

schedule.every(2).minutes.do(run_threaded, run_dashboard).tag('dashboard_job')

Expand Down

0 comments on commit 52420a6

Please sign in to comment.