bugfixing

This commit is contained in:
MuslemRahimi 2025-01-24 17:41:12 +01:00
parent 417af6ba3e
commit ccea773989

View File

@ -82,7 +82,7 @@ def parse_option_symbol(option_symbol):
ticker, expiration, option_type, strike_price = match.groups() ticker, expiration, option_type, strike_price = match.groups()
# Convert expiration to datetime # Convert expiration to datetime
date_expiration = datetime.strptime(expiration, "%y%m%d").date().strftime("%Y-%m-%d") date_expiration = datetime.strptime(expiration, "%y%m%d").date()
# Convert strike price to float # Convert strike price to float
strike_price = int(strike_price) / 1000 strike_price = int(strike_price) / 1000
@ -102,20 +102,22 @@ async def get_data(symbol):
option_symbol = trade_data['contract'].replace("___","") option_symbol = trade_data['contract'].replace("___","")
date_expiration, option_type, strike_price = parse_option_symbol(option_symbol) date_expiration, option_type, strike_price = parse_option_symbol(option_symbol)
res_list.append({'date': trade_data['timestamp'].strftime("%Y-%m-%d"), if trade_data['underlying_price_at_execution'] > 0 and date_expiration >= datetime.today().date():
'askprice': trade_data['ask_at_execution'],
'bidPrice': trade_data['bid_at_execution'], res_list.append({'date': trade_data['timestamp'].strftime("%Y-%m-%d"),
'premium': trade_data['total_value'], 'askprice': trade_data['ask_at_execution'],
'sentiment': trade_data['sentiment'].capitalize(), 'bidPrice': trade_data['bid_at_execution'],
'avgPrice': trade_data['average_price'], 'premium': trade_data['total_value'],
'price': trade_data['underlying_price_at_execution'], 'sentiment': trade_data['sentiment'].capitalize(),
'unusualType': trade_data['type'].capitalize(), 'avgPrice': trade_data['average_price'],
'size': trade_data['total_size'], 'price': trade_data['underlying_price_at_execution'],
'optionSymbol': option_symbol, 'unusualType': trade_data['type'].capitalize(),
'strike': strike_price, 'size': trade_data['total_size'],
'expiry': date_expiration, 'optionSymbol': option_symbol,
'optionType': option_type.replace("P","Put").replace("C","Call") 'strike': strike_price,
}) 'expiry': date_expiration.strftime("%Y-%m-%d"),
'optionType': option_type.replace("P","Put").replace("C","Call")
})
except: except:
pass pass
@ -130,7 +132,7 @@ async def main():
total_symbols = get_total_symbols() total_symbols = get_total_symbols()
print(f"Number of tickers: {len(total_symbols)}") print(f"Number of tickers: {len(total_symbols)}")
for symbol in tqdm(['AMD']): for symbol in tqdm(total_symbols):
try: try:
data = await get_data(symbol) data = await get_data(symbol)
except Exception as e: except Exception as e: