bugfixing
This commit is contained in:
parent
774cec78cf
commit
1f779d5e20
@ -41,7 +41,7 @@ def get_quote_data(symbol):
|
||||
|
||||
def save_to_daily_file(data, directory):
|
||||
try:
|
||||
# Create a set to track unique entries based on a combination of 'ticker' and 'date'
|
||||
# Create a set to track unique entries based on a combination of 'ticker' and 'trackingID'
|
||||
seen = set()
|
||||
unique_data = []
|
||||
|
||||
@ -54,10 +54,13 @@ def save_to_daily_file(data, directory):
|
||||
# Sort the data by date
|
||||
latest_data = sorted(unique_data, key=lambda x: datetime.fromisoformat(x['date'].replace('Z', '+00:00')), reverse=True)
|
||||
|
||||
# Use the date from the first element of sorted data
|
||||
if latest_data:
|
||||
first_date = datetime.fromisoformat(latest_data[0]['date'].replace('Z', '+00:00')).strftime('%Y-%m-%d')
|
||||
else:
|
||||
first_date = datetime.now().strftime('%Y-%m-%d') # Fallback in case data is empty
|
||||
|
||||
# Get today's date
|
||||
today = datetime.now().strftime('%Y-%m-%d')
|
||||
json_file_path = os.path.join(directory, f"{today}.json")
|
||||
json_file_path = os.path.join(directory, f"{first_date}.json")
|
||||
|
||||
# Ensure the directory exists
|
||||
os.makedirs(directory, exist_ok=True)
|
||||
@ -72,6 +75,7 @@ def save_to_daily_file(data, directory):
|
||||
|
||||
|
||||
|
||||
|
||||
def get_data():
|
||||
try:
|
||||
response = requests.get(url, headers=headers, params=querystring)
|
||||
@ -90,6 +94,9 @@ def main():
|
||||
|
||||
# Fetch new data from the API
|
||||
data = get_data()
|
||||
|
||||
print(data[0])
|
||||
|
||||
res = []
|
||||
for item in data:
|
||||
symbol = item['ticker']
|
||||
|
||||
@ -6,7 +6,7 @@ import subprocess
|
||||
import threading # Import threading module for parallel execution
|
||||
#import logging # Import logging module
|
||||
#from logging.handlers import RotatingFileHandler
|
||||
|
||||
from pytz import timezone
|
||||
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
@ -17,6 +17,7 @@ job_status = {
|
||||
'options_flow_job': {'running': False},
|
||||
}
|
||||
|
||||
ny_tz = timezone('America/New_York')
|
||||
|
||||
# Setup logging
|
||||
'''
|
||||
@ -58,13 +59,17 @@ def run_command(command):
|
||||
'''
|
||||
|
||||
def run_dark_pool_flow():
|
||||
week = datetime.today().weekday()
|
||||
if week <= 4:
|
||||
now = datetime.now(ny_tz)
|
||||
week = now.weekday()
|
||||
hour = now.hour
|
||||
if week <= 4 and 8 <= hour < 20:
|
||||
run_command(["python3", "cron_dark_pool_flow.py"])
|
||||
|
||||
def run_fda_calendar():
|
||||
week = datetime.today().weekday()
|
||||
if week <= 4:
|
||||
now = datetime.now(ny_tz)
|
||||
week = now.weekday()
|
||||
hour = now.hour
|
||||
if week <= 4 and 8 <= hour < 20:
|
||||
run_command(["python3", "cron_fda_calendar.py"])
|
||||
|
||||
def run_cron_insider_trading():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user