bugfixing
This commit is contained in:
parent
15070b4d6c
commit
c535d24a1c
@ -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}")
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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 = []
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user