Skip to main content

Performance Optimization

Optimize API usage for cost and performance.

Cost Optimization

Use Free Tier

# FREE - Check business day
is_bday = check_business_day("2024-01-15")

# 2 CREDITS - Price option
price = price_option(...)

Cache Results

# 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)

Speed Optimization

Parallel Requests

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)

Batch Operations

Design endpoints to accept batches when possible. Learn more →