revert back to old db

This commit is contained in:
MuslemRahimi 2025-04-14 18:13:09 +02:00
parent 9d055869e5
commit 39e12a7534

View File

@ -181,21 +181,6 @@ class StockDatabase:
print(e) print(e)
pass pass
# --- New Code: Check marketCap for PNK stocks ---
# Query the exchange short name from the database for this symbol
self.cursor.execute("SELECT exchangeShortName FROM stocks WHERE symbol = ?", (symbol,))
row = self.cursor.fetchone()
if row and row[0] == "PNK":
market_cap = fundamental_data.get('marketCap')
if market_cap is not None and market_cap < 10E9:
# Delete the stock record as market cap is below 1 billion
self.cursor.execute("DELETE FROM stocks WHERE symbol = ?", (symbol,))
self.conn.commit()
# Optionally, drop the OHLC table for that symbol if it exists
self.cursor.execute(f"DROP TABLE IF EXISTS '{symbol}'")
self.conn.commit()
print(f"Deleted {symbol} from database due to marketCap ({market_cap}) below 1B.")
return # Exit early without proceeding further
# Check if columns already exist in the table # Check if columns already exist in the table
self.cursor.execute("PRAGMA table_info(stocks)") self.cursor.execute("PRAGMA table_info(stocks)")
@ -228,22 +213,22 @@ class StockDatabase:
for stock in stocks: for stock in stocks:
exchange_short_name = stock.get('exchangeShortName', '') exchange_short_name = stock.get('exchangeShortName', '')
ticker_type = stock.get('type', '') ticker_type = stock.get('type', '')
if exchange_short_name in ['NYSE', 'NASDAQ','AMEX', 'PNK'] and ticker_type in ['stock']: if exchange_short_name in ['XETRA','NYSE', 'NASDAQ','AMEX', 'PNK','EURONEXT'] and ticker_type in ['stock']:
symbol = stock.get('symbol', '') symbol = stock.get('symbol', '')
#if exchange_short_name == 'PNK' and symbol not in ['RNMBF','ODYS','FSRNQ','TSSI','DRSHF','NTDOY','OTGLF','TCEHY', 'KRKNF','BYDDY','XIACY','NSRGY','TLPFY','TLPFF']: if exchange_short_name == 'PNK' and symbol not in ['ODYS','FSRNQ','TSSI','DRSHF','NTDOY','OTGLF','TCEHY', 'KRKNF','BYDDY','XIACY','NSRGY','TLPFY','TLPFF']:
# pass pass
#elif exchange_short_name == 'EURONEXT' and symbol not in ['ALEUP.PA','ALNEV.PA','ALGAU.PA','ALDRV.PA','ALHYG.PA','ALVMG.PA','TEP.PA']: elif exchange_short_name == 'EURONEXT' and symbol not in ['ALEUP.PA','ALNEV.PA','ALGAU.PA','ALDRV.PA','ALHYG.PA','ALVMG.PA','TEP.PA']:
# pass pass
#else: else:
name = stock.get('name', '') name = stock.get('name', '')
exchange = stock.get('exchange', '') exchange = stock.get('exchange', '')
#if name and '-' not in symbol: #if name and '-' not in symbol:
if name: if name:
symbols.append(symbol) symbols.append(symbol)
names.append(name) names.append(name)
ticker_data.append((symbol, name, exchange, exchange_short_name, ticker_type)) ticker_data.append((symbol, name, exchange, exchange_short_name, ticker_type))
self.cursor.execute("BEGIN TRANSACTION") # Begin a transaction self.cursor.execute("BEGIN TRANSACTION") # Begin a transaction