update cron jobs
This commit is contained in:
parent
46495462bb
commit
5b5f0da2e9
@ -8,12 +8,16 @@ import ujson
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(description='Market Status')
|
parser = argparse.ArgumentParser(description='Post Type')
|
||||||
parser.add_argument('--market_status', choices=[0, 1, 2], type=int, default=0,
|
parser.add_argument('--post_type', choices=['earnings', 'stock-list', 'premarket', 'aftermarket'],
|
||||||
help='Market status: 0 for Open (default), 1 for Premarket, 2 for Afterhours')
|
type=str, default='earnings',
|
||||||
|
help='Post type: "earnings" (default), "stock-list", "premarket", or "aftermarket"')
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def get_current_weekday():
|
def get_current_weekday():
|
||||||
"""Return the current weekday name."""
|
"""Return the current weekday name."""
|
||||||
return datetime.now().strftime("%A")
|
return datetime.now().strftime("%A")
|
||||||
@ -355,7 +359,7 @@ def post_to_reddit():
|
|||||||
# Load environment variables
|
# Load environment variables
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
market_status = args.market_status
|
post_type = args.post_type
|
||||||
|
|
||||||
|
|
||||||
# Initialize Reddit instance
|
# Initialize Reddit instance
|
||||||
@ -392,7 +396,7 @@ def post_to_reddit():
|
|||||||
with open("json/dashboard/data.json", "rb") as file:
|
with open("json/dashboard/data.json", "rb") as file:
|
||||||
data = orjson.loads(file.read())
|
data = orjson.loads(file.read())
|
||||||
|
|
||||||
'''
|
if post_type == 'stock-list':
|
||||||
post_configs = [
|
post_configs = [
|
||||||
{
|
{
|
||||||
"data_type": "penny-stocks",
|
"data_type": "penny-stocks",
|
||||||
@ -430,7 +434,7 @@ def post_to_reddit():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
'''
|
if post_type == 'earnings':
|
||||||
# Define the post configurations
|
# Define the post configurations
|
||||||
post_configs = [
|
post_configs = [
|
||||||
{
|
{
|
||||||
@ -447,10 +451,10 @@ def post_to_reddit():
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
if market_status == 0:
|
|
||||||
try:
|
try:
|
||||||
# Loop through post configurations to submit each post
|
# Loop through post configurations to submit each post
|
||||||
for config in post_configs:
|
for config in post_configs:
|
||||||
|
if len(data.get(config["data_key"], [])) > 0:
|
||||||
formatted_text = config["format_func"](data.get(config["data_key"], []))
|
formatted_text = config["format_func"](data.get(config["data_key"], []))
|
||||||
title = config["title"]
|
title = config["title"]
|
||||||
flair_id = config["flair_id"]
|
flair_id = config["flair_id"]
|
||||||
@ -461,14 +465,14 @@ def post_to_reddit():
|
|||||||
selftext=formatted_text,
|
selftext=formatted_text,
|
||||||
flair_id=flair_id
|
flair_id=flair_id
|
||||||
)
|
)
|
||||||
print(f"Post created successfully: {post.url}")
|
print(f"Post created successfully")
|
||||||
|
|
||||||
except praw.exceptions.PRAWException as e:
|
except praw.exceptions.PRAWException as e:
|
||||||
print(f"Error posting to Reddit: {str(e)}")
|
print(f"Error posting to Reddit: {str(e)}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Unexpected error: {str(e)}")
|
print(f"Unexpected error: {str(e)}")
|
||||||
|
|
||||||
elif market_status == 1: #premarket
|
if post_type == 'premarket':
|
||||||
try:
|
try:
|
||||||
formatted_content = format_premarket_market()
|
formatted_content = format_premarket_market()
|
||||||
title = "Premarket Gainers and Losers for Today 🚀📉"
|
title = "Premarket Gainers and Losers for Today 🚀📉"
|
||||||
@ -477,7 +481,7 @@ def post_to_reddit():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error posting to Reddit: {str(e)}")
|
print(f"Error posting to Reddit: {str(e)}")
|
||||||
|
|
||||||
elif market_status == 2: #aftermarket
|
if post_type == 'aftermarket':
|
||||||
try:
|
try:
|
||||||
formatted_content = format_afterhour_market()
|
formatted_content = format_afterhour_market()
|
||||||
title = "Afterhours Gainers and Losers for Today 🚀📉"
|
title = "Afterhours Gainers and Losers for Today 🚀📉"
|
||||||
|
|||||||
@ -359,7 +359,7 @@ schedule.every(1).hours.do(run_threaded, run_cron_company_news).tag('company_new
|
|||||||
schedule.every(2).minutes.do(run_threaded, run_dashboard).tag('dashboard_job')
|
schedule.every(2).minutes.do(run_threaded, run_dashboard).tag('dashboard_job')
|
||||||
|
|
||||||
|
|
||||||
schedule.every(20).seconds.do(run_threaded, run_if_not_running(run_cron_options_flow, 'options_flow_job')).tag('options_flow_job')
|
schedule.every(10).seconds.do(run_threaded, run_if_not_running(run_cron_options_flow, 'options_flow_job')).tag('options_flow_job')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,7 @@ def run_json_job():
|
|||||||
subprocess.run(["python3", "restart_json.py"])
|
subprocess.run(["python3", "restart_json.py"])
|
||||||
subprocess.run(["pm2", "restart","fastapi"])
|
subprocess.run(["pm2", "restart","fastapi"])
|
||||||
subprocess.run(["pm2", "restart","fastify"])
|
subprocess.run(["pm2", "restart","fastify"])
|
||||||
|
subprocess.run(["pm2", "restart","websocket"])
|
||||||
|
|
||||||
def run_cron_price_alert():
|
def run_cron_price_alert():
|
||||||
week = datetime.today().weekday()
|
week = datetime.today().weekday()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user