GET Open Interest
Last updated
@common_router.get(
'/open-interest',
responses={status.HTTP_200_OK: {"model": OpenInterestResponseSchema}},
response_model=OpenInterestResponseSchema,
dependencies=[
Depends(CustomRateLimiter(times=1, seconds=1)),
Depends(CustomRateLimiter(times=40, minutes=1)),
Depends(CustomRateLimiter(times=1500, hours=1)),
]
)
@with_context_db_session
async def get_open_interest():
# 1. Compute hedger’s capacity and usage
total_cap, used = await OpenCapEngine.get_total_cap_and_used_amount_async(from_stats=True)
# 2. Emit metrics for monitoring
apm.label(total_cap=total_cap, used=used)
# 3. Return JSON response
return {
"total_cap": total_cap,
"used": used
}total_cap, used = await OpenCapEngine.get_total_cap_and_used_amount_async(from_stats=True)apm.label(total_cap=total_cap, used=used)return {"total_cap": total_cap, "used": used}class OpenInterestResponseSchema(BaseModel):
total_cap: Decimal
used: Decimalclass OpenInterestResponseSchema(BaseModel):
total_cap: Decimal
used: Decimal