gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
перепиши код чтобы ускорить через asyncio gather: spreadsbook = {} for symbol in…
- User
перепиши код чтобы ускорить через asyncio gather: spreads_book = {} for symbol in tqdm(best_pairs): spreads_book.update({ symbol: { "open": await counter_repeats(df, symbol, 'open_spread'), "close": await counter_repeats(df, symbol, 'close_spread') } })
- Assistant
async def get_spreads(symbol, df): return { "open": await counter_repeats(df, symbol, 'open_spread'), "close": await counter_repeats(df, symbol, 'close_spread') }
tasks = [get_spreads(symbol, df) for symbol in best_pairs] results = await asyncio.gather(*tasks)
spreads_book = dict(zip(best_pairs, results))