bugfixing

This commit is contained in:
MuslemRahimi 2025-02-10 01:44:57 +01:00
parent 15070b4d6c
commit c535d24a1c
3 changed files with 5 additions and 3 deletions

View File

@ -35,7 +35,7 @@ index_symbols =["^SPX","^VIX"]
con.close()
etf_con.close()
total_symbols = stocks_symbols+etf_symbols+index_symbols
total_symbols = index_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
@ -66,7 +66,7 @@ def get_contracts_from_directory(directory: str):
def get_expiration_date(option_symbol):
# Define regex pattern to match the symbol structure
match = re.match(r"([A-Z]+)(\d{6})([CP])(\d+)", option_symbol)
match = re.match(r"(\^?[A-Z]+)(\d{6})([CP])(\d+)", option_symbol)
if not match:
raise ValueError(f"Invalid option_symbol format: {option_symbol}")

View File

@ -46,7 +46,7 @@ def save_json(data, symbol, directory="json/hottest-contracts/companies"):
def parse_option_symbol(option_symbol):
match = re.match(r"([A-Z]+)(\d{6})([CP])(\d+)", option_symbol)
match = re.match(r"(\^?[A-Z]+)(\d{6})([CP])(\d+)", option_symbol)
if not match:
raise ValueError(f"Invalid option_symbol format: {option_symbol}")
ticker, expiration, option_type, strike_price = match.groups()

View File

@ -84,6 +84,8 @@ async def get_single_contract_data(symbol, expiration, semaphore):
return None
async def process_batch(symbol, batch, semaphore, pbar):
symbol = symbol.replace("^","") #for index symbols
tasks = [get_single_contract_data(symbol, contract, semaphore) for contract in batch]
results = []