Reduce costs and improve speed
# FREE - Check business day is_bday = check_business_day("2024-01-15") # 2 CREDITS - Price option price = price_option(...)
# Cache yield curve (2 credits once) curve = build_curve(...) # 2 credits cache.set("curve_2024", curve, ttl=3600) # Reuse for 100 bonds (0 extra credits) for bond in bonds: price = price_bond(bond, cached_curve)
import asyncio import aiohttp async def price_options_parallel(options): async with aiohttp.ClientSession() as session: tasks = [price_option_async(session, opt) for opt in options] return await asyncio.gather(*tasks)