From 622bc8d9a1ad03595bce4f4d4cbbd511f076ad54 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Sun, 18 Aug 2024 16:34:34 +0200 Subject: [PATCH] update share statistics --- app/cron_share_statistics.py | 20 +++++++++++------- .../fundamental_predictor.cpython-310.pyc | Bin 10781 -> 10781 bytes app/ml_models/fundamental_predictor.py | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/cron_share_statistics.py b/app/cron_share_statistics.py index 149b5cf..5ff3803 100644 --- a/app/cron_share_statistics.py +++ b/app/cron_share_statistics.py @@ -85,20 +85,24 @@ async def run(): cursor = con.cursor() cursor.execute("PRAGMA journal_mode = wal") - cursor.execute("SELECT DISTINCT symbol FROM stocks") + cursor.execute("SELECT DISTINCT symbol FROM stocks WHERE symbol NOT LIKE '%.%'") stock_symbols = [row[0] for row in cursor.fetchall()] counter = 0 for ticker in tqdm(stock_symbols): - forward_pe_dict, short_dict = await get_data(ticker, con) - if forward_pe_dict.keys() and short_dict.keys(): - await save_as_json(ticker, forward_pe_dict, short_dict) + try: + forward_pe_dict, short_dict = await get_data(ticker, con) + if forward_pe_dict.keys() and short_dict.keys(): + await save_as_json(ticker, forward_pe_dict, short_dict) + + counter += 1 + if counter % 20 == 0: + print(f"Processed {counter} tickers, waiting for 5 seconds...") + await asyncio.sleep(5) + except Exception as e: + print(ticker, e) - counter += 1 - if counter % 100 == 0: - print(f"Processed {counter} tickers, waiting for 10 seconds...") - await asyncio.sleep(10) con.close() diff --git a/app/ml_models/__pycache__/fundamental_predictor.cpython-310.pyc b/app/ml_models/__pycache__/fundamental_predictor.cpython-310.pyc index f538d97096fb50cfd0e5a6d28457788ed10c598a..659dd330ca92e11fbb8a82ca52bad86c896b50c3 100644 GIT binary patch delta 35 pcmbOmGB<=fpO=@50SKP+AKb{jQfP96km=-?LWYcto27-B!~wY&3B&*Z delta 37 rcmbOmGB<=fpO=@50SF#!?%&A0Qizdva-)#(G} diff --git a/app/ml_models/fundamental_predictor.py b/app/ml_models/fundamental_predictor.py index 07149f8..4a77fbb 100755 --- a/app/ml_models/fundamental_predictor.py +++ b/app/ml_models/fundamental_predictor.py @@ -144,7 +144,7 @@ class FundamentalPredictor: # Second LSTM layer with dropout and batch normalization - model.add(LSTM(128, return_sequences=True, kernel_regularizer=regularizers.l2(0.01))) + model.add(LSTM(256, return_sequences=True, kernel_regularizer=regularizers.l2(0.01))) model.add(Dropout(0.5)) model.add(BatchNormalization()) @@ -153,7 +153,7 @@ class FundamentalPredictor: model.add(Dropout(0.5)) model.add(BatchNormalization()) - model.add(Dense(32, activation='relu', kernel_regularizer=regularizers.l2(0.01))) + model.add(Dense(64, activation='relu', kernel_regularizer=regularizers.l2(0.01))) model.add(Dropout(0.2)) model.add(BatchNormalization())