bugfixing
This commit is contained in:
parent
3b461b08d0
commit
15070b4d6c
@ -35,6 +35,7 @@ index_symbols =["^SPX","^VIX"]
|
||||
con.close()
|
||||
etf_con.close()
|
||||
|
||||
total_symbols = stocks_symbols+etf_symbols+index_symbols
|
||||
|
||||
def save_json(data, symbol, directory_path):
|
||||
os.makedirs(directory_path, exist_ok=True) # Ensure the directory exists
|
||||
@ -228,8 +229,6 @@ def aggregate_data_by_expiration(symbol):
|
||||
|
||||
def get_overview_data():
|
||||
directory_path = "json/gex-dex/overview"
|
||||
total_symbols = stocks_symbols+etf_symbols+index_symbols
|
||||
|
||||
|
||||
#Test mode
|
||||
#total_symbols = ['TSLA']
|
||||
@ -258,7 +257,6 @@ def get_overview_data():
|
||||
|
||||
def get_strike_data():
|
||||
directory_path = "json/gex-dex/strike/"
|
||||
total_symbols = stocks_symbols+etf_symbols
|
||||
|
||||
#Test mode
|
||||
#total_symbols = ['TSLA']
|
||||
@ -278,7 +276,6 @@ def get_strike_data():
|
||||
|
||||
def get_expiry_data():
|
||||
directory_path = "json/gex-dex/expiry/"
|
||||
total_symbols = stocks_symbols+etf_symbols
|
||||
|
||||
#Test mode
|
||||
#total_symbols = ['TSLA']
|
||||
|
||||
@ -206,7 +206,14 @@ def prepare_data(data, symbol):
|
||||
end_date_str = data[0]['date']
|
||||
|
||||
query = query_template.format(ticker=symbol)
|
||||
df_price = pd.read_sql_query(query, con if symbol in stocks_symbols else etf_con, params=(start_date_str, end_date_str)).round(2)
|
||||
if symbol in stocks_symbols:
|
||||
query_con = con
|
||||
elif symbol in etf_symbols:
|
||||
query_con = etf_con
|
||||
else:
|
||||
query_con = index_con
|
||||
|
||||
df_price = pd.read_sql_query(query, query_con, params=(start_date_str, end_date_str)).round(2)
|
||||
df_price = df_price.rename(columns={"change_percent": "changesPercentage"})
|
||||
|
||||
# Convert the DataFrame to a dictionary for quick lookups by date
|
||||
@ -298,6 +305,8 @@ def get_contracts_from_directory(directory: str):
|
||||
# Connect to the databases
|
||||
con = sqlite3.connect('stocks.db')
|
||||
etf_con = sqlite3.connect('etf.db')
|
||||
index_con = sqlite3.connect("index.db")
|
||||
|
||||
cursor = con.cursor()
|
||||
cursor.execute("PRAGMA journal_mode = wal")
|
||||
#cursor.execute("SELECT DISTINCT symbol FROM stocks WHERE symbol NOT LIKE '%.%' AND marketCap > 1E9")
|
||||
@ -323,4 +332,5 @@ for symbol in tqdm(total_symbols):
|
||||
pass
|
||||
|
||||
con.close()
|
||||
etf_con.close()
|
||||
etf_con.close()
|
||||
index_con.close()
|
||||
@ -22,10 +22,12 @@ directory_path = "json/all-options-contracts"
|
||||
current_date = datetime.now().date()
|
||||
|
||||
async def save_json(data, symbol, contract_id):
|
||||
if symbol in ['SPX', 'VIX']:
|
||||
if symbol in 'SPX':
|
||||
symbol = '^SPX'
|
||||
contract_id = "^"+contract_id
|
||||
elif symbol == 'VIX':
|
||||
symbol = '^VIX'
|
||||
contract_id = "^"+contract_id
|
||||
|
||||
directory_path = f"json/all-options-contracts/{symbol}"
|
||||
os.makedirs(directory_path, exist_ok=True) # Ensure the directory exists
|
||||
|
||||
@ -343,7 +343,7 @@ def run_push_notifications():
|
||||
now = datetime.now(ny_tz)
|
||||
week = now.weekday()
|
||||
hour = now.hour
|
||||
if week <= 4 and 9 <= hour < 20:
|
||||
if week <= 4 and 7 <= hour < 20:
|
||||
run_command(["python3", "cron_push_notifications.py"])
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user