GET Open Interest
/open-interest
/open-interestExample Query:
https://base-hedger82.rasa.capital/open-interestExample Response:
{
"total_cap": "2438560.667955634347925220",
"used": "111969.991183710650000000"
}Data Source
All values are configured and managed exclusively by the hedger. This data reflects the hedger’s internal risk management settings and is not derived from on-chain contracts or user positions.
Response Fields
total_cap: The maximum total open interest across all assets (in collateral, e.g., USDT).used: The portion of the total capacity currently utilized by open positions across all assets.
Open Interest Implementation (Rasa)
Router
Path:
GET /open-interestRate‐limits: 1 req/sec, 40 req/min, 1 500 req/hr
DB session: injected via
@with_context_db_session(in case the capacity engine reads from SQL)
Logic
Call Capacity Engine
Invokes your hedger’s internal risk‐management component to compute:
total_cap: how much notional collateral the hedger is willing to allow in aggregate.
used: how much of that allowance is currently locked up by open positions.
Instrumentation
Sends metrics (via your APM/tracing tool) for observability.
Return Payload
FastAPI serializes this to JSON matching
OpenInterestResponseSchema.
Steps to Implement Your Own Version
Define the Response Schema
Build or Wire Up Your Capacity Engine
Implement
OpenCapEngine.get_total_cap_and_used_amount_async(from_stats: bool) → Tuple[Decimal, Decimal].Internally, read from your own data sources:
Configuration table (max capacities per asset or global).
Positions table (sum up open positions’ collateral needs).
Return
(total_cap, used).
Add the FastAPI Route
In your
common_router, add the@common_router.get("/open-interest")handler shown above.Import
OpenInterestResponseSchemaandOpenCapEngine.Include your rate‐limiting dependencies and
@with_context_db_sessionif your engine needs DB access.
Instrumentation (Optional)
If you have an APM or metrics library, record these values on each call.
Last updated
